|
|
|
|
@ -25,7 +25,7 @@
|
|
|
|
|
item.name
|
|
|
|
|
}}</a-checkbox>
|
|
|
|
|
</p>
|
|
|
|
|
</a-collapse-panel>
|
|
|
|
|
</a-collapse-panel>
|
|
|
|
|
</a-collapse>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@ -56,7 +56,7 @@
|
|
|
|
|
|
|
|
|
|
<a-upload
|
|
|
|
|
name="file"
|
|
|
|
|
:before-upload="handleImportCoorinateChange"
|
|
|
|
|
:before-upload="handleImportShapeFileChange"
|
|
|
|
|
:showUploadList="false"
|
|
|
|
|
>
|
|
|
|
|
<p class="split-panel-item">导入图层分割</p>
|
|
|
|
|
@ -237,6 +237,9 @@
|
|
|
|
|
import { polygonCut } from './lib/segmentation';
|
|
|
|
|
import { splitPolygonByLine, splitPolygonByFill } from './lib/splitpolygon';
|
|
|
|
|
|
|
|
|
|
// 线分割
|
|
|
|
|
import {chunkUtil} from './lib/chunkutil.ts';
|
|
|
|
|
|
|
|
|
|
// 图片切换
|
|
|
|
|
import { userFormFileStore } from '@/store/modules/formFileUrl';
|
|
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
|
@ -260,7 +263,73 @@
|
|
|
|
|
import { useCloudQueryStore } from '@/store/modules/cloudquery';
|
|
|
|
|
import { AddDroneTask } from '@/api/demo/cloudQuery.ts';
|
|
|
|
|
|
|
|
|
|
// 坐标系转换
|
|
|
|
|
import proj4 from 'proj4'
|
|
|
|
|
|
|
|
|
|
// shp数据转换
|
|
|
|
|
import JSZip from 'jszip'
|
|
|
|
|
import shp from 'shpjs'
|
|
|
|
|
|
|
|
|
|
// 这里的zip为上传的zip文件
|
|
|
|
|
const parseZip = async(zip)=>{
|
|
|
|
|
// 解析zip数据为二进制数据
|
|
|
|
|
const jsZip = new JSZip()
|
|
|
|
|
const zipData = await jsZip.loadAsync(zip)
|
|
|
|
|
// 将zip文件转化为二进制流
|
|
|
|
|
const data = await zipData.generateAsync({ type: 'arraybuffer' })
|
|
|
|
|
return await shp(data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 文件选择
|
|
|
|
|
const handleImportShapeFileChange = (e)=>{
|
|
|
|
|
parseZip(e).then(res=>{
|
|
|
|
|
|
|
|
|
|
let geojson = JSON.parse(JSON.stringify(res))
|
|
|
|
|
|
|
|
|
|
// 绘制导入的shapgefile图斑
|
|
|
|
|
handlerDetails(
|
|
|
|
|
res,
|
|
|
|
|
'shapefileSource',
|
|
|
|
|
'shapefileLayer',
|
|
|
|
|
{
|
|
|
|
|
lineStyle: { 'line-color': '#ff0000', 'line-width': 3 },
|
|
|
|
|
fillStyle: { 'fill-color': '#ff0000', 'fill-opacity': 0.1 },
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '是否确认分割图斑?',
|
|
|
|
|
onCancel() {
|
|
|
|
|
handlerDetails(
|
|
|
|
|
{type:"FeatureCollection",features:[]},
|
|
|
|
|
'shapefileSource',
|
|
|
|
|
'shapefileLayer',
|
|
|
|
|
{
|
|
|
|
|
lineStyle: { 'line-color': '#ff0000', 'line-width': 3 },
|
|
|
|
|
fillStyle: { 'fill-color': '#ff0000', 'fill-opacity': 0.1 },
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
async onOk() {
|
|
|
|
|
splitFeatureByFill(geojson.features[0].geometry.coordinates[0]);
|
|
|
|
|
handlerDetails(
|
|
|
|
|
{type:"FeatureCollection",features:[]},
|
|
|
|
|
'shapefileSource',
|
|
|
|
|
'shapefileLayer',
|
|
|
|
|
{
|
|
|
|
|
lineStyle: { 'line-color': '#ff0000', 'line-width': 3 },
|
|
|
|
|
fillStyle: { 'fill-color': '#ff0000', 'fill-opacity': 0.1 },
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 绘制导入的shapefile面图斑
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 投影转地理坐标系
|
|
|
|
|
function GkToCGCS2000(lngLat){
|
|
|
|
|
@ -289,9 +358,6 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const useCloudQuery = useCloudQueryStore();
|
|
|
|
|
|
|
|
|
|
const { VITE_GLOB_API_URL } = getAppEnvConfig();
|
|
|
|
|
@ -716,43 +782,63 @@
|
|
|
|
|
let splitPolygon = currentGeoJson.value;
|
|
|
|
|
try {
|
|
|
|
|
// let features = polygonCut(splitPolygon,splitLineString,0.1,"meters");
|
|
|
|
|
let features = splitPolygonByLine(splitLineString, splitPolygon);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
splitPolygon?.geometry.coordinates[0].forEach((item,index)=>{
|
|
|
|
|
splitPolygon.geometry.coordinates[0][index] = [item[0],item[1]];
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let features = splitPolygonByLine(splitLineString, splitPolygon);
|
|
|
|
|
|
|
|
|
|
let tempFeatures = JSON.parse(JSON.stringify(features))
|
|
|
|
|
|
|
|
|
|
let splitAfterFeatures = {
|
|
|
|
|
type: 'FeatureCollection',
|
|
|
|
|
features: [],
|
|
|
|
|
};
|
|
|
|
|
splitAfterFeatures.features = features;
|
|
|
|
|
|
|
|
|
|
emit('handlerSplitPolygon', features);
|
|
|
|
|
handlerDetails(splitAfterFeatures);
|
|
|
|
|
splitAfterFeatures.features = tempFeatures;
|
|
|
|
|
|
|
|
|
|
console.log("tempFeatures",tempFeatures)
|
|
|
|
|
// 分割数据返回父组件中
|
|
|
|
|
emit('handlerSplitPolygon', tempFeatures);
|
|
|
|
|
|
|
|
|
|
// 分割完成后重新渲染面数据
|
|
|
|
|
// handlerDetails(splitAfterFeatures);
|
|
|
|
|
handlerUnDraw();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
createMessage.warning('分割线起点、终点需要在图斑外');
|
|
|
|
|
console.log("error error",e);
|
|
|
|
|
createMessage.warning('分割线起点、终点需要在图斑外,多个图斑时需要点击选择需要分割的图斑!');
|
|
|
|
|
handlerUnDraw();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 根据面分割
|
|
|
|
|
const splitFeatureByFill = (fill) => {
|
|
|
|
|
let splitLineString = {
|
|
|
|
|
|
|
|
|
|
let drawPolygon = {
|
|
|
|
|
type: 'Feature',
|
|
|
|
|
properties: {},
|
|
|
|
|
properties: {
|
|
|
|
|
id:null,
|
|
|
|
|
},
|
|
|
|
|
geometry: {
|
|
|
|
|
coordinates: [fill],
|
|
|
|
|
type: 'Polygon',
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
let splitPolygon = currentGeoJson.value;
|
|
|
|
|
// let features = polygonCut(splitPolygon,splitLineString,0.1,"meters");
|
|
|
|
|
let features = splitPolygonByFill(splitLineString, splitPolygon);
|
|
|
|
|
|
|
|
|
|
let features = splitPolygonByFill(drawPolygon, splitPolygon);
|
|
|
|
|
|
|
|
|
|
let tempFeatures = JSON.parse(JSON.stringify(features))
|
|
|
|
|
|
|
|
|
|
let splitAfterFeatures = {
|
|
|
|
|
type: 'FeatureCollection',
|
|
|
|
|
features: [],
|
|
|
|
|
};
|
|
|
|
|
splitAfterFeatures.features = [features];
|
|
|
|
|
handlerDetails(splitAfterFeatures);
|
|
|
|
|
splitAfterFeatures.features = tempFeatures;
|
|
|
|
|
emit('handlerSplitPolygon', tempFeatures);
|
|
|
|
|
handlerUnDraw();
|
|
|
|
|
};
|
|
|
|
|
//绘制点
|
|
|
|
|
@ -790,11 +876,21 @@
|
|
|
|
|
splitPanelVisible.value = false;
|
|
|
|
|
mp.draw('Polygon');
|
|
|
|
|
mp.on('Polygon', function (e) {
|
|
|
|
|
let coordinates = [];
|
|
|
|
|
e?.forEach((item, index) => {
|
|
|
|
|
coordinates?.push([item.lng, item.lat]);
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '是否确认分割图斑?',
|
|
|
|
|
onCancel() {
|
|
|
|
|
handlerUnDraw();
|
|
|
|
|
},
|
|
|
|
|
async onOk() {
|
|
|
|
|
let coordinates = [];
|
|
|
|
|
e?.forEach((item, index) => {
|
|
|
|
|
coordinates?.push([item.lng, item.lat]);
|
|
|
|
|
});
|
|
|
|
|
coordinates.push(coordinates[0]);
|
|
|
|
|
splitFeatureByFill(coordinates);
|
|
|
|
|
handlerUnDraw();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
splitFeatureByFill(coordinates);
|
|
|
|
|
emit('mapDraw', 'Polygon', e);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
@ -1131,7 +1227,6 @@
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const currentGeoJson = ref({});
|
|
|
|
|
|
|
|
|
|
const handlerDetails = (
|
|
|
|
|
geojson,
|
|
|
|
|
source = 'detailsSource',
|
|
|
|
|
@ -1141,26 +1236,30 @@
|
|
|
|
|
fillStyle: { 'fill-color': '#fcf003', 'fill-opacity': 0.1 },
|
|
|
|
|
},
|
|
|
|
|
) => {
|
|
|
|
|
|
|
|
|
|
let fillLayerName = layer + 'Fill';
|
|
|
|
|
let lineLayerName = layer + 'Line';
|
|
|
|
|
|
|
|
|
|
if (source == 'detailsSource') {
|
|
|
|
|
console.log('currentGeoJson', geojson);
|
|
|
|
|
if (source == 'detailsSource' || source == "splitPolygonSource") {
|
|
|
|
|
// 判断是单面还是多面
|
|
|
|
|
let coordinates = null;
|
|
|
|
|
if (geojson.features.length>0 && geojson.features[0].geometry.type == 'MultiPolygon') {
|
|
|
|
|
|
|
|
|
|
if (geojson.features.length>0 && geojson.features[0].geometry.type == 'MultiPolygon') { // 多面
|
|
|
|
|
// 默认取了第一个面的数据
|
|
|
|
|
coordinates = geojson.features[0].geometry.coordinates[0];
|
|
|
|
|
} else if (geojson.features.length>0 && geojson.features[0].geometry.type == 'Polygon') {
|
|
|
|
|
} else if (geojson.features.length>0 && geojson.features[0].geometry.type == 'Polygon') { // 单面
|
|
|
|
|
coordinates = geojson.features[0].geometry.coordinates;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 天坑! 判读端传回的的图斑数据 最后2个坐标完全相同导致Mapbox解析不了报错!!!!
|
|
|
|
|
if (coordinates) {
|
|
|
|
|
if(
|
|
|
|
|
coordinates[0][coordinates[0].length - 1][0] ==
|
|
|
|
|
coordinates[0][coordinates[0].length - 2][0]
|
|
|
|
|
) {
|
|
|
|
|
if((coordinates[0][coordinates[0].length - 1][0] == coordinates[0][coordinates[0].length - 2][0]) && (coordinates[0][coordinates[0].length - 1][1] == coordinates[0][coordinates[0].length - 2][1])) {
|
|
|
|
|
coordinates[0]?.pop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let singleFeature = {
|
|
|
|
|
type: 'Feature',
|
|
|
|
|
properties: {},
|
|
|
|
|
@ -1169,10 +1268,13 @@
|
|
|
|
|
type: 'Polygon',
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
currentGeoJson.value = singleFeature;
|
|
|
|
|
console.log('currentGeoJson', currentGeoJson.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 需要将传入的geojson处理成单面才能在分割工具中使用
|
|
|
|
|
currentGeoJson.value = singleFeature;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (map.getSource(source)) {
|
|
|
|
|
map.getSource(source).setData(geojson);
|
|
|
|
|
} else {
|
|
|
|
|
@ -1195,10 +1297,14 @@
|
|
|
|
|
paint: style.lineStyle,
|
|
|
|
|
});
|
|
|
|
|
map.on('click', fillLayerName, function (e) {
|
|
|
|
|
|
|
|
|
|
if (e.features.length > 0) {
|
|
|
|
|
var feature = e.features[0];
|
|
|
|
|
emit('onFeatureClick', feature);
|
|
|
|
|
}
|
|
|
|
|
if(fillLayerName == 'detailsLayerFill' || fillLayerName == 'detailsLayerLine'){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
@ -1297,7 +1403,7 @@
|
|
|
|
|
};
|
|
|
|
|
const handlerLocationRemove = (index: number) => {
|
|
|
|
|
locationArrays.value.splice(index, 1);
|
|
|
|
|
locationDrawArrays.value.splice(index, 1);
|
|
|
|
|
locationDrawArrays.value?.splice(index, 1);
|
|
|
|
|
handlerLocationGeoJson();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -1311,7 +1417,7 @@
|
|
|
|
|
console.log(obj);
|
|
|
|
|
locationDrawArrays.value?.push(obj)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
locationDrawArrays.value?.forEach((item,index)=>{
|
|
|
|
|
// 坐标系转换
|
|
|
|
|
if(item.lng > 180){
|
|
|
|
|
|