@vcmap/core 6.0.0-rc.4 → 6.0.0-rc.6

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 (209) hide show
  1. package/dist/cesium.d.ts +11 -0
  2. package/dist/index.d.ts +23 -16
  3. package/dist/index.js +21 -14
  4. package/dist/index.js.map +1 -1
  5. package/dist/ol.d.ts +15 -2
  6. package/dist/src/layer/cesium/clusterContext.d.ts +8 -14
  7. package/dist/src/layer/cesium/clusterContext.js +62 -41
  8. package/dist/src/layer/cesium/clusterContext.js.map +1 -1
  9. package/dist/src/layer/cesium/vectorCesiumImpl.d.ts +2 -3
  10. package/dist/src/layer/cesium/vectorCesiumImpl.js +16 -10
  11. package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
  12. package/dist/src/layer/cesium/vectorContext.d.ts +10 -53
  13. package/dist/src/layer/cesium/vectorContext.js +88 -172
  14. package/dist/src/layer/cesium/vectorContext.js.map +1 -1
  15. package/dist/src/layer/geojsonHelpers.d.ts +1 -1
  16. package/dist/src/layer/geojsonHelpers.js +5 -10
  17. package/dist/src/layer/geojsonHelpers.js.map +1 -1
  18. package/dist/src/layer/oblique/obliqueHelpers.js +6 -6
  19. package/dist/src/layer/oblique/obliqueHelpers.js.map +1 -1
  20. package/dist/src/layer/vectorLayer.d.ts +0 -37
  21. package/dist/src/layer/vectorLayer.js.map +1 -1
  22. package/dist/src/layer/vectorProperties.d.ts +8 -3
  23. package/dist/src/layer/vectorProperties.js +30 -5
  24. package/dist/src/layer/vectorProperties.js.map +1 -1
  25. package/dist/src/map/baseOLMap.js +1 -1
  26. package/dist/src/map/baseOLMap.js.map +1 -1
  27. package/dist/src/map/obliqueMap.d.ts +3 -0
  28. package/dist/src/map/obliqueMap.js +27 -6
  29. package/dist/src/map/obliqueMap.js.map +1 -1
  30. package/dist/src/map/vcsMap.d.ts +8 -0
  31. package/dist/src/map/vcsMap.js +11 -0
  32. package/dist/src/map/vcsMap.js.map +1 -1
  33. package/dist/src/oblique/helpers.js +5 -5
  34. package/dist/src/oblique/helpers.js.map +1 -1
  35. package/dist/src/oblique/obliqueDataSet.js +4 -4
  36. package/dist/src/oblique/obliqueDataSet.js.map +1 -1
  37. package/dist/src/ol/geom/geometryCollection.js +19 -2
  38. package/dist/src/ol/geom/geometryCollection.js.map +1 -1
  39. package/dist/src/style/arcStyle.js +1 -0
  40. package/dist/src/style/arcStyle.js.map +1 -1
  41. package/dist/src/util/editor/createFeatureSession.d.ts +5 -1
  42. package/dist/src/util/editor/createFeatureSession.js +48 -4
  43. package/dist/src/util/editor/createFeatureSession.js.map +1 -1
  44. package/dist/src/util/editor/editFeaturesSession.d.ts +10 -4
  45. package/dist/src/util/editor/editFeaturesSession.js +74 -37
  46. package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
  47. package/dist/src/util/editor/editGeometrySession.d.ts +5 -1
  48. package/dist/src/util/editor/editGeometrySession.js +77 -55
  49. package/dist/src/util/editor/editGeometrySession.js.map +1 -1
  50. package/dist/src/util/editor/editorHelpers.d.ts +12 -6
  51. package/dist/src/util/editor/editorHelpers.js +47 -20
  52. package/dist/src/util/editor/editorHelpers.js.map +1 -1
  53. package/dist/src/util/editor/editorSessionHelpers.d.ts +5 -0
  54. package/dist/src/util/editor/editorSessionHelpers.js +1 -0
  55. package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
  56. package/dist/src/util/editor/editorSymbols.d.ts +1 -1
  57. package/dist/src/util/editor/editorSymbols.js +1 -1
  58. package/dist/src/util/editor/editorSymbols.js.map +1 -1
  59. package/dist/src/util/editor/interactions/createBBoxInteraction.d.ts +1 -0
  60. package/dist/src/util/editor/interactions/createBBoxInteraction.js +20 -16
  61. package/dist/src/util/editor/interactions/createBBoxInteraction.js.map +1 -1
  62. package/dist/src/util/editor/interactions/createCircleInteraction.js +1 -1
  63. package/dist/src/util/editor/interactions/createCircleInteraction.js.map +1 -1
  64. package/dist/src/util/editor/interactions/createLineStringInteraction.js +3 -3
  65. package/dist/src/util/editor/interactions/createLineStringInteraction.js.map +1 -1
  66. package/dist/src/util/editor/interactions/createPointInteraction.js +1 -1
  67. package/dist/src/util/editor/interactions/createPointInteraction.js.map +1 -1
  68. package/dist/src/util/editor/interactions/createPolygonInteraction.d.ts +4 -0
  69. package/dist/src/util/editor/interactions/createPolygonInteraction.js +9 -3
  70. package/dist/src/util/editor/interactions/createPolygonInteraction.js.map +1 -1
  71. package/dist/src/util/editor/interactions/creationSnapping.d.ts +26 -0
  72. package/dist/src/util/editor/interactions/creationSnapping.js +139 -0
  73. package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -0
  74. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +3 -2
  75. package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
  76. package/dist/src/util/editor/interactions/insertVertexInteraction.d.ts +3 -1
  77. package/dist/src/util/editor/interactions/insertVertexInteraction.js +14 -6
  78. package/dist/src/util/editor/interactions/insertVertexInteraction.js.map +1 -1
  79. package/dist/src/util/editor/interactions/layerSnapping.d.ts +19 -0
  80. package/dist/src/util/editor/interactions/layerSnapping.js +87 -0
  81. package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -0
  82. package/dist/src/util/editor/interactions/translateVertexInteraction.js +2 -2
  83. package/dist/src/util/editor/interactions/translateVertexInteraction.js.map +1 -1
  84. package/dist/src/util/editor/interactions/translationSnapping.d.ts +25 -0
  85. package/dist/src/util/editor/interactions/translationSnapping.js +179 -0
  86. package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -0
  87. package/dist/src/util/editor/snappingHelpers.d.ts +44 -0
  88. package/dist/src/util/editor/snappingHelpers.js +329 -0
  89. package/dist/src/util/editor/snappingHelpers.js.map +1 -0
  90. package/dist/src/util/editor/transformation/create2DHandlers.js +26 -26
  91. package/dist/src/util/editor/transformation/create2DHandlers.js.map +1 -1
  92. package/dist/src/util/editor/transformation/create3DHandlers.js +65 -14
  93. package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
  94. package/dist/src/util/editor/transformation/scaleInteraction.js +27 -5
  95. package/dist/src/util/editor/transformation/scaleInteraction.js.map +1 -1
  96. package/dist/src/util/editor/transformation/transformationHandler.js +56 -38
  97. package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
  98. package/dist/src/util/editor/transformation/transformationTypes.d.ts +2 -0
  99. package/dist/src/util/editor/transformation/transformationTypes.js +4 -0
  100. package/dist/src/util/editor/transformation/transformationTypes.js.map +1 -1
  101. package/dist/src/util/featureconverter/arcToCesium.d.ts +5 -19
  102. package/dist/src/util/featureconverter/arcToCesium.js +15 -42
  103. package/dist/src/util/featureconverter/arcToCesium.js.map +1 -1
  104. package/dist/src/util/featureconverter/circleToCesium.d.ts +2 -27
  105. package/dist/src/util/featureconverter/circleToCesium.js +84 -63
  106. package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
  107. package/dist/src/util/featureconverter/clampedPrimitive.d.ts +2 -0
  108. package/dist/src/util/featureconverter/clampedPrimitive.js +29 -0
  109. package/dist/src/util/featureconverter/clampedPrimitive.js.map +1 -0
  110. package/dist/src/util/featureconverter/convert.d.ts +26 -7
  111. package/dist/src/util/featureconverter/convert.js +221 -44
  112. package/dist/src/util/featureconverter/convert.js.map +1 -1
  113. package/dist/src/util/featureconverter/extent3D.d.ts +4 -3
  114. package/dist/src/util/featureconverter/extent3D.js +4 -3
  115. package/dist/src/util/featureconverter/extent3D.js.map +1 -1
  116. package/dist/src/util/featureconverter/lineStringToCesium.d.ts +12 -27
  117. package/dist/src/util/featureconverter/lineStringToCesium.js +85 -107
  118. package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
  119. package/dist/src/util/featureconverter/pointHelpers.d.ts +8 -11
  120. package/dist/src/util/featureconverter/pointHelpers.js +134 -120
  121. package/dist/src/util/featureconverter/pointHelpers.js.map +1 -1
  122. package/dist/src/util/featureconverter/pointToCesium.d.ts +14 -17
  123. package/dist/src/util/featureconverter/pointToCesium.js +47 -96
  124. package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
  125. package/dist/src/util/featureconverter/polygonToCesium.d.ts +2 -26
  126. package/dist/src/util/featureconverter/polygonToCesium.js +62 -72
  127. package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
  128. package/dist/src/util/featureconverter/storeyHelpers.d.ts +17 -0
  129. package/dist/src/util/featureconverter/storeyHelpers.js +78 -0
  130. package/dist/src/util/featureconverter/storeyHelpers.js.map +1 -0
  131. package/dist/src/util/featureconverter/vectorGeometryFactory.d.ts +54 -0
  132. package/dist/src/util/featureconverter/vectorGeometryFactory.js +278 -0
  133. package/dist/src/util/featureconverter/vectorGeometryFactory.js.map +1 -0
  134. package/dist/src/util/featureconverter/vectorHeightInfo.d.ts +86 -0
  135. package/dist/src/util/featureconverter/vectorHeightInfo.js +242 -0
  136. package/dist/src/util/featureconverter/vectorHeightInfo.js.map +1 -0
  137. package/dist/src/util/geometryHelpers.d.ts +22 -1
  138. package/dist/src/util/geometryHelpers.js +65 -2
  139. package/dist/src/util/geometryHelpers.js.map +1 -1
  140. package/dist/src/util/mapCollection.js +8 -0
  141. package/dist/src/util/mapCollection.js.map +1 -1
  142. package/dist/src/util/math.d.ts +6 -2
  143. package/dist/src/util/math.js +34 -12
  144. package/dist/src/util/math.js.map +1 -1
  145. package/dist/tests/unit/helpers/cesiumHelpers.js +3 -1
  146. package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
  147. package/dist/tests/unit/helpers/helpers.d.ts +2 -9
  148. package/dist/tests/unit/helpers/helpers.js +2 -8
  149. package/dist/tests/unit/helpers/helpers.js.map +1 -1
  150. package/index.ts +74 -35
  151. package/package.json +3 -3
  152. package/src/cesium/cesium.d.ts +11 -0
  153. package/src/layer/cesium/clusterContext.ts +82 -91
  154. package/src/layer/cesium/vectorCesiumImpl.ts +17 -11
  155. package/src/layer/cesium/vectorContext.ts +120 -348
  156. package/src/layer/geojsonHelpers.ts +9 -12
  157. package/src/layer/oblique/obliqueHelpers.ts +6 -6
  158. package/src/layer/vectorLayer.ts +0 -71
  159. package/src/layer/vectorProperties.ts +46 -9
  160. package/src/map/baseOLMap.ts +1 -1
  161. package/src/map/obliqueMap.ts +46 -6
  162. package/src/map/vcsMap.ts +20 -2
  163. package/src/oblique/helpers.ts +11 -5
  164. package/src/oblique/obliqueDataSet.ts +4 -4
  165. package/src/ol/geom/geometryCollection.js +21 -2
  166. package/src/ol/ol.d.ts +15 -2
  167. package/src/style/arcStyle.ts +1 -0
  168. package/src/util/editor/createFeatureSession.ts +64 -6
  169. package/src/util/editor/editFeaturesSession.ts +105 -39
  170. package/src/util/editor/editGeometrySession.ts +118 -75
  171. package/src/util/editor/editorHelpers.ts +78 -30
  172. package/src/util/editor/editorSessionHelpers.ts +7 -0
  173. package/src/util/editor/editorSymbols.ts +1 -1
  174. package/src/util/editor/interactions/createBBoxInteraction.ts +25 -16
  175. package/src/util/editor/interactions/createCircleInteraction.ts +1 -1
  176. package/src/util/editor/interactions/createLineStringInteraction.ts +9 -3
  177. package/src/util/editor/interactions/createPointInteraction.ts +1 -1
  178. package/src/util/editor/interactions/createPolygonInteraction.ts +16 -3
  179. package/src/util/editor/interactions/creationSnapping.ts +226 -0
  180. package/src/util/editor/interactions/editGeometryMouseOverInteraction.ts +3 -2
  181. package/src/util/editor/interactions/insertVertexInteraction.ts +27 -7
  182. package/src/util/editor/interactions/layerSnapping.ts +136 -0
  183. package/src/util/editor/interactions/translateVertexInteraction.ts +8 -2
  184. package/src/util/editor/interactions/translationSnapping.ts +302 -0
  185. package/src/util/editor/snappingHelpers.ts +490 -0
  186. package/src/util/editor/transformation/create2DHandlers.ts +38 -26
  187. package/src/util/editor/transformation/create3DHandlers.ts +84 -22
  188. package/src/util/editor/transformation/scaleInteraction.ts +28 -5
  189. package/src/util/editor/transformation/transformationHandler.ts +72 -41
  190. package/src/util/editor/transformation/transformationTypes.ts +5 -0
  191. package/src/util/featureconverter/arcToCesium.ts +25 -95
  192. package/src/util/featureconverter/circleToCesium.ts +127 -113
  193. package/src/util/featureconverter/clampedPrimitive.ts +70 -0
  194. package/src/util/featureconverter/convert.ts +446 -114
  195. package/src/util/featureconverter/extent3D.ts +13 -6
  196. package/src/util/featureconverter/lineStringToCesium.ts +132 -179
  197. package/src/util/featureconverter/pointHelpers.ts +271 -214
  198. package/src/util/featureconverter/pointToCesium.ts +111 -175
  199. package/src/util/featureconverter/polygonToCesium.ts +98 -117
  200. package/src/util/featureconverter/storeyHelpers.ts +104 -0
  201. package/src/util/featureconverter/vectorGeometryFactory.ts +601 -0
  202. package/src/util/featureconverter/vectorHeightInfo.ts +393 -0
  203. package/src/util/geometryHelpers.ts +79 -5
  204. package/src/util/mapCollection.ts +8 -0
  205. package/src/util/math.ts +59 -12
  206. package/dist/src/util/featureconverter/featureconverterHelper.d.ts +0 -35
  207. package/dist/src/util/featureconverter/featureconverterHelper.js +0 -404
  208. package/dist/src/util/featureconverter/featureconverterHelper.js.map +0 -1
  209. package/src/util/featureconverter/featureconverterHelper.ts +0 -672
