@itwin/map-layers-formats 4.1.0-dev.62 → 4.1.0-dev.66

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/lib/cjs/ArcGisFeature/ArcGisCanvasRenderer.d.ts +3 -1
  3. package/lib/cjs/ArcGisFeature/ArcGisCanvasRenderer.d.ts.map +1 -1
  4. package/lib/cjs/ArcGisFeature/ArcGisCanvasRenderer.js +4 -0
  5. package/lib/cjs/ArcGisFeature/ArcGisCanvasRenderer.js.map +1 -1
  6. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.d.ts +10 -4
  7. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.d.ts.map +1 -1
  8. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js +71 -12
  9. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
  10. package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.d.ts +1 -0
  11. package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.d.ts.map +1 -1
  12. package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js +18 -0
  13. package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
  14. package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.d.ts +9 -1
  15. package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.d.ts.map +1 -1
  16. package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.js +144 -110
  17. package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.js.map +1 -1
  18. package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.d.ts +32 -77
  19. package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.d.ts.map +1 -1
  20. package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js +88 -128
  21. package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
  22. package/lib/cjs/ArcGisFeature/EsriSymbology.d.ts +152 -0
  23. package/lib/cjs/ArcGisFeature/EsriSymbology.d.ts.map +1 -0
  24. package/lib/cjs/ArcGisFeature/EsriSymbology.js +181 -0
  25. package/lib/cjs/ArcGisFeature/EsriSymbology.js.map +1 -0
  26. package/lib/esm/ArcGisFeature/ArcGisCanvasRenderer.d.ts +3 -1
  27. package/lib/esm/ArcGisFeature/ArcGisCanvasRenderer.d.ts.map +1 -1
  28. package/lib/esm/ArcGisFeature/ArcGisCanvasRenderer.js +4 -0
  29. package/lib/esm/ArcGisFeature/ArcGisCanvasRenderer.js.map +1 -1
  30. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.d.ts +10 -4
  31. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.d.ts.map +1 -1
  32. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js +71 -12
  33. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
  34. package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.d.ts +1 -0
  35. package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.d.ts.map +1 -1
  36. package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js +18 -0
  37. package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
  38. package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.d.ts +9 -1
  39. package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.d.ts.map +1 -1
  40. package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.js +144 -110
  41. package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.js.map +1 -1
  42. package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.d.ts +32 -77
  43. package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.d.ts.map +1 -1
  44. package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js +84 -124
  45. package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
  46. package/lib/esm/ArcGisFeature/EsriSymbology.d.ts +152 -0
  47. package/lib/esm/ArcGisFeature/EsriSymbology.d.ts.map +1 -0
  48. package/lib/esm/ArcGisFeature/EsriSymbology.js +170 -0
  49. package/lib/esm/ArcGisFeature/EsriSymbology.js.map +1 -0
  50. package/package.json +11 -11
@@ -3,142 +3,84 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { Logger } from "@itwin/core-bentley";
6
- import { ColorDef } from "@itwin/core-common";
7
- // Convert a channel array [r, g, b, a] to ColorDef
8
- function colorFromArray(channels) {
9
- if (channels && channels.length === 4) {
10
- // Alpha channel is reversed, 255 = opaque
11
- return ColorDef.from(channels[0], channels[1], channels[2], 255 - channels[3]);
12
- }
13
- return undefined;
14
- }
15
- const loggerCategory = "MapLayersFormats.ArcGISFeature";
16
- /** @internal */
17
- export class EsriSLS {
18
- get color() { return colorFromArray(this.props.color); }
19
- get type() { return this.props.type; }
20
- get width() { return this.props.width; }
21
- get style() { return this.props.style; }
22
- constructor(json) {
23
- this.props = json;
24
- }
25
- static fromJSON(json) {
26
- return new EsriSLS(json);
27
- }
28
- }
29
6
  /** @internal */
30
- export class EsriPMS {
31
- get type() { return this.props.type; }
32
- get url() { return this.props.url; }
33
- get imageData() { return this.props.imageData; }
34
- get imageUrl() { return `data:${this.contentType};base64,${this.imageData}`; }
35
- get image() { return this._image; }
36
- get contentType() { return this.props.contentType; }
37
- get width() { return this.props.width; }
38
- get height() { return this.props.height; }
39
- get xoffset() { return this.props.xoffset; }
40
- get yoffset() { return this.props.yoffset; }
41
- get angle() { return this.props.angle; }
42
- constructor(json) {
43
- this.props = json;
44
- this._image = new Image();
45
- this._image.src = this.imageUrl;
46
- }
47
- static fromJSON(json) {
48
- return new EsriPMS(json);
49
- }
50
- }
7
+ const loggerCategory = "MapLayersFormats.ArcGISFeature";
51
8
  /** @internal */
