gisviewer-vue3-arcgis 1.0.285 → 1.0.286
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 +2 -2
- package/es/src/gis-map/index.d.ts +2 -2
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow.mjs +6 -2
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +5 -3
- package/es/src/gis-map/utils/overlay.d.ts +2 -2
- package/es/src/gis-map/utils/overlay.mjs +2 -2
- package/es/src/gis-map/utils/police-jurisdiction.mjs +1 -1
- package/es/src/gis-map/utils/signal-system/signal-system-controller.mjs +2 -2
- package/es/src/gis-map-ol/gis-map-ol.vue.d.ts +30 -1
- package/es/src/gis-map-ol/gis-map-ol.vue.mjs +69 -43
- package/es/src/gis-map-ol/index.d.ts +25 -0
- package/es/src/gis-map-ol/utils/cluster/index.d.ts +2 -0
- package/es/src/gis-map-ol/utils/cluster/pixel-cluster-calculator.d.ts +65 -0
- package/es/src/gis-map-ol/utils/cluster/pixel-cluster-calculator.mjs +122 -0
- package/es/src/gis-map-ol/utils/ol-map-initializer.d.ts +1 -0
- package/es/src/gis-map-ol/utils/ol-map-initializer.mjs +95 -41
- package/es/src/gis-map-ol/utils/overlay/cluster-point-controller.d.ts +23 -0
- package/es/src/gis-map-ol/utils/overlay/cluster-point-controller.mjs +102 -0
- package/es/src/gis-map-ol/utils/overlay/overlay-controller.d.ts +116 -0
- package/es/src/gis-map-ol/utils/overlay/overlay-controller.mjs +276 -0
- package/es/src/gis-map-ol/utils/police-area-controller.d.ts +16 -0
- package/es/src/gis-map-ol/utils/police-area-controller.mjs +155 -0
- package/es/src/gis-map-ol/utils/signal-control/signal-cross-controller.d.ts +1 -10
- package/es/src/gis-map-ol/utils/signal-control/signal-cross-controller.mjs +124 -166
- package/es/src/gis-map-ol/utils/signal-control/signal-system-controller.d.ts +49 -0
- package/es/src/gis-map-ol/utils/signal-control/signal-system-controller.mjs +127 -0
- package/es/src/gis-map-ol/utils/style/line-style.d.ts +64 -0
- package/es/src/gis-map-ol/utils/style/line-style.mjs +151 -0
- package/es/src/gis-map-ol/utils/style/point-style.d.ts +78 -0
- package/es/src/gis-map-ol/utils/style/point-style.mjs +206 -0
- package/es/src/gis-map-ol/utils/style/polygon-style.d.ts +60 -0
- package/es/src/gis-map-ol/utils/style/polygon-style.mjs +166 -0
- package/es/src/types/index.d.ts +2 -1
- package/lib/src/gis-map/gis-map.vue.d.ts +2 -2
- package/lib/src/gis-map/index.d.ts +2 -2
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
- package/lib/src/gis-map/utils/overlay.d.ts +2 -2
- package/lib/src/gis-map/utils/overlay.js +1 -1
- package/lib/src/gis-map/utils/police-jurisdiction.js +1 -1
- package/lib/src/gis-map/utils/signal-system/signal-system-controller.js +1 -1
- package/lib/src/gis-map-ol/gis-map-ol.vue.d.ts +30 -1
- package/lib/src/gis-map-ol/gis-map-ol.vue.js +1 -1
- package/lib/src/gis-map-ol/index.d.ts +25 -0
- package/lib/src/gis-map-ol/utils/cluster/index.d.ts +2 -0
- package/lib/src/gis-map-ol/utils/cluster/pixel-cluster-calculator.d.ts +65 -0
- package/lib/src/gis-map-ol/utils/cluster/pixel-cluster-calculator.js +1 -0
- package/lib/src/gis-map-ol/utils/ol-map-initializer.d.ts +1 -0
- package/lib/src/gis-map-ol/utils/ol-map-initializer.js +1 -1
- package/lib/src/gis-map-ol/utils/overlay/cluster-point-controller.d.ts +23 -0
- package/lib/src/gis-map-ol/utils/overlay/cluster-point-controller.js +1 -0
- package/lib/src/gis-map-ol/utils/overlay/overlay-controller.d.ts +116 -0
- package/lib/src/gis-map-ol/utils/overlay/overlay-controller.js +1 -0
- package/lib/src/gis-map-ol/utils/police-area-controller.d.ts +16 -0
- package/lib/src/gis-map-ol/utils/police-area-controller.js +1 -0
- package/lib/src/gis-map-ol/utils/signal-control/signal-cross-controller.d.ts +1 -10
- package/lib/src/gis-map-ol/utils/signal-control/signal-cross-controller.js +1 -1
- package/lib/src/gis-map-ol/utils/signal-control/signal-system-controller.d.ts +49 -0
- package/lib/src/gis-map-ol/utils/signal-control/signal-system-controller.js +1 -0
- package/lib/src/gis-map-ol/utils/style/line-style.d.ts +64 -0
- package/lib/src/gis-map-ol/utils/style/line-style.js +1 -0
- package/lib/src/gis-map-ol/utils/style/point-style.d.ts +78 -0
- package/lib/src/gis-map-ol/utils/style/point-style.js +1 -0
- package/lib/src/gis-map-ol/utils/style/polygon-style.d.ts +60 -0
- package/lib/src/gis-map-ol/utils/style/polygon-style.js +1 -0
- package/lib/src/types/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -5,16 +5,12 @@ export default class SignalCrossController {
|
|
|
5
5
|
private crossLayer;
|
|
6
6
|
private source;
|
|
7
7
|
private view;
|
|
8
|
+
private clusterCalculator;
|
|
8
9
|
private showName;
|
|
9
10
|
private showStyle;
|
|
10
11
|
private viewChangeKey;
|
|
11
12
|
private mapMoveKey;
|
|
12
13
|
private resolutionChangeTimeout;
|
|
13
|
-
private readonly clusterRadius;
|
|
14
|
-
private readonly minClusterPoints;
|
|
15
|
-
private readonly maxClusterSymbolSize;
|
|
16
|
-
private readonly minClusterSymbolSize;
|
|
17
|
-
private clusteredLocations;
|
|
18
14
|
private locations;
|
|
19
15
|
constructor(map: OlMap);
|
|
20
16
|
showSignalCross(params: IShowSignalCrossParams): IResult;
|
|
@@ -33,10 +29,5 @@ export default class SignalCrossController {
|
|
|
33
29
|
private getBrandLabel;
|
|
34
30
|
private getOnlineLabel;
|
|
35
31
|
private getMalfunctionLabel;
|
|
36
|
-
private locationToScreen;
|
|
37
|
-
private doPixelCluster;
|
|
38
|
-
private getNeighbors;
|
|
39
|
-
private getDistance;
|
|
40
|
-
private createClusters;
|
|
41
32
|
private showClusterResult;
|
|
42
33
|
}
|
|
@@ -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 L=require("ol/Feature"),x=require("ol/geom/Point"),Y=require("ol/layer/Vector"),N=require("ol/Observable"),U=require("ol/source/Vector"),v=require("ol/style/Circle"),u=require("ol/style/Fill"),F=require("ol/style/Icon"),w=require("ol/style/Stroke"),c=require("ol/style/Style"),K=require("ol/style/Text"),X=require("../cluster/pixel-cluster-calculator.js");class ${constructor(e){this.showName="detail",this.showStyle="scatter",this.viewChangeKey=null,this.mapMoveKey=null,this.resolutionChangeTimeout=null,this.locations=[],this.map=e,this.view=e.getView(),this.clusterCalculator=new X.PixelClusterCalculator(e),this.source=new U,this.crossLayer=new Y({source:this.source}),this.crossLayer.set("id","signal-control-cross-layer"),this.map.addLayer(this.crossLayer),this.configureVectorLayerStyle()}showSignalCross(e){if(this.source.clear(),this.showName=e.showName||"detail",this.showStyle=e.style||"scatter",this.viewChangeKey||(this.viewChangeKey=this.view.on("change:resolution",()=>{this.showStyle==="cluster"&&(this.resolutionChangeTimeout&&clearTimeout(this.resolutionChangeTimeout),this.resolutionChangeTimeout=setTimeout(()=>{this.calculateCluster(),this.resolutionChangeTimeout=null},150))})),this.mapMoveKey||(this.mapMoveKey=this.map.on("moveend",()=>{this.showStyle==="cluster"&&this.calculateCluster()})),this.showStyle==="scatter"){const t=[],i=[];e.points.forEach(l=>{const a=this.createCrossFeature(l);l.isMalfunction===!0||l.isOnline===!1?i.push(a):t.push(a)}),this.source.addFeatures(t),this.source.addFeatures(i),this.crossLayer.changed()}else this.locations=e.points.map(t=>({id:t.crossId,x:t.x,y:t.y,visited:!1,clusterId:void 0,properties:t})),this.calculateCluster();return{status:0,message:"success"}}calculateCluster(){const e=this.clusterCalculator.calculate(this.locations),t=this.clusterCalculator.calculateSymbolSizes(e);this.showClusterResult(t)}clearSignalCross(){this.source.clear(),this.viewChangeKey&&(N.unByKey(this.viewChangeKey),this.viewChangeKey=null),this.mapMoveKey&&(N.unByKey(this.mapMoveKey),this.mapMoveKey=null),this.resolutionChangeTimeout&&(clearTimeout(this.resolutionChangeTimeout),this.resolutionChangeTimeout=null)}changeShowName(e){this.showName=e,this.showStyle==="scatter"&&this.updateScatterSymbol()}updateScatterSymbol(){this.crossLayer.changed()}configureVectorLayerStyle(){const f=this.map.getView(),E=f.getResolutionForZoom(13),q=f.getResolutionForZoom(15),Z=f.getResolutionForZoom(17),z=(s,n,o)=>`/GisViewerAssets/Images/cross/ic_${(s??"gc").toLowerCase()==="scats"?"scats":"gc"}_${n===!1?"offline":"online"}_${o?"malfunction":"normal"}.png`,d=new Map,S=new Map,m=new WeakMap,C={online:"#22c55e",offline:"#9ca3af"},O=new w({color:"#ffffff",width:1.5}),M=new Map,k=s=>{const n=s===!1?"offline":"online",o=M.get(n);if(o)return o;const r=[new c({image:new v({radius:3,fill:new u({color:C[n]}),stroke:O}),zIndex:1})];return M.set(n,r),r},b=new Map,B=s=>{const n=s===!1?"offline":"online",o=b.get(n);if(o)return o;const r=[new c({image:new v({radius:6,fill:new u({color:C[n]}),stroke:O}),zIndex:1})];return b.set(n,r),r},A=new u({color:"#1f2937"}),R=new w({color:"#ffffff",width:3}),p=s=>{const n=d.get(s);if(n)return n;const o=new c({image:new F({src:s,scale:.5,anchor:[.5,1],anchorXUnits:"fraction",anchorYUnits:"fraction"}),zIndex:1});return d.set(s,o),o},P=s=>{const n=S.get(s);if(n)return n;const o=[p(s)];return S.set(s,o),o};this.crossLayer.setStyle((s,n)=>{if((s.get("type")??"")==="signal-cluster")return this.getClusterStyle(s.getProperties());const r=this.showName==="crossName"?s.get("name"):this.showName==="signalId"?s.get("signalId"):`${s.get("name")}(${s.get("signalId")})`,_=s.get("brand")??"gc",h=s.get("isOnline"),I=s.get("isMalfunction"),g=z(_,h,I);if(n>E)return k(h);if(n>q)return B(h);if(n>Z)return P(g);const y=m.get(s);if(y&&y.label===r&&y.iconKey===g)return y.styles;const V=p(g),D=new c({text:new K({text:r,font:'12px "Microsoft YaHei"',textAlign:"center",textBaseline:"bottom",offsetY:-28,fill:A,stroke:R}),zIndex:2}),T=[V,D];return m.set(s,{label:r,iconKey:g,styles:T}),T})}createCrossFeature(e){return e.brand=e.brand.toLowerCase(),new L({geometry:new x([e.x,e.y]),type:"signal-cross",id:e.crossId,brandLabel:this.getBrandLabel(e.brand),isOnlineLabel:this.getOnlineLabel(e.isOnline),isMalfunctionLabel:this.getMalfunctionLabel(e.isMalfunction),...e})}getClusterStyle(e){const t=e.clusterSymbolSize,i=new F({src:"/GisViewerAssets/Images/cross/gis_xhj_blue.png",scale:t/32}),l=-(t+10),a=new K({text:String(e.count??0),font:"16px Arial Unicode MS",fill:new u({color:[255,255,255,255]}),backgroundFill:new u({color:[2,72,200,1]}),backgroundStroke:new w({color:[2,72,200,.5],width:2}),padding:[1,2,1,2],offsetY:l,textAlign:"center",justify:"center",textBaseline:"middle"});return[new c({image:i}),new c({text:a})]}getBrandLabel(e){const t=(e??"").toLowerCase();return t==="scats"?"SCATS":t==="gc"?"国产":e??""}getOnlineLabel(e){return e?"在线":"离线"}getMalfunctionLabel(e){return e?"故障":"正常"}showClusterResult(e){this.source.clear(),e.forEach(t=>{if(t.id!==-1&&t.center&&t.symbolSize){const i=new L({geometry:new x([t.center.x,t.center.y]),type:"signal-cluster",count:t.count,clusterSymbolSize:t.symbolSize});this.source.addFeature(i)}else t.items.forEach(i=>{const l=this.createCrossFeature({...i.properties,x:i.x,y:i.y});this.source.addFeature(l)})}),this.crossLayer.changed()}}exports.default=$;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { default as OlMap } from 'ol/Map';
|
|
2
|
+
import { IResult, IShowSignalSystemParams, IShowSubSignalSystemParams } from 'packages/components/src/types';
|
|
3
|
+
/**
|
|
4
|
+
* 信号系统控制器
|
|
5
|
+
* 用于在 OpenLayers 地图上展示和管理信号子区系统
|
|
6
|
+
* 包括子区道路线(LineString)和路口节点(Point)的渲染
|
|
7
|
+
*/
|
|
8
|
+
export default class SignalSystemController {
|
|
9
|
+
/** OpenLayers 地图实例 */
|
|
10
|
+
private map;
|
|
11
|
+
/** 矢量数据源,存储所有信号系统要素 */
|
|
12
|
+
private source;
|
|
13
|
+
/** 信号系统图层 */
|
|
14
|
+
private signalSystemLayer;
|
|
15
|
+
/**
|
|
16
|
+
* 构造函数
|
|
17
|
+
* @param map - OpenLayers 地图实例
|
|
18
|
+
*/
|
|
19
|
+
constructor(map: OlMap);
|
|
20
|
+
showSignalSystem(params: IShowSignalSystemParams): Promise<IResult> | {
|
|
21
|
+
status: number;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
removeSignalSystem(areaCode?: string): void;
|
|
25
|
+
private showSystem;
|
|
26
|
+
/**
|
|
27
|
+
* 展示多个信号子区系统
|
|
28
|
+
* 遍历所有子区并渲染,完成后自动缩放地图视角以显示所有子区
|
|
29
|
+
*
|
|
30
|
+
* @param params - 展示参数,包含子区列表
|
|
31
|
+
* @returns 操作结果
|
|
32
|
+
*/
|
|
33
|
+
showSubSignalSystem(params: IShowSubSignalSystemParams): Promise<IResult>;
|
|
34
|
+
/**
|
|
35
|
+
* 移除信号子区系统
|
|
36
|
+
* 若不传 subCode,则清除所有子区;否则只清除指定子区
|
|
37
|
+
*
|
|
38
|
+
* @param subCode - 可选,子区编码。不传则清除全部
|
|
39
|
+
*/
|
|
40
|
+
removeSubSignalSystem(subCode?: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* 渲染单个信号子区系统
|
|
43
|
+
* 包括子区道路线和路口节点的渲染
|
|
44
|
+
*
|
|
45
|
+
* @param subSystem - 信号子区系统数据
|
|
46
|
+
* @param areaCode - 区域编码,用于关联要素
|
|
47
|
+
*/
|
|
48
|
+
private showSubSystem;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("ol/Feature"),u=require("ol/geom"),l=require("ol/layer/Vector"),h=require("ol/source/Vector"),c=require("../style/line-style.js"),S=require("../style/point-style.js");class g{constructor(e){this.map=e,this.source=new h,this.signalSystemLayer=new l({source:this.source}),this.signalSystemLayer.set("id","signal-system-layer"),this.map.addLayer(this.signalSystemLayer)}showSignalSystem(e){e.areaList.forEach(t=>{this.showSystem(t)});const s=this.source.getExtent();return s&&s[0]!==1/0?new Promise(t=>{this.map.getView().fit(s,{padding:[50,50,50,50],callback:()=>{t({status:0,message:"success"})}})}):{status:1,message:"No features to display"}}removeSignalSystem(e){if(!e){this.source.clear();return}this.source.getFeatures().filter(t=>t.get("areaCode")===e).forEach(t=>{this.source.removeFeature(t)})}showSystem(e){if(e.shape){let s;typeof e.shape=="string"?s=JSON.parse(e.shape):s=e.shape;const t=c.getLineStyle(e.lineSymbol,e),r=new n({geometry:new u.LineString(s),areaCode:e.areaCode});r.setStyle(t),this.source.addFeature(r)}e.children&&e.children.forEach(s=>{this.showSubSystem(s,e.areaCode)})}async showSubSignalSystem(e){e.areaList.forEach(t=>{this.showSubSystem(t)});const s=this.source.getExtent();return s&&s[0]!==1/0?new Promise(t=>{this.map.getView().fit(s,{padding:[50,50,50,50],callback:()=>{t({status:0,message:"success"})}})}):{status:1,message:"No features to display"}}removeSubSignalSystem(e){if(!e){this.source.clear();return}this.source.getFeatures().filter(t=>t.get("subCode")===e).forEach(t=>{this.source.removeFeature(t)})}showSubSystem(e,s){if(e.subShape){let t;typeof e.subShape=="string"?t=JSON.parse(e.subShape):t=e.subShape;const r=c.getLineStyle(e.roadSymbol,e),o=t.map(i=>{const a=new n({geometry:new u.LineString(i),subCode:e.subAreaCode,areaCode:s||""});return a.setStyle(r),a});this.source.addFeatures(o)}if(e.children){const t=e.children.map(r=>{const o=r.symbol||e.nodeSymbol,i=S.getPointStyle(o,r),a=new n({...r,subCode:e.subAreaCode,areaCode:s||"",geometry:new u.Point([r.x,r.y])});return a.setStyle(i),a});this.source.addFeatures(t)}}}exports.default=g;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Style from 'ol/style/Style';
|
|
2
|
+
/**
|
|
3
|
+
* 根据 ArcGIS simple-line 的 style 获取 lineDash 配置
|
|
4
|
+
* @param style ArcGIS line style
|
|
5
|
+
* @param width 线宽,用于计算 dash 长度
|
|
6
|
+
*/
|
|
7
|
+
export declare function getLineDashByStyle(style: string, width: number): number[] | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* 清除样式缓存
|
|
10
|
+
*/
|
|
11
|
+
export declare function clearStyleCache(): void;
|
|
12
|
+
/**
|
|
13
|
+
* 获取当前缓存大小
|
|
14
|
+
*/
|
|
15
|
+
export declare function getStyleCacheSize(): number;
|
|
16
|
+
/**
|
|
17
|
+
* 获取线样式
|
|
18
|
+
* 支持 symbol 数组配置(line + text),或单个 symbol 配置
|
|
19
|
+
* 若 symbol 为空则显示蓝色线
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // 简单线样式配置
|
|
23
|
+
* { symbol: { strokeColor: '#ff0000', strokeWidth: 3 } }
|
|
24
|
+
*
|
|
25
|
+
* // 虚线样式配置
|
|
26
|
+
* { symbol: { strokeColor: '#2563eb', strokeWidth: 2, lineDash: [10, 5] } }
|
|
27
|
+
*
|
|
28
|
+
* // 带边框的线样式配置
|
|
29
|
+
* { symbol: { type: 'bordered', strokeColor: '#ffffff', strokeWidth: 4, borderColor: '#000000', borderWidth: 1 } }
|
|
30
|
+
*
|
|
31
|
+
* // 数组配置(线 + 文字)
|
|
32
|
+
* {
|
|
33
|
+
* symbol: [
|
|
34
|
+
* { type: 'line', strokeColor: '#2563eb', strokeWidth: 3 },
|
|
35
|
+
* { type: 'text', field: 'name', font: '14px Arial', fillColor: [0,0,0], placement: 'line' }
|
|
36
|
+
* ]
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* // 数组配置(带边框线 + 文字)
|
|
40
|
+
* {
|
|
41
|
+
* symbol: [
|
|
42
|
+
* { type: 'bordered', strokeColor: '#ffffff', strokeWidth: 4, borderColor: '#333333', borderWidth: 1 },
|
|
43
|
+
* { type: 'text', field: 'roadName', font: '12px Arial', fillColor: [0,0,0], placement: 'line', overflow: true }
|
|
44
|
+
* ]
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* // ArcGIS simple-line 配置
|
|
48
|
+
* // style 可选值: 'solid', 'dash', 'dot', 'dash-dot', 'long-dash', 'long-dash-dot',
|
|
49
|
+
* // 'long-dash-dot-dot', 'short-dash', 'short-dot', 'short-dash-dot', 'short-dash-dot-dot', 'none'
|
|
50
|
+
* { symbol: { type: 'simple-line', style: 'solid', color: [255, 0, 0, 1], width: 2 } }
|
|
51
|
+
* { symbol: { type: 'simple-line', style: 'dash', color: [0, 0, 255, 1], width: 3 } }
|
|
52
|
+
* { symbol: { type: 'simple-line', style: 'dot', color: [0, 128, 0, 1], width: 2 } }
|
|
53
|
+
* { symbol: { type: 'simple-line', style: 'dash-dot', color: [255, 128, 0, 1], width: 2 } }
|
|
54
|
+
* { symbol: { type: 'simple-line', style: 'long-dash-dot-dot', color: [128, 0, 128, 1], width: 2 } }
|
|
55
|
+
*
|
|
56
|
+
* // 数组配置(ArcGIS simple-line + 文字)
|
|
57
|
+
* {
|
|
58
|
+
* symbol: [
|
|
59
|
+
* { type: 'simple-line', style: 'dash', color: [0, 0, 255, 1], width: 3, cap: 'butt', join: 'miter' },
|
|
60
|
+
* { type: 'text', field: 'name', font: '12px Arial', fillColor: [0,0,0], placement: 'line' }
|
|
61
|
+
* ]
|
|
62
|
+
* }
|
|
63
|
+
*/
|
|
64
|
+
export declare function getLineStyle(symbol: any, attributes?: any): Style | Style[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("ol/style/Fill"),a=require("ol/style/Stroke"),c=require("ol/style/Style"),D=require("ol/style/Text"),f=new Map;let d=null;function x(e,n){return e?Array.isArray(e)?e.map(o=>{if(o.type==="text"&&o.field){const r=(n==null?void 0:n[o.field])??"";return JSON.stringify({...o,__textContent__:r})}return JSON.stringify(o)}).join("|"):JSON.stringify(e):"__default__"}function h(){return d||(d=new c({stroke:new a({color:"#2563eb",width:2})})),d}function s(e){return new c({stroke:new a({color:e.color??"#2563eb",width:e.width??2,lineCap:e.lineCap??"round",lineJoin:e.lineJoin??"round",lineDash:e.lineDash,lineDashOffset:e.lineDashOffset??0})})}function p(e){const n=new c({stroke:new a({color:e.borderColor??"#000000",width:(e.width??2)+(e.borderWidth??2)*2,lineCap:e.lineCap??"round",lineJoin:e.lineJoin??"round",lineDash:e.lineDash,lineDashOffset:e.lineDashOffset??0})}),t=new c({stroke:new a({color:e.color??"#2563eb",width:e.width??2,lineCap:e.lineCap??"round",lineJoin:e.lineJoin??"round",lineDash:e.lineDash,lineDashOffset:e.lineDashOffset??0})});return[n,t]}function S(e,n){const t=n||2;switch(e){case"solid":return;case"dash":return[t*4,t*2];case"dot":return[t,t*2];case"dash-dot":return[t*4,t*2,t,t*2];case"long-dash":return[t*6,t*3];case"long-dash-dot":return[t*6,t*2,t,t*2];case"long-dash-dot-dot":return[t*6,t*2,t,t*2,t,t*2];case"short-dash":return[t*2,t];case"short-dot":return[t,t];case"short-dash-dot":return[t*2,t,t,t];case"short-dash-dot-dot":return[t*2,t,t,t,t,t];case"none":return[0,1];default:return}}function w(e){const n=e.width??2,t=S(e.style??"solid",n);return new c({stroke:new a({color:e.color??[0,0,0,1],width:n,lineCap:e.cap??"round",lineJoin:e.join??"round",lineDash:t,lineDashOffset:0})})}function C(e,n){const t=new D({text:String(n),font:e.font??"14px Arial Unicode MS",fill:new g({color:e.fillColor??[0,0,0]}),stroke:new a({color:e.strokeColor??[255,255,255],width:e.strokeWidth??3}),offsetX:e.offsetX??0,offsetY:e.offsetY??0,textAlign:e.textAlign??"center",textBaseline:e.textBaseline??"middle",placement:e.placement??"point",overflow:e.overflow??!1,maxAngle:e.maxAngle??Math.PI/4});return new c({text:t})}function k(e,n){if(!e)return h();const t=x(e,n),o=f.get(t);if(o)return o;let r;if(Array.isArray(e)&&e.length>0){const l=[];if(e.forEach(i=>{if(i.type==="line")l.push(s(i));else if(i.type==="simple-line")l.push(w(i));else if(i.type==="bordered")l.push(...p(i));else if(i.type==="text"&&i.field){const u=(n==null?void 0:n[i.field])??"";u&&l.push(C(i,u))}}),l.length>0)return r=l,f.set(t,r),r}return e&&e.type==="bordered"?(r=p(e),f.set(t,r),r):e&&e.type==="simple-line"?(r=w(e),f.set(t,r),r):e?(r=s(e),f.set(t,r),r):h()}exports.getLineDashByStyle=S;exports.getLineStyle=k;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import Style from 'ol/style/Style';
|
|
2
|
+
/**
|
|
3
|
+
* 清除样式缓存
|
|
4
|
+
*/
|
|
5
|
+
export declare function clearStyleCache(): void;
|
|
6
|
+
/**
|
|
7
|
+
* 获取当前缓存大小
|
|
8
|
+
*/
|
|
9
|
+
export declare function getStyleCacheSize(): number;
|
|
10
|
+
/**
|
|
11
|
+
* 获取单点样式
|
|
12
|
+
* 支持 symbol 数组配置(icon + text + circle + shape),或单个 symbol 配置
|
|
13
|
+
* 若 symbol 为空则显示蓝色圆点
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // 单个图标配置
|
|
17
|
+
* { symbol: { url: '/path/to/icon.png', scale: 1 } }
|
|
18
|
+
*
|
|
19
|
+
* // 圆点样式配置
|
|
20
|
+
* { symbol: { type: 'circle', radius: 8, fillColor: '#ff0000', strokeColor: '#ffffff', strokeWidth: 2 } }
|
|
21
|
+
*
|
|
22
|
+
* // 规则图形样式配置(三角形)
|
|
23
|
+
* { symbol: { type: 'shape', points: 3, radius: 10, fillColor: 'red', strokeColor: 'black', strokeWidth: 1 } }
|
|
24
|
+
*
|
|
25
|
+
* // 规则图形样式配置(正方形,旋转45度)
|
|
26
|
+
* { symbol: { type: 'shape', points: 4, radius: 10, angle: Math.PI / 4, fillColor: 'blue' } }
|
|
27
|
+
*
|
|
28
|
+
* // 规则图形样式配置(五角星)
|
|
29
|
+
* { symbol: { type: 'shape', points: 5, radius: 12, radius2: 6, fillColor: 'gold', strokeColor: 'orange' } }
|
|
30
|
+
*
|
|
31
|
+
* // 规则图形样式配置(十字形)
|
|
32
|
+
* { symbol: { type: 'shape', points: 4, radius: 10, radius2: 0, strokeColor: 'red', strokeWidth: 2 } }
|
|
33
|
+
*
|
|
34
|
+
* // ArcGIS picture-marker 配置 (转换为 OpenLayers Icon)
|
|
35
|
+
* { symbol: { type: 'picture-marker', url: '/path/to/icon.png', width: 24, height: 24, angle: 0, xoffset: 0, yoffset: 0 } }
|
|
36
|
+
*
|
|
37
|
+
* // ArcGIS simple-marker 配置 (根据 style 返回对应的 OpenLayers 样式)
|
|
38
|
+
* // style 可选值: 'circle', 'square', 'diamond', 'triangle', 'cross', 'x', 'path'
|
|
39
|
+
* { symbol: { type: 'simple-marker', style: 'circle', size: 12, color: [255, 0, 0, 1], outline: { color: [255, 255, 255, 1], width: 1 } } }
|
|
40
|
+
* { symbol: { type: 'simple-marker', style: 'square', size: 12, color: [0, 128, 255, 1], outline: { color: [0, 0, 0, 1], width: 2 } } }
|
|
41
|
+
* { symbol: { type: 'simple-marker', style: 'diamond', size: 14, color: [255, 215, 0, 1], outline: { color: [139, 69, 19, 1], width: 1 } } }
|
|
42
|
+
* { symbol: { type: 'simple-marker', style: 'triangle', size: 12, color: [0, 255, 0, 1], outline: { color: [0, 100, 0, 1], width: 1 } } }
|
|
43
|
+
* { symbol: { type: 'simple-marker', style: 'cross', size: 12, outline: { color: [255, 0, 0, 1], width: 2 } } }
|
|
44
|
+
* { symbol: { type: 'simple-marker', style: 'x', size: 12, outline: { color: [0, 0, 255, 1], width: 2 } } }
|
|
45
|
+
*
|
|
46
|
+
* // 数组配置(图标 + 文字)
|
|
47
|
+
* {
|
|
48
|
+
* symbol: [
|
|
49
|
+
* { type: 'icon', url: '/path/to/icon.png', scale: 1 },
|
|
50
|
+
* { type: 'text', field: 'name', font: '14px Arial', fillColor: [0,0,0], offsetY: 20 }
|
|
51
|
+
* ]
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* // 数组配置(圆点 + 文字)
|
|
55
|
+
* {
|
|
56
|
+
* symbol: [
|
|
57
|
+
* { type: 'circle', radius: 10, fillColor: 'rgba(255,0,0,0.8)', strokeColor: '#fff', strokeWidth: 2 },
|
|
58
|
+
* { type: 'text', field: 'label', font: '12px Arial', fillColor: [255,255,255], offsetY: 0 }
|
|
59
|
+
* ]
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // 数组配置(五角星 + 文字)
|
|
63
|
+
* {
|
|
64
|
+
* symbol: [
|
|
65
|
+
* { type: 'shape', points: 5, radius: 12, radius2: 6, fillColor: 'gold', strokeColor: 'orange' },
|
|
66
|
+
* { type: 'text', field: 'name', font: '12px Arial', fillColor: [0,0,0], offsetY: 18 }
|
|
67
|
+
* ]
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* // 数组配置(ArcGIS simple-marker + 文字)
|
|
71
|
+
* {
|
|
72
|
+
* symbol: [
|
|
73
|
+
* { type: 'simple-marker', style: 'diamond', size: 16, color: [255, 0, 0, 1], outline: { color: [255, 255, 255, 1], width: 2 } },
|
|
74
|
+
* { type: 'text', field: 'name', font: '12px Arial', fillColor: [0,0,0], offsetY: 20 }
|
|
75
|
+
* ]
|
|
76
|
+
* }
|
|
77
|
+
*/
|
|
78
|
+
export declare function getPointStyle(symbol: any, attributes?: any): Style | Style[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("ol/style/Circle"),d=require("ol/style/Fill"),M=require("ol/style/Icon"),u=require("ol/style/RegularShape"),s=require("ol/style/Stroke"),f=require("ol/style/Style"),_=require("ol/style/Text"),a=new Map;let w=null;function A(e,t){return e?Array.isArray(e)?e.map(c=>{if(c.type==="text"&&c.field){const n=(t==null?void 0:t[c.field])??"";return JSON.stringify({...c,__textContent__:n})}return JSON.stringify(c)}).join("|"):JSON.stringify(e):"__default__"}function k(){return w||(w=new f({image:new h({radius:6,fill:new d({color:"#2563eb"}),stroke:new s({color:"#ffffff",width:1.5})})})),w}function S(e){const t=new M({src:e.url,scale:e.scale??1,anchor:e.anchor??[.5,.5],anchorXUnits:e.anchorXUnits??"fraction",anchorYUnits:e.anchorYUnits??"fraction",rotation:e.rotation??0});return new f({image:t})}function x(e){const t=new h({radius:e.radius??6,fill:new d({color:e.fillColor??"#2563eb"}),stroke:new s({color:e.strokeColor??"#ffffff",width:e.strokeWidth??1.5})});return new f({image:t})}function C(e){const t=new u({points:e.points??4,radius:e.radius??10,radius2:e.radius2,angle:e.angle??0,rotation:e.rotation??0,fill:e.fillColor?new d({color:e.fillColor}):void 0,stroke:new s({color:e.strokeColor??"#000000",width:e.strokeWidth??1})});return new f({image:t})}function P(e){const t=e.width!=null||e.height!=null,i={src:e.url,anchor:e.anchor??[.5,.5],anchorXUnits:"fraction",anchorYUnits:"fraction",rotation:(e.angle??0)*Math.PI/180,displacement:[e.xoffset??0,-(e.yoffset??0)]};t?(e.width!=null&&(i.width=e.width),e.height!=null&&(i.height=e.height)):e.scale!=null&&(i.scale=e.scale);const c=new M(i);return new f({image:c})}function q(e){var p,g;const t=e.size??12,i=e.color??[0,0,0,1],c=((p=e.outline)==null?void 0:p.color)??[255,255,255,1],n=((g=e.outline)==null?void 0:g.width)??1,o=new d({color:i}),r=new s({color:c,width:n});let l;switch(e.style){case"circle":l=new h({radius:t/2,fill:o,stroke:r});break;case"square":l=new u({points:4,radius:t/2,angle:Math.PI/4,fill:o,stroke:r});break;case"diamond":l=new u({points:4,radius:t/2,angle:0,fill:o,stroke:r});break;case"triangle":l=new u({points:3,radius:t/2,angle:0,fill:o,stroke:r});break;case"cross":l=new u({points:4,radius:t/2,radius2:0,angle:0,stroke:r});break;case"x":l=new u({points:4,radius:t/2,radius2:0,angle:Math.PI/4,stroke:r});break;case"path":l=new h({radius:t/2,fill:o,stroke:r});break;default:l=new h({radius:t/2,fill:o,stroke:r});break}return new f({image:l})}function U(e,t){const i=new _({text:String(t),font:e.font??"14px Arial Unicode MS",fill:new d({color:e.fillColor??[0,0,0]}),stroke:new s({color:e.strokeColor??[255,255,255],width:e.strokeWidth??3}),offsetX:e.offsetX??0,offsetY:e.offsetY??0,textAlign:e.textAlign??"center",textBaseline:e.textBaseline??"middle"});return new f({text:i})}function I(e,t){if(!e)return k();const i=A(e,t),c=a.get(i);if(c)return c;let n;if(Array.isArray(e)&&e.length>0){const o=[];if(e.forEach(r=>{if(r.type==="icon"&&r.url)o.push(S(r));else if(r.type==="picture-marker"&&r.url)o.push(P(r));else if(r.type==="simple-marker")o.push(q(r));else if(r.type==="circle")o.push(x(r));else if(r.type==="shape")o.push(C(r));else if(r.type==="text"&&r.field){const l=(t==null?void 0:t[r.field])??"";l&&o.push(U(r,l))}}),o.length>0)return n=o,a.set(i,n),n}return e&&e.url?(n=S(e),a.set(i,n),n):e&&e.type==="picture-marker"&&e.url?(n=P(e),a.set(i,n),n):e&&e.type==="simple-marker"?(n=q(e),a.set(i,n),n):e&&e.type==="circle"?(n=x(e),a.set(i,n),n):e&&e.type==="shape"?(n=C(e),a.set(i,n),n):k()}exports.getPointStyle=I;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Style from 'ol/style/Style';
|
|
2
|
+
/**
|
|
3
|
+
* 清除样式缓存
|
|
4
|
+
*/
|
|
5
|
+
export declare function clearStyleCache(): void;
|
|
6
|
+
/**
|
|
7
|
+
* 获取当前缓存大小
|
|
8
|
+
*/
|
|
9
|
+
export declare function getStyleCacheSize(): number;
|
|
10
|
+
/**
|
|
11
|
+
* 获取多边形样式
|
|
12
|
+
* 支持 symbol 数组配置(polygon + text),或单个 symbol 配置
|
|
13
|
+
* 若 symbol 为空则显示默认半透明蓝色填充
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // 简单多边形样式配置
|
|
17
|
+
* { symbol: { fillColor: 'rgba(255,0,0,0.5)', strokeColor: '#ff0000', strokeWidth: 2 } }
|
|
18
|
+
*
|
|
19
|
+
* // 仅边框样式配置(无填充)
|
|
20
|
+
* { symbol: { strokeColor: '#2563eb', strokeWidth: 3 } }
|
|
21
|
+
*
|
|
22
|
+
* // 虚线边框样式配置
|
|
23
|
+
* { symbol: { fillColor: 'rgba(0,128,255,0.3)', strokeColor: '#0080ff', strokeWidth: 2, lineDash: [10, 5] } }
|
|
24
|
+
*
|
|
25
|
+
* // 带边框的多边形样式配置(双边框效果)
|
|
26
|
+
* { symbol: { type: 'bordered', fillColor: 'rgba(255,255,255,0.8)', strokeColor: '#ffffff', strokeWidth: 4, borderColor: '#333333', borderWidth: 1 } }
|
|
27
|
+
*
|
|
28
|
+
* // 数组配置(多边形 + 文字)
|
|
29
|
+
* {
|
|
30
|
+
* symbol: [
|
|
31
|
+
* { type: 'polygon', fillColor: 'rgba(255,0,0,0.5)', strokeColor: '#ff0000', strokeWidth: 2 },
|
|
32
|
+
* { type: 'text', field: 'name', font: '14px Arial', fillColor: [0,0,0] }
|
|
33
|
+
* ]
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* // 数组配置(带边框多边形 + 文字)
|
|
37
|
+
* {
|
|
38
|
+
* symbol: [
|
|
39
|
+
* { type: 'bordered', fillColor: 'rgba(255,255,255,0.8)', strokeColor: '#ffffff', strokeWidth: 4, borderColor: '#333333', borderWidth: 1 },
|
|
40
|
+
* { type: 'text', field: 'areaName', font: '12px Arial', fillColor: [0,0,0] }
|
|
41
|
+
* ]
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* // ArcGIS simple-fill 配置
|
|
45
|
+
* // style 可选值: 'solid', 'none', 'horizontal', 'vertical', 'cross', 'forward-diagonal', 'backward-diagonal', 'diagonal-cross'
|
|
46
|
+
* { symbol: { type: 'simple-fill', style: 'solid', color: [255, 0, 0, 0.5], outline: { color: [0, 0, 0, 1], width: 2, style: 'solid' } } }
|
|
47
|
+
* { symbol: { type: 'simple-fill', style: 'none', outline: { color: [255, 0, 0, 1], width: 3, style: 'dash' } } }
|
|
48
|
+
*
|
|
49
|
+
* // ArcGIS picture-fill 配置(降级为纯色填充)
|
|
50
|
+
* { symbol: { type: 'picture-fill', url: '/path/to/pattern.png', width: 32, height: 32, outline: { color: [0, 0, 0, 1], width: 1 } } }
|
|
51
|
+
*
|
|
52
|
+
* // 数组配置(ArcGIS simple-fill + 文字)
|
|
53
|
+
* {
|
|
54
|
+
* symbol: [
|
|
55
|
+
* { type: 'simple-fill', style: 'solid', color: [0, 128, 255, 0.4], outline: { color: [0, 0, 128, 1], width: 2, style: 'solid' } },
|
|
56
|
+
* { type: 'text', field: 'name', font: '12px Arial', fillColor: [0,0,0] }
|
|
57
|
+
* ]
|
|
58
|
+
* }
|
|
59
|
+
*/
|
|
60
|
+
export declare function getPolygonStyle(symbol: any, attributes?: any): Style | Style[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("ol/style/Fill"),f=require("ol/style/Stroke"),u=require("ol/style/Style"),k=require("ol/style/Text"),C=require("./line-style.js"),a=new Map;let d=null;function D(e,n){return e?Array.isArray(e)?e.map(o=>{if(o.type==="text"&&o.field){const t=(n==null?void 0:n[o.field])??"";return JSON.stringify({...o,__textContent__:t})}return JSON.stringify(o)}).join("|"):JSON.stringify(e):"__default__"}function w(){return d||(d=new u({fill:new c({color:"rgba(37, 99, 235, 0.3)"}),stroke:new f({color:"#2563eb",width:2})})),d}function s(e){return new u({fill:e.fillColor?new c({color:e.fillColor}):void 0,stroke:new f({color:e.strokeColor??"#2563eb",width:e.strokeWidth??2,lineCap:e.lineCap??"round",lineJoin:e.lineJoin??"round",lineDash:e.lineDash,lineDashOffset:e.lineDashOffset??0})})}function x(e,n){switch(e){case"solid":return new c({color:n??[0,0,0,.5]});case"none":case"null":return;case"horizontal":case"vertical":case"cross":case"forward-diagonal":case"backward-diagonal":case"diagonal-cross":return new c({color:n??[0,0,0,.3]});default:return new c({color:n??[0,0,0,.5]})}}function p(e){const n=e.style??"solid",l=x(n,e.color);let o;if(e.outline){const t=e.outline.width??1,r=e.outline.style??"solid",i=C.getLineDashByStyle(r,t);o=new f({color:e.outline.color??[0,0,0,1],width:t,lineCap:e.outline.cap??"round",lineJoin:e.outline.join??"round",lineDash:i})}return new u({fill:l,stroke:o})}function S(e){const n=new c({color:e.color??"rgba(128, 128, 128, 0.3)"});let l;if(e.outline){const o=e.outline.width??1,t=e.outline.style??"solid",r=C.getLineDashByStyle(t,o);l=new f({color:e.outline.color??[0,0,0,1],width:o,lineDash:r})}return new u({fill:n,stroke:l})}function g(e){const n=new u({stroke:new f({color:e.borderColor??"#000000",width:(e.strokeWidth??2)+(e.borderWidth??2)*2,lineCap:e.lineCap??"round",lineJoin:e.lineJoin??"round",lineDash:e.lineDash,lineDashOffset:e.lineDashOffset??0})}),l=new u({fill:e.fillColor?new c({color:e.fillColor}):void 0,stroke:new f({color:e.strokeColor??"#2563eb",width:e.strokeWidth??2,lineCap:e.lineCap??"round",lineJoin:e.lineJoin??"round",lineDash:e.lineDash,lineDashOffset:e.lineDashOffset??0})});return[n,l]}function J(e,n){const l=new k({text:String(n),font:e.font??"14px Arial Unicode MS",fill:new c({color:e.fillColor??[0,0,0]}),stroke:new f({color:e.strokeColor??[255,255,255],width:e.strokeWidth??3}),offsetX:e.offsetX??0,offsetY:e.offsetY??0,textAlign:e.textAlign??"center",textBaseline:e.textBaseline??"middle",overflow:e.overflow??!1});return new u({text:l})}function O(e,n){if(!e)return w();const l=D(e,n),o=a.get(l);if(o)return o;let t;if(Array.isArray(e)&&e.length>0){const r=[];if(e.forEach(i=>{if(i.type==="polygon")r.push(s(i));else if(i.type==="simple-fill")r.push(p(i));else if(i.type==="picture-fill")r.push(S(i));else if(i.type==="bordered")r.push(...g(i));else if(i.type==="text"&&i.field){const h=(n==null?void 0:n[i.field])??"";h&&r.push(J(i,h))}}),r.length>0)return t=r,a.set(l,t),t}return e&&e.type==="bordered"?(t=g(e),a.set(l,t),t):e&&e.type==="simple-fill"?(t=p(e),a.set(l,t),t):e&&e.type==="picture-fill"?(t=S(e),a.set(l,t),t):e?(t=s(e),a.set(l,t),t):w()}exports.getPolygonStyle=O;
|
package/lib/src/types/index.d.ts
CHANGED
|
@@ -149,6 +149,7 @@ export interface IOverlayParam {
|
|
|
149
149
|
defaultSymbol?: IPointSymbol | ILineSymbol | IPolygonSymbol;
|
|
150
150
|
defaultVisible?: boolean;
|
|
151
151
|
overlays: Array<IOverlay>;
|
|
152
|
+
needZoom?: boolean;
|
|
152
153
|
}
|
|
153
154
|
export interface IClusterPointParams {
|
|
154
155
|
type?: string;
|
|
@@ -323,7 +324,7 @@ export interface ISignalSubSystem {
|
|
|
323
324
|
subShape?: number[][][] | string;
|
|
324
325
|
nodeSymbol?: any;
|
|
325
326
|
roadSymbol?: any;
|
|
326
|
-
children
|
|
327
|
+
children?: {
|
|
327
328
|
x: number;
|
|
328
329
|
y: number;
|
|
329
330
|
nodeId: string;
|