|
@@ -253,177 +253,174 @@ export default {
|
|
|
/**
|
|
|
* 左键点击查询图层
|
|
|
*/
|
|
|
- mapLayerQuery() {
|
|
|
- this.setData();
|
|
|
+ async mapLayerQuery(movement) {
|
|
|
let that = this;
|
|
|
- this.handler.setInputAction(async function (movement) {
|
|
|
- that.activeLayerId = "0";
|
|
|
- that.layerList = [];
|
|
|
- that.layersData = [];
|
|
|
- let scene = viewer.scene;
|
|
|
- that.viewer.entities.removeAll();
|
|
|
- that.dataSourceLayer.entities.removeAll();
|
|
|
- //拾取模型
|
|
|
- let pickedFeature = scene.pick(movement.position);
|
|
|
- if (
|
|
|
- scene.pickPositionSupported &&
|
|
|
- Cesium.defined(pickedFeature) &&
|
|
|
- pickedFeature != null &&
|
|
|
- pickedFeature.primitive
|
|
|
- ) {
|
|
|
- //解构赋值点击对象的id
|
|
|
- let Pid = pickedFeature.getProperty("id");
|
|
|
- let commaIndex = pickedFeature.primitive.url.indexOf("=");
|
|
|
- let substring = "";
|
|
|
- if (commaIndex !== -1) {
|
|
|
- //primitive级别id
|
|
|
- substring = pickedFeature.primitive.url.substring(commaIndex + 1); // 从逗号后一位开始,到字符串末尾
|
|
|
- }
|
|
|
- //定义数组用于存储转换完成的管井数据
|
|
|
- let newArr = [];
|
|
|
- //判断对象类型
|
|
|
+ that.activeLayerId = "0";
|
|
|
+ that.layerList = [];
|
|
|
+ that.layersData = [];
|
|
|
+ let scene = viewer.scene;
|
|
|
+ that.viewer.entities.removeAll();
|
|
|
+ that.dataSourceLayer.entities.removeAll();
|
|
|
+ //拾取模型
|
|
|
+ let pickedFeature = scene.pick(movement.position);
|
|
|
+ if (
|
|
|
+ scene.pickPositionSupported &&
|
|
|
+ Cesium.defined(pickedFeature) &&
|
|
|
+ pickedFeature != null &&
|
|
|
+ pickedFeature.primitive
|
|
|
+ ) {
|
|
|
+ //解构赋值点击对象的id
|
|
|
+ let Pid = pickedFeature.getProperty("id");
|
|
|
+ let commaIndex = pickedFeature.primitive.url.indexOf("=");
|
|
|
+ let substring = "";
|
|
|
+ if (commaIndex !== -1) {
|
|
|
+ //primitive级别id
|
|
|
+ substring = pickedFeature.primitive.url.substring(commaIndex + 1); // 从逗号后一位开始,到字符串末尾
|
|
|
+ }
|
|
|
+ //定义数组用于存储转换完成的管井数据
|
|
|
+ let newArr = [];
|
|
|
+ //判断对象类型
|
|
|
|
|
|
- if (Pid.indexOf("_") < 0) {
|
|
|
- gwtype = 1;
|
|
|
- } else {
|
|
|
- Pid = Pid.replace("_", "-");
|
|
|
- gwtype = 2;
|
|
|
+ if (Pid.indexOf("_") < 0) {
|
|
|
+ gwtype = 1;
|
|
|
+ } else {
|
|
|
+ Pid = Pid.replace("_", "-");
|
|
|
+ gwtype = 2;
|
|
|
+ }
|
|
|
+ GetGDlnfo({ type: gwtype, key: Pid }).then((res) => {
|
|
|
+ let aaa = Object.entries(res.data);
|
|
|
+ for (const [name, value] of aaa) {
|
|
|
+ newArr.push({
|
|
|
+ name: name,
|
|
|
+ value: value,
|
|
|
+ });
|
|
|
}
|
|
|
- GetGDlnfo({ type: gwtype, key: Pid }).then((res) => {
|
|
|
- let aaa = Object.entries(res.data);
|
|
|
- for (const [name, value] of aaa) {
|
|
|
- newArr.push({
|
|
|
- name: name,
|
|
|
- value: value,
|
|
|
- });
|
|
|
- }
|
|
|
- for (let p = 0; p < store.state.vectorlayerlist.length; i++) {
|
|
|
- if (store.state.vectorlayerlist[p].id == substring) {
|
|
|
- that.layerList.push(store.state.vectorlayerlist[p]);
|
|
|
- break;
|
|
|
- }
|
|
|
+ for (let p = 0; p < store.state.vectorlayerlist.length; i++) {
|
|
|
+ if (store.state.vectorlayerlist[p].id == substring) {
|
|
|
+ that.layerList.push(store.state.vectorlayerlist[p]);
|
|
|
+ break;
|
|
|
}
|
|
|
- that.queryResults[substring] = [newArr];
|
|
|
- that.queryResultsGeom[substring] = [];
|
|
|
- that.activeLayerId = substring;
|
|
|
- });
|
|
|
+ }
|
|
|
+ that.queryResults[substring] = [newArr];
|
|
|
+ that.queryResultsGeom[substring] = [];
|
|
|
+ that.activeLayerId = substring;
|
|
|
+ });
|
|
|
|
|
|
- that.loading = true;
|
|
|
- that.queryByPickFeature(pickedFeature, function (result, Fields) {
|
|
|
- that.loading = false;
|
|
|
- if (result != null) {
|
|
|
- result.features[0].fieldNames.forEach((fieldName, i) => {
|
|
|
- const Field = Fields.find((c) => c.FieldEn == fieldName);
|
|
|
- that.layersData.push({
|
|
|
- label: Field ? Field.FieldCn : fieldName,
|
|
|
- value: result.features[0].fieldValues[i],
|
|
|
- });
|
|
|
+ that.loading = true;
|
|
|
+ that.queryByPickFeature(pickedFeature, function (result, Fields) {
|
|
|
+ that.loading = false;
|
|
|
+ if (result != null) {
|
|
|
+ result.features[0].fieldNames.forEach((fieldName, i) => {
|
|
|
+ const Field = Fields.find((c) => c.FieldEn == fieldName);
|
|
|
+ that.layersData.push({
|
|
|
+ label: Field ? Field.FieldCn : fieldName,
|
|
|
+ value: result.features[0].fieldValues[i],
|
|
|
});
|
|
|
- } else {
|
|
|
- that.layersData = [];
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- //拾取图层
|
|
|
- // let pickRay = viewer.camera.getPickRay(movement.position);
|
|
|
- // let artesian3 = viewer.scene.globe.pick(pickRay, viewer.scene);
|
|
|
- let artesian3 = viewer.scene.pickPosition(movement.position);
|
|
|
- let xy = that.cartesian3ToWGS84(artesian3);
|
|
|
- //TODO wanger 分图层查询
|
|
|
- for (let i = 0; i < store.state.vectorlayerlist.length; i++) {
|
|
|
- let obj = store.state.vectorlayerlist[i];
|
|
|
- if (!obj.source) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- let queryByIDParameters = {
|
|
|
- getFeatureMode: "BUFFER",
|
|
|
- // getFeatureMode: "SPATIAL",
|
|
|
- spatialQueryMode: "INTERSECT",
|
|
|
- datasetNames: obj.source.split(","),
|
|
|
- geometry: {
|
|
|
- parts: [1],
|
|
|
- points: [{ y: xy.lat, x: xy.lng }],
|
|
|
- type: "POINT",
|
|
|
- },
|
|
|
- bufferDistance: 0.00005,
|
|
|
- hasGeometry: true,
|
|
|
- };
|
|
|
- let e;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ that.layersData = [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ //拾取图层
|
|
|
+ // let pickRay = viewer.camera.getPickRay(movement.position);
|
|
|
+ // let artesian3 = viewer.scene.globe.pick(pickRay, viewer.scene);
|
|
|
+ let artesian3 = viewer.scene.pickPosition(movement.position);
|
|
|
+ let xy = that.cartesian3ToWGS84(artesian3);
|
|
|
+ //TODO wanger 分图层查询
|
|
|
+ for (let i = 0; i < store.state.vectorlayerlist.length; i++) {
|
|
|
+ let obj = store.state.vectorlayerlist[i];
|
|
|
+ if (!obj.source) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ let queryByIDParameters = {
|
|
|
+ getFeatureMode: "BUFFER",
|
|
|
+ // getFeatureMode: "SPATIAL",
|
|
|
+ spatialQueryMode: "INTERSECT",
|
|
|
+ datasetNames: obj.source.split(","),
|
|
|
+ geometry: {
|
|
|
+ parts: [1],
|
|
|
+ points: [{ y: xy.lat, x: xy.lng }],
|
|
|
+ type: "POINT",
|
|
|
+ },
|
|
|
+ bufferDistance: 0.00005,
|
|
|
+ hasGeometry: true,
|
|
|
+ };
|
|
|
+ let e;
|
|
|
|
|
|
- if (obj.type == "S3M") {
|
|
|
- e = await that.mapQuery(
|
|
|
- window.baseModelQueryLayer,
|
|
|
- queryByIDParameters
|
|
|
- );
|
|
|
- } else {
|
|
|
- e = await that.mapQuery(
|
|
|
- that.calcIserverURI(obj.url),
|
|
|
- queryByIDParameters
|
|
|
- );
|
|
|
- }
|
|
|
- if (e && e.totalCount > 0) {
|
|
|
- that.layerList.push(store.state.vectorlayerlist[i]);
|
|
|
- let queryData = [];
|
|
|
- let geoms = [];
|
|
|
- for (let u = 0; u < e.features.length; u++) {
|
|
|
- let cur = [];
|
|
|
- e.features[u].fieldNames.forEach((fieldName, i) => {
|
|
|
- if (fieldName.toLowerCase().indexOf("shape") < 0) {
|
|
|
- cur.push({
|
|
|
- name: fieldName,
|
|
|
- value: e.features[u].fieldValues[i],
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- let points = [];
|
|
|
- for (let y = 0; y < e.features[u].geometry.points.length; y++) {
|
|
|
- let c = that.cartesianToCartographic84(
|
|
|
- e.features[u].geometry.points[y].x,
|
|
|
- e.features[u].geometry.points[y].y
|
|
|
- );
|
|
|
- points.push([c.x, c.y]);
|
|
|
+ if (obj.type == "S3M") {
|
|
|
+ e = await that.mapQuery(
|
|
|
+ window.baseModelQueryLayer,
|
|
|
+ queryByIDParameters
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ e = await that.mapQuery(
|
|
|
+ that.calcIserverURI(obj.url),
|
|
|
+ queryByIDParameters
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (e && e.totalCount > 0) {
|
|
|
+ that.layerList.push(store.state.vectorlayerlist[i]);
|
|
|
+ let queryData = [];
|
|
|
+ let geoms = [];
|
|
|
+ for (let u = 0; u < e.features.length; u++) {
|
|
|
+ let cur = [];
|
|
|
+ e.features[u].fieldNames.forEach((fieldName, i) => {
|
|
|
+ if (fieldName.toLowerCase().indexOf("shape") < 0) {
|
|
|
+ cur.push({
|
|
|
+ name: fieldName,
|
|
|
+ value: e.features[u].fieldValues[i],
|
|
|
+ });
|
|
|
}
|
|
|
- geoms.push(points);
|
|
|
- queryData.push(cur);
|
|
|
+ });
|
|
|
+ let points = [];
|
|
|
+ for (let y = 0; y < e.features[u].geometry.points.length; y++) {
|
|
|
+ let c = that.cartesianToCartographic84(
|
|
|
+ e.features[u].geometry.points[y].x,
|
|
|
+ e.features[u].geometry.points[y].y
|
|
|
+ );
|
|
|
+ points.push([c.x, c.y]);
|
|
|
}
|
|
|
- console.log(
|
|
|
- that.queryResults,
|
|
|
- "that.queryResults,",
|
|
|
- obj.id,
|
|
|
- that.queryResults[obj.id]
|
|
|
- );
|
|
|
- that.queryResults[obj.id] = queryData;
|
|
|
- that.queryResultsGeom[obj.id] = geoms;
|
|
|
+ geoms.push(points);
|
|
|
+ queryData.push(cur);
|
|
|
}
|
|
|
- }
|
|
|
- if (that.layerList.length > 0) {
|
|
|
- that.activeLayerId = that.layerList[0].id;
|
|
|
- console.log(that.activeLayerId, "that.activeLayerId");
|
|
|
- } else {
|
|
|
- that.$message({
|
|
|
- message: "查询结果为空!",
|
|
|
- type: "warning",
|
|
|
- customClass: "messageIndex",
|
|
|
- });
|
|
|
+ console.log(
|
|
|
+ that.queryResults,
|
|
|
+ "that.queryResults,",
|
|
|
+ obj.id,
|
|
|
+ that.queryResults[obj.id]
|
|
|
+ );
|
|
|
+ that.queryResults[obj.id] = queryData;
|
|
|
+ that.queryResultsGeom[obj.id] = geoms;
|
|
|
}
|
|
|
}
|
|
|
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
|
- this.handler.setInputAction(async function (movement) {
|
|
|
- that.removeMapLayerQuery();
|
|
|
- }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
|
+ if (that.layerList.length > 0) {
|
|
|
+ that.activeLayerId = that.layerList[0].id;
|
|
|
+ console.log(that.activeLayerId, "that.activeLayerId");
|
|
|
+ } else {
|
|
|
+ that.$message({
|
|
|
+ message: "查询结果为空!",
|
|
|
+ type: "warning",
|
|
|
+ customClass: "messageIndex",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 左键点击模型查询
|
|
|
*/
|
|
|
- mapModelQuery() {
|
|
|
+ mapModelQuery(movement) {
|
|
|
+ this.viewer.entities.removeAll();
|
|
|
+ this.dataSourceLayer.entities.removeAll();
|
|
|
+ handlerModel(movement);
|
|
|
+ },
|
|
|
+ mapQuerys(queryName) {
|
|
|
this.setData();
|
|
|
let that = this;
|
|
|
- this.handler.setInputAction(async function (movement) {
|
|
|
- that.viewer.entities.removeAll();
|
|
|
- that.dataSourceLayer.entities.removeAll();
|
|
|
- handlerModel(movement);
|
|
|
+ this.handler.setInputAction(function (movement) {
|
|
|
+ that[queryName](movement);
|
|
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
|
|
- this.handler.setInputAction(async function (movement) {
|
|
|
+ this.handler.setInputAction(function () {
|
|
|
that.removeMapLayerQuery();
|
|
|
clearTranslate();
|
|
|
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
|
|
@@ -534,11 +531,11 @@ export default {
|
|
|
changleQueryItem(item) {
|
|
|
switch (item.index) {
|
|
|
case 1: {
|
|
|
- this.mapLayerQuery(); //图层点击事件
|
|
|
+ this.mapQuerys("mapLayerQuery"); //图层点击事件
|
|
|
break;
|
|
|
}
|
|
|
case 2: {
|
|
|
- this.mapModelQuery();
|
|
|
+ this.mapQuerys("mapModelQuery");
|
|
|
break;
|
|
|
}
|
|
|
case 3: {
|