52
- export class EsriSFS {
53
- get color() { return colorFromArray(this.props.color); }
54
- get type() { return this.props.type; }
55
- get style() { return this.props.style; }
56
- get outline() { return this._outline; }
57
- constructor(json) {
58
- this.props = json;
59
- if (json.outline)
60
- this._outline = EsriSLS.fromJSON(json.outline);
61
- }
62
- static fromJSON(json) {
63
- return new EsriSFS(json);
9
+ export class ArcGisSymbologyRenderer {
10
+ static create(renderer, defaultSymbol) {
11
+ if (renderer?.type === "uniqueValue") {
12
+ return new ArcGisUniqueValueSymbologyRenderer(renderer, defaultSymbol);
13
+ }
14
+ else {
15
+ return new ArcGisSimpleSymbologyRenderer(renderer, defaultSymbol);
16
+ }
64
17
  }
65
18
  }
66
19
  /** @internal */
67
- class ArcGisSymbologyRenderer {
68
- constructor(geometryType, rendererDefinition) {
69
- let symbol;
70
- if (rendererDefinition?.symbol) {
71
- symbol = rendererDefinition.symbol;
72
- }
73
- else if (rendererDefinition?.defaultSymbol) {
74
- symbol = rendererDefinition?.defaultSymbol;
20
+ export class ArcGisSimpleSymbologyRenderer extends ArcGisSymbologyRenderer {
21
+ isAttributeDriven() { return false; }
22
+ get symbol() { return this._symbol; }
23
+ get defaultSymbol() { return this._defaultSymbol; }
24
+ constructor(renderer, defaultSymbol) {
25
+ super();
26
+ this.lineWidthScaleFactor = 2; // This is value is empirical, this might need to be adjusted
27
+ this._defaultSymbol = defaultSymbol;
28
+ this.renderer = renderer;
29
+ if (this.renderer?.type === "simple") {
30
+ this._symbol = this.renderer.symbol;
75
31
  }
76
- if (symbol) {
77
- if (symbol.type === "esriSFS") {
78
- this._symbol = EsriSFS.fromJSON(symbol);
79
- }
80
- else if (symbol.type === "esriSLS") {
81
- this._symbol = EsriSLS.fromJSON(symbol);
82
- }
83
- else if (symbol.type === "esriPMS") {
84
- this._symbol = EsriPMS.fromJSON(symbol);
85
- }
86
- }
87
- // If '_symbol' is still undefined at this point, that means we could not find
88
- // any symbology definition from the metadata, let's use some default symbology
89
- // so that we display at least something.
90
- if (this._symbol === undefined) {
91
- Logger.logWarning(loggerCategory, "Symbology definition not supported, using default symbology");
92
- if (geometryType === "esriGeometryPoint" || geometryType === "esriGeometryMultipoint") {
93
- this._symbol = EsriPMS.fromJSON(ArcGisSymbologyRenderer.defaultPMS);
94
- }
95
- else if (geometryType === "esriGeometryLine" || geometryType === "esriGeometryPolyline") {
96
- this._symbol = EsriSLS.fromJSON(ArcGisSymbologyRenderer.defaultSLS);
97
- }
98
- else if (geometryType === "esriGeometryPolygon") {
99
- this._symbol = EsriSFS.fromJSON(ArcGisSymbologyRenderer.defaultSFS);
100
- }
101
- else {
102
- Logger.logError(loggerCategory, "Could not determine default symbology: geometry type not supported");
103
- }
32
+ else {
33
+ this._symbol = defaultSymbol;
104
34
  }
105
35
  }
106
36
  applyFillStyle(context) {
107
37
  if (!context)
108
38
  return;
109
- if (this._symbol?.type === "esriSFS") {
39
+ const fillColor = this.getFillColor();
40
+ if (fillColor) {
41
+ context.fillStyle = fillColor.toRgbaString();
42
+ }
43
+ else {
44
+ Logger.logTrace(loggerCategory, `Could not apply fill style`);
45
+ }
46
+ }
47
+ getFillColor() {
48
+ let fillColor;
49
+ if (this._symbol.type === "esriSFS") {
110
50
  const sfs = this._symbol;
111
- if (sfs.style === "esriSFSSolid" && sfs.color) {
112
- context.fillStyle = sfs.color.toRgbaString();
113
- }
114
- else {
115
- context.fillStyle = ColorDef.from(200, 0, 0, 100).toRgbaString(); // default color is red?
51
+ if (sfs.color) {
52
+ fillColor = sfs.color;
116
53
  }
117
54
  }
55
+ return fillColor;
118
56
  }
119
57
  applyStrokeStyle(context) {
120
58
  if (!context)
121
59
  return;
60
+ // Stroke style can be from SFS's outline style or a SLS's color
122
61
  let sls;
123
- if (this._symbol?.type === "esriSFS") {
62
+ if (this._symbol.type === "esriSFS") {
124
63
  const sfs = this._symbol;
125
64
  if (sfs.outline && sfs.outline.style === "esriSLSSolid") {
126
65
  sls = sfs.outline;
127
66
  }
128
67
  }
129
- else if (this._symbol?.type === "esriSLS") {
68
+ else if (this._symbol.type === "esriSLS") {
130
69
  sls = this._symbol;
131
70
  }
132
71
  if (sls) {
133
72
  if (sls.color)
134
73
  context.strokeStyle = sls.color.toRgbaString();
135
- context.lineWidth = sls.width * 2; // TODO: Should we scale this value here?
74
+ context.lineWidth = sls.width * this.lineWidthScaleFactor;
75
+ }
76
+ else {
77
+ Logger.logTrace(loggerCategory, `Could not apply stroke style`);
136
78
  }
137
79
  }
138
80
  drawPoint(context, ptX, ptY) {
139
81
  if (!context)
140
82
  return;
141
- if (this._symbol?.type === "esriPMS") {
83
+ if (this._symbol.type === "esriPMS") {
142
84
  const pms = this._symbol;
143
85
  let xOffset = 0, yOffset = 0;
144
86
  if (pms.xoffset)
@@ -159,26 +101,44 @@ class ArcGisSymbologyRenderer {
159
101
  }
160
102
  }
161
103
  }
162
- ArcGisSymbologyRenderer.defaultPMS = {
163
- type: "esriPMS",
164
- url: "",
165
- contentType: "image/png",
166
- imageData: "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAmBJREFUOE+Nk01IVFEUx//n3jfvOZOaJkMtiiJ7o9RG3LgoqKhFSFJBTS1ahFBBi0ijfJXCIyQr+hBbSIsoW7iQoKKFCw2CkAI3tZAgy8Ei+xhoTCbnje/NPfHGnA816KzuPR+/c8/HJRQJE7o+VUhym0DcCOYGgBQEXjOLlyqo+nHanCkMoaL4rslKjZwOQLT4ek3Mmz3FACFNLB67ut6M1nWphbg8wI6VyJK5KEH0EQFVJRKbwzokAW++p/ErraAYSQK3u47bC3vLnA+ZB9i2gHF0oyQMCfCGNaUa+vauxs71wWz2V18cnBj8gQ8J1/eeBnHUa4sMFQDGdGno+4gwEAoQzjVUon3rqlx1KY9x7+0MWobjAPg3QJ2eZV4tAEyFNCN5FkSXyw2B3j1hRGvLcgBXMV5MptA4MOXr0gT0u5bZnAf0jBsyiSgJPAxqhON1K3FlRxUMvwFAtv7u0Wl0jvwEmJNEuOhakTt5wKEBifr6Oo14BIBRpgt07w6jcVMIngKGY7NofR5HwlF+zDcpsC193vyYB/innvHywCzdZfAR/+onX1segBTAxHzzfPE7/8yzzIPLjJE1LTixHZx5CtCK4gXLzovBiDPUsYxVM7gUkB3nWKlm6DYEnQGzXARxCOK+a1WfKtQXb6LNAvr7iCboCUA1Ocdsdv5KLPe7F6pH/w3wLbc+BwOuc5IZ1wEE/jonQbjptZn24tKKX7BgvR2r0NKZRwDvAqCI+Z30VJPTURv7P4A9psuQcYAUPwAoReBLrmX2Lmls7i8sZ7kWLwuoxA1FVJGxzMPLufi6P2r+2xFbOUjGAAAAAElFTkSuQmCC",
167
- width: 16,
168
- height: 16,
169
- xoffset: -8,
170
- yoffset: -16,
171
- };
172
- ArcGisSymbologyRenderer.defaultSLS = {
173
- type: "esriSLS",
174
- color: [0, 0, 0, 255],
175
- width: 1,
176
- style: "esriSLSSolid",
177
- };
178
- ArcGisSymbologyRenderer.defaultSFS = {
179
- type: "esriSFS",
180
- color: [0, 0, 0, 255],
181
- style: "esriSFSSolid",
182
- };
183
- export { ArcGisSymbologyRenderer };
104
+ /** @internal */
105
+ export class ArcGisUniqueValueSymbologyRenderer extends ArcGisSimpleSymbologyRenderer {
106
+ isAttributeDriven() { return true; }
107
+ get rendererFields() {
108
+ if (this.uvRenderer.field1)
109
+ return [this.uvRenderer.field1];
110
+ else
111
+ return undefined;
112
+ }
113
+ constructor(renderer, defaultSymbol) {
114
+ super(renderer, defaultSymbol);
115
+ this.uvRenderer = this.renderer;
116
+ if (this.uvRenderer.defaultSymbol) {
117
+ this._defaultSymbol = this.uvRenderer.defaultSymbol;
118
+ this._symbol = this.defaultSymbol;
119
+ }
120
+ }
121
+ setActiveFeatureAttributes(attributes) {
122
+ this._activeFeatureAttributes = attributes;
123
+ let newSymbolApplied = false;
124
+ if (this._activeFeatureAttributes) {
125
+ if (this.uvRenderer.field1 && Object.keys(this._activeFeatureAttributes).includes(this.uvRenderer.field1)) {
126
+ const queryValue = this._activeFeatureAttributes[this.uvRenderer.field1];
127
+ for (const uvi of this.uvRenderer.uniqueValueInfos) {
128
+ // Strangely, ArcGIS documentation says 'value' is a string,
129
+ // not too sure if a comparison on other types is possible, or its always forced to string properties?
130
+ if (uvi.value === queryValue.toString()) {
131
+ this._symbol = uvi.symbol;
132
+ newSymbolApplied = true;
133
+ break;
134
+ }
135
+ }
136
+ }
137
+ }
138
+ // Fallback to default symbology to make sure we render something
139
+ if (!newSymbolApplied) {
140
+ this._symbol = this.defaultSymbol;
141
+ }
142
+ }
143
+ }
184
144
  //# sourceMappingURL=ArcGisSymbologyRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ArcGisSymbologyRenderer.js","sourceRoot":"","sources":["../../../src/ArcGisFeature/ArcGisSymbologyRenderer.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,mDAAmD;AACnD,SAAS,cAAc,CAAC,QAAmB;IACzC,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACrC,0CAA0C;QAC1C,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;KAChF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,cAAc,GAAI,gCAAgC,CAAC;AAmBzD,gBAAgB;AAChB,MAAM,OAAO,OAAO;IAGlB,IAAW,KAAK,KAAK,OAAO,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/D,IAAW,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,IAAW,KAAK,K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tB,CAAC;AAEsB,kCAAU,GAAiB;IACjD,IAAI,EAAE,SAAS;IACf,KAAK,EAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;IACtB,KAAK,EAAE,cAAc;CACtB,CAAC;SAzBS,uBAAuB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { ColorDef } from \"@itwin/core-common\";\r\nimport { ArcGisFeatureGeometryType } from \"./ArcGisFeatureQuery\";\r\n\r\n// Convert a channel array [r, g, b, a] to ColorDef\r\nfunction colorFromArray(channels?: number[]) {\r\n if (channels && channels.length === 4) {\r\n // Alpha channel is reversed, 255 = opaque\r\n return ColorDef.from(channels[0], channels[1], channels[2], 255 - channels[3]);\r\n }\r\n return undefined;\r\n}\r\n\r\nconst loggerCategory = \"MapLayersFormats.ArcGISFeature\";\r\n\r\n/** @internal */\r\nexport type EsriSymbolType = \"esriSFS\" | \"esriPMS\" | \"esriSLS\" | \"esriSMS\" | \"esriTS\" | \"CIMSymbolReference\";\r\ninterface EsriSymbol {\r\n type: EsriSymbolType;\r\n}\r\n\r\n/** @internal */\r\nexport type EsriSLSStyle = \"esriSLSDash\" | \"esriSLSDashDot\" | \"esriSLSDashDotDot\" | \"esriSLSDot\" | \"esriSLSLongDash\" | \"esriSLSLongDashDot\" |\r\n\"esriSLSNull\" | \"esriSLSShortDash\" | \"esriSLSShortDashDot\" | \"esriSLSShortDashDotDot\" | \"esriSLSShortDot\" | \"esriSLSSolid\";\r\n\r\ninterface EsriSLSProps {\r\n color: number[];\r\n type: EsriSymbolType;\r\n width: number;\r\n style: EsriSLSStyle;\r\n}\r\n\r\n/** @internal */\r\nexport class EsriSLS implements EsriSymbol {\r\n public readonly props: EsriSLSProps;\r\n\r\n public get color() { return colorFromArray(this.props.color); }\r\n public get type() { return this.props.type; }\r\n public get width() { return this.props.width; }\r\n public get style() { return this.props.style; }\r\n\r\n constructor(json: EsriSLSProps) {\r\n this.props = json;\r\n }\r\n\r\n public static fromJSON(json: EsriSLSProps) {\r\n return new EsriSLS(json);\r\n }\r\n}\r\n\r\ninterface EsriPMSProps {\r\n type: EsriSymbolType;\r\n url: string;\r\n imageData: string;\r\n contentType: string;\r\n width?: number;\r\n height?: number;\r\n xoffset?: number;\r\n yoffset?: number;\r\n angle?: number;\r\n}\r\n\r\n/** @internal */\r\nexport class EsriPMS implements EsriSymbol {\r\n public readonly props: EsriPMSProps;\r\n private _image: HTMLImageElement;\r\n\r\n public get type() { return this.props.type; }\r\n public get url() { return this.props.url; }\r\n public get imageData() { return this.props.imageData; }\r\n public get imageUrl() { return `data:${this.contentType};base64,${this.imageData}`; }\r\n public get image() { return this._image; }\r\n public get contentType() { return this.props.contentType; }\r\n public get width() { return this.props.width; }\r\n public get height() { return this.props.height; }\r\n public get xoffset() { return this.props.xoffset; }\r\n public get yoffset() { return this.props.yoffset; }\r\n public get angle() { return this.props.angle; }\r\n\r\n constructor(json: EsriPMSProps) {\r\n this.props = json;\r\n this._image = new Image();\r\n this._image.src = this.imageUrl;\r\n }\r\n\r\n public static fromJSON(json: EsriPMSProps) {\r\n return new EsriPMS(json);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type EsriSFSStyleProps = \"esriSFSBackwardDiagonal\" | \"esriSFSCross\" | \"esriSFSDiagonalCross\" | \"esriSFSForwardDiagonal\" | \"esriSFSHorizontal\" | \"esriSFSNull\" | \"esriSFSSolid\" | \"esriSFSVertical\";\r\ninterface EsriSFSProps {\r\n color?: number[];\r\n type: EsriSymbolType;\r\n style: EsriSFSStyleProps;\r\n outline?: EsriSLSProps;\r\n}\r\n\r\n/** @internal */\r\nexport class EsriSFS implements EsriSymbol {\r\n public readonly props: EsriSFSProps;\r\n private _outline: EsriSLS | undefined;\r\n\r\n public get color() { return colorFromArray(this.props.color); }\r\n public get type() { return this.props.type; }\r\n public get style() { return this.props.style; }\r\n public get outline() { return this._outline; }\r\n constructor(json: EsriSFSProps) {\r\n this.props = json;\r\n if (json.outline)\r\n this._outline = EsriSLS.fromJSON(json.outline);\r\n }\r\n\r\n public static fromJSON(json: EsriSFSProps): EsriSFS {\r\n return new EsriSFS(json);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class ArcGisSymbologyRenderer {\r\n private _symbol: EsriSymbol | undefined;\r\n\r\n private static readonly defaultPMS: EsriPMSProps = {\r\n type: \"esriPMS\",\r\n url: \"\",\r\n contentType: \"image/png\",\r\n imageData: \"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAmBJREFUOE+Nk01IVFEUx//n3jfvOZOaJkMtiiJ7o9RG3LgoqKhFSFJBTS1ahFBBi0ijfJXCIyQr+hBbSIsoW7iQoKKFCw2CkAI3tZAgy8Ei+xhoTCbnje/NPfHGnA816KzuPR+/c8/HJRQJE7o+VUhym0DcCOYGgBQEXjOLlyqo+nHanCkMoaL4rslKjZwOQLT4ek3Mmz3FACFNLB67ut6M1nWphbg8wI6VyJK5KEH0EQFVJRKbwzokAW++p/ErraAYSQK3u47bC3vLnA+ZB9i2gHF0oyQMCfCGNaUa+vauxs71wWz2V18cnBj8gQ8J1/eeBnHUa4sMFQDGdGno+4gwEAoQzjVUon3rqlx1KY9x7+0MWobjAPg3QJ2eZV4tAEyFNCN5FkSXyw2B3j1hRGvLcgBXMV5MptA4MOXr0gT0u5bZnAf0jBsyiSgJPAxqhON1K3FlRxUMvwFAtv7u0Wl0jvwEmJNEuOhakTt5wKEBifr6Oo14BIBRpgt07w6jcVMIngKGY7NofR5HwlF+zDcpsC193vyYB/innvHywCzdZfAR/+onX1segBTAxHzzfPE7/8yzzIPLjJE1LTixHZx5CtCK4gXLzovBiDPUsYxVM7gUkB3nWKlm6DYEnQGzXARxCOK+a1WfKtQXb6LNAvr7iCboCUA1Ocdsdv5KLPe7F6pH/w3wLbc+BwOuc5IZ1wEE/jonQbjptZn24tKKX7BgvR2r0NKZRwDvAqCI+Z30VJPTURv7P4A9psuQcYAUPwAoReBLrmX2Lmls7i8sZ7kWLwuoxA1FVJGxzMPLufi6P2r+2xFbOUjGAAAAAElFTkSuQmCC\",\r\n width: 16,\r\n height: 16,\r\n xoffset: -8,\r\n yoffset: -16,\r\n };\r\n\r\n private static readonly defaultSLS: EsriSLSProps = {\r\n type: \"esriSLS\",\r\n color: [0, 0, 0, 255],\r\n width: 1,\r\n style: \"esriSLSSolid\",\r\n };\r\n\r\n private static readonly defaultSFS: EsriSFSProps = {\r\n type: \"esriSFS\",\r\n color: [0, 0, 0, 255],\r\n style: \"esriSFSSolid\",\r\n };\r\n\r\n constructor(geometryType: ArcGisFeatureGeometryType, rendererDefinition: any) {\r\n let symbol;\r\n if (rendererDefinition?.symbol) {\r\n symbol = rendererDefinition.symbol;\r\n } else if (rendererDefinition?.defaultSymbol) {\r\n symbol = rendererDefinition?.defaultSymbol;\r\n }\r\n\r\n if (symbol) {\r\n if (symbol.type === \"esriSFS\") {\r\n this._symbol = EsriSFS.fromJSON(symbol);\r\n } else if (symbol.type === \"esriSLS\") {\r\n this._symbol = EsriSLS.fromJSON(symbol);\r\n } else if (symbol.type === \"esriPMS\") {\r\n this._symbol = EsriPMS.fromJSON(symbol);\r\n }\r\n }\r\n\r\n // If '_symbol' is still undefined at this point, that means we could not find\r\n // any symbology definition from the metadata, let's use some default symbology\r\n // so that we display at least something.\r\n if (this._symbol === undefined) {\r\n Logger.logWarning(loggerCategory, \"Symbology definition not supported, using default symbology\");\r\n if (geometryType === \"esriGeometryPoint\" || geometryType === \"esriGeometryMultipoint\") {\r\n this._symbol = EsriPMS.fromJSON(ArcGisSymbologyRenderer.defaultPMS);\r\n } else if (geometryType === \"esriGeometryLine\" || geometryType === \"esriGeometryPolyline\") {\r\n this._symbol = EsriSLS.fromJSON(ArcGisSymbologyRenderer.defaultSLS);\r\n } else if (geometryType === \"esriGeometryPolygon\") {\r\n this._symbol = EsriSFS.fromJSON(ArcGisSymbologyRenderer.defaultSFS);\r\n } else {\r\n Logger.logError(loggerCategory, \"Could not determine default symbology: geometry type not supported\");\r\n }\r\n }\r\n }\r\n\r\n public applyFillStyle(context: CanvasRenderingContext2D) {\r\n if (!context)\r\n return;\r\n\r\n if (this._symbol?.type === \"esriSFS\") {\r\n const sfs = this._symbol as EsriSFS;\r\n if (sfs.style === \"esriSFSSolid\" && sfs.color) {\r\n context.fillStyle = sfs.color.toRgbaString();\r\n } else {\r\n context.fillStyle = ColorDef.from(200, 0, 0, 100).toRgbaString(); // default color is red?\r\n }\r\n }\r\n }\r\n\r\n public applyStrokeStyle(context: CanvasRenderingContext2D) {\r\n if (!context)\r\n return;\r\n\r\n let sls: EsriSLS | undefined;\r\n if (this._symbol?.type === \"esriSFS\") {\r\n const sfs = this._symbol as EsriSFS;\r\n if (sfs.outline && sfs.outline.style === \"esriSLSSolid\") {\r\n sls = sfs.outline;\r\n }\r\n } else if (this._symbol?.type === \"esriSLS\") {\r\n sls = this._symbol as EsriSLS;\r\n }\r\n\r\n if (sls) {\r\n if (sls.color)\r\n context.strokeStyle = sls.color.toRgbaString();\r\n context.lineWidth = sls.width * 2; // TODO: Should we scale this value here?\r\n }\r\n }\r\n\r\n public drawPoint(context: CanvasRenderingContext2D, ptX: number, ptY: number) {\r\n if (!context)\r\n return;\r\n\r\n if (this._symbol?.type === \"esriPMS\") {\r\n const pms = this._symbol as EsriPMS;\r\n let xOffset = 0, yOffset = 0;\r\n if (pms.xoffset)\r\n xOffset = pms.xoffset;\r\n else if (pms.width)\r\n xOffset = pms.width * -0.5; // if no offset center in the middle\r\n\r\n if (pms.yoffset)\r\n yOffset = pms.yoffset;\r\n else if (pms.height)\r\n yOffset = pms.height * -0.5; // if no offset center in the middle\r\n\r\n if (pms.width && pms.height) {\r\n context.drawImage(pms.image, ptX + xOffset, ptY + yOffset, pms.width, pms.height);\r\n } else {\r\n context.drawImage(pms.image, ptX + xOffset, ptY + yOffset);\r\n }\r\n\r\n // TODO: marker rotation angle\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ArcGisSymbologyRenderer.js","sourceRoot":"","sources":["../../../src/ArcGisFeature/ArcGisSymbologyRenderer.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK7C,gBAAgB;AAChB,MAAM,cAAc,GAAI,gCAAgC,CAAC;AAKzD,gBAAgB;AAChB,MAAM,OAAgB,uBAAuB;IAMpC,MAAM,CAAC,MAAM,CAAC,QAAgC,EAAE,aAAyB;QAC9E,IAAI,QAAQ,EAAE,IAAI,KAAK,aAAa,EAAE;YACpC,OAAO,IAAI,kCAAkC,CAAC,QAAmC,EAAE,aAAa,CAAC,CAAC;SACnG;aAAM;YACL,OAAO,IAAI,6BAA6B,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;SACnE;IACH,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,OAAO,6BAA+B,SAAQ,uBAAuB;IACzD,iBAAiB,KAA4C,OAAO,KAAK,CAAC,CAAA,CAAC;IAG3F,IAAW,MAAM,KAAI,OAAO,IAAI,CAAC,OAAO,CAAC,CAAA,CAAC;IAC1C,IAAW,aAAa,KAAI,OAAO,IAAI,CAAC,cAAc,CAAC,CAAA,CAAC;IAMxD,YAAoB,QAAgC,EAAE,aAAyB;QAC7E,KAAK,EAAE,CAAC;QAVH,yBAAoB,GAAG,CAAC,CAAC,CAAI,6DAA6D;QAW/F,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ,EAAE;YACpC,IAAI,CAAC,OAAO,GAAI,IAAI,CAAC,QAA+B,CAAC,MAAM,CAAC;SAC7D;aAAO;YACN,IA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CAAC,gBAAgB,EAAE;YACrB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC;SACnC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { ColorDef } from \"@itwin/core-common\";\r\nimport { EsriPMS, EsriRenderer, EsriSFS, EsriSimpleRenderer, EsriSLS, EsriSymbol, EsriUniqueValueRenderer } from \"./EsriSymbology\";\r\nimport { ArcGisAttributeDrivenSymbology } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nconst loggerCategory = \"MapLayersFormats.ArcGISFeature\";\r\n\r\n/** @internal */\r\nexport type ArcGisSymbologyRendererType = \"simple\" | \"attributeDriven\";\r\n\r\n/** @internal */\r\nexport abstract class ArcGisSymbologyRenderer {\r\n public abstract isAttributeDriven(): this is ArcGisAttributeDrivenSymbology;\r\n public abstract applyFillStyle(context: CanvasRenderingContext2D): void;\r\n public abstract applyStrokeStyle(context: CanvasRenderingContext2D): void;\r\n public abstract drawPoint(context: CanvasRenderingContext2D, ptX: number, ptY: number): void;\r\n\r\n public static create(renderer: EsriRenderer|undefined, defaultSymbol: EsriSymbol) {\r\n if (renderer?.type === \"uniqueValue\") {\r\n return new ArcGisUniqueValueSymbologyRenderer(renderer as EsriUniqueValueRenderer, defaultSymbol);\r\n } else {\r\n return new ArcGisSimpleSymbologyRenderer(renderer, defaultSymbol);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class ArcGisSimpleSymbologyRenderer extends ArcGisSymbologyRenderer {\r\n public override isAttributeDriven(): this is ArcGisAttributeDrivenSymbology {return false;}\r\n public lineWidthScaleFactor = 2; // This is value is empirical, this might need to be adjusted\r\n\r\n public get symbol() {return this._symbol;}\r\n public get defaultSymbol() {return this._defaultSymbol;}\r\n protected _symbol: EsriSymbol;\r\n protected _defaultSymbol: EsriSymbol;\r\n\r\n public readonly renderer?: EsriRenderer;\r\n\r\n public constructor(renderer: EsriRenderer|undefined, defaultSymbol: EsriSymbol) {\r\n super();\r\n this._defaultSymbol = defaultSymbol;\r\n this.renderer = renderer;\r\n\r\n if (this.renderer?.type === \"simple\") {\r\n this._symbol = (this.renderer as EsriSimpleRenderer).symbol;\r\n } else {\r\n this._symbol = defaultSymbol;\r\n }\r\n\r\n }\r\n\r\n public applyFillStyle(context: CanvasRenderingContext2D) {\r\n if (!context)\r\n return;\r\n\r\n const fillColor = this.getFillColor();\r\n if (fillColor) {\r\n context.fillStyle = fillColor.toRgbaString();\r\n } else {\r\n Logger.logTrace(loggerCategory, `Could not apply fill style`);\r\n }\r\n }\r\n\r\n private getFillColor() {\r\n let fillColor: ColorDef | undefined;\r\n if (this._symbol.type === \"esriSFS\") {\r\n const sfs = this._symbol as EsriSFS;\r\n if (sfs.color) {\r\n fillColor = sfs.color;\r\n }\r\n }\r\n\r\n return fillColor;\r\n }\r\n\r\n public applyStrokeStyle(context: CanvasRenderingContext2D) {\r\n if (!context)\r\n return;\r\n\r\n // Stroke style can be from SFS's outline style or a SLS's color\r\n let sls: EsriSLS | undefined;\r\n if (this._symbol.type === \"esriSFS\") {\r\n const sfs = this._symbol as EsriSFS;\r\n if (sfs.outline && sfs.outline.style === \"esriSLSSolid\") {\r\n sls = sfs.outline;\r\n }\r\n } else if (this._symbol.type === \"esriSLS\") {\r\n sls = this._symbol as EsriSLS;\r\n }\r\n\r\n if (sls) {\r\n if (sls.color)\r\n context.strokeStyle = sls.color.toRgbaString();\r\n context.lineWidth = sls.width * this.lineWidthScaleFactor;\r\n } else {\r\n Logger.logTrace(loggerCategory, `Could not apply stroke style`);\r\n }\r\n\r\n }\r\n\r\n public drawPoint(context: CanvasRenderingContext2D, ptX: number, ptY: number) {\r\n if (!context)\r\n return;\r\n\r\n if (this._symbol.type === \"esriPMS\") {\r\n const pms = this._symbol as EsriPMS;\r\n let xOffset = 0, yOffset = 0;\r\n if (pms.xoffset)\r\n xOffset = pms.xoffset;\r\n else if (pms.width)\r\n xOffset = pms.width * -0.5; // if no offset center in the middle\r\n\r\n if (pms.yoffset)\r\n yOffset = pms.yoffset;\r\n else if (pms.height)\r\n yOffset = pms.height * -0.5; // if no offset center in the middle\r\n\r\n if (pms.width && pms.height) {\r\n context.drawImage(pms.image, ptX + xOffset, ptY + yOffset, pms.width, pms.height);\r\n } else {\r\n context.drawImage(pms.image, ptX + xOffset, ptY + yOffset);\r\n }\r\n\r\n // TODO: marker rotation angle\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class ArcGisUniqueValueSymbologyRenderer extends ArcGisSimpleSymbologyRenderer implements ArcGisAttributeDrivenSymbology {\r\n public override isAttributeDriven(): this is ArcGisAttributeDrivenSymbology {return true;}\r\n protected _activeFeatureAttributes: {[key: string]: any} | undefined;\r\n protected uvRenderer: EsriUniqueValueRenderer;\r\n\r\n public get rendererFields() {\r\n if (this.uvRenderer.field1)\r\n return [this.uvRenderer.field1];\r\n else\r\n return undefined;\r\n }\r\n\r\n public constructor(renderer: EsriUniqueValueRenderer, defaultSymbol: EsriSymbol) {\r\n super(renderer, defaultSymbol);\r\n\r\n this.uvRenderer = (this.renderer as EsriUniqueValueRenderer);\r\n if (this.uvRenderer.defaultSymbol) {\r\n this._defaultSymbol = this.uvRenderer.defaultSymbol;\r\n this._symbol = this.defaultSymbol;\r\n }\r\n }\r\n\r\n public setActiveFeatureAttributes(attributes: { [key: string]: any }) {\r\n this._activeFeatureAttributes = attributes;\r\n\r\n let newSymbolApplied = false;\r\n if (this._activeFeatureAttributes) {\r\n if (this.uvRenderer.field1 && Object.keys(this._activeFeatureAttributes).includes(this.uvRenderer.field1)) {\r\n\r\n const queryValue = this._activeFeatureAttributes[this.uvRenderer.field1];\r\n\r\n for (const uvi of this.uvRenderer.uniqueValueInfos) {\r\n // Strangely, ArcGIS documentation says 'value' is a string,\r\n // not too sure if a comparison on other types is possible, or its always forced to string properties?\r\n if (uvi.value === queryValue.toString()) {\r\n this._symbol = uvi.symbol;\r\n newSymbolApplied = true;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Fallback to default symbology to make sure we render something\r\n if (!newSymbolApplied) {\r\n this._symbol = this.defaultSymbol;\r\n }\r\n }\r\n}\r\n"]}
@@ -0,0 +1,152 @@
1
+ import { ColorDef } from "@itwin/core-common";
2
+ /** @internal */
3
+ export type EsriSymbolPropsType = "esriSFS" | "esriPMS" | "esriSLS" | "esriSMS" | "esriTS" | "CIMSymbolReference";
4
+ /** @internal */
5
+ export interface EsriSymbolCommonProps {
6
+ type: EsriSymbolPropsType;
7
+ }
8
+ /** @internal */
9
+ export type EsriSymbolProps = EsriSLSProps | EsriPMSProps | EsriSFSProps;
10
+ /** @internal */
11
+ export declare abstract class EsriSymbol implements EsriSymbolCommonProps {
12
+ abstract readonly type: EsriSymbolPropsType;
13
+ static fromJSON(props: EsriSymbolProps): EsriSFS | EsriSLS | EsriPMS;
14
+ }
15
+ /** @internal */
16
+ export type EsriSLSStyle = "esriSLSDash" | "esriSLSDashDot" | "esriSLSDashDotDot" | "esriSLSDot" | "esriSLSLongDash" | "esriSLSLongDashDot" | "esriSLSNull" | "esriSLSShortDash" | "esriSLSShortDashDot" | "esriSLSShortDashDotDot" | "esriSLSShortDot" | "esriSLSSolid";
17
+ /** @internal */
18
+ export interface EsriSLSProps extends EsriSymbolCommonProps {
19
+ color: number[];
20
+ type: EsriSymbolPropsType;
21
+ width: number;
22
+ style: EsriSLSStyle;
23
+ }
24
+ /** @internal */
25
+ export declare class EsriSLS implements EsriSymbolCommonProps {
26
+ readonly props: EsriSLSProps;
27
+ get color(): ColorDef | undefined;
28
+ get type(): EsriSymbolPropsType;
29
+ get width(): number;
30
+ get style(): EsriSLSStyle;
31
+ constructor(json: EsriSLSProps);
32
+ static fromJSON(json: EsriSLSProps): EsriSLS;
33
+ }
34
+ /** @internal */
35
+ export interface EsriPMSProps extends EsriSymbolCommonProps {
36
+ type: EsriSymbolPropsType;
37
+ url: string;
38
+ imageData: string;
39
+ contentType: string;
40
+ width?: number;
41
+ height?: number;
42
+ xoffset?: number;
43
+ yoffset?: number;
44
+ angle?: number;
45
+ }
46
+ /** @internal */
47
+ export declare class EsriPMS implements EsriSymbolCommonProps {
48
+ readonly props: EsriPMSProps;
49
+ private _image;
50
+ get type(): EsriSymbolPropsType;
51
+ get url(): string;
52
+ get imageData(): string;
53
+ get imageUrl(): string;
54
+ get image(): HTMLImageElement;
55
+ get contentType(): string;
56
+ get width(): number | undefined;
57
+ get height(): number | undefined;
58
+ get xoffset(): number | undefined;
59
+ get yoffset(): number | undefined;
60
+ get angle(): number | undefined;
61
+ loadImage(): Promise<void>;
62
+ private constructor();
63
+ static fromJSON(json: EsriPMSProps): EsriPMS;
64
+ }
65
+ /** @internal */
66
+ export type EsriSFSStyleProps = "esriSFSBackwardDiagonal" | "esriSFSCross" | "esriSFSDiagonalCross" | "esriSFSForwardDiagonal" | "esriSFSHorizontal" | "esriSFSNull" | "esriSFSSolid" | "esriSFSVertical";
67
+ /** @internal */
68
+ export interface EsriSFSProps {
69
+ color?: number[];
70
+ type: EsriSymbolPropsType;
71
+ style: EsriSFSStyleProps;
72
+ outline?: EsriSLSProps;
73
+ }
74
+ /** @internal */
75
+ export declare class EsriSFS implements EsriSymbolCommonProps {
76
+ readonly props: EsriSFSProps;
77
+ private _outline;
78
+ get color(): ColorDef | undefined;
79
+ get type(): EsriSymbolPropsType;
80
+ get style(): EsriSFSStyleProps;
81
+ get outline(): EsriSLS | undefined;
82
+ constructor(json: EsriSFSProps);
83
+ static fromJSON(json: EsriSFSProps): EsriSFS;
84
+ }
85
+ /** @internal */
86
+ export interface EsriUniqueValueInfoProps {
87
+ value: string;
88
+ label?: string;
89
+ description?: string;
90
+ symbol: EsriSymbolProps;
91
+ }
92
+ /** @internal */
93
+ export declare class EsriUniqueValueInfo {
94
+ readonly value: string;
95
+ readonly label: string | undefined;
96
+ readonly description: string | undefined;
97
+ readonly symbol: EsriSymbol;
98
+ private constructor();
99
+ static fromJSON(json: EsriUniqueValueInfoProps): EsriUniqueValueInfo;
100
+ }
101
+ /** @internal */
102
+ export interface EsriRendererBaseProps {
103
+ type: EsriRendererType;
104
+ }
105
+ /** @internal */
106
+ export interface EsriSimpleRendererProps extends EsriRendererBaseProps {
107
+ symbol: EsriSymbolProps;
108
+ }
109
+ /** @internal */
110
+ export interface EsriUniqueValueRendererProps extends EsriRendererBaseProps {
111
+ symbol?: EsriSymbolProps;
112
+ }
113
+ /** @internal */
114
+ export interface EsriUniqueValueRendererProps extends EsriRendererBaseProps {
115
+ field1?: string;
116
+ field2?: string;
117
+ field3?: string;
118
+ defaultSymbol?: EsriSymbolProps;
119
+ uniqueValueInfos: EsriUniqueValueInfoProps[];
120
+ }
121
+ /** @internal */
122
+ export type EsriRendererType = "simple" | "uniqueValue";
123
+ /** @internal */
124
+ export type EsriRendererProps = EsriSimpleRendererProps | EsriUniqueValueRendererProps;
125
+ /** @internal */
126
+ export declare abstract class EsriRenderer {
127
+ abstract readonly type: EsriRendererType;
128
+ abstract initialize(): Promise<void>;
129
+ static fromJSON(json: EsriRendererProps): EsriRenderer;
130
+ }
131
+ /** @internal */
132
+ export declare class EsriSimpleRenderer extends EsriRenderer {
133
+ readonly type: EsriRendererType;
134
+ readonly symbol: EsriSymbol;
135
+ protected constructor(json: EsriSimpleRendererProps);
136
+ initialize(): Promise<void>;
137
+ static fromJSON(json: EsriSimpleRendererProps): EsriSimpleRenderer;
138
+ }
139
+ /** @internal */
140
+ export declare class EsriUniqueValueRenderer extends EsriRenderer {
141
+ private _props;
142
+ readonly type: EsriRendererType;
143
+ readonly defaultSymbol?: EsriSymbol;
144
+ readonly uniqueValueInfos: EsriUniqueValueInfo[];
145
+ get field1(): string | undefined;
146
+ get field2(): string | undefined;
147
+ get field3(): string | undefined;
148
+ protected constructor(json: EsriUniqueValueRendererProps);
149
+ initialize(): Promise<void>;
150
+ static fromJSON(json: EsriUniqueValueRendererProps): EsriUniqueValueRenderer;
151
+ }
152
+ //# sourceMappingURL=EsriSymbology.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EsriSymbology.d.ts","sourceRoot":"","sources":["../../../src/ArcGisFeature/EsriSymbology.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAW9C,gBAAgB;AAChB,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,oBAAoB,CAAC;AAElH,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,gBAAgB;AAChB,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC;AAEzE,gBAAgB;AAChB,8BAAsB,UAAW,YAAW,qBAAqB;IAC/D,kBAAyB,IAAI,EAAE,mBAAmB,CAAC;WAErC,QAAQ,CAAC,KAAK,EAAE,eAAe;CAU9C;AAED,gBAAgB;AAChB,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,YAAY,GAAG,iBAAiB,GAAG,oBAAoB,GAC3I,aAAa,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,wBAAwB,GAAG,iBAAiB,GAAG,cAAc,CAAC;AAE3H,gBAAgB;AAChB,MAAM,WAAW,YAAa,SAAQ,qBAAqB;IACzD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,gBAAgB;AAChB,qBAAa,OAAQ,YAAW,qBAAqB;IACnD,SAAgB,KAAK,EAAE,YAAY,CAAC;IAEpC,IAAW,KAAK,yBAA+C;IAC/D,IAAW,IAAI,wBAA8B;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AC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,eAAe,CAAC;IAChC,gBAAgB,EAAE,wBAAwB,EAAE,CAAC;CAC9C;AAED,gBAAgB;AAChB,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,aAAa,CAAC;AAExD,gBAAgB;AAChB,MAAM,MAAO,iBAAiB,GAAG,uBAAuB,GAAG,4BAA4B,CAAC;AAExF,gBAAgB;AAChB,8BAAsB,YAAY;IAChC,kBAAyB,IAAI,EAAE,gBAAgB,CAAC;aAChC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;WAC7B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,YAAY;CAQ9D;AAED,gBAAgB;AAChB,qBAAa,kBAAmB,SAAQ,YAAY;IAClD,SAAgB,IAAI,EAAE,gBAAgB,CAAY;IAClD,SAAgB,MAAM,EAAE,UAAU,CAAC;IAEnC,SAAS,aAAa,IAAI,EAAE,uBAAuB;IAKtC,UAAU;WAQA,QAAQ,CAAC,IAAI,EAAE,uBAAuB;CAG9D;AAED,gBAAgB;AAChB,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAO,CAAC,MAAM,CAA+B;IAC7C,SAAgB,IAAI,EAAE,gBAAgB,CAAiB;IACvD,SAAgB,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3C,SAAgB,gBAAgB,EAAE,mBAAmB,EAAE,CAAM;IAE7D,IAAW,MAAM,uBAA8C;IAC/D,IAAW,MAAM,uBAA8C;IAC/D,IAAW,MAAM,uBAA8C;IAE/D,SAAS,aAAa,IAAI,EAAE,4BAA4B;IAWlC,UAAU;WAaT,QAAQ,CAAC,IAAI,EAAE,4BAA4B;CAGnE"}
@@ -0,0 +1,170 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { assert } from "@itwin/core-bentley";
6
+ import { ColorDef } from "@itwin/core-common";
7
+ // Convert a channel array [r, g, b, a] to ColorDef
8
+ function colorFromArray(channels) {
9
+ if (channels && channels.length === 4) {
10
+ // Alpha channel is reversed, 255 = opaque
11
+ return ColorDef.from(channels[0], channels[1], channels[2], 255 - channels[3]);
12
+ }
13
+ return undefined;
14
+ }
15
+ /** @internal */
16
+ export class EsriSymbol {
17
+ static fromJSON(props) {
18
+ if (props.type === "esriSFS") {
19
+ return EsriSFS.fromJSON(props);
20
+ }
21
+ else if (props.type === "esriSLS") {
22
+ return EsriSLS.fromJSON(props);
23
+ }
24
+ else if (props.type === "esriPMS") {
25
+ return EsriPMS.fromJSON(props);
26
+ }
27
+ throw new Error("Unknown ESRI symbology type");
28
+ }
29
+ }
30
+ /** @internal */
31
+ export class EsriSLS {
32
+ get color() { return colorFromArray(this.props.color); }
33
+ get type() { return this.props.type; }
34
+ get width() { return this.props.width; }
35
+ get style() { return this.props.style; }
36
+ constructor(json) {
37
+ this.props = json;
38
+ }
39
+ static fromJSON(json) {
40
+ return new EsriSLS(json);
41
+ }
42
+ }
43
+ /** @internal */
44
+ export class EsriPMS {
45
+ get type() { return this.props.type; }
46
+ get url() { return this.props.url; }
47
+ get imageData() { return this.props.imageData; }
48
+ get imageUrl() { return `data:${this.contentType};base64,${this.imageData}`; }
49
+ get image() {
50
+ assert(this._image !== undefined);
51
+ return this._image;
52
+ }
53
+ get contentType() { return this.props.contentType; }
54
+ get width() { return this.props.width; }
55
+ get height() { return this.props.height; }
56
+ get xoffset() { return this.props.xoffset; }
57
+ get yoffset() { return this.props.yoffset; }
58
+ get angle() { return this.props.angle; }
59
+ async loadImage() {
60
+ if (this._image === undefined) {
61
+ this._image = new Image();
62
+ return new Promise((resolve, reject) => {
63
+ if (this._image) {
64
+ this._image.addEventListener("load", () => {
65
+ resolve();
66
+ });
67
+ this._image.src = this.imageUrl;
68
+ }
69
+ else
70
+ reject(new Error("Failed to load image"));
71
+ });
72
+ }
73
+ }
74
+ constructor(json) {
75
+ this.props = json;
76
+ }
77
+ static fromJSON(json) {
78
+ return new EsriPMS(json);
79
+ }
80
+ }
81
+ /** @internal */
82
+ export class EsriSFS {
83
+ get color() { return colorFromArray(this.props.color); }
84
+ get type() { return this.props.type; }
85
+ get style() { return this.props.style; }
86
+ get outline() { return this._outline; }
87
+ constructor(json) {
88
+ this.props = json;
89
+ if (json.outline)
90
+ this._outline = EsriSLS.fromJSON(json.outline);
91
+ }
92
+ static fromJSON(json) {
93
+ return new EsriSFS(json);
94
+ }
95
+ }
96
+ /** @internal */
97
+ export class EsriUniqueValueInfo {
98
+ constructor(json) {
99
+ this.value = json.value;
100
+ this.label = json.label;
101
+ this.description = json.description;
102
+ this.symbol = EsriSymbol.fromJSON(json.symbol);
103
+ }
104
+ static fromJSON(json) {
105
+ return new EsriUniqueValueInfo(json);
106
+ }
107
+ }
108
+ /** @internal */
109
+ export class EsriRenderer {
110
+ static fromJSON(json) {
111
+ if (json.type === "simple")
112
+ return EsriSimpleRenderer.fromJSON(json);
113
+ else if (json.type === "uniqueValue")
114
+ return EsriUniqueValueRenderer.fromJSON(json);
115
+ else
116
+ throw Error("Unknown renderer type");
117
+ }
118
+ }
119
+ /** @internal */
120
+ export class EsriSimpleRenderer extends EsriRenderer {
121
+ constructor(json) {
122
+ super();
123
+ this.type = "simple";
124
+ this.type = json.type;
125
+ this.symbol = EsriSymbol.fromJSON(json.symbol);
126
+ }
127
+ async initialize() {
128
+ const promises = [];
129
+ if (this.symbol.type === "esriPMS") {
130
+ promises.push(this.symbol.loadImage());
131
+ }
132
+ await Promise.all(promises);
133
+ }
134
+ static fromJSON(json) {
135
+ return new EsriSimpleRenderer(json);
136
+ }
137
+ }
138
+ /** @internal */
139
+ export class EsriUniqueValueRenderer extends EsriRenderer {
140
+ get field1() { return this._props.field1 ?? undefined; }
141
+ get field2() { return this._props.field2 ?? undefined; }
142
+ get field3() { return this._props.field3 ?? undefined; }
143
+ constructor(json) {
144
+ super();
145
+ this.type = "uniqueValue";
146
+ this.uniqueValueInfos = [];
147
+ if (json.defaultSymbol)
148
+ this.defaultSymbol = EsriSymbol.fromJSON(json.defaultSymbol);
149
+ for (const uvi of json.uniqueValueInfos) {
150
+ this.uniqueValueInfos.push(EsriUniqueValueInfo.fromJSON(uvi));
151
+ }
152
+ this._props = json;
153
+ }
154
+ async initialize() {
155
+ const promises = [];
156
+ if (this.defaultSymbol?.type === "esriPMS") {
157
+ promises.push(this.defaultSymbol.loadImage());
158
+ }
159
+ for (const uvi of this.uniqueValueInfos) {
160
+ if (uvi.symbol.type === "esriPMS") {
161
+ promises.push(uvi.symbol.loadImage());
162
+ }
163
+ }
164
+ await Promise.all(promises);
165
+ }
166
+ static fromJSON(json) {
167
+ return new EsriUniqueValueRenderer(json);
168
+ }
169
+ }
170
+ //# sourceMappingURL=EsriSymbology.js.map