import ExeJSZip from "@/utils/ExeJSZip"; const MapDefaultConfig = Object.freeze({ terrain: false, baseMap: [], skyBox: NewFiberMap.Enum.SkyBox.STARMAP, }); export default class NewFiberMapUtils { static _layers = [ { id: 'jz', params: { url: 'http://192.168.16.133:9994/zhoukou/tileset.json' } } ] _nmObjects = { map: null } constructor(container, options = MapDefaultConfig, newfiberMap = {}) { !!newfiberMap.getMap ? this._nmObjects.map = newfiberMap : this.initMap(container, options); } flyto (callback) { let self = this; self._nmObjects.map.setCenter({ "roll": 0, "pitch": -89.9789632487528, "heading": 359.668649161515, "lng": 114.79135440606686, "lat": 33.708784722408105, "height": 1079783.5463980145, duration: 5, callback: () => { self._nmObjects.map.setCenter({ "roll": 0, "pitch": -89.97897700421618, "heading": 359.66864916154407, "lng": 114.65317286078579, "lat": 33.62531665850251, "height": 48171.58619786275, duration: 3, callback: () => self._nmObjects.map.setCenter({ "roll": 0.008918587209573099, "pitch": -31.34711691790419, "heading": 0.33084051306203693, "lng": 114.65981781173507, "lat": 33.452691351966934, "height": 11152.253644133574, duration: 3, callback: () => callback && callback(), }), }); }, }); } /* async vectorToMap () { const getStyleByCategory = (item) => { let { category } = item; return { //水系 'river_system': (item) => { let feature = turf.polygonToLine(Terraformer.WKT.parse(item.geometrys)); return { ...item, layerKey: category, geometrys: Terraformer.WKT.convert(feature.geometry || feature.features[0].geometry), type: NewFiberMap.Enum.VectorType.WALL, // name: item.categoryName, style: { show: true, maximumHeights: 100, minimunHeights: 0, // distanceDisplayCondition: [5000, 25000], material: new NewFiberMap.Material.WallImageTrailMaterialProperty({ image: NewFiberMapConfig.SDK_INIT_SRC_PREFIX + '/static/images/material/wall/line2.png', duration: 1000 }) }, } NewFiberMap.Layer.Primitive.loadWaterPrimitive({ geojson: results, height: 20, id: '08-14' + NewFiberMapUtils.lineFLag, show: false }, newfiberMap.getMap()); }, //行政区 'region_category': (item) => { let feature = turf.polygonToLine(Terraformer.WKT.parse(item.geometrys)); return { ...item, layerKey: category, geometrys: Terraformer.WKT.convert(feature.geometry || feature.features[0].geometry), type: NewFiberMap.Enum.VectorType.POLYLINE, style: { width: 5, //顺时针 material: 'rgba(0,148,232,1)', clampToGround: true }, } return [ { ...item, layerKey: category, geometrys: Terraformer.WKT.convert(feature.geometry || feature.features[0].geometry), type: NewFiberMap.Enum.VectorType.POLYLINE, style: { width: 2, //顺时针 material: 'rgba(0,148,232,1)', clampToGround: true }, }, ] }, //建成区 'built_up_area': (item) => { return { ...item, layerKey: category, type: NewFiberMap.Enum.VectorType.WALL, // name: item.categoryName, style: { show: true, maximumHeights: 200, minimunHeights: 0, material: new NewFiberMap.Material.WallImageTrailMaterialProperty({ image: NewFiberMapConfig.SDK_INIT_SRC_PREFIX + '/static/images/material/wall/line10.png', duration: 1000 }) /!* material: new NewFiberMap.Material.WallDiffuseMaterialProperty({ image: NewFiberMapConfig.SDK_INIT_SRC_PREFIX + '/static/images/material/wall/colors_blue_v1.png', duration: 1000 })*!/ }, } } }[category](item); } let dictList = await listData({ dictType: 'layer_category' }); let dictValues = dictList.data.map(item => item.dictValue); // let {data} = await layerManagementLists({category:dictValues.join(',')}); let results = await Promise.all(dictValues.map(value => layerManagementList({ category: value }))); let data = results.map(item => item.data).flat(); NewFiberMap.Layer.Primitive.loadWaterPrimitive({ geojson: NewFiberMap.Data.ToGeoJSON.beansWktToGeoJson(data.filter(item => item.category == 'river_system')), height: 10, id: 'river_system', show: true }, this._nmObjects.map.getMap()); this._nmObjects.map.geojsonToMap(NewFiberMap.Data.ToGeoJSON.beansWktToGeoJson(data.map(item => getStyleByCategory(item)).flat().flat(), { id: 'layerKey' })) let timeout = setTimeout(() => { let entitys = this._nmObjects.map.getLayers(['region_category']); if (!!!entitys.length) return; clearTimeout(timeout); entitys.forEach(entity => { entity.operation = "+"; entity.opacity = 0; entity.polyline.material = new Cesium.ColorMaterialProperty(new Cesium.CallbackProperty(function () { if (entity.opacity == 0) entity.operation = '+'; if (entity.opacity == 100) entity.operation = '-'; eval(`entity.opacity ${entity.operation}=5`); let cesiumColor = Cesium.Color.fromCssColorString(`rgba(0, 148, 232, 1)`); cesiumColor.alpha = entity.opacity / 100; return cesiumColor; }, false)) }) }, 1000) }*/ baseMapChange (type) { let baseMapOptions = [ { enums: [NewFiberMap.Enum.BaseMap.MAPBOX_STYLE_VECTOR], options: { style: { background: { id: "background", paint: { "background-color": "rgb(0,34,82)", }, }, "road-street": { id: "road-street", paint: { "line-width": { base: 1.5, stops: [ [12.5, 0.5], [14, 2], [18, 18], ], }, "line-opacity": { base: 1, stops: [ [13.99, 0], [14, 1], ], }, "line-color": "rgba(10,48,136,1)", }, }, "road-secondary-tertiary": { id: "road-secondary-tertiary", paint: { "line-width": { base: 1.5, stops: [ [8.5, 1], [10, 2], [16, 20], [17, 25], [18, 37], ], }, "line-opacity": { base: 1.2, stops: [ [5, 0], [5.5, 1], ], }, "line-color": "rgba(0,53,91,1)", }, }, park: { id: "park", paint: { "fill-color": "rgba(0,108,106,1)", }, }, water: { id: "water", paint: { "fill-color": "rgba(0,6,63,1)", }, }, "road-trunk": { id: "road-trunk", paint: { "line-width": { base: 1.5, stops: [ [5, 0.75], [18, 32], ], }, "line-opacity": 1, "line-color": "rgba(0,53,91,1)", }, }, "road-primary": { id: "road-primary", paint: { "line-opacity": 1, "line-color": "rgba(0,53,91,1)", }, }, school: { id: "school", paint: { "fill-color": "rgba(39,92,52,1)", }, }, cemetery: { id: "cemetery", paint: { "fill-color": "rgba(46,55,48,1)", }, }, "bridge-primary-case": { id: "bridge-primary-case", paint: { "line-width": { base: 1.5, stops: [ [10, 1], [16, 2], ], }, "line-color": "rgba(0,53,91,1)", "line-gap-width": { base: 1.5, stops: [ [5, 0.75], [18, 32], ], }, "line-translate": [0, 0], }, }, "bridge-primary": { id: "bridge-primary", paint: { "line-width": { base: 1.5, stops: [ [5, 0.75], [18, 32], ], }, "line-color": "rgba(0,53,91,1)", "line-opacity": 1, }, }, "road-shields-black": { id: "road-shields-black", layout: {}, paint: { "text-color": "hsl(0, 0%, 7%)", "icon-halo-color": "rgba(0, 0, 0, 1)", "icon-halo-width": 1, "text-opacity": 0, "icon-color": "white", }, }, landcover_crop: { id: "landcover_crop", paint: { "fill-opacity": { base: 1.5, stops: [ [2, 0], [7, 0], ], }, "fill-color": "hsl(180, 18%, 10%)", }, }, 'road-motorway': { "id": "road-motorway", "layout": { "line-cap": "round", "line-join": "round", "visibility": "visible" }, "paint": { "line-width": [ "interpolate", [ "exponential", 1.5 ], [ "zoom" ], 5, 0.75, 18, 32 ], "line-color": [ "interpolate", [ "linear" ], [ "zoom" ], 6, "rgba(65,90,119,1)", 8, "rgba(65,90,119,1)", ], "line-opacity": 1 } }, 'bridge-motorway': { "id": "bridge-motorway", "layout": { "line-cap": "round", "line-join": "round", "visibility": "visible" }, "paint": { "line-width": [ "interpolate", [ "exponential", 1.5 ], [ "zoom" ], 5, 0.75, 18, 32 ], "line-color": [ "interpolate", [ "linear" ], [ "zoom" ], 6, "rgba(65,90,119,1)", 8, "rgba(65,90,119,1)", ], "line-opacity": 1 } }, 'bridge-motorway-case': { "id": "bridge-motorway-case", "layout": { "line-cap": "round", "line-join": "round", "visibility": "visible" }, "paint": { "line-width": [ "interpolate", [ "exponential", 1.5 ], [ "zoom" ], 5, 0.75, 18, 32 ], "line-color": [ "interpolate", [ "linear" ], [ "zoom" ], 6, "rgba(65,90,119,1)", 8, "rgba(65,90,119,1)", ], "line-opacity": 1 } }, 'road-primary-case': { "id": "road-primary-case", "layout": { "line-cap": "round", "line-join": "round", "visibility": "visible" }, "paint": { "line-width": [ "interpolate", [ "exponential", 1.5 ], [ "zoom" ], 5, 0.75, 18, 32 ], "line-color": [ "interpolate", [ "linear" ], [ "zoom" ], 6, "rgba(0,53,91,1)", 8, "rgba(0,53,91,1)", ], "line-opacity": 1 } }, 'bridge-secondary-tertiary-case': { "id": "bridge-secondary-tertiary-case", "layout": { "line-cap": "round", "line-join": "round", "visibility": "visible" }, "paint": { "line-width": [ "interpolate", [ "exponential", 1.5 ], [ "zoom" ], 5, 0.75, 18, 32 ], "line-color": [ "interpolate", [ "linear" ], [ "zoom" ], 6, "rgba(65,90,119,1)", 8, "rgba(65,90,119,1)", ], "line-opacity": 1 } }, 'road-motorway-link': { "id": "road-motorway-link", "paint": { "line-width": [ "interpolate", [ "exponential", 1.5 ], [ "zoom" ], 12, 0.5, 14, 2, 18, 18 ], "line-color": [ "interpolate", [ "linear" ], [ "zoom" ], 6, "rgba(65,90,119,1)", 8, "rgba(65,90,119,1)", ], "line-opacity": 1 }, }, 'bridge-motorway-link': { "id": "bridge-motorway-link", "paint": { "line-width": [ "interpolate", [ "exponential", 1.5 ], [ "zoom" ], 12, 0.5, 14, 2, 18, 18 ], "line-color": [ "interpolate", [ "linear" ], [ "zoom" ], 6, "rgba(65,90,119,1)", 8, "rgba(65,90,119,1)", ], "line-opacity": 1 }, }, 'bridge-motorway-link-case': { "id": "bridge-motorway-link-case", "paint": { "line-width": [ "interpolate", [ "exponential", 1.5 ], [ "zoom" ], 12, 0.5, 14, 2, 18, 18 ], "line-color": [ "interpolate", [ "linear" ], [ "zoom" ], 6, "rgba(65,90,119,1)", 8, "rgba(65,90,119,1)", ], "line-opacity": 1 }, }, "poi-parks-small": { "id": "poi-parks-small", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "poi-small": { "id": "poi-small", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "poi-parks-large": { "id": "poi-parks-large", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "poi-large": { "id": "poi-large", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "airport-label": { "id": "airport-label", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "rail-station-label": { "id": "rail-station-label", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "road-label-small": { "id": "road-label-small", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "road-label-medium": { "id": "road-label-medium", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "road-label-large": { "id": "road-label-large", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "place-islets-archipelago-aboriginal": { "id": "place-islets-archipelago-aboriginal", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "place-islets-archipelago-aboriginal-2": { "id": "place-islets-archipelago-aboriginal-2", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "place-town": { "id": "place-town", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "place-islands": { "id": "place-islands", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "place-islands-2": { "id": "place-islands-2", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1 } }, "place-city-small": { "id": "place-city-small", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1, "text-translate": [ 0, 0 ] } }, "place-city-medium": { "id": "place-city-medium", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1, "text-translate": [ 0, 0 ] } }, "place-city-large": { "id": "place-city-large", "paint": { "text-color": "rgba(154,231,255,1)", "text-halo-width": 1, "text-halo-color": "hsl(0, 0%, 0%)", "text-translate": [ 0, 0 ] } }, 'place-village': { "id": "place-village", "paint": { "text-halo-color": "hsl(0, 0%, 0%)", "text-halo-width": 1, "text-color": "rgba(154,231,255,1)" }, }, }, }, }, /* { enums: [ NewFiberMap.Enum.BaseMap.MAPBOX_STYLE_VECTOR ], options: {}, },*/ { enums: [ NewFiberMap.Enum.BaseMap.AMAP_VECTOR_V2 ], options: {}, }, { enums: [ NewFiberMap.Enum.BaseMap.TC_LABEL, NewFiberMap.Enum.BaseMap.ARCGIS_IMAGE, ], options: {}, }, ]; this._nmObjects.map.setBaseMapByEnum(baseMapOptions[type].enums, [], baseMapOptions[type].options); } loadBuildingsModel () { this._nmObjects.map.loadCesium3DTileSet({ id: NewFiberMapUtils._layers[0].id, url: NewFiberMapUtils._layers[0].params.url, offsetHeight: 0, show: true, }); let baimo = this._nmObjects.map.getLayers([NewFiberMapUtils._layers[0].id])[0]; baimo.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ['${height} >= 30', "rgba(25,111,227,1)"],//pink ['${height} >= 20', 'rgb(20,87,180)'], ['${height} >= 10', 'rgb(16,74,156)'], ['true', 'rgb(14,62,130)'], ] } }) } initMap (container, options) { if (!!!container || !!!document.getElementById(container)) throw new Error(`id为:${container}容器的容器无法被初始化,请检查`); this._nmObjects.map = new NewFiberMap(container, options); this._nmObjects.map.getMap().scene.globe.baseColor = Cesium.Color.fromCssColorString("rgba(25,25,112,.1)"); if(import.meta.env.VITE_PROJECT_ISERVER_URL){ [ {id:'1',name:'影像图',url:import.meta.env.VITE_PROJECT_ISERVER_URL+'/iserver/services/map-arcgis-15/rest/maps/图层'}, {id:'2',name:'注记',url:import.meta.env.VITE_PROJECT_ISERVER_URL + '/iserver/services/map-arcgis-3/rest/maps/图层'}, ].forEach(i => { let imagery = newfiberMap.getMap().imageryLayers.addImageryProvider(new SuperMap3D.SuperMapImageryProvider({url : i.url})); imagery.alpha = 1.0; // 缩放到图层可见 newfiberMap.getMap().zoomTo(imagery); }) }else{ this.baseMapChange(1); } /* this._nmObjects.map.loadMtsLayer({ url:import.meta.env.BASE_MAP_CONFIG.offLine + '/overlay/{z}/{x}/{y}.png',tilingScheme:new Cesium.GCJToMercatorTilingScheme() }) this._nmObjects.map.loadMtsLayer({ url:import.meta.env.BASE_MAP_CONFIG.offLine + '/satellite/{z}/{x}/{y}.png',tilingScheme:new Cesium.GCJToMercatorTilingScheme() })*/ } setLayersVisible (ids, visible) { if (!!!ids.length) return; this._nmObjects.map.setLayersVisible(ids, visible); } registerLeftClick (callback) { this._nmObjects.map.registerLeftClickEvt((position, point, feature = {}) => { callback && callback(feature); console.log('feature.properties', feature.properties.getValue()); }); } initPipeLine () { let self = this; let colors = { ys: { color: 'rgba(7,70,180,1)', key: '3-1' }, hs: { color: 'rgba(255,229,23,1)', key: '3-3' }, ws: { color: 'rgba(255,0,0,1)', key: '3-2' }, }; request(`/static/map/pipeline.json`, { method: "GET" }).then((res) => { res.features.forEach((i) => { i.properties.style_ = { id: colors[i.properties.type].key, type: NewFiberMap.Enum.VectorType.POLYLINE, options: { show: false, width: 15, clampToGround: true, material: new NewFiberMap.Material.PolylineTrailLinkAntiMaterialProperty({ duration: 1.0001, image: NewFiberMapConfig.SDK_INIT_SRC_PREFIX + '/static/images/material/polyline/' + (i.properties.type + '_v2.png'), color: Cesium.Color.fromCssColorString(colors[i.properties.type].color) }) }, }; }); self._nmObjects.map.geojsonToMap(res); }); } initBoundary () { let self = this; request(`/static/map/boundary.json`, { method: "GET" }).then((res) => { res.features.forEach((i) => { i.properties.style_ = { id: '4-1', type: NewFiberMap.Enum.VectorType.WALL, options: { show: false, maximumHeights: 80, minimunHeights: 0, material: new NewFiberMap.Material.WallDiffuseMaterialProperty({ image: NewFiberMapConfig.SDK_INIT_SRC_PREFIX + "/static/images/material/wall/line2.png", duration: 1000, }), }, }; }); self._nmObjects.map.geojsonToMap(res); }); } initSitePoint (id) { let self = this; let type2ImageUrl = { 3: '/static/img/img/nlz_icon.png', 4: '/static/img/img/ylz_zc_icon.png', 16: '/static/img/img/jlz_zc_icon.png' } prositeinfoData(id).then((result) => { let data = result.data.records; let points = data.map(item => { let { siteName, typeName, siteNo, fileList, typeId, pointx, pointy } = item; if (!!!pointx || !!!pointy) return; [pointx, pointy] = NewFiberMap.CoordTransform.gcj02towgs84(pointx, pointy); return { id: siteName, name: siteName, typeName, siteNo, fileList, typeId, geometrys: `POINT(${pointx} ${pointy})`, type: NewFiberMap.Enum.VectorType.ICON, style: { url: type2ImageUrl[id], width: 35, height: 40, pixelOffset: [0, -25], show: false, distanceDisplayCondition: [Number.MIN_VALUE, 10000], }, labelOptions: { style: Cesium.LabelStyle.FILL_AND_OUTLINE, outlineColor: 'rgba(255,0,0,1)', outline: true, outlineWidth: 3, color: "#ffffff", pixelOffset: [0, 16], distanceDisplayCondition: [Number.MIN_VALUE, 5000], } }; }).filter(Boolean); self._nmObjects.map.geojsonToMap(NewFiberMap.Data.ToGeoJSON.beansWktToGeoJson(points)); }) } initProjectPoint () { let self = this; let type2ImageUrl = { 1: '/static/img/img/gkzb_icon.png', 2: '/static/img/img/xmjxz_icon.png', 3: '/static/img/img/xmywc_icon.png' } projectinfoData2('').then((result) => { let data = result.data.records; let points = data.map(item => { let { projectStatus, pointx, pointy } = item; if (!!!pointx || !!!pointy) return; [pointx, pointy] = NewFiberMap.CoordTransform.gcj02towgs84(pointx, pointy); return { ...item, id: '2-1', name: item.projectName, geometrys: `POINT(${pointx} ${pointy})`, type: NewFiberMap.Enum.VectorType.ICON, style: { url: type2ImageUrl[projectStatus], width: 40, height: 40, pixelOffset: [0, -25], show: false, distanceDisplayCondition: [Number.MIN_VALUE, 10000], }, labelOptions: { style: Cesium.LabelStyle.FILL_AND_OUTLINE, outlineColor: 'rgba(7,70,180,1)', outline: true, outlineWidth: 3, color: "#ffffff", pixelOffset: [0, 16], distanceDisplayCondition: [Number.MIN_VALUE, 5000], } }; }).filter(Boolean); self._nmObjects.map.geojsonToMap(NewFiberMap.Data.ToGeoJSON.beansWktToGeoJson(points)); }) } initWaterPoint () { let self = this; let type2ImageUrl = { 1: '/static/img/img/dxs_icon.png', 2: '/static/img/img/pk_icon.png', 3: '/static/img/img/yys_icon.png' } environmentinfoData({}).then((result) => { let data = result.data; let points = data.map(item => { let { type, pointx, pointy } = item; if (!!!pointx || !!!pointy) return; [pointx, pointy] = NewFiberMap.CoordTransform.gcj02towgs84(pointx, pointy); return { ...item, name: item.samplingPointname, geometrys: `POINT(${pointx} ${pointy})`, type: NewFiberMap.Enum.VectorType.ICON, style: { url: type2ImageUrl[type], width: 40, height: 40, pixelOffset: [0, -25], show: false, distanceDisplayCondition: [Number.MIN_VALUE, 10000], }, labelOptions: { style: Cesium.LabelStyle.FILL_AND_OUTLINE, outlineColor: 'rgba(106,110,164,1)', outline: true, outlineWidth: 3, color: "#ffffff", pixelOffset: [0, 16], distanceDisplayCondition: [Number.MIN_VALUE, 5000], } }; }).filter(Boolean); self._nmObjects.map.geojsonToMap(NewFiberMap.Data.ToGeoJSON.beansWktToGeoJson(points)); }) } initMonitorPoint () { let self = this; let type2ImageUrl = { 3: { getUrl: (onLine, warnLogs) => onLine ? 'static/img/img/nlz_zc_icon.png' : !!warnLogs.length ? '/static/img/img/nlz_bj_icon.gif' : 'static/img/img/nlz_dx_icon.png', key: '1-1' }, 16: { getUrl: (onLine, warnLogs) => onLine ? 'static/img/img/jlz_zc_icon.png' : !!warnLogs.length ? '/static/img/img/jlz_bj_icon.gif' : 'static/img/img/jlz_dx_icon.png', key: '1-2' }, 4: { getUrl: (onLine, warnLogs) => onLine ? 'static/img/img/ylz_zc_icon.png' : !!warnLogs.length ? '/static/img/img/ylz_bj_icon.gif' : 'static/img/img/ylz_dx_icon.png', key: '1-3' } } getSiteStatusList({}).then((result) => { let data = result.data.data; let points = data.map(item => { let { typeId, onLine, warnLogs, pointx, pointy } = item; if (!!!pointx || !!!pointy) return; [pointx, pointy] = NewFiberMap.CoordTransform.gcj02towgs84(pointx, pointy); return { ...item, id: type2ImageUrl[typeId].key, name: item.siteName, geometrys: `POINT(${pointx} ${pointy})`, type: NewFiberMap.Enum.VectorType.ICON, style: { url: type2ImageUrl[typeId].getUrl(onLine, warnLogs), width: 40, height: 40, pixelOffset: [0, -25], show: false, distanceDisplayCondition: [Number.MIN_VALUE, 10000], }, labelOptions: { style: Cesium.LabelStyle.FILL_AND_OUTLINE, outlineColor: 'rgba(106,110,164,1)', outline: true, outlineWidth: 3, color: "#ffffff", pixelOffset: [0, 16], distanceDisplayCondition: [Number.MIN_VALUE, 5000], } }; }).filter(Boolean); self._nmObjects.map.geojsonToMap(NewFiberMap.Data.ToGeoJSON.beansWktToGeoJson(points)); }) } async initCadParseToMap(url = "/http/1697084952290426883.zip"){ let textName = "text.csv"; let obj = {}; const exeJSZip = new ExeJSZip(); const data = await exeJSZip.getBinaryContent(url); const zip = await exeJSZip.iterateZipFile(data); await Promise.all(Object.keys(zip.files).map(async (key) => { try { let split = '","'; if(key == textName ) split = ','; let csvData = await zip.file(key).async("text"); const rows = csvData.split(/[\r\n]+/); const headers = rows[0].split(','); rows.shift(); obj[key] = rows.map(v => _.zipObject(headers,v.split(split).map(i => i.replaceAll('\"',"")))).filter(i => !!i.Geometry || (key == textName && i.text)); }catch (e) { obj[key] = []; } })); let geojson = turf.featureCollection(Object.keys(obj).filter(key => key != textName).map(key => { let color = randomRgb(); if(!!!obj[key].length) return []; return NewFiberMap.Data.ToGeoJSON.beansWktToGeoJson(obj[key].map(i => { let type = getTypeByGeometry(i.Geometry); let style = getStyle(type,{color}); if(!!!style || type == 'text') debugger return {Geometry:i.Geometry,id:key,type,name:i.text,style}; }),{geometry:'Geometry'}).features; }).flat().flat()); debugger; this._nmObjects.map.geojsonToMap(geojson); this.toCenterByGeoJson(geojson); let labels = this._nmObjects.map.getMap().scene.primitives.add(new Cesium.LabelCollection()); // obj[textName].map(item => { // labels.add({ // position: new Cesium.Cartesian3.fromDegrees(item.x, item.y, 10), // text: item.text + '', // font: '14px Helvetica', // fillColor: Cesium.Color.fromCssColorString( 'rgba(0,0,0,1)'), // horizontalOrigin : Cesium.HorizontalOrigin.LEFT, // verticalOrigin : Cesium.VerticalOrigin.CENTER, // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 500000), // disableDepthTestDistance: Number.POSITIVE_INFINITY, // // eyeOffset: Cesium.Cartesian3(100.0, 0.0, 0.0), // heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, // style: Cesium.LabelStyle.FILL, // outlineColor: Cesium.Color.fromCssColorString("rgba(66,133,244,1)"), // outline:true, // pixelOffset: new Cesium.Cartesian2(10,-20), // }) // }) function getTypeByGeometry(geometry) { const {LINESTRING,POLYGON,POINT} = NewFiberMap.Enum.WKTType; return [geometry.includes(LINESTRING) && NewFiberMap.Enum.VectorType.POLYLINE.toLocaleLowerCase(),geometry.includes(POINT) && POINT.toLocaleLowerCase(),geometry.includes(POLYGON) && POLYGON.toLocaleLowerCase()].filter(Boolean)[0]; } function randomRgb(){//rgb颜色随机 const r = Math.floor(Math.random()*256); const g = Math.floor(Math.random()*256); const b = Math.floor(Math.random()*256); return `rgba(${r},${g},${b},1)`; } function getStyle(type,options) { const {POLYLINE,POLYGON,POINT} = NewFiberMap.Enum.VectorType; return { [POINT]:{ pixelSize:0.1, color: Cesium.Color.fromCssColorString(options.color || '#fff'), outlineColor: Cesium.Color.fromCssColorString(options.color || '#fff'), outlineWidth: 0.1, }, [POLYGON]:{ material: options.color }, [POLYLINE]:{ material: options.color } }[type] } } toCenterByGeoJson(geojson) { let coords = turf.getCoords(geojson.features[0].geometry).flat(); let flag = geojson.features.length == 1 && coords.length == 2; if (!!geojson.features.length && !flag) { this._nmObjects.map.getMap().camera.flyTo({destination: new Cesium.Rectangle.fromDegrees(...turf.bbox(turf.transformScale(turf.bboxPolygon(turf.bbox(geojson)), 2)))}); } else { this._nmObjects.map.setCenter({ "roll": 0.01658908985506884, "pitch": -87.24924906709752, "heading": 5.026928271138224, "lng": coords[0], "lat": coords[1], "height": 943.5996932813425 }) } } }