@@ -1,15 +1,16 @@
1
- import { Cartesian3, WallGeometry, WallOutlineGeometry, GroundPolylineGeometry, PolylineGeometry, Math as CesiumMath, HeightReference, } from '@vcmap-cesium/engine';
1
+ import { WallGeometry, WallOutlineGeometry, GroundPolylineGeometry, PolylineGeometry, Math as CesiumMath, Cartesian3, } from '@vcmap-cesium/engine';
2
2
  import { Feature } from 'ol';
3
3
  import { Point } from 'ol/geom.js';
4
4
  import { parseNumber } from '@vcsuite/parsers';
5
- import Projection from '../projection.js';
6
- import { addPrimitivesToContext } from './featureconverterHelper.js';
7
- import { getFlatCoordinatesFromSimpleGeometry } from '../geometryHelpers.js';
8
- import ArrowStyle, { ArrowEnd } from '../../style/arrowStyle.js';
5
+ import { ArrowEnd } from '../../style/arrowStyle.js';
9
6
  import { getCartesianBearing, getCartesianPitch } from '../math.js';
10
7
  import { getPrimitiveOptions } from './pointHelpers.js';
8
+ import { getWgs84CoordinatesForPoint } from './pointToCesium.js';
9
+ import { getHeightInfo, mercatorToCartesianTransformerForHeightInfo, isAbsoluteHeightReference, } from './vectorHeightInfo.js';
11
10
  function getArrowOptions(from, to, heightReference) {
12
- let pitch = heightReference === HeightReference.NONE ? getCartesianPitch(to, from) : 0;
11
+ let pitch = isAbsoluteHeightReference(heightReference)
12
+ ? getCartesianPitch(to, from)
13
+ : 0;
13
14
  pitch += 90;
14
15
  return {
15
16
  location: to,
@@ -17,128 +18,107 @@ function getArrowOptions(from, to, heightReference) {
17
18
  heading: CesiumMath.toDegrees(getCartesianBearing(from, to) + CesiumMath.PI_OVER_TWO),
18
19
  };
19
20
  }
20
- export async function addArrowsToContext(feature, style, validGeometries, vectorProperties, scene, lineGeometryFactory, context) {
21
+ export function getArrowHeadPrimitives(feature, style, geometry, vectorProperties, scene, inputCoordinates) {
21
22
  if (style.end === ArrowEnd.NONE || !style.primitiveOptions?.geometryOptions) {
22
- return;
23
+ return [];
23
24
  }
24
25
  const arrowOptions = [];
25
26
  const heightReference = vectorProperties.getAltitudeMode(feature);
26
- validGeometries.forEach((geom) => {
27
- const coordinates = lineGeometryFactory.getCoordinates([geom]);
28
- if (style.end === ArrowEnd.START || style.end === ArrowEnd.BOTH) {
29
- arrowOptions.push(getArrowOptions(coordinates[1], coordinates[0], heightReference));
30
- }
31
- if (style.end === ArrowEnd.END || style.end === ArrowEnd.BOTH) {
32
- arrowOptions.push(getArrowOptions(coordinates.at(-2), coordinates.at(-1), heightReference));
33
- }
34
- });
27
+ const coordinates = inputCoordinates ?? geometry.getCoordinates();
28
+ if (style.end === ArrowEnd.START || style.end === ArrowEnd.BOTH) {
29
+ arrowOptions.push(getArrowOptions(coordinates[1], coordinates[0], heightReference));
30
+ }
31
+ if (style.end === ArrowEnd.END || style.end === ArrowEnd.BOTH) {
32
+ arrowOptions.push(getArrowOptions(coordinates.at(-2), coordinates.at(-1), heightReference));
33
+ }
35
34
  if (arrowOptions.length === 0) {
36
- return;
35
+ return [];
37
36
  }
38
37
  const usedStyle = style.getOlcsStyle();
39
- const allowPicking = vectorProperties.getAllowPicking(feature);
40
- await Promise.all(arrowOptions.map(async (arrowOption) => {
38
+ return arrowOptions
39
+ .map((arrowOption) => {
40
+ const arrowHeadGeometry = new Point(arrowOption.location);
41
41
  const arrowFeature = new Feature({
42
42
  ...feature.getProperties(),
43
43
  olcs_primitiveOptions: style.primitiveOptions,
44
44
  olcs_modelHeading: arrowOption.heading,
45
45
  olcs_modelPitch: arrowOption.pitch,
46
- geometry: new Point(arrowOption.location),
46
+ geometry: arrowHeadGeometry,
47
47
  olcs_modelAutoScale: true,
48
48
  });
49
- const wgs84Position = Projection.mercatorToWgs84(arrowOption.location);
50
- const cartesianLocation = Cartesian3.fromDegrees(wgs84Position[0], wgs84Position[1], wgs84Position[2]);
51
- const primitiveOptions = await getPrimitiveOptions(arrowFeature, usedStyle, [wgs84Position], [cartesianLocation], vectorProperties, scene);
52
- if (primitiveOptions?.primitives) {
53
- context.addScaledPrimitives(primitiveOptions.primitives, feature, allowPicking);
54
- }
55
- }));
49
+ const heightInfo = getHeightInfo(arrowFeature, arrowHeadGeometry, vectorProperties);
50
+ const wgs84Coords = getWgs84CoordinatesForPoint(arrowHeadGeometry, heightInfo);
51
+ const position = Cartesian3.fromDegrees(wgs84Coords[0], wgs84Coords[1], wgs84Coords[2]);
52
+ return getPrimitiveOptions(arrowFeature, usedStyle, position, wgs84Coords, vectorProperties, scene, heightInfo);
53
+ })
54
+ .flat();
56
55
  }
57
- export function createSolidGeometries(options, height, perPositionHeight, extrudedHeight) {
56
+ export function createSolidGeometries(options, heightInfo, height, perPositionHeight, extrudedHeight) {
58
57
  return [
59
- WallGeometry.fromConstantHeights({
60
- ...options,
61
- maximumHeight: !perPositionHeight ? height : undefined,
62
- minimumHeight: extrudedHeight,
63
- }),
58
+ {
59
+ type: 'solid',
60
+ geometry: WallGeometry.fromConstantHeights({
61
+ ...options,
62
+ maximumHeight: !perPositionHeight ? height : undefined,
63
+ minimumHeight: extrudedHeight,
64
+ }),
65
+ heightInfo,
66
+ },
64
67
  ];
65
68
  }
66
- export function createOutlineGeometries(options, height, perPositionHeight, extrudedHeight) {
69
+ export function createOutlineGeometries(options, heightInfo, height, perPositionHeight, extrudedHeight) {
67
70
  // maxium and minimum are flipped, to create the same perPositionHeight behaviour as in polygons
68
71
  // WallGeometries extrudes down instead of up, so we switch the behaviour and extrude in the other direction
69
72
  return [
70
- WallOutlineGeometry.fromConstantHeights({
71
- ...options,
72
- maximumHeight: !perPositionHeight ? height : undefined,
73
- minimumHeight: extrudedHeight,
74
- }),
73
+ {
74
+ type: 'outline',
75
+ geometry: WallOutlineGeometry.fromConstantHeights({
76
+ ...options,
77
+ maximumHeight: !perPositionHeight ? height : undefined,
78
+ minimumHeight: extrudedHeight,
79
+ }),
80
+ heightInfo,
81
+ },
75
82
  ];
76
83
  }
77
- export function createFillGeometries(_options, _height, _perPositionHeight) {
78
- return [];
79
- }
80
- export function createGroundLineGeometries(options, style) {
84
+ export function createGroundLineGeometries(options, heightInfo, style) {
81
85
  const width = parseNumber(style.getStroke().getWidth(), 1.0);
82
86
  return [
83
- new GroundPolylineGeometry({
84
- ...options,
85
- width,
86
- }),
87
+ {
88
+ type: 'groundLine',
89
+ geometry: new GroundPolylineGeometry({
90
+ ...options,
91
+ width,
92
+ }),
93
+ heightInfo,
94
+ },
87
95
  ];
88
96
  }
89
- export function createLineGeometries(options, style) {
97
+ export function createLineGeometries(options, heightInfo, style) {
90
98
  const width = parseNumber(style.getStroke().getWidth(), 1.0);
91
99
  return [
92
- new PolylineGeometry({
93
- ...options,
94
- width,
95
- }),
100
+ {
101
+ type: 'line',
102
+ geometry: new PolylineGeometry({
103
+ ...options,
104
+ width,
105
+ }),
106
+ heightInfo,
107
+ },
96
108
  ];
97
109
  }
98
110
  /**
99
111
  * Creates the positions array for PolylineGeometry
100
112
  * @param geometry
101
- * @param positionHeightAdjustment
102
- * @param perPositionHeight
103
- * @param groundLevelOrMinHeight
113
+ * @param heightInfo
104
114
  * @private
105
115
  */
106
- export function getGeometryOptions(geometry, positionHeightAdjustment, perPositionHeight, groundLevelOrMinHeight) {
116
+ export function getGeometryOptions(geometry, heightInfo) {
107
117
  const coords = geometry.getCoordinates();
108
- const positions = coords.map((coord) => {
109
- const wgs84Coords = Projection.mercatorToWgs84(coord);
110
- if (!perPositionHeight && groundLevelOrMinHeight) {
111
- wgs84Coords[2] = groundLevelOrMinHeight;
112
- }
113
- else if (wgs84Coords[2] != null) {
114
- wgs84Coords[2] += positionHeightAdjustment;
115
- }
116
- return Cartesian3.fromDegrees(wgs84Coords[0], wgs84Coords[1], wgs84Coords[2]);
117
- });
118
+ const coordinateTransformer = mercatorToCartesianTransformerForHeightInfo(heightInfo);
119
+ const positions = coords.map(coordinateTransformer);
118
120
  return { positions };
119
121
  }
120
- export function getCoordinates(geometries) {
121
- const coordinates = [];
122
- geometries.forEach((lineString) => {
123
- coordinates.push(...getFlatCoordinatesFromSimpleGeometry(lineString));
124
- });
125
- return coordinates;
126
- }
127
- let geometryFactory = null;
128
- function getGeometryFactory() {
129
- if (!geometryFactory) {
130
- geometryFactory = {
131
- getCoordinates,
132
- getGeometryOptions,
133
- createSolidGeometries,
134
- createOutlineGeometries,
135
- createFillGeometries,
136
- createGroundLineGeometries,
137
- createLineGeometries,
138
- };
139
- }
140
- return geometryFactory;
141
- }
142
122
  /**
143
123
  * validates if a lineString is renderable
144
124
  * @param lineString
@@ -154,24 +134,22 @@ export function validateLineString(lineString) {
154
134
  }
155
135
  return false;
156
136
  }
157
- /**
158
- * converts a linestring to a a cesium primitive, with optional labels
159
- * @param feature
160
- * @param style
161
- * @param geometries
162
- * @param vectorProperties
163
- * @param scene
164
- * @param context
165
- */
166
- export default async function lineStringToCesium(feature, style, geometries, vectorProperties, scene, context) {
167
- if (!style.getFill() && !style.getStroke()) {
168
- return;
169
- }
170
- const lineGeometryFactory = getGeometryFactory();
171
- const validGeometries = geometries.filter((lineString) => validateLineString(lineString));
172
- addPrimitivesToContext(feature, style, validGeometries, vectorProperties, scene, lineGeometryFactory, context);
173
- if (style instanceof ArrowStyle) {
174
- await addArrowsToContext(feature, style, validGeometries, vectorProperties, scene, lineGeometryFactory, context);
137
+ let geometryFactory;
138
+ export function getLineStringGeometryFactory() {
139
+ if (!geometryFactory) {
140
+ geometryFactory = {
141
+ type: 'lineString',
142
+ getGeometryOptions,
143
+ createSolidGeometries,
144
+ createOutlineGeometries,
145
+ createFillGeometries() {
146
+ return [];
147
+ },
148
+ createGroundLineGeometries,
149
+ createLineGeometries,
150
+ validateGeometry: validateLineString,
151
+ };
175
152
  }
153
+ return geometryFactory;
176
154
  }
177
155
  //# sourceMappingURL=lineStringToCesium.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lineStringToCesium.js","sourceRoot":"","sources":["../../../../src/util/featureconverter/lineStringToCesium.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,IAAI,IAAI,UAAU,EAClB,eAAe,GAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAmB,KAAK,EAAE,MAAM,YAAY,CAAC;AAIpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oCAAoC,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAWxD,SAAS,eAAe,CACtB,IAAgB,EAChB,EAAc,EACd,eAAgC;IAEhC,IAAI,KAAK,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AAC,CAAC;IACjD,IAAI,eAAe,IAAI,eAAe,CAAC,MAAM,IAAI,aAAa,EAAE;QAC9D,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;KACjE;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,IAAI,eAAgE,CAAC;AAErE,MAAM,UAAU,4BAA4B;IAC1C,IAAI,CAAC,eAAe,EAAE;QACpB,eAAe,GAAG;YAChB,IAAI,EAAE,YAAY;YAClB,kBAAkB;YAClB,qBAAqB;YACrB,uBAAuB;YACvB,oBAAoB;gBAClB,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,0BAA0B;YAC1B,oBAAoB;YACpB,gBAAgB,EAAE,kBAAkB;SACrC,CAAC;KACH;IACD,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -1,13 +1,10 @@
1
- import { Cartesian3, Model, Primitive, type Scene } from '@vcmap-cesium/engine';
1
+ import { Cartesian3, type Scene } from '@vcmap-cesium/engine';
2
2
  import type { Feature } from 'ol/index.js';
3
- import type { Coordinate } from 'ol/coordinate.js';
4
3
  import { type Style } from 'ol/style.js';
5
- import VectorProperties, { VectorPropertiesModelOptions, VectorPropertiesPrimitive } from '../../layer/vectorProperties.js';
6
- export declare function getModelOptions(feature: Feature, wgs84Positions: Coordinate[], positions: Cartesian3[], vectorProperties: VectorProperties, scene: Scene, style?: Style): Promise<null | {
7
- primitives: Model[];
8
- options: VectorPropertiesModelOptions;
9
- }>;
10
- export declare function getPrimitiveOptions(feature: Feature, style: Style, wgs84Positions: Coordinate[], positions: Cartesian3[], vectorProperties: VectorProperties, scene: Scene): Promise<null | {
11
- primitives: Primitive[];
12
- options: VectorPropertiesPrimitive;
13
- }>;
4
+ import { Coordinate } from 'ol/coordinate.js';
5
+ import VectorProperties from '../../layer/vectorProperties.js';
6
+ import { ConvertedItem } from './convert.js';
7
+ import { VectorHeightInfo } from './vectorHeightInfo.js';
8
+ export declare function getModelOptions(feature: Feature, position: Cartesian3, wgs84Coords: Coordinate, vectorProperties: VectorProperties, scene: Scene, heightInfo: VectorHeightInfo, style?: Style): Promise<null | ConvertedItem<'primitive'>>;
9
+ export declare function getPrimitiveOptions(feature: Feature, style: Style, position: Cartesian3, wgs84Coords: Coordinate, vectorProperties: VectorProperties, scene: Scene, heightInfo: VectorHeightInfo): ConvertedItem<'primitive'>[];
10
+ export declare function getModelOrPointPrimitiveOptions(feature: Feature, style: Style, position: Cartesian3, wgs84Coords: Coordinate, vectorProperties: VectorProperties, heightInfo: VectorHeightInfo, scene: Scene): Promise<ConvertedItem<'primitive'>[]>;
@@ -1,10 +1,12 @@
1
- import { BoxGeometry, BoxOutlineGeometry, Cartesian3, Cartographic, Color, ColorGeometryInstanceAttribute, CylinderGeometry, CylinderOutlineGeometry, EllipsoidGeometry, EllipsoidOutlineGeometry, GeometryInstance, HeadingPitchRoll, HeightReference, Material, MaterialAppearance, Matrix4, Model, ModelAnimationLoop, PerInstanceColorAppearance, Primitive, sampleTerrainMostDetailed, SphereGeometry, SphereOutlineGeometry, Transforms, } from '@vcmap-cesium/engine';
1
+ import { BoxGeometry, BoxOutlineGeometry, Cartesian3, Cartographic, Color, ColorGeometryInstanceAttribute, CylinderGeometry, CylinderOutlineGeometry, EllipsoidGeometry, EllipsoidOutlineGeometry, GeometryInstance, HeadingPitchRoll, Material, MaterialAppearance, Matrix4, Model, ModelAnimationLoop, PerInstanceColorAppearance, Primitive, SphereGeometry, SphereOutlineGeometry, Transforms, } from '@vcmap-cesium/engine';
2
2
  import { RegularShape } from 'ol/style.js';
3
3
  import { asColorLike } from 'ol/colorlike.js';
4
4
  import { createSync } from '../../layer/vectorSymbols.js';
5
5
  import { PrimitiveOptionsType, vectorPropertiesOfType, } from '../../layer/vectorProperties.js';
6
6
  import { getCesiumColor } from '../../style/styleHelpers.js';
7
7
  import ModelFill from '../../style/modelFill.js';
8
+ import { wgs84ToCartographic } from '../math.js';
9
+ import { isRelativeHeightReference, } from './vectorHeightInfo.js';
8
10
  function makeOffsetAutoScalePrimitive(primitive, transform, scale, offset) {
9
11
  const { modelMatrix } = primitive;
10
12
  let currentScale = scale.clone();
@@ -43,23 +45,33 @@ function makeScaledAutoScalePrimitive(primitive, scale) {
43
45
  },
44
46
  });
45
47
  }
46
- async function placePrimitiveOnTerrain(primitive, position, scene, offset) {
47
- await sampleTerrainMostDetailed(scene.globe.terrainProvider, [
48
- Cartographic.fromCartesian(position),
49
- ])
50
- .then(([cartoWithNewHeight]) => {
51
- if (!primitive.isDestroyed()) {
52
- const { modelMatrix } = primitive;
53
- const newPosition = Cartographic.toCartesian(cartoWithNewHeight, undefined, position);
54
- if (offset) {
55
- Cartesian3.add(newPosition, offset, newPosition);
56
- }
57
- primitive.modelMatrix = Matrix4.setTranslation(modelMatrix, newPosition, modelMatrix);
48
+ const scratchUpdateHeightCartesian = new Cartesian3();
49
+ function makeClampedPrimitive(primitive, scale, headingPitchRoll, heightReference, scene, wgs84Coords, offset) {
50
+ const originCartographic = wgs84ToCartographic(wgs84Coords);
51
+ const updatePrimitiveHeight = (clampedPosition) => {
52
+ clampedPosition.height += wgs84Coords[2];
53
+ Cartographic.toCartesian(clampedPosition, undefined, scratchUpdateHeightCartesian);
54
+ const geometryModelMatrix = Matrix4.fromScale(scale);
55
+ if (offset) {
56
+ Matrix4.setTranslation(geometryModelMatrix, Cartesian3.multiplyComponents(offset, scale, new Cartesian3()), geometryModelMatrix);
58
57
  }
59
- })
60
- .catch(() => { });
58
+ const transform = Transforms.headingPitchRollToFixedFrame(scratchUpdateHeightCartesian, headingPitchRoll);
59
+ primitive.modelMatrix = Matrix4.multiply(transform, geometryModelMatrix, new Matrix4());
60
+ };
61
+ const callbackHandler = scene.updateHeight(originCartographic, updatePrimitiveHeight, heightReference);
62
+ const height = scene.getHeight(originCartographic, heightReference);
63
+ if (height) {
64
+ const updatedHeightCarto = originCartographic.clone();
65
+ updatedHeightCarto.height = height;
66
+ updatePrimitiveHeight(updatedHeightCarto);
67
+ }
68
+ const destroy = primitive.destroy.bind(primitive);
69
+ primitive.destroy = () => {
70
+ callbackHandler();
71
+ destroy();
72
+ };
61
73
  }
62
- export async function getModelOptions(feature, wgs84Positions, positions, vectorProperties, scene, style) {
74
+ export async function getModelOptions(feature, position, wgs84Coords, vectorProperties, scene, heightInfo, style) {
63
75
  const options = vectorProperties.getModel(feature);
64
76
  if (!options) {
65
77
  return null;
@@ -75,44 +87,42 @@ export async function getModelOptions(feature, wgs84Positions, positions, vector
75
87
  color = Color.fromCssColorString(asColorLike(olColor));
76
88
  }
77
89
  }
78
- const primitives = await Promise.all(positions.map(async (position, index) => {
79
- const modelMatrix = Matrix4.multiply(Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll), Matrix4.fromScale(scale), new Matrix4());
80
- const additionalModelOptions = vectorProperties.getModelOptions(feature);
81
- const heightReference = vectorProperties.getAltitudeMode(feature);
82
- const model = await Model.fromGltfAsync({
83
- asynchronous: !feature[createSync],
84
- url: options.url,
85
- modelMatrix,
86
- allowPicking,
87
- color,
88
- ...additionalModelOptions,
90
+ const modelMatrix = Matrix4.multiply(Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll), Matrix4.fromScale(scale), new Matrix4());
91
+ const additionalModelOptions = vectorProperties.getModelOptions(feature);
92
+ const model = await Model.fromGltfAsync({
93
+ asynchronous: !feature[createSync],
94
+ url: options.url,
95
+ modelMatrix,
96
+ allowPicking,
97
+ color,
98
+ ...additionalModelOptions,
99
+ });
100
+ const activateAnimations = () => {
101
+ model.activeAnimations.addAll({
102
+ loop: ModelAnimationLoop.REPEAT,
89
103
  });
90
- if (wgs84Positions[index][2] == null ||
91
- heightReference === HeightReference.CLAMP_TO_GROUND) {
92
- await placePrimitiveOnTerrain(model, position, scene);
93
- }
94
- const activateAnimations = () => {
95
- model.activeAnimations.addAll({
96
- loop: ModelAnimationLoop.REPEAT,
97
- });
98
- };
99
- if (model.ready) {
104
+ };
105
+ if (model.ready) {
106
+ activateAnimations();
107
+ }
108
+ else {
109
+ const listener = model.readyEvent.addEventListener(() => {
110
+ listener();
100
111
  activateAnimations();
101
- }
102
- else {
103
- const listener = model.readyEvent.addEventListener(() => {
104
- listener();
105
- activateAnimations();
106
- });
107
- }
108
- if (options.autoScale && !Cartesian3.ONE.equals(scale)) {
109
- makeScaledAutoScalePrimitive(model, scale);
110
- }
111
- return model;
112
- }));
112
+ });
113
+ }
114
+ if (options.autoScale && !Cartesian3.ONE.equals(scale)) {
115
+ makeScaledAutoScalePrimitive(model, scale);
116
+ }
117
+ if (isRelativeHeightReference(heightInfo.heightReference) &&
118
+ heightInfo.groundLevel ==
119
+ null) {
120
+ makeClampedPrimitive(model, scale, headingPitchRoll, heightInfo.heightReference, scene, wgs84Coords);
121
+ }
113
122
  return {
114
- primitives,
115
- options,
123
+ type: 'primitive',
124
+ item: model,
125
+ autoScale: options.autoScale,
116
126
  };
117
127
  }
118
128
  function getGeometryInstanceFromOptions(options, color, outline) {
@@ -159,10 +169,10 @@ function getGeometryInstanceFromOptions(options, color, outline) {
159
169
  }
160
170
  return null;
161
171
  }
162
- export async function getPrimitiveOptions(feature, style, wgs84Positions, positions, vectorProperties, scene) {
172
+ export function getPrimitiveOptions(feature, style, position, wgs84Coords, vectorProperties, scene, heightInfo) {
163
173
  const options = vectorProperties.getPrimitive(feature);
164
174
  if (!options) {
165
- return null;
175
+ return [];
166
176
  }
167
177
  const imageStyle = style.getImage();
168
178
  let fill;
@@ -177,7 +187,7 @@ export async function getPrimitiveOptions(feature, style, wgs84Positions, positi
177
187
  stroke = style.getStroke(); // XXX this makes it impossible to create an extruded un-stroked primitive with an icon in 2D or we add a new primitive option
178
188
  }
179
189
  if (!fill && !stroke) {
180
- return null;
190
+ return [];
181
191
  }
182
192
  let fillColor;
183
193
  if (fill) {
@@ -190,76 +200,80 @@ export async function getPrimitiveOptions(feature, style, wgs84Positions, positi
190
200
  const scale = Cartesian3.fromArray(options.scale);
191
201
  const headingPitchRoll = HeadingPitchRoll.fromDegrees(options.heading, options.pitch, options.roll);
192
202
  const allowPicking = vectorProperties.getAllowPicking(feature);
193
- const heightReference = vectorProperties.getAltitudeMode(feature);
194
- const primitives = await Promise.all(positions.map(async (position, index) => {
195
- const geometryModelMatrix = Matrix4.fromScale(scale);
196
- let offset;
197
- if (options.primitiveOptions.offset?.length === 3) {
198
- offset = Cartesian3.fromArray(options.primitiveOptions.offset);
199
- Matrix4.setTranslation(geometryModelMatrix, Cartesian3.multiplyComponents(offset, scale, new Cartesian3()), geometryModelMatrix);
200
- }
201
- const transform = Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll);
202
- const modelMatrix = Matrix4.multiply(transform, geometryModelMatrix, new Matrix4());
203
- let depthFail;
204
- if (options.primitiveOptions.depthFailColor) {
205
- const depthFailColor = getCesiumColor(options.primitiveOptions.depthFailColor, [255, 255, 255, 0.4]);
206
- depthFail = new MaterialAppearance({
207
- translucent: depthFailColor.alpha < 1,
208
- material: Material.fromType('Color', {
209
- color: depthFailColor,
210
- }),
211
- });
212
- }
213
- const createPrimitive = async (translucent, geometryInstances, depthFailAppearance) => {
214
- const primitive = new Primitive({
215
- asynchronous: !feature[createSync],
216
- geometryInstances: geometryInstances.filter((g) => g),
217
- modelMatrix,
218
- appearance: new PerInstanceColorAppearance({
219
- translucent,
220
- flat: true,
221
- }),
222
- depthFailAppearance,
223
- allowPicking,
224
- ...options.primitiveOptions.additionalOptions,
225
- });
226
- if (wgs84Positions[index][2] == null ||
227
- heightReference === HeightReference.CLAMP_TO_GROUND) {
228
- await placePrimitiveOnTerrain(primitive, position, scene, offset);
229
- Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll, undefined, undefined, transform); // update transform for usage in offset auto scale
203
+ const geometryModelMatrix = Matrix4.fromScale(scale);
204
+ let offset;
205
+ if (options.primitiveOptions.offset?.length === 3) {
206
+ offset = Cartesian3.fromArray(options.primitiveOptions.offset);
207
+ Matrix4.setTranslation(geometryModelMatrix, Cartesian3.multiplyComponents(offset, scale, new Cartesian3()), geometryModelMatrix);
208
+ }
209
+ const transform = Transforms.headingPitchRollToFixedFrame(position, headingPitchRoll);
210
+ const modelMatrix = Matrix4.multiply(transform, geometryModelMatrix, new Matrix4());
211
+ let depthFail;
212
+ if (options.primitiveOptions.depthFailColor) {
213
+ const depthFailColor = getCesiumColor(options.primitiveOptions.depthFailColor, [255, 255, 255, 0.4]);
214
+ depthFail = new MaterialAppearance({
215
+ translucent: depthFailColor.alpha < 1,
216
+ material: Material.fromType('Color', {
217
+ color: depthFailColor,
218
+ }),
219
+ });
220
+ }
221
+ const createPrimitive = (translucent, geometryInstances, depthFailAppearance) => {
222
+ const primitive = new Primitive({
223
+ asynchronous: !feature[createSync],
224
+ geometryInstances: geometryInstances.filter((g) => g),
225
+ modelMatrix,
226
+ appearance: new PerInstanceColorAppearance({
227
+ translucent,
228
+ flat: true,
229
+ }),
230
+ depthFailAppearance,
231
+ allowPicking,
232
+ ...options.primitiveOptions.additionalOptions,
233
+ });
234
+ if (options.autoScale) {
235
+ if (offset) {
236
+ makeOffsetAutoScalePrimitive(primitive, transform, scale, offset);
230
237
  }
231
- if (options.autoScale) {
232
- if (offset) {
233
- makeOffsetAutoScalePrimitive(primitive, transform, scale, offset);
234
- }
235
- else if (!Cartesian3.ONE.equals(scale)) {
236
- makeScaledAutoScalePrimitive(primitive, scale);
237
- }
238
+ else if (!Cartesian3.ONE.equals(scale)) {
239
+ makeScaledAutoScalePrimitive(primitive, scale);
238
240
  }
239
- return primitive;
240
- };
241
- const fillAndOutline = [];
242
- if (fillColor) {
243
- fillAndOutline.push(createPrimitive(fillColor.alpha < 1 || !!depthFail, [
244
- getGeometryInstanceFromOptions(options.primitiveOptions, fillColor),
245
- ], depthFail));
246
- }
247
- else if (depthFail) {
248
- const transparent = Color.TRANSPARENT;
249
- fillAndOutline.push(createPrimitive(true, [
250
- getGeometryInstanceFromOptions(options.primitiveOptions, transparent),
251
- ], depthFail));
252
241
  }
253
- if (strokeColor) {
254
- fillAndOutline.push(createPrimitive(strokeColor.alpha < 1 || !!depthFail, [
255
- getGeometryInstanceFromOptions(options.primitiveOptions, strokeColor, true),
256
- ]));
242
+ if (isRelativeHeightReference(heightInfo.heightReference) &&
243
+ heightInfo.groundLevel ==
244
+ null) {
245
+ makeClampedPrimitive(primitive, scale, headingPitchRoll, heightInfo.heightReference, scene, wgs84Coords, offset);
257
246
  }
258
- return Promise.all(fillAndOutline);
259
- }));
260
- return {
261
- primitives: primitives.flatMap((p) => p),
262
- options,
247
+ return primitive;
263
248
  };
249
+ const fillAndOutline = [];
250
+ if (fillColor) {
251
+ fillAndOutline.push(createPrimitive(fillColor.alpha < 1 || !!depthFail, [getGeometryInstanceFromOptions(options.primitiveOptions, fillColor)], depthFail));
252
+ }
253
+ else if (depthFail) {
254
+ const transparent = Color.TRANSPARENT;
255
+ fillAndOutline.push(createPrimitive(true, [getGeometryInstanceFromOptions(options.primitiveOptions, transparent)], depthFail));
256
+ }
257
+ if (strokeColor) {
258
+ fillAndOutline.push(createPrimitive(strokeColor.alpha < 1 || !!depthFail, [
259
+ getGeometryInstanceFromOptions(options.primitiveOptions, strokeColor, true),
260
+ ]));
261
+ }
262
+ return fillAndOutline.map((item) => ({
263
+ type: 'primitive',
264
+ item,
265
+ autoScale: options.autoScale,
266
+ }));
267
+ }
268
+ export async function getModelOrPointPrimitiveOptions(feature, style, position, wgs84Coords, vectorProperties, heightInfo, scene) {
269
+ const renderAs = vectorProperties.renderAs(feature);
270
+ if (renderAs === 'model') {
271
+ const modelOptions = await getModelOptions(feature, position, wgs84Coords, vectorProperties, scene, heightInfo, style);
272
+ return modelOptions ? [modelOptions] : [];
273
+ }
274
+ if (renderAs === 'primitive') {
275
+ return getPrimitiveOptions(feature, style, position, wgs84Coords, vectorProperties, scene, heightInfo);
276
+ }
277
+ return [];
264
278
  }
265
279
  //# sourceMappingURL=pointHelpers.js.map