gisviewer-vue3-arcgis 1.0.223 → 1.0.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/src/gis-map/gis-map.vue.d.ts +32 -2
- package/es/src/gis-map/gis-map.vue.mjs +12 -11
- package/es/src/gis-map/index.d.ts +32 -2
- package/es/src/gis-map/style/index.css +12 -0
- package/es/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.d.ts +31 -2
- package/es/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.mjs +94 -78
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.mjs +159 -117
- package/es/src/gis-map/utils/sketchView.d.ts +1 -0
- package/es/src/gis-map/utils/sketchView.mjs +3 -0
- package/es/src/types/index.d.ts +1 -0
- package/lib/src/gis-map/gis-map.vue.d.ts +32 -2
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +32 -2
- package/lib/src/gis-map/style/index.css +12 -0
- package/lib/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.d.ts +31 -2
- package/lib/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.js +1 -1
- package/lib/src/gis-map/utils/sketchView.d.ts +1 -0
- package/lib/src/gis-map/utils/sketchView.js +1 -1
- package/lib/src/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -3,6 +3,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
3
3
|
type: StringConstructor;
|
|
4
4
|
required: true;
|
|
5
5
|
};
|
|
6
|
+
flash: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
6
10
|
crossId: {
|
|
7
11
|
type: StringConstructor;
|
|
8
12
|
required: true;
|
|
@@ -36,6 +40,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
36
40
|
required: true;
|
|
37
41
|
};
|
|
38
42
|
}, {
|
|
43
|
+
colors: string[];
|
|
39
44
|
props: any;
|
|
40
45
|
panelStyle: import("vue").ComputedRef<{
|
|
41
46
|
top: string;
|
|
@@ -43,16 +48,36 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
43
48
|
'transform-origin': string;
|
|
44
49
|
transform: string;
|
|
45
50
|
}>;
|
|
46
|
-
uImage: import("vue").ComputedRef<string>;
|
|
47
|
-
uNumberStyle: import("vue").ComputedRef<any>;
|
|
48
51
|
blImage: import("vue").ComputedRef<string>;
|
|
49
52
|
blNumberStyle: import("vue").ComputedRef<any>;
|
|
53
|
+
blLampStyle: import("vue").ComputedRef<{
|
|
54
|
+
display: string;
|
|
55
|
+
animation: string;
|
|
56
|
+
}>;
|
|
57
|
+
uImage: import("vue").ComputedRef<string>;
|
|
58
|
+
uNumberStyle: import("vue").ComputedRef<any>;
|
|
59
|
+
uLampStyle: import("vue").ComputedRef<{
|
|
60
|
+
display: string;
|
|
61
|
+
animation: string;
|
|
62
|
+
}>;
|
|
50
63
|
lImage: import("vue").ComputedRef<string>;
|
|
51
64
|
lNumberStyle: import("vue").ComputedRef<any>;
|
|
65
|
+
lLampStyle: import("vue").ComputedRef<{
|
|
66
|
+
display: string;
|
|
67
|
+
animation: string;
|
|
68
|
+
}>;
|
|
52
69
|
sImage: import("vue").ComputedRef<string>;
|
|
53
70
|
sNumberStyle: import("vue").ComputedRef<any>;
|
|
71
|
+
sLampStyle: import("vue").ComputedRef<{
|
|
72
|
+
display: string;
|
|
73
|
+
animation: string;
|
|
74
|
+
}>;
|
|
54
75
|
rImage: import("vue").ComputedRef<string>;
|
|
55
76
|
rNumberStyle: import("vue").ComputedRef<any>;
|
|
77
|
+
rLampStyle: import("vue").ComputedRef<{
|
|
78
|
+
display: string;
|
|
79
|
+
animation: string;
|
|
80
|
+
}>;
|
|
56
81
|
getColorString: (color: string | undefined) => "red" | "rgb(255, 192, 2)" | "lime" | "white";
|
|
57
82
|
getNumberStyle: (color: string | undefined) => any;
|
|
58
83
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -60,6 +85,10 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
60
85
|
type: StringConstructor;
|
|
61
86
|
required: true;
|
|
62
87
|
};
|
|
88
|
+
flash: {
|
|
89
|
+
type: BooleanConstructor;
|
|
90
|
+
required: true;
|
|
91
|
+
};
|
|
63
92
|
crossId: {
|
|
64
93
|
type: StringConstructor;
|
|
65
94
|
required: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),V={key:0,class:"signal-countdown-container"},E=["src"],_={key:1,class:"signal-countdown-container"},B=["src"],I={key:2,class:"signal-countdown-container"},z=["src"],L={key:3,class:"signal-countdown-container"},$=["src"],A={key:4,class:"signal-countdown-container"},D=["src"],G=e.defineComponent({__name:"signal-countdown-panel",props:{displayMode:{},flash:{type:Boolean},crossId:{},roadId:{},mapPoint:{},stopLine:{},scale:{},position:{},rotation:{},lampStatus:{}},setup(r){const o=["red","yellow","green","grey"],t=r,i=e.computed(()=>({top:`${t.position.top}px`,left:`${t.position.left}px`,"transform-origin":"bottom center",transform:`translateX(-50%) translateY(-100%) rotate(${t.rotation}deg) scale(${t.scale})`})),u=e.computed(()=>!t.lampStatus.blColor||!o.includes(t.lampStatus.blColor)?"":`/GisViewerAssets/Images/SignalLamp/bl-${t.lampStatus.blColor}.png`),m=e.computed(()=>n(t.lampStatus.blColor)),c=e.computed(()=>({display:t.lampStatus.blColor&&o.includes(t.lampStatus.blColor)?"block":"none",animation:t.flash?"blink 2s infinite":"none"})),p=e.computed(()=>!t.lampStatus.uColor||!o.includes(t.lampStatus.uColor)?"":`/GisViewerAssets/Images/SignalLamp/u-${t.lampStatus.uColor}.png`),d=e.computed(()=>n(t.lampStatus.uColor)),S=e.computed(()=>({display:t.lampStatus.uColor&&o.includes(t.lampStatus.uColor)?"block":"none",animation:t.flash?"blink 2s infinite":"none"})),g=e.computed(()=>!t.lampStatus.lColor||!o.includes(t.lampStatus.lColor)?"":`/GisViewerAssets/Images/SignalLamp/l-${t.lampStatus.lColor}.png`),y=e.computed(()=>n(t.lampStatus.lColor)),b=e.computed(()=>({display:t.lampStatus.lColor&&o.includes(t.lampStatus.lColor)?"block":"none",animation:t.flash?"blink 2s infinite":"none"})),C=e.computed(()=>!t.lampStatus.sColor||!o.includes(t.lampStatus.sColor)?"":`/GisViewerAssets/Images/SignalLamp/s-${t.lampStatus.sColor}.png`),v=e.computed(()=>n(t.lampStatus.sColor)),h=e.computed(()=>({display:t.lampStatus.sColor&&o.includes(t.lampStatus.sColor)?"block":"none",animation:t.flash?"blink 2s infinite":"none"})),N=e.computed(()=>!t.lampStatus.rColor||!o.includes(t.lampStatus.rColor)?"":`/GisViewerAssets/Images/SignalLamp/r-${t.lampStatus.rColor}.png`),f=e.computed(()=>n(t.lampStatus.rColor)),k=e.computed(()=>({display:t.lampStatus.rColor&&o.includes(t.lampStatus.rColor)?"block":"none",animation:t.flash?"blink 2s infinite":"none"})),w=l=>{switch(l){case"red":return"red";case"yellow":return"rgb(255, 192, 2)";case"green":return"lime";default:return"white"}},n=l=>{const a={color:w(l)},s=t.rotation<0?t.rotation+360:t.rotation;return s>135&&s<225&&(a.transform="rotate(180deg)"),a};return(l,a)=>(e.openBlock(),e.createElementBlock("div",{class:"signal-countdown-panel",style:e.normalizeStyle(i.value)},[l.lampStatus.uColor?(e.openBlock(),e.createElementBlock("div",V,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(d.value)},e.toDisplayString(l.lampStatus.uNumber),5),e.createElementVNode("div",{style:e.normalizeStyle(S.value)},[e.createElementVNode("img",{src:p.value,width:"20px",height:"20px"},null,8,E)],4)])):e.createCommentVNode("",!0),l.lampStatus.blColor?(e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(m.value)},e.toDisplayString(l.lampStatus.blNumber),5),e.createElementVNode("div",{style:e.normalizeStyle(c.value)},[e.createElementVNode("img",{src:u.value,width:"20px",height:"20px"},null,8,B)],4)])):e.createCommentVNode("",!0),l.lampStatus.lColor?(e.openBlock(),e.createElementBlock("div",I,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(y.value)},e.toDisplayString(l.lampStatus.lNumber),5),e.createElementVNode("div",{style:e.normalizeStyle(b.value)},[e.createElementVNode("img",{src:g.value,width:"20px",height:"20px"},null,8,z)],4)])):e.createCommentVNode("",!0),l.lampStatus.sColor?(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(v.value)},e.toDisplayString(l.lampStatus.sNumber),5),e.createElementVNode("div",{style:e.normalizeStyle(h.value)},[e.createElementVNode("img",{src:C.value,width:"20px",height:"20px"},null,8,$)],4)])):e.createCommentVNode("",!0),l.lampStatus.rColor!==void 0?(e.openBlock(),e.createElementBlock("div",A,[e.createElementVNode("div",{class:"signal-countdown-number",style:e.normalizeStyle(f.value)},e.toDisplayString(l.lampStatus.rNumber),5),e.createElementVNode("div",{style:e.normalizeStyle(k.value)},[e.createElementVNode("img",{src:N.value,width:"20px",height:"20px"},null,8,D)],4)])):e.createCommentVNode("",!0)],4))}});exports.default=G;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/core/reactiveUtils"),d=require("@arcgis/core/geometry"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),b=require("@arcgis/core/layers/GraphicsLayer"),L=require("./signal-holo-flow.js");function P(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const a in u)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(u,a);Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>u[a]})}}return e.default=u,Object.freeze(e)}const w=P(y),m=P(S);class M extends L.default{constructor(e,a){var l,i;super(e),this.stopLineLayer=new b,this.watchHandle=null,this.trajectoryDelayTime=2,this.stopLineMap=new Map,this.lampGroupMap=new Map,this.countdownPanelProps=a,this.view.map.add(this.stopLineLayer),this.trajectoryDelayTime=((i=(l=this.mapConfig.holoFlow)==null?void 0:l.signal)==null?void 0:i.delay)||2}async initializeLayer(){var i,t;if(this.stopLineMap.size>0)return;console.time("初始化停止线图层");let e=(t=(i=this.mapConfig.holoFlow)==null?void 0:i.signal)==null?void 0:t.stopLineLayer;if(!e)return;e=this.mapConfig.assetsRoot+"/"+e;const l=await(await fetch(e)).json();for(const n of l.features){const{roadId:s}=n.properties;let{destinationPoint:o}=n.properties;const{coordinates:r}=n.geometry;if(o){if(typeof o=="string")try{o=JSON.parse(o)}catch(c){console.error("解析面板基准点失败",c);continue}}else{const c=r[0],h=r[r.length-1],p=(c[0]+h[0])/2,f=(c[1]+h[1])/2;o=[p,f]}this.stopLineMap.set(s,{coord:r,panelPoint:o})}console.timeEnd("初始化停止线图层")}initializeLampGroup(e){const{sigId:a,lampGroupList:l}=e,i=[];l.forEach(t=>{const{lampGroupNo:n,lampGroupType:s,crossFlowList:o,pedList:r}=t;o.length>0&&o.forEach(c=>{const h=c.upSectionId;let p="s";switch(c.turn){case 1:p="s";break;case 2:p="l";break;case 4:p="r";break;case 8:p="u";break}s===81&&(p="bl"),i.push({lampGroupId:n,roadId:h,dir:p})}),r.length>0}),this.lampGroupMap.set(a,i)}handleUniSignalData(e){this.watchHandle||(this.watchHandle=w.watch(()=>this.view.extent,()=>this.updatePanelPosition()));const{sigId:a,runningStatus:l}=e.data.basicInfo,i=this.lampGroupMap.get(a);if(!i)return{status:-1,message:"灯组未初始化"};const t=new Map;let n=!1;switch(String(l)){case"4":{n=!0,i.forEach(s=>{const{roadId:o,dir:r}=s;t.set(o,{...t.get(o)||{},[`${r}Number`]:"",[`${r}Color`]:"yellow"})});break}case"5":{i.forEach(s=>{const{roadId:o,dir:r}=s;t.set(o,{...t.get(o)||{},[`${r}Number`]:"",[`${r}Color`]:"red"})});break}case"6":case"9":{i.forEach(s=>{const{roadId:o,dir:r}=s;t.set(o,{...t.get(o)||{},[`${r}Number`]:"",[`${r}Color`]:"off"})});break}default:{const{curSigColorInfo:s}=e.data;s.forEach(o=>{const r=String(o.lamgroupId),{color:c,leftTime:h}=o,p=i.find(f=>f.lampGroupId===r);if(p){const{roadId:f,dir:g}=p;t.set(f,{...t.get(f)||{},[`${g}Number`]:h,[`${g}Color`]:c===1?"red":c===2?"yellow":"green"})}})}}return this.updateLampGroupPanelStatus(a,t,n),{status:0,message:"ok"}}getPanelScale(){const e=this.view.scale;let a=1;return e<1e3?a=1:e<2e3?a=.8:e<4e3?a=.4:a=0,a}updatePanelPosition(){const e=this.getPanelScale();for(const a of this.countdownPanelProps){e!==this.currentPanelScale&&(a.scale=e);const{mapPoint:l}=a;let i=new d.Point({x:l[0],y:l[1]});this.view.spatialReference.isWebMercator&&(i=m.geographicToWebMercator(i));const t=this.view.toScreen(i);if(a.position.left=t.x,a.position.top=t.y,this.view.type==="3d"){const n=this.getPanelRotation(a.stopLine);a.rotation=n}}this.currentPanelScale=e}doHoloSignalData(e){const a=e.crossId,l=e.phaseCountDownList,i=new Map;for(const t of l){let n="";for(let c of t.roadIdList)if(c.startsWith("-")&&(c=c.slice(1)),this.stopLineMap.has(c)){n=c;break}if(!n){console.log(`没有找到对应的进口道${a}--${n}`);continue}let s=i.get(n);if(s||(s={},i.set(n,s)),!t.direction)continue;const o=t.direction.toLowerCase(),r=t.color===1?"red":t.color===2?"yellow":"green";o==="u"?(s.uNumber=t.leftTime,s.uColor=r):o==="l"?(s.lNumber=t.leftTime,s.lColor=r):o==="s"?(s.sNumber=t.leftTime,s.sColor=r):o==="r"&&(s.rNumber=t.leftTime,s.rColor=r)}this.updateLampGroupPanelStatus(a,i)}updateLampGroupPanelStatus(e,a,l=!1){a.forEach((i,t)=>{const n=this.stopLineMap.get(t);if(!n)return;const s=this.countdownPanelProps.find(o=>o.roadId===t);if(s)s.lampStatus=i,s.flash=l;else{let o=new d.Point({x:n.panelPoint[0],y:n.panelPoint[1]});this.view.spatialReference.isWebMercator&&(o=m.geographicToWebMercator(o));const r=this.view.toScreen(o),c=this.getPanelRotation(n.coord);this.countdownPanelProps.push({displayMode:"complex",flash:l,crossId:e,roadId:t,mapPoint:n.panelPoint,stopLine:n.coord,position:{left:r.x,top:r.y},rotation:c,scale:this.getPanelScale(),lampStatus:i})}})}async handleHoloSignalData(e){this.watchHandle||(this.watchHandle=w.watch(()=>this.view.extent,()=>this.updatePanelPosition())),this.trajectoryDelayTime===0?this.doHoloSignalData(e):setTimeout(()=>this.doHoloSignalData(e),this.trajectoryDelayTime*1e3)}clearSignal(){var e;this.stopLineLayer.removeAll(),this.countdownPanelProps.length=0,(e=this.watchHandle)==null||e.remove(),this.watchHandle=null}getPanelRotation(e){const a=e[0];let l=new d.Point({x:a[0],y:a[1]});this.view.spatialReference.isWebMercator&&(l=m.geographicToWebMercator(l));const i=this.view.toScreen(l),t=e[e.length-1];let n=new d.Point({x:t[0],y:t[1]});this.view.spatialReference.isWebMercator&&(n=m.geographicToWebMercator(n));const s=this.view.toScreen(n),o=s.x-i.x,r=s.y-i.y;return Math.atan2(r,o)*(180/Math.PI)}}exports.default=M;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/geometry/geometryEngine.js"),P=require("@arcgis/core/geometry/Polygon"),G=require("@arcgis/core/geometry/Polyline"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),l=require("@arcgis/core/Graphic"),d=require("@arcgis/core/layers/GraphicsLayer"),k=require("@arcgis/core/widgets/Sketch"),M=require("@arcgis/core/widgets/Sketch/SketchViewModel"),A=require("@turf/helpers"),x=require("@turf/intersect"),v=require("uuid"),E=require("../stores/index.js");function f(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const V=f(b),g=f(S),u=f(A);function w(a,e=[]){if(a===null||typeof a!="object")return a;if(Object.prototype.toString.call(a)==="[object Date]")return new Date(a);if(Object.prototype.toString.call(a)==="[object RegExp]")return new RegExp(a);if(Object.prototype.toString.call(a)==="[object Error]")return new Error(a);const t=e.filter(s=>s.original===a)[0];if(t)return t.copy;const i=Array.isArray(a)?[]:{};return e.push({original:a,copy:i}),Object.keys(a).forEach(s=>{i[s]=w(a[s],e)}),i}const O={maxAllowedGraphics:0,GraphicsLayer:{},sketchVisibleElements:{},sketchPosition:"top-right",defaultSketchVisible:!0,sketchViewModelItemSymbol:{}},m={type:"simple-line",color:"#556DEA",width:2},y={type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}};class D{constructor(e,t){this.viewer=e,this.options={...O,...t},this.graphicsLayer=new d({...this.options.GraphicsLayer}),this.TextGraphicsLayer=new d,this.viewer.map.addMany([this.graphicsLayer,this.TextGraphicsLayer]),this.init()}updateSketch(e){const t=new l({geometry:{type:"polygon",rings:[e]},symbol:{type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}}});this.graphicsLayer.add(t),this.sketchViewModel.update([t],{tool:"reshape",enableRotation:!0})}init(){this.sketchViewModel=new M({layer:this.graphicsLayer,view:this.viewer,updateOnGraphicClick:!0,polylineSymbol:m,polygonSymbol:y,...this.options.sketchViewModelItemSymbol});const e=this.findLayerById("TrafficMarkings"),t=[];e&&t.push({layer:e,enabled:!0}),this.sketch=new k({view:this.viewer,viewModel:this.sketchViewModel,layer:this.graphicsLayer,visible:this.options.defaultSketchVisible,creationMode:this.options.creationMode||"single",snappingOptions:{enabled:!0,featureSources:t}}),this.sketch.visibleElements={...this.options.sketchVisibleElements},this.viewer.ui.add(this.sketch,this.options.sketchPosition);const i=E.default.useAppDataStore;this.sketch.on("create",s=>{s.state==="complete"?i.isSketching=!1:s.state==="start"&&(i.isSketching=!0)})}initPoint(e,t="all",i=!1){if(!e)return;const{crossArea:s,sectionArea:r}=e;if(s&&(t=="crossArea"||t=="all")){const o=this.initCrossArea(s);this.graphicsLayer.add(o)}if(r&&(t=="sectionArea"||t=="all")){const o=this.initSectionArea(r,i);this.graphicsLayer.addMany(o)}}initEntranceFusionZone(e){const t=[];e.map(i=>{t.push(this.createPolygonGraphic(i,y,{}))}),this.graphicsLayer.addMany(t)}initCrossArea(e){return this.createPolygonGraphic(e,y,{})}initSectionArea(e,t=!1){const i=[],s={type:"simple-line",color:[0,0,255],width:2};return Object.keys(e).map(r=>{const o=e[r][0],c=e[r][1];t&&(o.reverse(),c.reverse());const n=v.v4(),h=this.createPolylineGraphic(o,m,{type:"draw",id:n}),p=this.createPolylineGraphic(c,s,{type:"shiftLine",id:n});i.push(h,p)}),i}createPolylineGraphic(e,t,i){const s=new G({paths:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}createPolygonGraphic(e,t,i){const s=new P({rings:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}on(e){const t=this;this.sketchViewModel.on("create",function(i){var r,o,c;const s=t.graphicsLayer.graphics;if((r=t.options)!=null&&r.maxAllowedGraphics&&s.length>((o=t.options)==null?void 0:o.maxAllowedGraphics)){t.graphicsLayer.remove(i.graphic),console.log("已达到最大图形数量,无法继续绘制!");return}if(i.state==="complete"&&((c=i.graphic)!=null&&c.geometry)){const n=i.graphic.geometry;i.graphic.setAttribute("type","draw"),i.graphic.setAttribute("id",new Date().getTime());const h=t.getGraphicPoint(n);e&&e("create",h,i)}}),this.sketchViewModel.on("update",function(i){if(i.aborted){const s=i.graphics[0];t.graphicsLayer.remove(s);return}if(i.state==="complete"&&i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("update",o,i)}}),this.sketchViewModel.on("delete",function(i){if(console.log("delete",i),i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("delete",o,i)}})}graphicPoint(){const e=[];return this.graphicsLayer.graphics.map(t=>{var r;const i=t.geometry,s=this.getGraphicPoint(i);e.push({point:s,type:(r=t.attributes)==null?void 0:r.type,attributes:t.attributes})}),e}getEntranceRoad(){const e={},t=this.graphicPoint().filter(n=>n.point.type==="polyline");if(console.log("🚀 ~ file: sketchView.ts:378 ~ SketchView ~ getEntranceRoad ~ graphics:",t),!t.length)return!1;const i=t.filter(n=>n.type=="draw"),s=t.filter(n=>n.type=="shiftLine");if(s.length==0)throw"未绘制平移!";if(i.length!=s.length)throw"绘制的线和平移的线数量不一致!";const r=i.sort((n,h)=>n.point.angle-h.point.angle),o=r.findIndex(n=>n.point.angle>135);return[...r.slice(o),...r.slice(0,o).reverse()].map((n,h)=>{const p=s.find(L=>L.attributes.id==n.attributes.id);if(!p)throw"绘制的线和平移的线不匹配!";console.log("🚀 ~ file: sketchView.ts:393 ~ SketchView ~ getEntranceRoad ~ m:",n,p),e[h+1]={0:[n.point.paths[0],n.point.paths[n.point.paths.length-1]],1:[p.point.paths[0],p.point.paths[p.point.paths.length-1]]}}),e}getEntranceFusionZone(e){const t=[],i={};this.graphicsLayer.graphics.map(r=>{var n;const o=r.geometry,c=this.getGraphicPoint(o,!1);t.push({point:c,type:(n=r.attributes)==null?void 0:n.type,attributes:r.attributes})});const s=t;return e.map((r,o)=>{i[r]=t[o]}),{graphics:i,rawData:s}}getIntersectionArea(e,t){const i=Object.keys(e);let s=!1;for(let r=0;r<i.length;r++){const o=i[r],c=e[o];if(x(u.polygon(t),u.polygon(c))){s=o;break}}return s}filterData(e){const t=w(e);return t.length>0&&t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&t.pop(),t}getGraphicPoint(e,t=!1){let i=e;this.viewer.spatialReference.isWebMercator&&(i=g.webMercatorToGeographic(e));let s;if(e.type==="point")s={type:e.type,x:i.x,y:i.y};else if(e.type==="polyline"){s={type:e.type,paths:[]},i.paths.forEach(n=>{let h=n;t&&(h=this.filterData(n)),h.forEach(p=>{s.paths.push(p)})});const r={x:s.paths[0][0],y:s.paths[0][1]},o={x:s.paths[s.paths.length-1][0],y:s.paths[s.paths.length-1][1]},c=this.getAngle(r,o);s.angle=c}else e.type==="polygon"&&(s={type:e.type,rings:[]},i.rings.forEach(r=>{let o=r;t&&(o=this.filterData(r)),o.forEach(c=>{s.rings.push(c)})}));return s}close(){this.sketch.visible=!1}show(){this.sketch.visible=!0}removeAll(){this.graphicsLayer.removeAll()}getAngle(e,t){const i=t.x-e.x,s=t.y-e.y;return Math.atan2(s,i)*180/Math.PI}getShiftLine(e,t,i="meters"){const s=e,r=-t;return V.offset(s,r,i)}setShiftLine(e,t="meters",i){i||(i={type:"simple-line",color:[0,0,255],width:2}),this.removeShiftLine(),this.graphicsLayer.graphics.map(s=>{const r=s.geometry,o=s.attributes;if((r==null?void 0:r.type)==="polyline"&&(o==null?void 0:o.type)==="draw"){const c=o.id,n=this.getShiftLine(r,e,t),h=new l({geometry:n,symbol:i,attributes:{type:"shiftLine",id:c}});this.graphicsLayer.add(h)}})}removeShiftLine(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="shiftLine"&&e.push(t)}),this.graphicsLayer.removeMany(e)}removeDraw(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="draw"&&e.push(t)}),this.graphicsLayer.removeMany(e)}addGraphic(e,t={type:"simple-line",color:[0,0,255],width:2},i){const s=new l({geometry:e,symbol:t,attributes:i});this.graphicsLayer.add(s)}getDirection(e,t){const i=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,i)*180/Math.PI;return o>=-45&&o<=45?0:o>45&&o<=135?1:o>135||o<=-135?2:3}findLayerById(e){return this.viewer.map.findLayerById(e)}findShiftLineGraphicsById(e){return this.graphicsLayer.graphics.find(i=>i.attributes.id===e&&i.attributes.type==="shiftLine")}remove(e){this.graphicsLayer.remove(e)}setMaxAllowedGraphics(e){this.options.maxAllowedGraphics=e===0?void 0:e}destroy(){var e,t;this.viewer.map.remove(this.graphicsLayer),this.viewer.map.remove(this.TextGraphicsLayer),(e=this.sketch)==null||e.destroy(),(t=this.sketchViewModel)==null||t.destroy()}}exports.default=D;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/geometry/geometryEngine.js"),P=require("@arcgis/core/geometry/Polygon"),G=require("@arcgis/core/geometry/Polyline"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),l=require("@arcgis/core/Graphic"),d=require("@arcgis/core/layers/GraphicsLayer"),k=require("@arcgis/core/widgets/Sketch"),M=require("@arcgis/core/widgets/Sketch/SketchViewModel"),A=require("@turf/helpers"),x=require("@turf/intersect"),v=require("uuid"),E=require("../stores/index.js");function f(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const V=f(b),g=f(S),u=f(A);function w(a,e=[]){if(a===null||typeof a!="object")return a;if(Object.prototype.toString.call(a)==="[object Date]")return new Date(a);if(Object.prototype.toString.call(a)==="[object RegExp]")return new RegExp(a);if(Object.prototype.toString.call(a)==="[object Error]")return new Error(a);const t=e.filter(s=>s.original===a)[0];if(t)return t.copy;const i=Array.isArray(a)?[]:{};return e.push({original:a,copy:i}),Object.keys(a).forEach(s=>{i[s]=w(a[s],e)}),i}const O={maxAllowedGraphics:0,GraphicsLayer:{},sketchVisibleElements:{},sketchPosition:"top-right",defaultSketchVisible:!0,sketchViewModelItemSymbol:{}},m={type:"simple-line",color:"#556DEA",width:2},y={type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}};class D{constructor(e,t){this.viewer=e,this.options={...O,...t},this.graphicsLayer=new d({...this.options.GraphicsLayer}),this.TextGraphicsLayer=new d,this.viewer.map.addMany([this.graphicsLayer,this.TextGraphicsLayer]),this.init()}updateSketch(e){const t=new l({geometry:{type:"polygon",rings:[e]},symbol:{type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}}});this.graphicsLayer.add(t),this.sketchViewModel.update([t],{tool:"reshape",enableRotation:!0})}cancelSketch(){this.sketchViewModel.cancel()}init(){this.sketchViewModel=new M({layer:this.graphicsLayer,view:this.viewer,updateOnGraphicClick:!0,polylineSymbol:m,polygonSymbol:y,...this.options.sketchViewModelItemSymbol});const e=this.findLayerById("TrafficMarkings"),t=[];e&&t.push({layer:e,enabled:!0}),this.sketch=new k({view:this.viewer,viewModel:this.sketchViewModel,layer:this.graphicsLayer,visible:this.options.defaultSketchVisible,creationMode:this.options.creationMode||"single",snappingOptions:{enabled:!0,featureSources:t}}),this.sketch.visibleElements={...this.options.sketchVisibleElements},this.viewer.ui.add(this.sketch,this.options.sketchPosition);const i=E.default.useAppDataStore;this.sketch.on("create",s=>{s.state==="complete"?i.isSketching=!1:s.state==="start"&&(i.isSketching=!0)})}initPoint(e,t="all",i=!1){if(!e)return;const{crossArea:s,sectionArea:r}=e;if(s&&(t=="crossArea"||t=="all")){const o=this.initCrossArea(s);this.graphicsLayer.add(o)}if(r&&(t=="sectionArea"||t=="all")){const o=this.initSectionArea(r,i);this.graphicsLayer.addMany(o)}}initEntranceFusionZone(e){const t=[];e.map(i=>{t.push(this.createPolygonGraphic(i,y,{}))}),this.graphicsLayer.addMany(t)}initCrossArea(e){return this.createPolygonGraphic(e,y,{})}initSectionArea(e,t=!1){const i=[],s={type:"simple-line",color:[0,0,255],width:2};return Object.keys(e).map(r=>{const o=e[r][0],c=e[r][1];t&&(o.reverse(),c.reverse());const n=v.v4(),h=this.createPolylineGraphic(o,m,{type:"draw",id:n}),p=this.createPolylineGraphic(c,s,{type:"shiftLine",id:n});i.push(h,p)}),i}createPolylineGraphic(e,t,i){const s=new G({paths:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}createPolygonGraphic(e,t,i){const s=new P({rings:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}on(e){const t=this;this.sketchViewModel.on("create",function(i){var r,o,c;const s=t.graphicsLayer.graphics;if((r=t.options)!=null&&r.maxAllowedGraphics&&s.length>((o=t.options)==null?void 0:o.maxAllowedGraphics)){t.graphicsLayer.remove(i.graphic),console.log("已达到最大图形数量,无法继续绘制!");return}if(i.state==="complete"&&((c=i.graphic)!=null&&c.geometry)){const n=i.graphic.geometry;i.graphic.setAttribute("type","draw"),i.graphic.setAttribute("id",new Date().getTime());const h=t.getGraphicPoint(n);e&&e("create",h,i)}}),this.sketchViewModel.on("update",function(i){if(i.aborted){const s=i.graphics[0];t.graphicsLayer.remove(s);return}if(i.state==="complete"&&i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("update",o,i)}}),this.sketchViewModel.on("delete",function(i){if(console.log("delete",i),i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("delete",o,i)}})}graphicPoint(){const e=[];return this.graphicsLayer.graphics.map(t=>{var r;const i=t.geometry,s=this.getGraphicPoint(i);e.push({point:s,type:(r=t.attributes)==null?void 0:r.type,attributes:t.attributes})}),e}getEntranceRoad(){const e={},t=this.graphicPoint().filter(n=>n.point.type==="polyline");if(console.log("🚀 ~ file: sketchView.ts:378 ~ SketchView ~ getEntranceRoad ~ graphics:",t),!t.length)return!1;const i=t.filter(n=>n.type=="draw"),s=t.filter(n=>n.type=="shiftLine");if(s.length==0)throw"未绘制平移!";if(i.length!=s.length)throw"绘制的线和平移的线数量不一致!";const r=i.sort((n,h)=>n.point.angle-h.point.angle),o=r.findIndex(n=>n.point.angle>135);return[...r.slice(o),...r.slice(0,o).reverse()].map((n,h)=>{const p=s.find(L=>L.attributes.id==n.attributes.id);if(!p)throw"绘制的线和平移的线不匹配!";console.log("🚀 ~ file: sketchView.ts:393 ~ SketchView ~ getEntranceRoad ~ m:",n,p),e[h+1]={0:[n.point.paths[0],n.point.paths[n.point.paths.length-1]],1:[p.point.paths[0],p.point.paths[p.point.paths.length-1]]}}),e}getEntranceFusionZone(e){const t=[],i={};this.graphicsLayer.graphics.map(r=>{var n;const o=r.geometry,c=this.getGraphicPoint(o,!1);t.push({point:c,type:(n=r.attributes)==null?void 0:n.type,attributes:r.attributes})});const s=t;return e.map((r,o)=>{i[r]=t[o]}),{graphics:i,rawData:s}}getIntersectionArea(e,t){const i=Object.keys(e);let s=!1;for(let r=0;r<i.length;r++){const o=i[r],c=e[o];if(x(u.polygon(t),u.polygon(c))){s=o;break}}return s}filterData(e){const t=w(e);return t.length>0&&t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&t.pop(),t}getGraphicPoint(e,t=!1){let i=e;this.viewer.spatialReference.isWebMercator&&(i=g.webMercatorToGeographic(e));let s;if(e.type==="point")s={type:e.type,x:i.x,y:i.y};else if(e.type==="polyline"){s={type:e.type,paths:[]},i.paths.forEach(n=>{let h=n;t&&(h=this.filterData(n)),h.forEach(p=>{s.paths.push(p)})});const r={x:s.paths[0][0],y:s.paths[0][1]},o={x:s.paths[s.paths.length-1][0],y:s.paths[s.paths.length-1][1]},c=this.getAngle(r,o);s.angle=c}else e.type==="polygon"&&(s={type:e.type,rings:[]},i.rings.forEach(r=>{let o=r;t&&(o=this.filterData(r)),o.forEach(c=>{s.rings.push(c)})}));return s}close(){this.sketch.visible=!1}show(){this.sketch.visible=!0}removeAll(){this.graphicsLayer.removeAll()}getAngle(e,t){const i=t.x-e.x,s=t.y-e.y;return Math.atan2(s,i)*180/Math.PI}getShiftLine(e,t,i="meters"){const s=e,r=-t;return V.offset(s,r,i)}setShiftLine(e,t="meters",i){i||(i={type:"simple-line",color:[0,0,255],width:2}),this.removeShiftLine(),this.graphicsLayer.graphics.map(s=>{const r=s.geometry,o=s.attributes;if((r==null?void 0:r.type)==="polyline"&&(o==null?void 0:o.type)==="draw"){const c=o.id,n=this.getShiftLine(r,e,t),h=new l({geometry:n,symbol:i,attributes:{type:"shiftLine",id:c}});this.graphicsLayer.add(h)}})}removeShiftLine(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="shiftLine"&&e.push(t)}),this.graphicsLayer.removeMany(e)}removeDraw(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="draw"&&e.push(t)}),this.graphicsLayer.removeMany(e)}addGraphic(e,t={type:"simple-line",color:[0,0,255],width:2},i){const s=new l({geometry:e,symbol:t,attributes:i});this.graphicsLayer.add(s)}getDirection(e,t){const i=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,i)*180/Math.PI;return o>=-45&&o<=45?0:o>45&&o<=135?1:o>135||o<=-135?2:3}findLayerById(e){return this.viewer.map.findLayerById(e)}findShiftLineGraphicsById(e){return this.graphicsLayer.graphics.find(i=>i.attributes.id===e&&i.attributes.type==="shiftLine")}remove(e){this.graphicsLayer.remove(e)}setMaxAllowedGraphics(e){this.options.maxAllowedGraphics=e===0?void 0:e}destroy(){var e,t;this.viewer.map.remove(this.graphicsLayer),this.viewer.map.remove(this.TextGraphicsLayer),(e=this.sketch)==null||e.destroy(),(t=this.sketchViewModel)==null||t.destroy()}}exports.default=D;
|
package/lib/src/types/index.d.ts
CHANGED