@map-colonies/react-components 3.12.2 → 3.12.3

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 (375) hide show
  1. package/.eslintignore +1 -1
  2. package/.storybook/main.js +13 -13
  3. package/.storybook/manager.js +6 -6
  4. package/.storybook/preview-head.html +21 -21
  5. package/.storybook/preview.js +18 -18
  6. package/.storybook/theme.js +9 -9
  7. package/CHANGELOG.md +828 -819
  8. package/README.md +53 -53
  9. package/dist/autocomplete/autocomplete.css +25 -25
  10. package/dist/autocomplete/autocomplete.d.ts +33 -33
  11. package/dist/autocomplete/autocomplete.js +478 -478
  12. package/dist/autocomplete/index.d.ts +1 -1
  13. package/dist/autocomplete/index.js +5 -5
  14. package/dist/box/box.d.ts +3 -3
  15. package/dist/box/box.js +35 -35
  16. package/dist/box/index.d.ts +1 -1
  17. package/dist/box/index.js +5 -5
  18. package/dist/cesium-map/data-sources/custom.data-source.d.ts +5 -5
  19. package/dist/cesium-map/data-sources/custom.data-source.js +23 -23
  20. package/dist/cesium-map/data-sources/drawings.data-source.d.ts +34 -34
  21. package/dist/cesium-map/data-sources/drawings.data-source.js +187 -187
  22. package/dist/cesium-map/data-sources/index.d.ts +2 -2
  23. package/dist/cesium-map/data-sources/index.js +14 -14
  24. package/dist/cesium-map/entities/entity.d.ts +5 -5
  25. package/dist/cesium-map/entities/entity.description.d.ts +6 -6
  26. package/dist/cesium-map/entities/entity.description.js +27 -27
  27. package/dist/cesium-map/entities/entity.js +23 -23
  28. package/dist/cesium-map/entities/graphics/polygon.graphics.d.ts +5 -5
  29. package/dist/cesium-map/entities/graphics/polygon.graphics.js +23 -23
  30. package/dist/cesium-map/entities/graphics/polyline.graphics.d.ts +5 -5
  31. package/dist/cesium-map/entities/graphics/polyline.graphics.js +23 -23
  32. package/dist/cesium-map/entities/graphics/rectangle.graphics.d.ts +5 -5
  33. package/dist/cesium-map/entities/graphics/rectangle.graphics.js +23 -23
  34. package/dist/cesium-map/entities/index.d.ts +4 -4
  35. package/dist/cesium-map/entities/index.js +16 -16
  36. package/dist/cesium-map/index.d.ts +8 -8
  37. package/dist/cesium-map/index.js +20 -20
  38. package/dist/cesium-map/layers/3d.tileset.d.ts +7 -7
  39. package/dist/cesium-map/layers/3d.tileset.js +43 -43
  40. package/dist/cesium-map/layers/3d.tileset.with.update.d.ts +6 -6
  41. package/dist/cesium-map/layers/3d.tileset.with.update.js +115 -115
  42. package/dist/cesium-map/layers/geojson.layer.d.ts +5 -5
  43. package/dist/cesium-map/layers/geojson.layer.js +23 -23
  44. package/dist/cesium-map/layers/imagery.layer.d.ts +6 -6
  45. package/dist/cesium-map/layers/imagery.layer.js +68 -68
  46. package/dist/cesium-map/layers/index.d.ts +7 -7
  47. package/dist/cesium-map/layers/index.js +19 -19
  48. package/dist/cesium-map/layers/osm.layer.d.ts +9 -9
  49. package/dist/cesium-map/layers/osm.layer.js +36 -36
  50. package/dist/cesium-map/layers/wms.layer.d.ts +9 -9
  51. package/dist/cesium-map/layers/wms.layer.js +36 -36
  52. package/dist/cesium-map/layers/wmts.layer.d.ts +9 -9
  53. package/dist/cesium-map/layers/wmts.layer.js +36 -36
  54. package/dist/cesium-map/layers/xyz.layer.d.ts +9 -9
  55. package/dist/cesium-map/layers/xyz.layer.js +36 -36
  56. package/dist/cesium-map/layers-manager.d.ts +55 -55
  57. package/dist/cesium-map/layers-manager.js +246 -246
  58. package/dist/cesium-map/map-legend/MapLegend.css +135 -135
  59. package/dist/cesium-map/map-legend/MapLegend.d.ts +15 -15
  60. package/dist/cesium-map/map-legend/MapLegend.js +57 -57
  61. package/dist/cesium-map/map-legend/MapLegendList.d.ts +13 -13
  62. package/dist/cesium-map/map-legend/MapLegendList.js +43 -43
  63. package/dist/cesium-map/map-legend/MapLegendSidebar.d.ts +16 -16
  64. package/dist/cesium-map/map-legend/MapLegendSidebar.js +20 -20
  65. package/dist/cesium-map/map-legend/MapLegendToggle.d.ts +7 -7
  66. package/dist/cesium-map/map-legend/MapLegendToggle.js +20 -20
  67. package/dist/cesium-map/map-legend/index.d.ts +3 -3
  68. package/dist/cesium-map/map-legend/index.js +14 -14
  69. package/dist/cesium-map/map.css +59 -59
  70. package/dist/cesium-map/map.d.ts +59 -59
  71. package/dist/cesium-map/map.js +305 -305
  72. package/dist/cesium-map/map.types.d.ts +8 -8
  73. package/dist/cesium-map/map.types.js +12 -12
  74. package/dist/cesium-map/proxied.types.d.ts +30 -30
  75. package/dist/cesium-map/proxied.types.js +132 -132
  76. package/dist/cesium-map/settings/base-maps.css +37 -37
  77. package/dist/cesium-map/settings/base-maps.d.ts +7 -7
  78. package/dist/cesium-map/settings/base-maps.js +78 -78
  79. package/dist/cesium-map/settings/scene-modes.css +19 -19
  80. package/dist/cesium-map/settings/scene-modes.d.ts +7 -7
  81. package/dist/cesium-map/settings/scene-modes.js +65 -65
  82. package/dist/cesium-map/settings/settings.css +52 -52
  83. package/dist/cesium-map/settings/settings.d.ts +23 -23
  84. package/dist/cesium-map/settings/settings.js +79 -79
  85. package/dist/cesium-map/terrain-providers/custom/dummy-quantized-mesh-tile.d.ts +3 -3
  86. package/dist/cesium-map/terrain-providers/custom/dummy-quantized-mesh-tile.js +245 -245
  87. package/dist/cesium-map/terrain-providers/custom/quantized-mesh-decoder.d.ts +9 -9
  88. package/dist/cesium-map/terrain-providers/custom/quantized-mesh-decoder.js +202 -202
  89. package/dist/cesium-map/terrain-providers/custom/quantized-mesh-terrain-provider.d.ts +50 -50
  90. package/dist/cesium-map/terrain-providers/custom/quantized-mesh-terrain-provider.js +136 -136
  91. package/dist/cesium-map/tools/cesium/primitives-conversions.cesium.d.ts +2 -2
  92. package/dist/cesium-map/tools/cesium/primitives-conversions.cesium.js +38 -38
  93. package/dist/cesium-map/tools/coordinates-tracker.tool.css +11 -11
  94. package/dist/cesium-map/tools/coordinates-tracker.tool.d.ts +7 -7
  95. package/dist/cesium-map/tools/coordinates-tracker.tool.js +78 -78
  96. package/dist/cesium-map/tools/draw/drawHelper.css +101 -101
  97. package/dist/cesium-map/tools/draw/drawHelper.d.ts +28 -28
  98. package/dist/cesium-map/tools/draw/drawHelper.js +1694 -1694
  99. package/dist/cesium-map/tools/geojson/geojson-to-primitive.d.ts +4 -4
  100. package/dist/cesium-map/tools/geojson/geojson-to-primitive.js +41 -41
  101. package/dist/cesium-map/tools/geojson/index.d.ts +2 -2
  102. package/dist/cesium-map/tools/geojson/index.js +14 -14
  103. package/dist/cesium-map/tools/geojson/point.geojson.d.ts +3 -3
  104. package/dist/cesium-map/tools/geojson/point.geojson.js +21 -21
  105. package/dist/cesium-map/tools/geojson/polygon.geojson.d.ts +3 -3
  106. package/dist/cesium-map/tools/geojson/polygon.geojson.js +24 -24
  107. package/dist/cesium-map/tools/geojson/rectangle.geojson.d.ts +3 -3
  108. package/dist/cesium-map/tools/geojson/rectangle.geojson.js +44 -44
  109. package/dist/cesium-map/tools/inspector.tool.d.ts +4 -4
  110. package/dist/cesium-map/tools/inspector.tool.js +33 -33
  111. package/dist/cesium-map/tools/scale-tracker.tool.css +16 -16
  112. package/dist/cesium-map/tools/scale-tracker.tool.d.ts +8 -8
  113. package/dist/cesium-map/tools/scale-tracker.tool.js +158 -158
  114. package/dist/cesium-map/tools/terranian-height.tool.d.ts +4 -4
  115. package/dist/cesium-map/tools/terranian-height.tool.js +114 -114
  116. package/dist/cssbaseline/cssbaseline.d.ts +5 -5
  117. package/dist/cssbaseline/cssbaseline.js +41 -41
  118. package/dist/cssbaseline/index.d.ts +1 -1
  119. package/dist/cssbaseline/index.js +6 -6
  120. package/dist/date-picker/date-picker.css +9 -9
  121. package/dist/date-picker/date-picker.d.ts +14 -14
  122. package/dist/date-picker/date-picker.js +78 -78
  123. package/dist/date-picker/index.d.ts +1 -1
  124. package/dist/date-picker/index.js +13 -13
  125. package/dist/date-range-picker/date-range-picker.css +9 -9
  126. package/dist/date-range-picker/date-range-picker.d.ts +26 -26
  127. package/dist/date-range-picker/date-range-picker.form-control.css +3 -3
  128. package/dist/date-range-picker/date-range-picker.form-control.d.ts +28 -28
  129. package/dist/date-range-picker/date-range-picker.form-control.js +95 -95
  130. package/dist/date-range-picker/date-range-picker.js +104 -104
  131. package/dist/date-range-picker/index.d.ts +2 -2
  132. package/dist/date-range-picker/index.js +14 -14
  133. package/dist/file-picker/file-picker.css +63 -63
  134. package/dist/file-picker/file-picker.d.ts +276 -276
  135. package/dist/file-picker/file-picker.js +151 -151
  136. package/dist/file-picker/fs-map.json +1556 -1556
  137. package/dist/file-picker/index.d.ts +2 -2
  138. package/dist/file-picker/index.js +14 -14
  139. package/dist/file-picker/localization.d.ts +11 -11
  140. package/dist/file-picker/localization.js +124 -124
  141. package/dist/index.d.ts +13 -13
  142. package/dist/index.js +25 -25
  143. package/dist/map-filter-container/container-map.css +5 -5
  144. package/dist/map-filter-container/container-map.d.ts +11 -11
  145. package/dist/map-filter-container/container-map.js +31 -31
  146. package/dist/map-filter-container/index.d.ts +1 -1
  147. package/dist/map-filter-container/index.js +13 -13
  148. package/dist/map-filter-container/map-filter-container.d.ts +9 -9
  149. package/dist/map-filter-container/map-filter-container.js +78 -78
  150. package/dist/map-filter-container/polygon-selection-ui.d.ts +12 -12
  151. package/dist/map-filter-container/polygon-selection-ui.js +62 -62
  152. package/dist/models/defaults.d.ts +28 -28
  153. package/dist/models/defaults.js +32 -32
  154. package/dist/models/enums.d.ts +14 -14
  155. package/dist/models/enums.js +20 -20
  156. package/dist/models/index.d.ts +1 -1
  157. package/dist/models/index.js +13 -13
  158. package/dist/ol-map/feature.d.ts +6 -6
  159. package/dist/ol-map/feature.js +20 -20
  160. package/dist/ol-map/index.d.ts +6 -6
  161. package/dist/ol-map/index.js +18 -18
  162. package/dist/ol-map/interactions/draw.d.ts +8 -8
  163. package/dist/ol-map/interactions/draw.js +44 -44
  164. package/dist/ol-map/interactions/index.d.ts +1 -1
  165. package/dist/ol-map/interactions/index.js +13 -13
  166. package/dist/ol-map/layers/index.d.ts +3 -3
  167. package/dist/ol-map/layers/index.js +15 -15
  168. package/dist/ol-map/layers/tile-layer.d.ts +9 -9
  169. package/dist/ol-map/layers/tile-layer.js +48 -48
  170. package/dist/ol-map/layers/vector-layer.d.ts +4 -4
  171. package/dist/ol-map/layers/vector-layer.js +48 -48
  172. package/dist/ol-map/layers/vector-tile-layer.d.ts +10 -10
  173. package/dist/ol-map/layers/vector-tile-layer.js +66 -66
  174. package/dist/ol-map/map.css +17 -17
  175. package/dist/ol-map/map.d.ts +14 -14
  176. package/dist/ol-map/map.js +117 -117
  177. package/dist/ol-map/source/index.d.ts +6 -6
  178. package/dist/ol-map/source/index.js +18 -18
  179. package/dist/ol-map/source/mvt.d.ts +11 -11
  180. package/dist/ol-map/source/mvt.js +37 -37
  181. package/dist/ol-map/source/osm.d.ts +2 -2
  182. package/dist/ol-map/source/osm.js +14 -14
  183. package/dist/ol-map/source/vector-source.d.ts +4 -4
  184. package/dist/ol-map/source/vector-source.js +45 -45
  185. package/dist/ol-map/source/wms.d.ts +17 -17
  186. package/dist/ol-map/source/wms.js +30 -30
  187. package/dist/ol-map/source/wmts.d.ts +21 -21
  188. package/dist/ol-map/source/wmts.js +59 -59
  189. package/dist/ol-map/source/xyz.d.ts +12 -12
  190. package/dist/ol-map/source/xyz.js +27 -27
  191. package/dist/ol-map/style.d.ts +4 -4
  192. package/dist/ol-map/style.js +22 -22
  193. package/dist/popover/index.d.ts +1 -1
  194. package/dist/popover/index.js +5 -5
  195. package/dist/popover/popover.d.ts +3 -3
  196. package/dist/popover/popover.js +35 -35
  197. package/dist/smart-table/__mock-data__/smartTableMocks.d.ts +7 -7
  198. package/dist/smart-table/__mock-data__/smartTableMocks.js +17 -17
  199. package/dist/smart-table/index.d.ts +2 -2
  200. package/dist/smart-table/index.js +14 -14
  201. package/dist/smart-table/smart-table-head.d.ts +11 -11
  202. package/dist/smart-table/smart-table-head.js +22 -22
  203. package/dist/smart-table/smart-table-row.d.ts +12 -12
  204. package/dist/smart-table/smart-table-row.js +46 -46
  205. package/dist/smart-table/smart-table-types.d.ts +9 -9
  206. package/dist/smart-table/smart-table-types.js +2 -2
  207. package/dist/smart-table/smart-table.d.ts +17 -17
  208. package/dist/smart-table/smart-table.js +51 -51
  209. package/dist/theme/index.d.ts +1 -1
  210. package/dist/theme/index.js +13 -13
  211. package/dist/theme/theme.d.ts +8 -8
  212. package/dist/theme/theme.js +124 -124
  213. package/dist/utils/map.d.ts +3 -3
  214. package/dist/utils/map.js +21 -21
  215. package/dist/utils/projections.d.ts +6 -6
  216. package/dist/utils/projections.js +10 -10
  217. package/dist/utils/story.d.ts +12 -12
  218. package/dist/utils/story.js +2 -2
  219. package/package.json +3 -3
  220. package/public/index.html +43 -43
  221. package/public/manifest.json +25 -25
  222. package/public/robots.txt +3 -3
  223. package/src/index.tsx +9 -9
  224. package/src/lib/autocomplete/autocomplete.css +25 -25
  225. package/src/lib/autocomplete/autocomplete.stories.tsx +101 -101
  226. package/src/lib/autocomplete/autocomplete.tsx +681 -681
  227. package/src/lib/autocomplete/index.ts +1 -1
  228. package/src/lib/box/box.tsx +7 -7
  229. package/src/lib/box/index.ts +1 -1
  230. package/src/lib/cesium-map/context-menu.stories.tsx +444 -444
  231. package/src/lib/cesium-map/data-sources/custom.data-source.tsx +12 -12
  232. package/src/lib/cesium-map/data-sources/drawings.data-source.stories.tsx +161 -161
  233. package/src/lib/cesium-map/data-sources/drawings.data-source.tsx +204 -204
  234. package/src/lib/cesium-map/data-sources/index.ts +2 -2
  235. package/src/lib/cesium-map/entities/entity.description.tsx +19 -19
  236. package/src/lib/cesium-map/entities/entity.graphics.stories.tsx +48 -48
  237. package/src/lib/cesium-map/entities/entity.stories.tsx +146 -146
  238. package/src/lib/cesium-map/entities/entity.tsx +10 -10
  239. package/src/lib/cesium-map/entities/graphics/polygon.graphics.tsx +12 -12
  240. package/src/lib/cesium-map/entities/graphics/polyline.graphics.tsx +12 -12
  241. package/src/lib/cesium-map/entities/graphics/rectangle.graphics.tsx +12 -12
  242. package/src/lib/cesium-map/entities/index.ts +4 -4
  243. package/src/lib/cesium-map/index.ts +8 -8
  244. package/src/lib/cesium-map/layers/3d.tileset.stories.tsx +164 -164
  245. package/src/lib/cesium-map/layers/3d.tileset.tsx +51 -51
  246. package/src/lib/cesium-map/layers/3d.tileset.with.update.tsx +120 -120
  247. package/src/lib/cesium-map/layers/geojson.layer.stories.tsx +119 -119
  248. package/src/lib/cesium-map/layers/geojson.layer.tsx +12 -12
  249. package/src/lib/cesium-map/layers/imagery.layer.stories.tsx +39 -39
  250. package/src/lib/cesium-map/layers/imagery.layer.tsx +37 -37
  251. package/src/lib/cesium-map/layers/index.ts +7 -7
  252. package/src/lib/cesium-map/layers/layers.rect.stories.tsx +171 -171
  253. package/src/lib/cesium-map/layers/osm.layer.stories.tsx +40 -40
  254. package/src/lib/cesium-map/layers/osm.layer.tsx +22 -22
  255. package/src/lib/cesium-map/layers/wms.layer.stories.tsx +38 -38
  256. package/src/lib/cesium-map/layers/wms.layer.tsx +22 -22
  257. package/src/lib/cesium-map/layers/wmts.layer.stories.tsx +53 -53
  258. package/src/lib/cesium-map/layers/wmts.layer.tsx +22 -22
  259. package/src/lib/cesium-map/layers/xyz.layer.stories.tsx +37 -37
  260. package/src/lib/cesium-map/layers/xyz.layer.tsx +22 -22
  261. package/src/lib/cesium-map/layers-manager.stories.tsx +286 -286
  262. package/src/lib/cesium-map/layers-manager.ts +354 -354
  263. package/src/lib/cesium-map/map-legend/MapLegend.css +135 -135
  264. package/src/lib/cesium-map/map-legend/MapLegend.tsx +92 -92
  265. package/src/lib/cesium-map/map-legend/MapLegendList.tsx +47 -47
  266. package/src/lib/cesium-map/map-legend/MapLegendSidebar.tsx +55 -55
  267. package/src/lib/cesium-map/map-legend/MapLegendToggle.tsx +31 -31
  268. package/src/lib/cesium-map/map-legend/index.tsx +3 -3
  269. package/src/lib/cesium-map/map-legend/legends-sidebar.stories.tsx +201 -201
  270. package/src/lib/cesium-map/map.css +59 -59
  271. package/src/lib/cesium-map/map.stories.tsx +143 -143
  272. package/src/lib/cesium-map/map.tsx +446 -446
  273. package/src/lib/cesium-map/map.types.ts +11 -11
  274. package/src/lib/cesium-map/proxied.types.ts +54 -54
  275. package/src/lib/cesium-map/settings/base-maps.css +37 -37
  276. package/src/lib/cesium-map/settings/base-maps.tsx +94 -94
  277. package/src/lib/cesium-map/settings/scene-modes.css +19 -19
  278. package/src/lib/cesium-map/settings/scene-modes.tsx +100 -100
  279. package/src/lib/cesium-map/settings/settings.css +52 -52
  280. package/src/lib/cesium-map/settings/settings.stories.tsx +182 -182
  281. package/src/lib/cesium-map/settings/settings.tsx +141 -141
  282. package/src/lib/cesium-map/terrain-providers/custom/dummy-quantized-mesh-tile.ts +243 -243
  283. package/src/lib/cesium-map/terrain-providers/custom/quantized-mesh-decoder.ts +321 -321
  284. package/src/lib/cesium-map/terrain-providers/custom/quantized-mesh-terrain-provider.ts +237 -237
  285. package/src/lib/cesium-map/terrain-providers/terrain-provider-heights-tool.stories.tsx +170 -170
  286. package/src/lib/cesium-map/terrain-providers/terrain-provider.stories.tsx +187 -187
  287. package/src/lib/cesium-map/tools/cesium/primitives-conversions.cesium.ts +15 -15
  288. package/src/lib/cesium-map/tools/coordinates-tracker.tool.css +11 -11
  289. package/src/lib/cesium-map/tools/coordinates-tracker.tool.tsx +79 -79
  290. package/src/lib/cesium-map/tools/draw/drawHelper.css +101 -101
  291. package/src/lib/cesium-map/tools/draw/drawHelper.ts +2116 -2116
  292. package/src/lib/cesium-map/tools/geojson/geojson-to-primitive.ts +54 -54
  293. package/src/lib/cesium-map/tools/geojson/index.ts +2 -2
  294. package/src/lib/cesium-map/tools/geojson/point.geojson.ts +29 -29
  295. package/src/lib/cesium-map/tools/geojson/polygon.geojson.ts +24 -24
  296. package/src/lib/cesium-map/tools/geojson/rectangle.geojson.ts +21 -21
  297. package/src/lib/cesium-map/tools/inspector.tool.tsx +15 -15
  298. package/src/lib/cesium-map/tools/scale-tracker.tool.css +16 -16
  299. package/src/lib/cesium-map/tools/scale-tracker.tool.tsx +192 -192
  300. package/src/lib/cesium-map/tools/terranian-height.tool.tsx +171 -171
  301. package/src/lib/cssbaseline/cssbaseline.tsx +19 -19
  302. package/src/lib/cssbaseline/index.ts +4 -4
  303. package/src/lib/date-picker/date-picker.css +9 -9
  304. package/src/lib/date-picker/date-picker.stories.tsx +130 -130
  305. package/src/lib/date-picker/date-picker.tsx +90 -90
  306. package/src/lib/date-picker/index.ts +1 -1
  307. package/src/lib/date-range-picker/date-range-picker.css +9 -9
  308. package/src/lib/date-range-picker/date-range-picker.form-control.css +3 -3
  309. package/src/lib/date-range-picker/date-range-picker.form-control.spec.tsx +58 -58
  310. package/src/lib/date-range-picker/date-range-picker.form-control.tsx +150 -150
  311. package/src/lib/date-range-picker/date-range-picker.stories.tsx +207 -207
  312. package/src/lib/date-range-picker/date-range-picker.tsx +156 -156
  313. package/src/lib/date-range-picker/index.ts +2 -2
  314. package/src/lib/file-picker/file-picker.css +63 -63
  315. package/src/lib/file-picker/file-picker.stories.tsx +447 -447
  316. package/src/lib/file-picker/file-picker.tsx +180 -180
  317. package/src/lib/file-picker/fs-map.json +1556 -1556
  318. package/src/lib/file-picker/index.ts +2 -2
  319. package/src/lib/file-picker/localization.ts +164 -164
  320. package/src/lib/index.ts +13 -13
  321. package/src/lib/map-filter-container/container-map.css +5 -5
  322. package/src/lib/map-filter-container/container-map.tsx +48 -48
  323. package/src/lib/map-filter-container/index.ts +1 -1
  324. package/src/lib/map-filter-container/map-filter-container.tsx +91 -91
  325. package/src/lib/map-filter-container/polygon-selection-ui.spec.tsx +119 -119
  326. package/src/lib/map-filter-container/polygon-selection-ui.tsx +111 -111
  327. package/src/lib/map-filter-container/stories/Map.stories.tsx +76 -76
  328. package/src/lib/models/defaults.ts +32 -32
  329. package/src/lib/models/enums.ts +16 -16
  330. package/src/lib/models/index.ts +1 -1
  331. package/src/lib/ol-map/feature.tsx +23 -23
  332. package/src/lib/ol-map/index.ts +6 -6
  333. package/src/lib/ol-map/interactions/draw.tsx +56 -56
  334. package/src/lib/ol-map/interactions/index.ts +1 -1
  335. package/src/lib/ol-map/layers/index.ts +3 -3
  336. package/src/lib/ol-map/layers/tile-layer.tsx +36 -36
  337. package/src/lib/ol-map/layers/vector-layer.tsx +32 -32
  338. package/src/lib/ol-map/layers/vector-tile-layer.tsx +56 -56
  339. package/src/lib/ol-map/map.css +17 -17
  340. package/src/lib/ol-map/map.tsx +137 -137
  341. package/src/lib/ol-map/source/index.ts +6 -6
  342. package/src/lib/ol-map/source/mvt.tsx +46 -46
  343. package/src/lib/ol-map/source/osm.tsx +13 -13
  344. package/src/lib/ol-map/source/stories/mvt.stories.tsx +68 -68
  345. package/src/lib/ol-map/source/stories/vector-source.stories.tsx +78 -78
  346. package/src/lib/ol-map/source/stories/wms.stories.tsx +51 -51
  347. package/src/lib/ol-map/source/stories/wmts.stories.tsx +72 -72
  348. package/src/lib/ol-map/source/stories/xyz.stories.tsx +53 -53
  349. package/src/lib/ol-map/source/vector-source.tsx +30 -30
  350. package/src/lib/ol-map/source/wms.tsx +40 -40
  351. package/src/lib/ol-map/source/wmts.tsx +82 -82
  352. package/src/lib/ol-map/source/xyz.tsx +33 -33
  353. package/src/lib/ol-map/stories/map.stories.tsx +60 -60
  354. package/src/lib/ol-map/style.ts +24 -24
  355. package/src/lib/popover/index.ts +1 -1
  356. package/src/lib/popover/popover.tsx +7 -7
  357. package/src/lib/smart-table/__mock-data__/smartTableMocks.ts +22 -22
  358. package/src/lib/smart-table/index.ts +2 -2
  359. package/src/lib/smart-table/smart-table-head.spec.tsx +116 -116
  360. package/src/lib/smart-table/smart-table-head.tsx +47 -47
  361. package/src/lib/smart-table/smart-table-row.spec.tsx +109 -109
  362. package/src/lib/smart-table/smart-table-row.tsx +78 -78
  363. package/src/lib/smart-table/smart-table-types.ts +10 -10
  364. package/src/lib/smart-table/smart-table.spec.tsx +116 -116
  365. package/src/lib/smart-table/smart-table.tsx +115 -115
  366. package/src/lib/smart-table/stories/SmartTable.stories.tsx +114 -114
  367. package/src/lib/theme/index.ts +1 -1
  368. package/src/lib/theme/theme.ts +123 -123
  369. package/src/lib/utils/map.ts +19 -19
  370. package/src/lib/utils/projections.ts +7 -7
  371. package/src/lib/utils/story.ts +11 -11
  372. package/src/react-app-env.d.ts +1 -1
  373. package/src/setupTests.ts +14 -14
  374. package/tsbuildconfig.json +37 -37
  375. package/tsconfig.json +26 -26
@@ -1,1694 +1,1694 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.DrawHelper = void 0;
23
- // inspired by https://github.com/leforthomas/cesium-drawhelper
24
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25
- // @ts-nocheck
26
- var Cesium = __importStar(require("cesium"));
27
- require("./drawHelper.css");
28
- /* eslint-disable */
29
- var DrawHelper = (function () {
30
- // static variables
31
- var ellipsoid = Cesium.Ellipsoid.WGS84;
32
- var drawingVertexColor;
33
- var material = Cesium.Material.fromType(Cesium.Material.ColorType);
34
- // constructor
35
- function _(cesiumWidget, materialClr, drawingVertexClr) {
36
- if (materialClr === void 0) { materialClr = new Cesium.Color(1.0, 1.0, 0.0, 0.5); }
37
- if (drawingVertexClr === void 0) { drawingVertexClr = new Cesium.Color(1.0, 1.0, 1.0, 1.0); }
38
- this._scene = cesiumWidget.scene;
39
- // UPDATE scoped varibles
40
- material.uniforms.color = materialClr;
41
- drawingVertexColor = drawingVertexClr;
42
- //MC_CHANGE disable/override tooltip
43
- this._tooltip = {
44
- setVisible: function () { },
45
- showAt: function () { },
46
- };
47
- // this._tooltip = createTooltip(cesiumWidget.container);
48
- this._surfaces = [];
49
- this.initialiseHandlers();
50
- this.enhancePrimitives();
51
- }
52
- _.prototype.initialiseHandlers = function () {
53
- var scene = this._scene;
54
- var _self = this;
55
- // scene events
56
- var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
57
- function callPrimitiveCallback(name, position) {
58
- if (_self._handlersMuted == true)
59
- return;
60
- var pickedObject = scene.pick(position);
61
- if (pickedObject &&
62
- pickedObject.primitive &&
63
- pickedObject.primitive[name]) {
64
- pickedObject.primitive[name](position);
65
- }
66
- }
67
- handler.setInputAction(function (movement) {
68
- callPrimitiveCallback('leftClick', movement.position);
69
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
70
- handler.setInputAction(function (movement) {
71
- callPrimitiveCallback('leftDoubleClick', movement.position);
72
- }, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
73
- var mouseOutObject;
74
- handler.setInputAction(function (movement) {
75
- if (_self._handlersMuted == true)
76
- return;
77
- var pickedObject = scene.pick(movement.endPosition);
78
- if (mouseOutObject &&
79
- (!pickedObject || mouseOutObject != pickedObject.primitive)) {
80
- !(mouseOutObject.isDestroyed && mouseOutObject.isDestroyed()) &&
81
- mouseOutObject.mouseOut(movement.endPosition);
82
- mouseOutObject = null;
83
- }
84
- if (pickedObject && pickedObject.primitive) {
85
- pickedObject = pickedObject.primitive;
86
- if (pickedObject.mouseOut) {
87
- mouseOutObject = pickedObject;
88
- }
89
- if (pickedObject.mouseMove) {
90
- pickedObject.mouseMove(movement.endPosition);
91
- }
92
- }
93
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
94
- handler.setInputAction(function (movement) {
95
- callPrimitiveCallback('leftUp', movement.position);
96
- }, Cesium.ScreenSpaceEventType.LEFT_UP);
97
- handler.setInputAction(function (movement) {
98
- callPrimitiveCallback('leftDown', movement.position);
99
- }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
100
- };
101
- _.prototype.setListener = function (primitive, type, callback) {
102
- primitive[type] = callback;
103
- };
104
- _.prototype.muteHandlers = function (muted) {
105
- this._handlersMuted = muted;
106
- };
107
- // register event handling for an editable shape
108
- // shape should implement setEditMode and setHighlighted
109
- _.prototype.registerEditableShape = function (surface) {
110
- var _self = this;
111
- // handlers for interactions
112
- // highlight polygon when mouse is entering
113
- setListener(surface, 'mouseMove', function (position) {
114
- surface.setHighlighted(true);
115
- if (!surface._editMode) {
116
- _self._tooltip.showAt(position, 'Click to edit this shape');
117
- }
118
- });
119
- // hide the highlighting when mouse is leaving the polygon
120
- setListener(surface, 'mouseOut', function (position) {
121
- surface.setHighlighted(false);
122
- _self._tooltip.setVisible(false);
123
- });
124
- setListener(surface, 'leftClick', function (position) {
125
- surface.setEditMode(true);
126
- });
127
- };
128
- _.prototype.startDrawing = function (cleanUp) {
129
- // undo any current edit of shapes
130
- this.disableAllEditMode();
131
- // check for cleanUp first
132
- if (this.editCleanUp) {
133
- this.editCleanUp();
134
- }
135
- this.editCleanUp = cleanUp;
136
- this.muteHandlers(true);
137
- };
138
- _.prototype.stopDrawing = function () {
139
- // check for cleanUp first
140
- if (this.editCleanUp) {
141
- this.editCleanUp();
142
- this.editCleanUp = null;
143
- }
144
- this.muteHandlers(false);
145
- };
146
- // make sure only one shape is highlighted at a time
147
- _.prototype.disableAllHighlights = function () {
148
- this.setHighlighted(undefined);
149
- };
150
- _.prototype.setHighlighted = function (surface) {
151
- if (this._highlightedSurface &&
152
- !this._highlightedSurface.isDestroyed() &&
153
- this._highlightedSurface != surface) {
154
- this._highlightedSurface.setHighlighted(false);
155
- }
156
- this._highlightedSurface = surface;
157
- };
158
- _.prototype.disableAllEditMode = function () {
159
- this.setEdited(undefined);
160
- };
161
- _.prototype.setEdited = function (surface) {
162
- if (this._editedSurface && !this._editedSurface.isDestroyed()) {
163
- this._editedSurface.setEditMode(false);
164
- }
165
- this._editedSurface = surface;
166
- };
167
- var defaultShapeOptions = {
168
- ellipsoid: Cesium.Ellipsoid.WGS84,
169
- textureRotationAngle: 0.0,
170
- height: 0.0,
171
- asynchronous: true,
172
- show: true,
173
- debugShowBoundingVolume: false,
174
- };
175
- var defaultSurfaceOptions = copyOptions(defaultShapeOptions, {
176
- appearance: new Cesium.EllipsoidSurfaceAppearance({
177
- aboveGround: false,
178
- }),
179
- material: material,
180
- granularity: Math.PI / 180.0,
181
- });
182
- var defaultPolygonOptions = copyOptions(defaultShapeOptions, {});
183
- var defaultExtentOptions = copyOptions(defaultShapeOptions, {});
184
- var defaultCircleOptions = copyOptions(defaultShapeOptions, {});
185
- var defaultEllipseOptions = copyOptions(defaultSurfaceOptions, {
186
- rotation: 0,
187
- });
188
- var defaultPolylineOptions = copyOptions(defaultShapeOptions, {
189
- width: 5,
190
- geodesic: true,
191
- granularity: 10000,
192
- appearance: new Cesium.PolylineMaterialAppearance({
193
- aboveGround: false,
194
- }),
195
- material: material,
196
- });
197
- // Cesium.Polygon.prototype.setStrokeStyle = setStrokeStyle;
198
- //
199
- // Cesium.Polygon.prototype.drawOutline = drawOutline;
200
- //
201
- var ChangeablePrimitive = (function () {
202
- function _() { }
203
- _.prototype.initialiseOptions = function (options) {
204
- fillOptions(this, options);
205
- this._ellipsoid = undefined;
206
- this._granularity = undefined;
207
- this._height = undefined;
208
- this._textureRotationAngle = undefined;
209
- this._id = undefined;
210
- // set the flags to initiate a first drawing
211
- this._createPrimitive = true;
212
- this._primitive = undefined;
213
- this._outlinePolygon = undefined;
214
- };
215
- _.prototype.setAttribute = function (name, value) {
216
- this[name] = value;
217
- this._createPrimitive = true;
218
- };
219
- _.prototype.getAttribute = function (name) {
220
- return this[name];
221
- };
222
- /**
223
- * @private
224
- */
225
- _.prototype.update = function (context, frameState, commandList) {
226
- if (!Cesium.defined(this.ellipsoid)) {
227
- throw new Cesium.DeveloperError('this.ellipsoid must be defined.');
228
- }
229
- if (!Cesium.defined(this.appearance)) {
230
- throw new Cesium.DeveloperError('this.material must be defined.');
231
- }
232
- if (this.granularity < 0.0) {
233
- throw new Cesium.DeveloperError('this.granularity and scene2D/scene3D overrides must be greater than zero.');
234
- }
235
- if (!this.show) {
236
- return;
237
- }
238
- if (!this._createPrimitive && !Cesium.defined(this._primitive)) {
239
- // No positions/hierarchy to draw
240
- return;
241
- }
242
- if (this._createPrimitive ||
243
- this._ellipsoid !== this.ellipsoid ||
244
- this._granularity !== this.granularity ||
245
- this._height !== this.height ||
246
- this._textureRotationAngle !== this.textureRotationAngle ||
247
- this._id !== this.id) {
248
- var geometry = this.getGeometry();
249
- if (!geometry) {
250
- return;
251
- }
252
- this._createPrimitive = false;
253
- this._ellipsoid = this.ellipsoid;
254
- this._granularity = this.granularity;
255
- this._height = this.height;
256
- this._textureRotationAngle = this.textureRotationAngle;
257
- this._id = this.id;
258
- this._primitive = this._primitive && this._primitive.destroy();
259
- this._primitive = new Cesium.Primitive({
260
- geometryInstances: new Cesium.GeometryInstance({
261
- geometry: geometry,
262
- id: this.id,
263
- pickPrimitive: this,
264
- }),
265
- appearance: this.appearance,
266
- asynchronous: this.asynchronous,
267
- });
268
- this._outlinePolygon =
269
- this._outlinePolygon && this._outlinePolygon.destroy();
270
- if (this.strokeColor && this.getOutlineGeometry) {
271
- // create the highlighting frame
272
- this._outlinePolygon = new Cesium.Primitive({
273
- geometryInstances: new Cesium.GeometryInstance({
274
- geometry: this.getOutlineGeometry(),
275
- attributes: {
276
- color: Cesium.ColorGeometryInstanceAttribute.fromColor(this.strokeColor),
277
- },
278
- }),
279
- appearance: new Cesium.PerInstanceColorAppearance({
280
- flat: true,
281
- renderState: {
282
- depthTest: {
283
- enabled: true,
284
- },
285
- //MC_CHANGE
286
- lineWidth: this.strokeWidth || 4.0,
287
- // lineWidth : Math.min(this.strokeWidth || 4.0, context._aliasedLineWidthRange[1])
288
- },
289
- }),
290
- });
291
- }
292
- }
293
- var primitive = this._primitive;
294
- primitive.appearance.material = this.material;
295
- primitive.debugShowBoundingVolume = this.debugShowBoundingVolume;
296
- primitive.update(context, frameState, commandList);
297
- this._outlinePolygon &&
298
- this._outlinePolygon.update(context, frameState, commandList);
299
- };
300
- _.prototype.isDestroyed = function () {
301
- return false;
302
- };
303
- _.prototype.destroy = function () {
304
- this._primitive = this._primitive && this._primitive.destroy();
305
- return Cesium.destroyObject(this);
306
- };
307
- _.prototype.setStrokeStyle = function (strokeColor, strokeWidth) {
308
- if (!this.strokeColor ||
309
- !this.strokeColor.equals(strokeColor) ||
310
- this.strokeWidth != strokeWidth) {
311
- this._createPrimitive = true;
312
- this.strokeColor = strokeColor;
313
- this.strokeWidth = strokeWidth;
314
- }
315
- };
316
- return _;
317
- })();
318
- _.ExtentPrimitive = (function () {
319
- function _(options) {
320
- if (!Cesium.defined(options.extent)) {
321
- throw new Cesium.DeveloperError('Extent is required');
322
- }
323
- options = copyOptions(options, defaultSurfaceOptions);
324
- this.initialiseOptions(options);
325
- this.setExtent(options.extent);
326
- }
327
- _.prototype = new ChangeablePrimitive();
328
- _.prototype.setExtent = function (extent) {
329
- this.setAttribute('extent', extent);
330
- };
331
- _.prototype.getExtent = function () {
332
- return this.getAttribute('extent');
333
- };
334
- _.prototype.getGeometry = function () {
335
- if (!Cesium.defined(this.extent)) {
336
- return;
337
- }
338
- return new Cesium.RectangleGeometry({
339
- rectangle: this.extent,
340
- height: this.height,
341
- vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
342
- stRotation: this.textureRotationAngle,
343
- ellipsoid: this.ellipsoid,
344
- granularity: this.granularity,
345
- });
346
- };
347
- _.prototype.getOutlineGeometry = function () {
348
- return new Cesium.RectangleOutlineGeometry({
349
- rectangle: this.extent,
350
- });
351
- };
352
- return _;
353
- })();
354
- _.PolygonPrimitive = (function () {
355
- function _(options) {
356
- options = copyOptions(options, defaultSurfaceOptions);
357
- this.initialiseOptions(options);
358
- this.isPolygon = true;
359
- }
360
- _.prototype = new ChangeablePrimitive();
361
- _.prototype.setPositions = function (positions) {
362
- this.setAttribute('positions', positions);
363
- };
364
- _.prototype.getPositions = function () {
365
- return this.getAttribute('positions');
366
- };
367
- _.prototype.getGeometry = function () {
368
- if (!Cesium.defined(this.positions) || this.positions.length < 3) {
369
- return;
370
- }
371
- return Cesium.PolygonGeometry.fromPositions({
372
- positions: this.positions,
373
- height: this.height,
374
- vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
375
- stRotation: this.textureRotationAngle,
376
- ellipsoid: this.ellipsoid,
377
- granularity: this.granularity,
378
- });
379
- };
380
- _.prototype.getOutlineGeometry = function () {
381
- return Cesium.PolygonOutlineGeometry.fromPositions({
382
- positions: this.getPositions(),
383
- });
384
- };
385
- return _;
386
- })();
387
- _.CirclePrimitive = (function () {
388
- function _(options) {
389
- if (!(Cesium.defined(options.center) && Cesium.defined(options.radius))) {
390
- throw new Cesium.DeveloperError('Center and radius are required');
391
- }
392
- options = copyOptions(options, defaultSurfaceOptions);
393
- this.initialiseOptions(options);
394
- this.setRadius(options.radius);
395
- }
396
- _.prototype = new ChangeablePrimitive();
397
- _.prototype.setCenter = function (center) {
398
- this.setAttribute('center', center);
399
- };
400
- _.prototype.setRadius = function (radius) {
401
- this.setAttribute('radius', Math.max(0.1, radius));
402
- };
403
- _.prototype.getCenter = function () {
404
- return this.getAttribute('center');
405
- };
406
- _.prototype.getRadius = function () {
407
- return this.getAttribute('radius');
408
- };
409
- _.prototype.getGeometry = function () {
410
- if (!(Cesium.defined(this.center) && Cesium.defined(this.radius))) {
411
- return;
412
- }
413
- return new Cesium.CircleGeometry({
414
- center: this.center,
415
- radius: this.radius,
416
- height: this.height,
417
- vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
418
- stRotation: this.textureRotationAngle,
419
- ellipsoid: this.ellipsoid,
420
- granularity: this.granularity,
421
- });
422
- };
423
- _.prototype.getOutlineGeometry = function () {
424
- return new Cesium.CircleOutlineGeometry({
425
- center: this.getCenter(),
426
- radius: this.getRadius(),
427
- });
428
- };
429
- return _;
430
- })();
431
- _.EllipsePrimitive = (function () {
432
- function _(options) {
433
- if (!(Cesium.defined(options.center) &&
434
- Cesium.defined(options.semiMajorAxis) &&
435
- Cesium.defined(options.semiMinorAxis))) {
436
- throw new Cesium.DeveloperError('Center and semi major and semi minor axis are required');
437
- }
438
- options = copyOptions(options, defaultEllipseOptions);
439
- this.initialiseOptions(options);
440
- }
441
- _.prototype = new ChangeablePrimitive();
442
- _.prototype.setCenter = function (center) {
443
- this.setAttribute('center', center);
444
- };
445
- _.prototype.setSemiMajorAxis = function (semiMajorAxis) {
446
- if (semiMajorAxis < this.getSemiMinorAxis())
447
- return;
448
- this.setAttribute('semiMajorAxis', semiMajorAxis);
449
- };
450
- _.prototype.setSemiMinorAxis = function (semiMinorAxis) {
451
- if (semiMinorAxis > this.getSemiMajorAxis())
452
- return;
453
- this.setAttribute('semiMinorAxis', semiMinorAxis);
454
- };
455
- _.prototype.setRotation = function (rotation) {
456
- return this.setAttribute('rotation', rotation);
457
- };
458
- _.prototype.getCenter = function () {
459
- return this.getAttribute('center');
460
- };
461
- _.prototype.getSemiMajorAxis = function () {
462
- return this.getAttribute('semiMajorAxis');
463
- };
464
- _.prototype.getSemiMinorAxis = function () {
465
- return this.getAttribute('semiMinorAxis');
466
- };
467
- _.prototype.getRotation = function () {
468
- return this.getAttribute('rotation');
469
- };
470
- _.prototype.getGeometry = function () {
471
- if (!(Cesium.defined(this.center) &&
472
- Cesium.defined(this.semiMajorAxis) &&
473
- Cesium.defined(this.semiMinorAxis))) {
474
- return;
475
- }
476
- return new Cesium.EllipseGeometry({
477
- ellipsoid: this.ellipsoid,
478
- center: this.center,
479
- semiMajorAxis: this.semiMajorAxis,
480
- semiMinorAxis: this.semiMinorAxis,
481
- rotation: this.rotation,
482
- height: this.height,
483
- vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
484
- stRotation: this.textureRotationAngle,
485
- ellipsoid: this.ellipsoid,
486
- granularity: this.granularity,
487
- });
488
- };
489
- _.prototype.getOutlineGeometry = function () {
490
- return new Cesium.EllipseOutlineGeometry({
491
- center: this.getCenter(),
492
- semiMajorAxis: this.getSemiMajorAxis(),
493
- semiMinorAxis: this.getSemiMinorAxis(),
494
- rotation: this.getRotation(),
495
- });
496
- };
497
- return _;
498
- })();
499
- _.PolylinePrimitive = (function () {
500
- function _(options) {
501
- options = copyOptions(options, defaultPolylineOptions);
502
- this.initialiseOptions(options);
503
- }
504
- _.prototype = new ChangeablePrimitive();
505
- _.prototype.setPositions = function (positions) {
506
- this.setAttribute('positions', positions);
507
- };
508
- _.prototype.setWidth = function (width) {
509
- this.setAttribute('width', width);
510
- };
511
- _.prototype.setGeodesic = function (geodesic) {
512
- this.setAttribute('geodesic', geodesic);
513
- };
514
- _.prototype.getPositions = function () {
515
- return this.getAttribute('positions');
516
- };
517
- _.prototype.getWidth = function () {
518
- return this.getAttribute('width');
519
- };
520
- _.prototype.getGeodesic = function (geodesic) {
521
- return this.getAttribute('geodesic');
522
- };
523
- _.prototype.getGeometry = function () {
524
- if (!Cesium.defined(this.positions) || this.positions.length < 2) {
525
- return;
526
- }
527
- return new Cesium.PolylineGeometry({
528
- positions: this.positions,
529
- height: this.height,
530
- width: this.width < 1 ? 1 : this.width,
531
- vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
532
- ellipsoid: this.ellipsoid,
533
- });
534
- };
535
- return _;
536
- })();
537
- var defaultBillboard = {
538
- iconUrl: './assets/img/dragIcon.png',
539
- shiftX: 0,
540
- shiftY: 0,
541
- };
542
- var dragBillboard = {
543
- iconUrl: './assets/img/dragIcon.png',
544
- shiftX: 0,
545
- shiftY: 0,
546
- };
547
- var dragHalfBillboard = {
548
- iconUrl: './assets/img/dragIconLight.png',
549
- shiftX: 0,
550
- shiftY: 0,
551
- };
552
- _.prototype.createBillboardGroup = function (points, options, callbacks) {
553
- var markers = new _.BillboardGroup(this, options);
554
- markers.addBillboards(points, callbacks);
555
- return markers;
556
- };
557
- _.BillboardGroup = function (drawHelper, options) {
558
- this._drawHelper = drawHelper;
559
- this._scene = drawHelper._scene;
560
- this._options = copyOptions(options, defaultBillboard);
561
- // create one common billboard collection for all billboards
562
- var b = new Cesium.BillboardCollection();
563
- this._scene.primitives.add(b);
564
- this._billboards = b;
565
- // keep an ordered list of billboards
566
- this._orderedBillboards = [];
567
- };
568
- _.BillboardGroup.prototype.createBillboard = function (position, callbacks) {
569
- var billboard = this._billboards.add({
570
- show: true,
571
- position: position,
572
- pixelOffset: new Cesium.Cartesian2(this._options.shiftX, this._options.shiftY),
573
- eyeOffset: new Cesium.Cartesian3(0.0, 0.0, 0.0),
574
- horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
575
- verticalOrigin: Cesium.VerticalOrigin.CENTER,
576
- scale: 1.0,
577
- image: this._options.iconUrl,
578
- color: drawingVertexColor,
579
- });
580
- // if editable
581
- if (callbacks) {
582
- var _self = this;
583
- var screenSpaceCameraController = this._scene.screenSpaceCameraController;
584
- function enableRotation(enable) {
585
- screenSpaceCameraController.enableRotate = enable;
586
- }
587
- function getIndex() {
588
- // find index
589
- for (var i = 0, I = _self._orderedBillboards.length; i < I && _self._orderedBillboards[i] != billboard; ++i)
590
- ;
591
- return i;
592
- }
593
- if (callbacks.dragHandlers) {
594
- var _self = this;
595
- setListener(billboard, 'leftDown', function (position) {
596
- // TODO - start the drag handlers here
597
- // create handlers for mouseOut and leftUp for the billboard and a mouseMove
598
- function onDrag(position) {
599
- billboard.position = position;
600
- // find index
601
- for (var i = 0, I = _self._orderedBillboards.length; i < I && _self._orderedBillboards[i] != billboard; ++i)
602
- ;
603
- callbacks.dragHandlers.onDrag &&
604
- callbacks.dragHandlers.onDrag(getIndex(), position);
605
- }
606
- function onDragEnd(position) {
607
- handler.destroy();
608
- enableRotation(true);
609
- callbacks.dragHandlers.onDragEnd &&
610
- callbacks.dragHandlers.onDragEnd(getIndex(), position);
611
- }
612
- var handler = new Cesium.ScreenSpaceEventHandler(_self._scene.canvas);
613
- handler.setInputAction(function (movement) {
614
- var cartesian = _self._scene.camera.pickEllipsoid(movement.endPosition, ellipsoid);
615
- if (cartesian) {
616
- onDrag(cartesian);
617
- }
618
- else {
619
- onDragEnd(cartesian);
620
- }
621
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
622
- handler.setInputAction(function (movement) {
623
- onDragEnd(_self._scene.camera.pickEllipsoid(movement.position, ellipsoid));
624
- }, Cesium.ScreenSpaceEventType.LEFT_UP);
625
- enableRotation(false);
626
- callbacks.dragHandlers.onDragStart &&
627
- callbacks.dragHandlers.onDragStart(getIndex(), _self._scene.camera.pickEllipsoid(position, ellipsoid));
628
- });
629
- }
630
- if (callbacks.onDoubleClick) {
631
- setListener(billboard, 'leftDoubleClick', function (position) {
632
- callbacks.onDoubleClick(getIndex());
633
- });
634
- }
635
- if (callbacks.onClick) {
636
- setListener(billboard, 'leftClick', function (position) {
637
- callbacks.onClick(getIndex());
638
- });
639
- }
640
- if (callbacks.tooltip) {
641
- setListener(billboard, 'mouseMove', function (position) {
642
- _self._drawHelper._tooltip.showAt(position, callbacks.tooltip());
643
- });
644
- setListener(billboard, 'mouseOut', function (position) {
645
- _self._drawHelper._tooltip.setVisible(false);
646
- });
647
- }
648
- }
649
- return billboard;
650
- };
651
- _.BillboardGroup.prototype.insertBillboard = function (index, position, callbacks) {
652
- this._orderedBillboards.splice(index, 0, this.createBillboard(position, callbacks));
653
- };
654
- _.BillboardGroup.prototype.addBillboard = function (position, callbacks) {
655
- this._orderedBillboards.push(this.createBillboard(position, callbacks));
656
- };
657
- _.BillboardGroup.prototype.addBillboards = function (positions, callbacks) {
658
- var index = 0;
659
- for (; index < positions.length; index++) {
660
- this.addBillboard(positions[index], callbacks);
661
- }
662
- };
663
- _.BillboardGroup.prototype.updateBillboardsPositions = function (positions) {
664
- var index = 0;
665
- for (; index < positions.length; index++) {
666
- this.getBillboard(index).position = positions[index];
667
- }
668
- };
669
- _.BillboardGroup.prototype.countBillboards = function () {
670
- return this._orderedBillboards.length;
671
- };
672
- _.BillboardGroup.prototype.getBillboard = function (index) {
673
- return this._orderedBillboards[index];
674
- };
675
- _.BillboardGroup.prototype.removeBillboard = function (index) {
676
- this._billboards.remove(this.getBillboard(index));
677
- this._orderedBillboards.splice(index, 1);
678
- };
679
- _.BillboardGroup.prototype.remove = function () {
680
- this._billboards =
681
- this._billboards &&
682
- this._billboards.removeAll() &&
683
- this._billboards.destroy();
684
- };
685
- _.BillboardGroup.prototype.setOnTop = function () {
686
- this._scene.primitives.raiseToTop(this._billboards);
687
- };
688
- _.prototype.startDrawingMarker = function (options) {
689
- var options = copyOptions(options, defaultBillboard);
690
- this.startDrawing(function () {
691
- markers.remove();
692
- mouseHandler.destroy();
693
- tooltip.setVisible(false);
694
- });
695
- var _self = this;
696
- var scene = this._scene;
697
- var primitives = scene.primitives;
698
- var tooltip = this._tooltip;
699
- var markers = new _.BillboardGroup(this, options);
700
- var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
701
- // Now wait for start
702
- mouseHandler.setInputAction(function (movement) {
703
- if (movement.position != null) {
704
- var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
705
- if (cartesian) {
706
- markers.addBillboard(cartesian);
707
- _self.stopDrawing();
708
- options.callback(cartesian);
709
- }
710
- }
711
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
712
- mouseHandler.setInputAction(function (movement) {
713
- var position = movement.endPosition;
714
- if (position != null) {
715
- var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
716
- if (cartesian) {
717
- tooltip.showAt(position, '<p>Click to add your marker. Position is: </p>' +
718
- getDisplayLatLngString(ellipsoid.cartesianToCartographic(cartesian)));
719
- }
720
- else {
721
- tooltip.showAt(position, '<p>Click on the globe to add your marker.</p>');
722
- }
723
- }
724
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
725
- };
726
- _.prototype.startDrawingPolygon = function (options) {
727
- var options = copyOptions(options, defaultSurfaceOptions);
728
- this.startDrawingPolyshape(true, options);
729
- };
730
- _.prototype.startDrawingPolyline = function (options) {
731
- var options = copyOptions(options, defaultPolylineOptions);
732
- this.startDrawingPolyshape(false, options);
733
- };
734
- _.prototype.startDrawingPolyshape = function (isPolygon, options) {
735
- this.startDrawing(function () {
736
- primitives.remove(poly);
737
- markers.remove();
738
- mouseHandler.destroy();
739
- tooltip.setVisible(false);
740
- unsetDrawCursor(scene);
741
- });
742
- var _self = this;
743
- var scene = this._scene;
744
- var primitives = scene.primitives;
745
- var tooltip = this._tooltip;
746
- var minPoints = isPolygon ? 3 : 2;
747
- var poly;
748
- if (isPolygon) {
749
- poly = new DrawHelper.PolygonPrimitive(options);
750
- }
751
- else {
752
- poly = new DrawHelper.PolylinePrimitive(options);
753
- }
754
- poly.asynchronous = false;
755
- primitives.add(poly);
756
- var positions = [];
757
- var markers = new _.BillboardGroup(this, defaultBillboard);
758
- var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
759
- setDrawCursor(scene);
760
- // Now wait for start
761
- mouseHandler.setInputAction(function (movement) {
762
- if (movement.position != null) {
763
- var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
764
- if (cartesian) {
765
- // first click
766
- if (positions.length == 0) {
767
- positions.push(cartesian.clone());
768
- markers.addBillboard(positions[0]);
769
- }
770
- if (positions.length >= minPoints) {
771
- poly.positions = positions;
772
- poly._createPrimitive = true;
773
- }
774
- // add new point to polygon
775
- // this one will move with the mouse
776
- positions.push(cartesian);
777
- // add marker at the new position
778
- markers.addBillboard(cartesian);
779
- }
780
- }
781
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
782
- mouseHandler.setInputAction(function (movement) {
783
- var position = movement.endPosition;
784
- if (position != null) {
785
- if (positions.length == 0) {
786
- tooltip.showAt(position, '<p>Click to add first point</p>');
787
- }
788
- else {
789
- var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
790
- if (cartesian) {
791
- positions.pop();
792
- // make sure it is slightly different
793
- cartesian.y += 1 + Math.random();
794
- positions.push(cartesian);
795
- if (positions.length >= minPoints) {
796
- poly.positions = positions;
797
- poly._createPrimitive = true;
798
- }
799
- // update marker
800
- markers.getBillboard(positions.length - 1).position = cartesian;
801
- // show tooltip
802
- tooltip.showAt(position, '<p>Click to add new point (' +
803
- positions.length +
804
- ')</p>' +
805
- (positions.length > minPoints
806
- ? '<p>Double click to finish drawing</p>'
807
- : ''));
808
- }
809
- }
810
- }
811
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
812
- mouseHandler.setInputAction(function (movement) {
813
- var position = movement.position;
814
- if (position != null) {
815
- if (positions.length < minPoints + 2) {
816
- return;
817
- }
818
- else {
819
- var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
820
- if (cartesian) {
821
- unsetDrawCursor(scene);
822
- _self.stopDrawing();
823
- if (typeof options.callback == 'function') {
824
- // remove overlapping ones
825
- var index = positions.length - 1;
826
- options.callback(positions);
827
- }
828
- }
829
- }
830
- }
831
- }, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
832
- };
833
- function getExtentCorners(value) {
834
- return ellipsoid.cartographicArrayToCartesianArray([
835
- Cesium.Rectangle.northwest(value),
836
- Cesium.Rectangle.northeast(value),
837
- Cesium.Rectangle.southeast(value),
838
- Cesium.Rectangle.southwest(value),
839
- ]);
840
- }
841
- // MC_CHANGE add to change draw mode cursor
842
- function setDrawCursor(scene) {
843
- if (scene) {
844
- scene.canvas.style.cursor = 'crosshair';
845
- }
846
- }
847
- // MC_CHANGE add to restore regular mode
848
- function unsetDrawCursor(scene) {
849
- if (scene) {
850
- scene.canvas.style.cursor = '';
851
- }
852
- }
853
- _.prototype.startDrawingExtent = function (options) {
854
- var options = copyOptions(options, defaultSurfaceOptions);
855
- this.startDrawing(function () {
856
- if (extent != null) {
857
- primitives.remove(extent);
858
- }
859
- //MC_CHANGE if added
860
- if (markers != null) {
861
- markers.remove();
862
- }
863
- mouseHandler.destroy();
864
- tooltip.setVisible(false);
865
- unsetDrawCursor(scene);
866
- });
867
- var _self = this;
868
- var scene = this._scene;
869
- var primitives = this._scene.primitives;
870
- var tooltip = this._tooltip;
871
- var firstPoint = null;
872
- var extent = null;
873
- var markers = null;
874
- var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
875
- setDrawCursor(scene);
876
- function updateExtent(value) {
877
- if (extent == null) {
878
- //MC_CHANGE
879
- extent = new DrawHelper.ExtentPrimitive({
880
- extent: value,
881
- material: options.material,
882
- });
883
- //extent = new Cesium.RectanglePrimitive();
884
- extent.asynchronous = false;
885
- primitives.add(extent);
886
- }
887
- extent.setExtent(value);
888
- // update the markers
889
- var corners = getExtentCorners(value);
890
- // create if they do not yet exist
891
- if (markers == null) {
892
- markers = new _.BillboardGroup(_self, defaultBillboard);
893
- markers.addBillboards(corners);
894
- }
895
- else {
896
- markers.updateBillboardsPositions(corners);
897
- }
898
- }
899
- // Now wait for start
900
- mouseHandler.setInputAction(function (movement) {
901
- if (movement.position != null) {
902
- var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
903
- if (cartesian) {
904
- if (extent == null) {
905
- // create the rectangle
906
- firstPoint = ellipsoid.cartesianToCartographic(cartesian);
907
- var value = getExtent(firstPoint, firstPoint);
908
- updateExtent(value);
909
- }
910
- else {
911
- _self.stopDrawing();
912
- if (typeof options.callback == 'function') {
913
- options.callback(getExtent(firstPoint, ellipsoid.cartesianToCartographic(cartesian)));
914
- }
915
- }
916
- }
917
- }
918
- }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
919
- mouseHandler.setInputAction(function (movement) {
920
- var position = movement.endPosition;
921
- if (position != null) {
922
- if (extent == null) {
923
- tooltip.showAt(position, '<p>Click to start drawing rectangle</p>');
924
- }
925
- else {
926
- var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
927
- if (cartesian) {
928
- var value = getExtent(firstPoint, ellipsoid.cartesianToCartographic(cartesian));
929
- updateExtent(value);
930
- tooltip.showAt(position, '<p>Drag to change rectangle extent</p><p>Click again to finish drawing</p>');
931
- }
932
- }
933
- }
934
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
935
- };
936
- _.prototype.startDrawingCircle = function (options) {
937
- var options = copyOptions(options, defaultSurfaceOptions);
938
- this.startDrawing(function cleanUp() {
939
- if (circle != null) {
940
- primitives.remove(circle);
941
- }
942
- markers.remove();
943
- mouseHandler.destroy();
944
- tooltip.setVisible(false);
945
- });
946
- var _self = this;
947
- var scene = this._scene;
948
- var primitives = this._scene.primitives;
949
- var tooltip = this._tooltip;
950
- var circle = null;
951
- var markers = null;
952
- var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
953
- // Now wait for start
954
- mouseHandler.setInputAction(function (movement) {
955
- if (movement.position != null) {
956
- var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
957
- if (cartesian) {
958
- if (circle == null) {
959
- // create the circle
960
- circle = new _.CirclePrimitive({
961
- center: cartesian,
962
- radius: 0,
963
- asynchronous: false,
964
- material: options.material,
965
- });
966
- primitives.add(circle);
967
- markers = new _.BillboardGroup(_self, defaultBillboard);
968
- markers.addBillboards([cartesian]);
969
- }
970
- else {
971
- if (typeof options.callback == 'function') {
972
- options.callback(circle.getCenter(), circle.getRadius());
973
- }
974
- _self.stopDrawing();
975
- }
976
- }
977
- }
978
- }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
979
- mouseHandler.setInputAction(function (movement) {
980
- var position = movement.endPosition;
981
- if (position != null) {
982
- if (circle == null) {
983
- tooltip.showAt(position, '<p>Click to start drawing the circle</p>');
984
- }
985
- else {
986
- var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
987
- if (cartesian) {
988
- circle.setRadius(Cesium.Cartesian3.distance(circle.getCenter(), cartesian));
989
- markers.updateBillboardsPositions(cartesian);
990
- tooltip.showAt(position, '<p>Move mouse to change circle radius</p><p>Click again to finish drawing</p>');
991
- }
992
- }
993
- }
994
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
995
- };
996
- _.prototype.enhancePrimitives = function () {
997
- var drawHelper = this;
998
- Cesium.Billboard.prototype.setEditable = function () {
999
- if (this._editable) {
1000
- return;
1001
- }
1002
- this._editable = true;
1003
- var billboard = this;
1004
- var _self = this;
1005
- function enableRotation(enable) {
1006
- drawHelper._scene.screenSpaceCameraController.enableRotate = enable;
1007
- }
1008
- setListener(billboard, 'leftDown', function (position) {
1009
- // TODO - start the drag handlers here
1010
- // create handlers for mouseOut and leftUp for the billboard and a mouseMove
1011
- function onDrag(position) {
1012
- billboard.position = position;
1013
- _self.executeListeners({ name: 'drag', positions: position });
1014
- }
1015
- function onDragEnd(position) {
1016
- handler.destroy();
1017
- enableRotation(true);
1018
- _self.executeListeners({ name: 'dragEnd', positions: position });
1019
- }
1020
- var handler = new Cesium.ScreenSpaceEventHandler(drawHelper._scene.canvas);
1021
- handler.setInputAction(function (movement) {
1022
- var cartesian = drawHelper._scene.camera.pickEllipsoid(movement.endPosition, ellipsoid);
1023
- if (cartesian) {
1024
- onDrag(cartesian);
1025
- }
1026
- else {
1027
- onDragEnd(cartesian);
1028
- }
1029
- }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
1030
- handler.setInputAction(function (movement) {
1031
- onDragEnd(drawHelper._scene.camera.pickEllipsoid(movement.position, ellipsoid));
1032
- }, Cesium.ScreenSpaceEventType.LEFT_UP);
1033
- enableRotation(false);
1034
- });
1035
- enhanceWithListeners(billboard);
1036
- };
1037
- function setHighlighted(highlighted) {
1038
- var scene = drawHelper._scene;
1039
- // if no change
1040
- // if already highlighted, the outline polygon will be available
1041
- if (this._highlighted && this._highlighted == highlighted) {
1042
- return;
1043
- }
1044
- // disable if already in edit mode
1045
- if (this._editMode === true) {
1046
- return;
1047
- }
1048
- this._highlighted = highlighted;
1049
- // highlight by creating an outline polygon matching the polygon points
1050
- if (highlighted) {
1051
- // make sure all other shapes are not highlighted
1052
- drawHelper.setHighlighted(this);
1053
- this._strokeColor = this.strokeColor;
1054
- this.setStrokeStyle(Cesium.Color.fromCssColorString('white'), this.strokeWidth);
1055
- }
1056
- else {
1057
- if (this._strokeColor) {
1058
- this.setStrokeStyle(this._strokeColor, this.strokeWidth);
1059
- }
1060
- else {
1061
- this.setStrokeStyle(undefined, undefined);
1062
- }
1063
- }
1064
- }
1065
- function setEditMode(editMode) {
1066
- // if no change
1067
- if (this._editMode == editMode) {
1068
- return;
1069
- }
1070
- // make sure all other shapes are not in edit mode before starting the editing of this shape
1071
- drawHelper.disableAllHighlights();
1072
- // display markers
1073
- if (editMode) {
1074
- drawHelper.setEdited(this);
1075
- var scene = drawHelper._scene;
1076
- var _self = this;
1077
- // create the markers and handlers for the editing
1078
- if (this._markers == null) {
1079
- var markers = new _.BillboardGroup(drawHelper, dragBillboard);
1080
- var editMarkers = new _.BillboardGroup(drawHelper, dragHalfBillboard);
1081
- // function for updating the edit markers around a certain point
1082
- function updateHalfMarkers(index, positions) {
1083
- // update the half markers before and after the index
1084
- var editIndex = index - 1 < 0 ? positions.length - 1 : index - 1;
1085
- if (editIndex < editMarkers.countBillboards()) {
1086
- editMarkers.getBillboard(editIndex).position = calculateHalfMarkerPosition(editIndex);
1087
- }
1088
- editIndex = index;
1089
- if (editIndex < editMarkers.countBillboards()) {
1090
- editMarkers.getBillboard(editIndex).position = calculateHalfMarkerPosition(editIndex);
1091
- }
1092
- }
1093
- function onEdited() {
1094
- _self.executeListeners({
1095
- name: 'onEdited',
1096
- positions: _self.positions,
1097
- });
1098
- }
1099
- var handleMarkerChanges = {
1100
- dragHandlers: {
1101
- onDrag: function (index, position) {
1102
- _self.positions[index] = position;
1103
- updateHalfMarkers(index, _self.positions);
1104
- _self._createPrimitive = true;
1105
- },
1106
- onDragEnd: function (index, position) {
1107
- _self._createPrimitive = true;
1108
- onEdited();
1109
- },
1110
- },
1111
- onDoubleClick: function (index) {
1112
- if (_self.positions.length < 4) {
1113
- return;
1114
- }
1115
- // remove the point and the corresponding markers
1116
- _self.positions.splice(index, 1);
1117
- _self._createPrimitive = true;
1118
- markers.removeBillboard(index);
1119
- editMarkers.removeBillboard(index);
1120
- updateHalfMarkers(index, _self.positions);
1121
- onEdited();
1122
- },
1123
- tooltip: function () {
1124
- if (_self.positions.length > 3) {
1125
- return 'Double click to remove this point';
1126
- }
1127
- },
1128
- };
1129
- // add billboards and keep an ordered list of them for the polygon edges
1130
- markers.addBillboards(_self.positions, handleMarkerChanges);
1131
- this._markers = markers;
1132
- function calculateHalfMarkerPosition(index) {
1133
- var positions = _self.positions;
1134
- return ellipsoid.cartographicToCartesian(new Cesium.EllipsoidGeodesic(ellipsoid.cartesianToCartographic(positions[index]), ellipsoid.cartesianToCartographic(positions[index < positions.length - 1 ? index + 1 : 0])).interpolateUsingFraction(0.5));
1135
- }
1136
- var halfPositions = [];
1137
- var index = 0;
1138
- var length = _self.positions.length + (this.isPolygon ? 0 : -1);
1139
- for (; index < length; index++) {
1140
- halfPositions.push(calculateHalfMarkerPosition(index));
1141
- }
1142
- var handleEditMarkerChanges = {
1143
- dragHandlers: {
1144
- onDragStart: function (index, position) {
1145
- // add a new position to the polygon but not a new marker yet
1146
- this.index = index + 1;
1147
- _self.positions.splice(this.index, 0, position);
1148
- _self._createPrimitive = true;
1149
- },
1150
- onDrag: function (index, position) {
1151
- _self.positions[this.index] = position;
1152
- _self._createPrimitive = true;
1153
- },
1154
- onDragEnd: function (index, position) {
1155
- // create new sets of makers for editing
1156
- markers.insertBillboard(this.index, position, handleMarkerChanges);
1157
- editMarkers.getBillboard(this.index - 1).position = calculateHalfMarkerPosition(this.index - 1);
1158
- editMarkers.insertBillboard(this.index, calculateHalfMarkerPosition(this.index), handleEditMarkerChanges);
1159
- _self._createPrimitive = true;
1160
- onEdited();
1161
- },
1162
- },
1163
- tooltip: function () {
1164
- return 'Drag to create a new point';
1165
- },
1166
- };
1167
- editMarkers.addBillboards(halfPositions, handleEditMarkerChanges);
1168
- this._editMarkers = editMarkers;
1169
- // add a handler for clicking in the globe
1170
- this._globeClickhandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
1171
- this._globeClickhandler.setInputAction(function (movement) {
1172
- var pickedObject = scene.pick(movement.position);
1173
- if (!(pickedObject && pickedObject.primitive)) {
1174
- _self.setEditMode(false);
1175
- }
1176
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1177
- // set on top of the polygon
1178
- markers.setOnTop();
1179
- editMarkers.setOnTop();
1180
- }
1181
- this._editMode = true;
1182
- }
1183
- else {
1184
- if (this._markers != null) {
1185
- this._markers.remove();
1186
- this._editMarkers.remove();
1187
- this._markers = null;
1188
- this._editMarkers = null;
1189
- this._globeClickhandler.destroy();
1190
- }
1191
- this._editMode = false;
1192
- }
1193
- }
1194
- DrawHelper.PolylinePrimitive.prototype.setEditable = function () {
1195
- if (this.setEditMode) {
1196
- return;
1197
- }
1198
- var polyline = this;
1199
- polyline.isPolygon = false;
1200
- polyline.asynchronous = false;
1201
- drawHelper.registerEditableShape(polyline);
1202
- polyline.setEditMode = setEditMode;
1203
- var originalWidth = this.width;
1204
- polyline.setHighlighted = function (highlighted) {
1205
- // disable if already in edit mode
1206
- if (this._editMode === true) {
1207
- return;
1208
- }
1209
- if (highlighted) {
1210
- drawHelper.setHighlighted(this);
1211
- this.setWidth(originalWidth * 2);
1212
- }
1213
- else {
1214
- this.setWidth(originalWidth);
1215
- }
1216
- };
1217
- polyline.getExtent = function () {
1218
- return Cesium.Extent.fromCartographicArray(ellipsoid.cartesianArrayToCartographicArray(this.positions));
1219
- };
1220
- enhanceWithListeners(polyline);
1221
- polyline.setEditMode(false);
1222
- };
1223
- DrawHelper.PolygonPrimitive.prototype.setEditable = function () {
1224
- var polygon = this;
1225
- polygon.asynchronous = false;
1226
- var scene = drawHelper._scene;
1227
- drawHelper.registerEditableShape(polygon);
1228
- polygon.setEditMode = setEditMode;
1229
- polygon.setHighlighted = setHighlighted;
1230
- enhanceWithListeners(polygon);
1231
- polygon.setEditMode(false);
1232
- };
1233
- DrawHelper.ExtentPrimitive.prototype.setEditable = function () {
1234
- if (this.setEditMode) {
1235
- return;
1236
- }
1237
- var extent = this;
1238
- var scene = drawHelper._scene;
1239
- drawHelper.registerEditableShape(extent);
1240
- extent.asynchronous = false;
1241
- extent.setEditMode = function (editMode) {
1242
- // if no change
1243
- if (this._editMode == editMode) {
1244
- return;
1245
- }
1246
- drawHelper.disableAllHighlights();
1247
- // display markers
1248
- if (editMode) {
1249
- // make sure all other shapes are not in edit mode before starting the editing of this shape
1250
- drawHelper.setEdited(this);
1251
- // create the markers and handlers for the editing
1252
- if (this._markers == null) {
1253
- var markers = new _.BillboardGroup(drawHelper, dragBillboard);
1254
- function onEdited() {
1255
- extent.executeListeners({
1256
- name: 'onEdited',
1257
- extent: extent.extent,
1258
- });
1259
- }
1260
- var handleMarkerChanges = {
1261
- dragHandlers: {
1262
- onDrag: function (index, position) {
1263
- var corner = markers.getBillboard((index + 2) % 4).position;
1264
- extent.setExtent(getExtent(ellipsoid.cartesianToCartographic(corner), ellipsoid.cartesianToCartographic(position)));
1265
- markers.updateBillboardsPositions(getExtentCorners(extent.extent));
1266
- },
1267
- onDragEnd: function (index, position) {
1268
- onEdited();
1269
- },
1270
- },
1271
- tooltip: function () {
1272
- return 'Drag to change the corners of this extent';
1273
- },
1274
- };
1275
- markers.addBillboards(getExtentCorners(extent.extent), handleMarkerChanges);
1276
- this._markers = markers;
1277
- // add a handler for clicking in the globe
1278
- this._globeClickhandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
1279
- this._globeClickhandler.setInputAction(function (movement) {
1280
- var pickedObject = scene.pick(movement.position);
1281
- // disable edit if pickedobject is different or not an object
1282
- if (!(pickedObject &&
1283
- !pickedObject.isDestroyed() &&
1284
- pickedObject.primitive)) {
1285
- extent.setEditMode(false);
1286
- }
1287
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1288
- // set on top of the polygon
1289
- markers.setOnTop();
1290
- }
1291
- this._editMode = true;
1292
- }
1293
- else {
1294
- if (this._markers != null) {
1295
- this._markers.remove();
1296
- this._markers = null;
1297
- this._globeClickhandler.destroy();
1298
- }
1299
- this._editMode = false;
1300
- }
1301
- };
1302
- extent.setHighlighted = setHighlighted;
1303
- enhanceWithListeners(extent);
1304
- extent.setEditMode(false);
1305
- };
1306
- _.EllipsePrimitive.prototype.setEditable = function () {
1307
- if (this.setEditMode) {
1308
- return;
1309
- }
1310
- var ellipse = this;
1311
- var scene = drawHelper._scene;
1312
- ellipse.asynchronous = false;
1313
- drawHelper.registerEditableShape(ellipse);
1314
- ellipse.setEditMode = function (editMode) {
1315
- // if no change
1316
- if (this._editMode == editMode) {
1317
- return;
1318
- }
1319
- drawHelper.disableAllHighlights();
1320
- // display markers
1321
- if (editMode) {
1322
- // make sure all other shapes are not in edit mode before starting the editing of this shape
1323
- drawHelper.setEdited(this);
1324
- var _self = this;
1325
- // create the markers and handlers for the editing
1326
- if (this._markers == null) {
1327
- var markers = new _.BillboardGroup(drawHelper, dragBillboard);
1328
- function getMarkerPositions() {
1329
- return Cesium.Shapes.computeEllipseBoundary(ellipsoid, ellipse.getCenter(), ellipse.getSemiMajorAxis(), ellipse.getSemiMinorAxis(), ellipse.getRotation() + Math.PI / 2, Math.PI / 2.0).splice(0, 4);
1330
- }
1331
- function onEdited() {
1332
- ellipse.executeListeners({
1333
- name: 'onEdited',
1334
- center: ellipse.getCenter(),
1335
- semiMajorAxis: ellipse.getSemiMajorAxis(),
1336
- semiMinorAxis: ellipse.getSemiMinorAxis(),
1337
- rotation: 0,
1338
- });
1339
- }
1340
- var handleMarkerChanges = {
1341
- dragHandlers: {
1342
- onDrag: function (index, position) {
1343
- var distance = Cesium.Cartesian3.distance(ellipse.getCenter(), position);
1344
- if (index % 2 == 0) {
1345
- ellipse.setSemiMajorAxis(distance);
1346
- }
1347
- else {
1348
- ellipse.setSemiMinorAxis(distance);
1349
- }
1350
- markers.updateBillboardsPositions(getMarkerPositions());
1351
- },
1352
- onDragEnd: function (index, position) {
1353
- onEdited();
1354
- },
1355
- },
1356
- tooltip: function () {
1357
- return 'Drag to change the excentricity and radius';
1358
- },
1359
- };
1360
- markers.addBillboards(getMarkerPositions(), handleMarkerChanges);
1361
- this._markers = markers;
1362
- // add a handler for clicking in the globe
1363
- this._globeClickhandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
1364
- this._globeClickhandler.setInputAction(function (movement) {
1365
- var pickedObject = scene.pick(movement.position);
1366
- if (!(pickedObject && pickedObject.primitive)) {
1367
- _self.setEditMode(false);
1368
- }
1369
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1370
- // set on top of the polygon
1371
- markers.setOnTop();
1372
- }
1373
- this._editMode = true;
1374
- }
1375
- else {
1376
- if (this._markers != null) {
1377
- this._markers.remove();
1378
- this._markers = null;
1379
- this._globeClickhandler.destroy();
1380
- }
1381
- this._editMode = false;
1382
- }
1383
- };
1384
- ellipse.setHighlighted = setHighlighted;
1385
- enhanceWithListeners(ellipse);
1386
- ellipse.setEditMode(false);
1387
- };
1388
- _.CirclePrimitive.prototype.getCircleCartesianCoordinates = function (granularity) {
1389
- var geometry = Cesium.CircleOutlineGeometry.createGeometry(new Cesium.CircleOutlineGeometry({
1390
- ellipsoid: ellipsoid,
1391
- center: this.getCenter(),
1392
- radius: this.getRadius(),
1393
- granularity: granularity,
1394
- }));
1395
- var count = 0, value, values = [];
1396
- for (; count < geometry.attributes.position.values.length; count += 3) {
1397
- value = geometry.attributes.position.values;
1398
- values.push(new Cesium.Cartesian3(value[count], value[count + 1], value[count + 2]));
1399
- }
1400
- return values;
1401
- };
1402
- _.CirclePrimitive.prototype.setEditable = function () {
1403
- if (this.setEditMode) {
1404
- return;
1405
- }
1406
- var circle = this;
1407
- var scene = drawHelper._scene;
1408
- circle.asynchronous = false;
1409
- drawHelper.registerEditableShape(circle);
1410
- circle.setEditMode = function (editMode) {
1411
- // if no change
1412
- if (this._editMode == editMode) {
1413
- return;
1414
- }
1415
- drawHelper.disableAllHighlights();
1416
- // display markers
1417
- if (editMode) {
1418
- // make sure all other shapes are not in edit mode before starting the editing of this shape
1419
- drawHelper.setEdited(this);
1420
- var _self = this;
1421
- // create the markers and handlers for the editing
1422
- if (this._markers == null) {
1423
- var markers = new _.BillboardGroup(drawHelper, dragBillboard);
1424
- function getMarkerPositions() {
1425
- return _self.getCircleCartesianCoordinates(Cesium.Math.PI_OVER_TWO);
1426
- }
1427
- function onEdited() {
1428
- circle.executeListeners({
1429
- name: 'onEdited',
1430
- center: circle.getCenter(),
1431
- radius: circle.getRadius(),
1432
- });
1433
- }
1434
- var handleMarkerChanges = {
1435
- dragHandlers: {
1436
- onDrag: function (index, position) {
1437
- circle.setRadius(Cesium.Cartesian3.distance(circle.getCenter(), position));
1438
- markers.updateBillboardsPositions(getMarkerPositions());
1439
- },
1440
- onDragEnd: function (index, position) {
1441
- onEdited();
1442
- },
1443
- },
1444
- tooltip: function () {
1445
- return 'Drag to change the radius';
1446
- },
1447
- };
1448
- markers.addBillboards(getMarkerPositions(), handleMarkerChanges);
1449
- this._markers = markers;
1450
- // add a handler for clicking in the globe
1451
- this._globeClickhandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
1452
- this._globeClickhandler.setInputAction(function (movement) {
1453
- var pickedObject = scene.pick(movement.position);
1454
- if (!(pickedObject && pickedObject.primitive)) {
1455
- _self.setEditMode(false);
1456
- }
1457
- }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1458
- // set on top of the polygon
1459
- markers.setOnTop();
1460
- }
1461
- this._editMode = true;
1462
- }
1463
- else {
1464
- if (this._markers != null) {
1465
- this._markers.remove();
1466
- this._markers = null;
1467
- this._globeClickhandler.destroy();
1468
- }
1469
- this._editMode = false;
1470
- }
1471
- };
1472
- circle.setHighlighted = setHighlighted;
1473
- enhanceWithListeners(circle);
1474
- circle.setEditMode(false);
1475
- };
1476
- };
1477
- _.DrawHelperWidget = (function () {
1478
- // constructor
1479
- function _(drawHelper, options) {
1480
- // container must be specified
1481
- if (!Cesium.defined(options.container)) {
1482
- throw new Cesium.DeveloperError('Container is required');
1483
- }
1484
- var drawOptions = {
1485
- markerIcon: './assets/img/glyphicons_242_google_maps.png',
1486
- polylineIcon: './assets/img/glyphicons_097_vector_path_line.png',
1487
- polygonIcon: './assets/img/glyphicons_096_vector_path_polygon.png',
1488
- circleIcon: './assets/img/glyphicons_095_vector_path_circle.png',
1489
- extentIcon: './assets/img/glyphicons_094_vector_path_square.png',
1490
- clearIcon: './assets/img/glyphicons_067_cleaning.png',
1491
- polylineDrawingOptions: defaultPolylineOptions,
1492
- polygonDrawingOptions: defaultPolygonOptions,
1493
- extentDrawingOptions: defaultExtentOptions,
1494
- circleDrawingOptions: defaultCircleOptions,
1495
- };
1496
- fillOptions(options, drawOptions);
1497
- var _self = this;
1498
- var toolbar = document.createElement('DIV');
1499
- toolbar.className = 'toolbar';
1500
- options.container.appendChild(toolbar);
1501
- function addIcon(id, url, title, callback) {
1502
- var div = document.createElement('DIV');
1503
- div.className = 'button';
1504
- div.title = title;
1505
- toolbar.appendChild(div);
1506
- div.onclick = callback;
1507
- var span = document.createElement('SPAN');
1508
- div.appendChild(span);
1509
- var image = document.createElement('IMG');
1510
- image.src = url;
1511
- span.appendChild(image);
1512
- return div;
1513
- }
1514
- var scene = drawHelper._scene;
1515
- addIcon('marker', options.markerIcon, 'Click to start drawing a 2D marker', function () {
1516
- drawHelper.startDrawingMarker({
1517
- callback: function (position) {
1518
- _self.executeListeners({
1519
- name: 'markerCreated',
1520
- position: position,
1521
- });
1522
- },
1523
- });
1524
- });
1525
- addIcon('polyline', options.polylineIcon, 'Click to start drawing a 2D polyline', function () {
1526
- drawHelper.startDrawingPolyline({
1527
- callback: function (positions) {
1528
- _self.executeListeners({
1529
- name: 'polylineCreated',
1530
- positions: positions,
1531
- });
1532
- },
1533
- });
1534
- });
1535
- addIcon('polygon', options.polygonIcon, 'Click to start drawing a 2D polygon', function () {
1536
- drawHelper.startDrawingPolygon({
1537
- callback: function (positions) {
1538
- _self.executeListeners({
1539
- name: 'polygonCreated',
1540
- positions: positions,
1541
- });
1542
- },
1543
- });
1544
- });
1545
- addIcon('extent', options.extentIcon, 'Click to start drawing an Extent', function () {
1546
- drawHelper.startDrawingExtent({
1547
- callback: function (extent) {
1548
- _self.executeListeners({ name: 'extentCreated', extent: extent });
1549
- },
1550
- });
1551
- });
1552
- addIcon('circle', options.circleIcon, 'Click to start drawing a Circle', function () {
1553
- drawHelper.startDrawingCircle({
1554
- callback: function (center, radius) {
1555
- _self.executeListeners({
1556
- name: 'circleCreated',
1557
- center: center,
1558
- radius: radius,
1559
- });
1560
- },
1561
- });
1562
- });
1563
- // add a clear button at the end
1564
- // add a divider first
1565
- var div = document.createElement('DIV');
1566
- div.className = 'divider';
1567
- toolbar.appendChild(div);
1568
- addIcon('clear', options.clearIcon, 'Remove all primitives', function () {
1569
- scene.primitives.removeAll();
1570
- });
1571
- enhanceWithListeners(this);
1572
- }
1573
- return _;
1574
- })();
1575
- _.prototype.addToolbar = function (container, options) {
1576
- options = copyOptions(options, { container: container });
1577
- return new _.DrawHelperWidget(this, options);
1578
- };
1579
- function getExtent(mn, mx) {
1580
- var e = new Cesium.Rectangle();
1581
- // Re-order so west < east and south < north
1582
- e.west = Math.min(mn.longitude, mx.longitude);
1583
- e.east = Math.max(mn.longitude, mx.longitude);
1584
- e.south = Math.min(mn.latitude, mx.latitude);
1585
- e.north = Math.max(mn.latitude, mx.latitude);
1586
- // Check for approx equal (shouldn't require abs due to re-order)
1587
- var epsilon = Cesium.Math.EPSILON7;
1588
- if (e.east - e.west < epsilon) {
1589
- e.east += epsilon * 2.0;
1590
- }
1591
- if (e.north - e.south < epsilon) {
1592
- e.north += epsilon * 2.0;
1593
- }
1594
- return e;
1595
- }
1596
- function createTooltip(frameDiv) {
1597
- var tooltip = function (frameDiv) {
1598
- var div = document.createElement('DIV');
1599
- div.className = 'twipsy right';
1600
- var arrow = document.createElement('DIV');
1601
- arrow.className = 'twipsy-arrow';
1602
- div.appendChild(arrow);
1603
- var title = document.createElement('DIV');
1604
- title.className = 'twipsy-inner';
1605
- div.appendChild(title);
1606
- this._div = div;
1607
- this._title = title;
1608
- // add to frame div and display coordinates
1609
- frameDiv.appendChild(div);
1610
- };
1611
- tooltip.prototype.setVisible = function (visible) {
1612
- this._div.style.display = visible ? 'block' : 'none';
1613
- };
1614
- tooltip.prototype.showAt = function (position, message) {
1615
- if (position && message) {
1616
- this.setVisible(true);
1617
- this._title.innerHTML = message;
1618
- this._div.style.left = position.x + 10 + 'px';
1619
- this._div.style.top = position.y - this._div.clientHeight / 2 + 'px';
1620
- }
1621
- };
1622
- return new tooltip(frameDiv);
1623
- }
1624
- function getDisplayLatLngString(cartographic, precision) {
1625
- return (cartographic.longitude.toFixed(precision || 3) +
1626
- ', ' +
1627
- cartographic.latitude.toFixed(precision || 3));
1628
- }
1629
- function clone(from, to) {
1630
- if (from == null || typeof from != 'object')
1631
- return from;
1632
- if (from.constructor != Object && from.constructor != Array)
1633
- return from;
1634
- if (from.constructor == Date ||
1635
- from.constructor == RegExp ||
1636
- from.constructor == Function ||
1637
- from.constructor == String ||
1638
- from.constructor == Number ||
1639
- from.constructor == Boolean)
1640
- return new from.constructor(from);
1641
- to = to || new from.constructor();
1642
- for (var name in from) {
1643
- to[name] =
1644
- typeof to[name] == 'undefined' ? clone(from[name], null) : to[name];
1645
- }
1646
- return to;
1647
- }
1648
- function fillOptions(options, defaultOptions) {
1649
- options = options || {};
1650
- var option;
1651
- for (option in defaultOptions) {
1652
- if (options[option] === undefined) {
1653
- options[option] = clone(defaultOptions[option]);
1654
- }
1655
- }
1656
- }
1657
- // shallow copy
1658
- function copyOptions(options, defaultOptions) {
1659
- var newOptions = clone(options), option;
1660
- for (option in defaultOptions) {
1661
- if (newOptions[option] === undefined) {
1662
- newOptions[option] = clone(defaultOptions[option]);
1663
- }
1664
- }
1665
- return newOptions;
1666
- }
1667
- function setListener(primitive, type, callback) {
1668
- primitive[type] = callback;
1669
- }
1670
- function enhanceWithListeners(element) {
1671
- element._listeners = {};
1672
- element.addListener = function (name, callback) {
1673
- this._listeners[name] = this._listeners[name] || [];
1674
- this._listeners[name].push(callback);
1675
- return this._listeners[name].length;
1676
- };
1677
- element.executeListeners = function (event, defaultCallback) {
1678
- if (this._listeners[event.name] &&
1679
- this._listeners[event.name].length > 0) {
1680
- var index = 0;
1681
- for (; index < this._listeners[event.name].length; index++) {
1682
- this._listeners[event.name][index](event);
1683
- }
1684
- }
1685
- else {
1686
- if (defaultCallback) {
1687
- defaultCallback(event);
1688
- }
1689
- }
1690
- };
1691
- }
1692
- return _;
1693
- })();
1694
- exports.DrawHelper = DrawHelper;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.DrawHelper = void 0;
23
+ // inspired by https://github.com/leforthomas/cesium-drawhelper
24
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25
+ // @ts-nocheck
26
+ var Cesium = __importStar(require("cesium"));
27
+ require("./drawHelper.css");
28
+ /* eslint-disable */
29
+ var DrawHelper = (function () {
30
+ // static variables
31
+ var ellipsoid = Cesium.Ellipsoid.WGS84;
32
+ var drawingVertexColor;
33
+ var material = Cesium.Material.fromType(Cesium.Material.ColorType);
34
+ // constructor
35
+ function _(cesiumWidget, materialClr, drawingVertexClr) {
36
+ if (materialClr === void 0) { materialClr = new Cesium.Color(1.0, 1.0, 0.0, 0.5); }
37
+ if (drawingVertexClr === void 0) { drawingVertexClr = new Cesium.Color(1.0, 1.0, 1.0, 1.0); }
38
+ this._scene = cesiumWidget.scene;
39
+ // UPDATE scoped varibles
40
+ material.uniforms.color = materialClr;
41
+ drawingVertexColor = drawingVertexClr;
42
+ //MC_CHANGE disable/override tooltip
43
+ this._tooltip = {
44
+ setVisible: function () { },
45
+ showAt: function () { },
46
+ };
47
+ // this._tooltip = createTooltip(cesiumWidget.container);
48
+ this._surfaces = [];
49
+ this.initialiseHandlers();
50
+ this.enhancePrimitives();
51
+ }
52
+ _.prototype.initialiseHandlers = function () {
53
+ var scene = this._scene;
54
+ var _self = this;
55
+ // scene events
56
+ var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
57
+ function callPrimitiveCallback(name, position) {
58
+ if (_self._handlersMuted == true)
59
+ return;
60
+ var pickedObject = scene.pick(position);
61
+ if (pickedObject &&
62
+ pickedObject.primitive &&
63
+ pickedObject.primitive[name]) {
64
+ pickedObject.primitive[name](position);
65
+ }
66
+ }
67
+ handler.setInputAction(function (movement) {
68
+ callPrimitiveCallback('leftClick', movement.position);
69
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
70
+ handler.setInputAction(function (movement) {
71
+ callPrimitiveCallback('leftDoubleClick', movement.position);
72
+ }, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
73
+ var mouseOutObject;
74
+ handler.setInputAction(function (movement) {
75
+ if (_self._handlersMuted == true)
76
+ return;
77
+ var pickedObject = scene.pick(movement.endPosition);
78
+ if (mouseOutObject &&
79
+ (!pickedObject || mouseOutObject != pickedObject.primitive)) {
80
+ !(mouseOutObject.isDestroyed && mouseOutObject.isDestroyed()) &&
81
+ mouseOutObject.mouseOut(movement.endPosition);
82
+ mouseOutObject = null;
83
+ }
84
+ if (pickedObject && pickedObject.primitive) {
85
+ pickedObject = pickedObject.primitive;
86
+ if (pickedObject.mouseOut) {
87
+ mouseOutObject = pickedObject;
88
+ }
89
+ if (pickedObject.mouseMove) {
90
+ pickedObject.mouseMove(movement.endPosition);
91
+ }
92
+ }
93
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
94
+ handler.setInputAction(function (movement) {
95
+ callPrimitiveCallback('leftUp', movement.position);
96
+ }, Cesium.ScreenSpaceEventType.LEFT_UP);
97
+ handler.setInputAction(function (movement) {
98
+ callPrimitiveCallback('leftDown', movement.position);
99
+ }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
100
+ };
101
+ _.prototype.setListener = function (primitive, type, callback) {
102
+ primitive[type] = callback;
103
+ };
104
+ _.prototype.muteHandlers = function (muted) {
105
+ this._handlersMuted = muted;
106
+ };
107
+ // register event handling for an editable shape
108
+ // shape should implement setEditMode and setHighlighted
109
+ _.prototype.registerEditableShape = function (surface) {
110
+ var _self = this;
111
+ // handlers for interactions
112
+ // highlight polygon when mouse is entering
113
+ setListener(surface, 'mouseMove', function (position) {
114
+ surface.setHighlighted(true);
115
+ if (!surface._editMode) {
116
+ _self._tooltip.showAt(position, 'Click to edit this shape');
117
+ }
118
+ });
119
+ // hide the highlighting when mouse is leaving the polygon
120
+ setListener(surface, 'mouseOut', function (position) {
121
+ surface.setHighlighted(false);
122
+ _self._tooltip.setVisible(false);
123
+ });
124
+ setListener(surface, 'leftClick', function (position) {
125
+ surface.setEditMode(true);
126
+ });
127
+ };
128
+ _.prototype.startDrawing = function (cleanUp) {
129
+ // undo any current edit of shapes
130
+ this.disableAllEditMode();
131
+ // check for cleanUp first
132
+ if (this.editCleanUp) {
133
+ this.editCleanUp();
134
+ }
135
+ this.editCleanUp = cleanUp;
136
+ this.muteHandlers(true);
137
+ };
138
+ _.prototype.stopDrawing = function () {
139
+ // check for cleanUp first
140
+ if (this.editCleanUp) {
141
+ this.editCleanUp();
142
+ this.editCleanUp = null;
143
+ }
144
+ this.muteHandlers(false);
145
+ };
146
+ // make sure only one shape is highlighted at a time
147
+ _.prototype.disableAllHighlights = function () {
148
+ this.setHighlighted(undefined);
149
+ };
150
+ _.prototype.setHighlighted = function (surface) {
151
+ if (this._highlightedSurface &&
152
+ !this._highlightedSurface.isDestroyed() &&
153
+ this._highlightedSurface != surface) {
154
+ this._highlightedSurface.setHighlighted(false);
155
+ }
156
+ this._highlightedSurface = surface;
157
+ };
158
+ _.prototype.disableAllEditMode = function () {
159
+ this.setEdited(undefined);
160
+ };
161
+ _.prototype.setEdited = function (surface) {
162
+ if (this._editedSurface && !this._editedSurface.isDestroyed()) {
163
+ this._editedSurface.setEditMode(false);
164
+ }
165
+ this._editedSurface = surface;
166
+ };
167
+ var defaultShapeOptions = {
168
+ ellipsoid: Cesium.Ellipsoid.WGS84,
169
+ textureRotationAngle: 0.0,
170
+ height: 0.0,
171
+ asynchronous: true,
172
+ show: true,
173
+ debugShowBoundingVolume: false,
174
+ };
175
+ var defaultSurfaceOptions = copyOptions(defaultShapeOptions, {
176
+ appearance: new Cesium.EllipsoidSurfaceAppearance({
177
+ aboveGround: false,
178
+ }),
179
+ material: material,
180
+ granularity: Math.PI / 180.0,
181
+ });
182
+ var defaultPolygonOptions = copyOptions(defaultShapeOptions, {});
183
+ var defaultExtentOptions = copyOptions(defaultShapeOptions, {});
184
+ var defaultCircleOptions = copyOptions(defaultShapeOptions, {});
185
+ var defaultEllipseOptions = copyOptions(defaultSurfaceOptions, {
186
+ rotation: 0,
187
+ });
188
+ var defaultPolylineOptions = copyOptions(defaultShapeOptions, {
189
+ width: 5,
190
+ geodesic: true,
191
+ granularity: 10000,
192
+ appearance: new Cesium.PolylineMaterialAppearance({
193
+ aboveGround: false,
194
+ }),
195
+ material: material,
196
+ });
197
+ // Cesium.Polygon.prototype.setStrokeStyle = setStrokeStyle;
198
+ //
199
+ // Cesium.Polygon.prototype.drawOutline = drawOutline;
200
+ //
201
+ var ChangeablePrimitive = (function () {
202
+ function _() { }
203
+ _.prototype.initialiseOptions = function (options) {
204
+ fillOptions(this, options);
205
+ this._ellipsoid = undefined;
206
+ this._granularity = undefined;
207
+ this._height = undefined;
208
+ this._textureRotationAngle = undefined;
209
+ this._id = undefined;
210
+ // set the flags to initiate a first drawing
211
+ this._createPrimitive = true;
212
+ this._primitive = undefined;
213
+ this._outlinePolygon = undefined;
214
+ };
215
+ _.prototype.setAttribute = function (name, value) {
216
+ this[name] = value;
217
+ this._createPrimitive = true;
218
+ };
219
+ _.prototype.getAttribute = function (name) {
220
+ return this[name];
221
+ };
222
+ /**
223
+ * @private
224
+ */
225
+ _.prototype.update = function (context, frameState, commandList) {
226
+ if (!Cesium.defined(this.ellipsoid)) {
227
+ throw new Cesium.DeveloperError('this.ellipsoid must be defined.');
228
+ }
229
+ if (!Cesium.defined(this.appearance)) {
230
+ throw new Cesium.DeveloperError('this.material must be defined.');
231
+ }
232
+ if (this.granularity < 0.0) {
233
+ throw new Cesium.DeveloperError('this.granularity and scene2D/scene3D overrides must be greater than zero.');
234
+ }
235
+ if (!this.show) {
236
+ return;
237
+ }
238
+ if (!this._createPrimitive && !Cesium.defined(this._primitive)) {
239
+ // No positions/hierarchy to draw
240
+ return;
241
+ }
242
+ if (this._createPrimitive ||
243
+ this._ellipsoid !== this.ellipsoid ||
244
+ this._granularity !== this.granularity ||
245
+ this._height !== this.height ||
246
+ this._textureRotationAngle !== this.textureRotationAngle ||
247
+ this._id !== this.id) {
248
+ var geometry = this.getGeometry();
249
+ if (!geometry) {
250
+ return;
251
+ }
252
+ this._createPrimitive = false;
253
+ this._ellipsoid = this.ellipsoid;
254
+ this._granularity = this.granularity;
255
+ this._height = this.height;
256
+ this._textureRotationAngle = this.textureRotationAngle;
257
+ this._id = this.id;
258
+ this._primitive = this._primitive && this._primitive.destroy();
259
+ this._primitive = new Cesium.Primitive({
260
+ geometryInstances: new Cesium.GeometryInstance({
261
+ geometry: geometry,
262
+ id: this.id,
263
+ pickPrimitive: this,
264
+ }),
265
+ appearance: this.appearance,
266
+ asynchronous: this.asynchronous,
267
+ });
268
+ this._outlinePolygon =
269
+ this._outlinePolygon && this._outlinePolygon.destroy();
270
+ if (this.strokeColor && this.getOutlineGeometry) {
271
+ // create the highlighting frame
272
+ this._outlinePolygon = new Cesium.Primitive({
273
+ geometryInstances: new Cesium.GeometryInstance({
274
+ geometry: this.getOutlineGeometry(),
275
+ attributes: {
276
+ color: Cesium.ColorGeometryInstanceAttribute.fromColor(this.strokeColor),
277
+ },
278
+ }),
279
+ appearance: new Cesium.PerInstanceColorAppearance({
280
+ flat: true,
281
+ renderState: {
282
+ depthTest: {
283
+ enabled: true,
284
+ },
285
+ //MC_CHANGE
286
+ lineWidth: this.strokeWidth || 4.0,
287
+ // lineWidth : Math.min(this.strokeWidth || 4.0, context._aliasedLineWidthRange[1])
288
+ },
289
+ }),
290
+ });
291
+ }
292
+ }
293
+ var primitive = this._primitive;
294
+ primitive.appearance.material = this.material;
295
+ primitive.debugShowBoundingVolume = this.debugShowBoundingVolume;
296
+ primitive.update(context, frameState, commandList);
297
+ this._outlinePolygon &&
298
+ this._outlinePolygon.update(context, frameState, commandList);
299
+ };
300
+ _.prototype.isDestroyed = function () {
301
+ return false;
302
+ };
303
+ _.prototype.destroy = function () {
304
+ this._primitive = this._primitive && this._primitive.destroy();
305
+ return Cesium.destroyObject(this);
306
+ };
307
+ _.prototype.setStrokeStyle = function (strokeColor, strokeWidth) {
308
+ if (!this.strokeColor ||
309
+ !this.strokeColor.equals(strokeColor) ||
310
+ this.strokeWidth != strokeWidth) {
311
+ this._createPrimitive = true;
312
+ this.strokeColor = strokeColor;
313
+ this.strokeWidth = strokeWidth;
314
+ }
315
+ };
316
+ return _;
317
+ })();
318
+ _.ExtentPrimitive = (function () {
319
+ function _(options) {
320
+ if (!Cesium.defined(options.extent)) {
321
+ throw new Cesium.DeveloperError('Extent is required');
322
+ }
323
+ options = copyOptions(options, defaultSurfaceOptions);
324
+ this.initialiseOptions(options);
325
+ this.setExtent(options.extent);
326
+ }
327
+ _.prototype = new ChangeablePrimitive();
328
+ _.prototype.setExtent = function (extent) {
329
+ this.setAttribute('extent', extent);
330
+ };
331
+ _.prototype.getExtent = function () {
332
+ return this.getAttribute('extent');
333
+ };
334
+ _.prototype.getGeometry = function () {
335
+ if (!Cesium.defined(this.extent)) {
336
+ return;
337
+ }
338
+ return new Cesium.RectangleGeometry({
339
+ rectangle: this.extent,
340
+ height: this.height,
341
+ vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
342
+ stRotation: this.textureRotationAngle,
343
+ ellipsoid: this.ellipsoid,
344
+ granularity: this.granularity,
345
+ });
346
+ };
347
+ _.prototype.getOutlineGeometry = function () {
348
+ return new Cesium.RectangleOutlineGeometry({
349
+ rectangle: this.extent,
350
+ });
351
+ };
352
+ return _;
353
+ })();
354
+ _.PolygonPrimitive = (function () {
355
+ function _(options) {
356
+ options = copyOptions(options, defaultSurfaceOptions);
357
+ this.initialiseOptions(options);
358
+ this.isPolygon = true;
359
+ }
360
+ _.prototype = new ChangeablePrimitive();
361
+ _.prototype.setPositions = function (positions) {
362
+ this.setAttribute('positions', positions);
363
+ };
364
+ _.prototype.getPositions = function () {
365
+ return this.getAttribute('positions');
366
+ };
367
+ _.prototype.getGeometry = function () {
368
+ if (!Cesium.defined(this.positions) || this.positions.length < 3) {
369
+ return;
370
+ }
371
+ return Cesium.PolygonGeometry.fromPositions({
372
+ positions: this.positions,
373
+ height: this.height,
374
+ vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
375
+ stRotation: this.textureRotationAngle,
376
+ ellipsoid: this.ellipsoid,
377
+ granularity: this.granularity,
378
+ });
379
+ };
380
+ _.prototype.getOutlineGeometry = function () {
381
+ return Cesium.PolygonOutlineGeometry.fromPositions({
382
+ positions: this.getPositions(),
383
+ });
384
+ };
385
+ return _;
386
+ })();
387
+ _.CirclePrimitive = (function () {
388
+ function _(options) {
389
+ if (!(Cesium.defined(options.center) && Cesium.defined(options.radius))) {
390
+ throw new Cesium.DeveloperError('Center and radius are required');
391
+ }
392
+ options = copyOptions(options, defaultSurfaceOptions);
393
+ this.initialiseOptions(options);
394
+ this.setRadius(options.radius);
395
+ }
396
+ _.prototype = new ChangeablePrimitive();
397
+ _.prototype.setCenter = function (center) {
398
+ this.setAttribute('center', center);
399
+ };
400
+ _.prototype.setRadius = function (radius) {
401
+ this.setAttribute('radius', Math.max(0.1, radius));
402
+ };
403
+ _.prototype.getCenter = function () {
404
+ return this.getAttribute('center');
405
+ };
406
+ _.prototype.getRadius = function () {
407
+ return this.getAttribute('radius');
408
+ };
409
+ _.prototype.getGeometry = function () {
410
+ if (!(Cesium.defined(this.center) && Cesium.defined(this.radius))) {
411
+ return;
412
+ }
413
+ return new Cesium.CircleGeometry({
414
+ center: this.center,
415
+ radius: this.radius,
416
+ height: this.height,
417
+ vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
418
+ stRotation: this.textureRotationAngle,
419
+ ellipsoid: this.ellipsoid,
420
+ granularity: this.granularity,
421
+ });
422
+ };
423
+ _.prototype.getOutlineGeometry = function () {
424
+ return new Cesium.CircleOutlineGeometry({
425
+ center: this.getCenter(),
426
+ radius: this.getRadius(),
427
+ });
428
+ };
429
+ return _;
430
+ })();
431
+ _.EllipsePrimitive = (function () {
432
+ function _(options) {
433
+ if (!(Cesium.defined(options.center) &&
434
+ Cesium.defined(options.semiMajorAxis) &&
435
+ Cesium.defined(options.semiMinorAxis))) {
436
+ throw new Cesium.DeveloperError('Center and semi major and semi minor axis are required');
437
+ }
438
+ options = copyOptions(options, defaultEllipseOptions);
439
+ this.initialiseOptions(options);
440
+ }
441
+ _.prototype = new ChangeablePrimitive();
442
+ _.prototype.setCenter = function (center) {
443
+ this.setAttribute('center', center);
444
+ };
445
+ _.prototype.setSemiMajorAxis = function (semiMajorAxis) {
446
+ if (semiMajorAxis < this.getSemiMinorAxis())
447
+ return;
448
+ this.setAttribute('semiMajorAxis', semiMajorAxis);
449
+ };
450
+ _.prototype.setSemiMinorAxis = function (semiMinorAxis) {
451
+ if (semiMinorAxis > this.getSemiMajorAxis())
452
+ return;
453
+ this.setAttribute('semiMinorAxis', semiMinorAxis);
454
+ };
455
+ _.prototype.setRotation = function (rotation) {
456
+ return this.setAttribute('rotation', rotation);
457
+ };
458
+ _.prototype.getCenter = function () {
459
+ return this.getAttribute('center');
460
+ };
461
+ _.prototype.getSemiMajorAxis = function () {
462
+ return this.getAttribute('semiMajorAxis');
463
+ };
464
+ _.prototype.getSemiMinorAxis = function () {
465
+ return this.getAttribute('semiMinorAxis');
466
+ };
467
+ _.prototype.getRotation = function () {
468
+ return this.getAttribute('rotation');
469
+ };
470
+ _.prototype.getGeometry = function () {
471
+ if (!(Cesium.defined(this.center) &&
472
+ Cesium.defined(this.semiMajorAxis) &&
473
+ Cesium.defined(this.semiMinorAxis))) {
474
+ return;
475
+ }
476
+ return new Cesium.EllipseGeometry({
477
+ ellipsoid: this.ellipsoid,
478
+ center: this.center,
479
+ semiMajorAxis: this.semiMajorAxis,
480
+ semiMinorAxis: this.semiMinorAxis,
481
+ rotation: this.rotation,
482
+ height: this.height,
483
+ vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
484
+ stRotation: this.textureRotationAngle,
485
+ ellipsoid: this.ellipsoid,
486
+ granularity: this.granularity,
487
+ });
488
+ };
489
+ _.prototype.getOutlineGeometry = function () {
490
+ return new Cesium.EllipseOutlineGeometry({
491
+ center: this.getCenter(),
492
+ semiMajorAxis: this.getSemiMajorAxis(),
493
+ semiMinorAxis: this.getSemiMinorAxis(),
494
+ rotation: this.getRotation(),
495
+ });
496
+ };
497
+ return _;
498
+ })();
499
+ _.PolylinePrimitive = (function () {
500
+ function _(options) {
501
+ options = copyOptions(options, defaultPolylineOptions);
502
+ this.initialiseOptions(options);
503
+ }
504
+ _.prototype = new ChangeablePrimitive();
505
+ _.prototype.setPositions = function (positions) {
506
+ this.setAttribute('positions', positions);
507
+ };
508
+ _.prototype.setWidth = function (width) {
509
+ this.setAttribute('width', width);
510
+ };
511
+ _.prototype.setGeodesic = function (geodesic) {
512
+ this.setAttribute('geodesic', geodesic);
513
+ };
514
+ _.prototype.getPositions = function () {
515
+ return this.getAttribute('positions');
516
+ };
517
+ _.prototype.getWidth = function () {
518
+ return this.getAttribute('width');
519
+ };
520
+ _.prototype.getGeodesic = function (geodesic) {
521
+ return this.getAttribute('geodesic');
522
+ };
523
+ _.prototype.getGeometry = function () {
524
+ if (!Cesium.defined(this.positions) || this.positions.length < 2) {
525
+ return;
526
+ }
527
+ return new Cesium.PolylineGeometry({
528
+ positions: this.positions,
529
+ height: this.height,
530
+ width: this.width < 1 ? 1 : this.width,
531
+ vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
532
+ ellipsoid: this.ellipsoid,
533
+ });
534
+ };
535
+ return _;
536
+ })();
537
+ var defaultBillboard = {
538
+ iconUrl: './assets/img/dragIcon.png',
539
+ shiftX: 0,
540
+ shiftY: 0,
541
+ };
542
+ var dragBillboard = {
543
+ iconUrl: './assets/img/dragIcon.png',
544
+ shiftX: 0,
545
+ shiftY: 0,
546
+ };
547
+ var dragHalfBillboard = {
548
+ iconUrl: './assets/img/dragIconLight.png',
549
+ shiftX: 0,
550
+ shiftY: 0,
551
+ };
552
+ _.prototype.createBillboardGroup = function (points, options, callbacks) {
553
+ var markers = new _.BillboardGroup(this, options);
554
+ markers.addBillboards(points, callbacks);
555
+ return markers;
556
+ };
557
+ _.BillboardGroup = function (drawHelper, options) {
558
+ this._drawHelper = drawHelper;
559
+ this._scene = drawHelper._scene;
560
+ this._options = copyOptions(options, defaultBillboard);
561
+ // create one common billboard collection for all billboards
562
+ var b = new Cesium.BillboardCollection();
563
+ this._scene.primitives.add(b);
564
+ this._billboards = b;
565
+ // keep an ordered list of billboards
566
+ this._orderedBillboards = [];
567
+ };
568
+ _.BillboardGroup.prototype.createBillboard = function (position, callbacks) {
569
+ var billboard = this._billboards.add({
570
+ show: true,
571
+ position: position,
572
+ pixelOffset: new Cesium.Cartesian2(this._options.shiftX, this._options.shiftY),
573
+ eyeOffset: new Cesium.Cartesian3(0.0, 0.0, 0.0),
574
+ horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
575
+ verticalOrigin: Cesium.VerticalOrigin.CENTER,
576
+ scale: 1.0,
577
+ image: this._options.iconUrl,
578
+ color: drawingVertexColor,
579
+ });
580
+ // if editable
581
+ if (callbacks) {
582
+ var _self = this;
583
+ var screenSpaceCameraController = this._scene.screenSpaceCameraController;
584
+ function enableRotation(enable) {
585
+ screenSpaceCameraController.enableRotate = enable;
586
+ }
587
+ function getIndex() {
588
+ // find index
589
+ for (var i = 0, I = _self._orderedBillboards.length; i < I && _self._orderedBillboards[i] != billboard; ++i)
590
+ ;
591
+ return i;
592
+ }
593
+ if (callbacks.dragHandlers) {
594
+ var _self = this;
595
+ setListener(billboard, 'leftDown', function (position) {
596
+ // TODO - start the drag handlers here
597
+ // create handlers for mouseOut and leftUp for the billboard and a mouseMove
598
+ function onDrag(position) {
599
+ billboard.position = position;
600
+ // find index
601
+ for (var i = 0, I = _self._orderedBillboards.length; i < I && _self._orderedBillboards[i] != billboard; ++i)
602
+ ;
603
+ callbacks.dragHandlers.onDrag &&
604
+ callbacks.dragHandlers.onDrag(getIndex(), position);
605
+ }
606
+ function onDragEnd(position) {
607
+ handler.destroy();
608
+ enableRotation(true);
609
+ callbacks.dragHandlers.onDragEnd &&
610
+ callbacks.dragHandlers.onDragEnd(getIndex(), position);
611
+ }
612
+ var handler = new Cesium.ScreenSpaceEventHandler(_self._scene.canvas);
613
+ handler.setInputAction(function (movement) {
614
+ var cartesian = _self._scene.camera.pickEllipsoid(movement.endPosition, ellipsoid);
615
+ if (cartesian) {
616
+ onDrag(cartesian);
617
+ }
618
+ else {
619
+ onDragEnd(cartesian);
620
+ }
621
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
622
+ handler.setInputAction(function (movement) {
623
+ onDragEnd(_self._scene.camera.pickEllipsoid(movement.position, ellipsoid));
624
+ }, Cesium.ScreenSpaceEventType.LEFT_UP);
625
+ enableRotation(false);
626
+ callbacks.dragHandlers.onDragStart &&
627
+ callbacks.dragHandlers.onDragStart(getIndex(), _self._scene.camera.pickEllipsoid(position, ellipsoid));
628
+ });
629
+ }
630
+ if (callbacks.onDoubleClick) {
631
+ setListener(billboard, 'leftDoubleClick', function (position) {
632
+ callbacks.onDoubleClick(getIndex());
633
+ });
634
+ }
635
+ if (callbacks.onClick) {
636
+ setListener(billboard, 'leftClick', function (position) {
637
+ callbacks.onClick(getIndex());
638
+ });
639
+ }
640
+ if (callbacks.tooltip) {
641
+ setListener(billboard, 'mouseMove', function (position) {
642
+ _self._drawHelper._tooltip.showAt(position, callbacks.tooltip());
643
+ });
644
+ setListener(billboard, 'mouseOut', function (position) {
645
+ _self._drawHelper._tooltip.setVisible(false);
646
+ });
647
+ }
648
+ }
649
+ return billboard;
650
+ };
651
+ _.BillboardGroup.prototype.insertBillboard = function (index, position, callbacks) {
652
+ this._orderedBillboards.splice(index, 0, this.createBillboard(position, callbacks));
653
+ };
654
+ _.BillboardGroup.prototype.addBillboard = function (position, callbacks) {
655
+ this._orderedBillboards.push(this.createBillboard(position, callbacks));
656
+ };
657
+ _.BillboardGroup.prototype.addBillboards = function (positions, callbacks) {
658
+ var index = 0;
659
+ for (; index < positions.length; index++) {
660
+ this.addBillboard(positions[index], callbacks);
661
+ }
662
+ };
663
+ _.BillboardGroup.prototype.updateBillboardsPositions = function (positions) {
664
+ var index = 0;
665
+ for (; index < positions.length; index++) {
666
+ this.getBillboard(index).position = positions[index];
667
+ }
668
+ };
669
+ _.BillboardGroup.prototype.countBillboards = function () {
670
+ return this._orderedBillboards.length;
671
+ };
672
+ _.BillboardGroup.prototype.getBillboard = function (index) {
673
+ return this._orderedBillboards[index];
674
+ };
675
+ _.BillboardGroup.prototype.removeBillboard = function (index) {
676
+ this._billboards.remove(this.getBillboard(index));
677
+ this._orderedBillboards.splice(index, 1);
678
+ };
679
+ _.BillboardGroup.prototype.remove = function () {
680
+ this._billboards =
681
+ this._billboards &&
682
+ this._billboards.removeAll() &&
683
+ this._billboards.destroy();
684
+ };
685
+ _.BillboardGroup.prototype.setOnTop = function () {
686
+ this._scene.primitives.raiseToTop(this._billboards);
687
+ };
688
+ _.prototype.startDrawingMarker = function (options) {
689
+ var options = copyOptions(options, defaultBillboard);
690
+ this.startDrawing(function () {
691
+ markers.remove();
692
+ mouseHandler.destroy();
693
+ tooltip.setVisible(false);
694
+ });
695
+ var _self = this;
696
+ var scene = this._scene;
697
+ var primitives = scene.primitives;
698
+ var tooltip = this._tooltip;
699
+ var markers = new _.BillboardGroup(this, options);
700
+ var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
701
+ // Now wait for start
702
+ mouseHandler.setInputAction(function (movement) {
703
+ if (movement.position != null) {
704
+ var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
705
+ if (cartesian) {
706
+ markers.addBillboard(cartesian);
707
+ _self.stopDrawing();
708
+ options.callback(cartesian);
709
+ }
710
+ }
711
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
712
+ mouseHandler.setInputAction(function (movement) {
713
+ var position = movement.endPosition;
714
+ if (position != null) {
715
+ var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
716
+ if (cartesian) {
717
+ tooltip.showAt(position, '<p>Click to add your marker. Position is: </p>' +
718
+ getDisplayLatLngString(ellipsoid.cartesianToCartographic(cartesian)));
719
+ }
720
+ else {
721
+ tooltip.showAt(position, '<p>Click on the globe to add your marker.</p>');
722
+ }
723
+ }
724
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
725
+ };
726
+ _.prototype.startDrawingPolygon = function (options) {
727
+ var options = copyOptions(options, defaultSurfaceOptions);
728
+ this.startDrawingPolyshape(true, options);
729
+ };
730
+ _.prototype.startDrawingPolyline = function (options) {
731
+ var options = copyOptions(options, defaultPolylineOptions);
732
+ this.startDrawingPolyshape(false, options);
733
+ };
734
+ _.prototype.startDrawingPolyshape = function (isPolygon, options) {
735
+ this.startDrawing(function () {
736
+ primitives.remove(poly);
737
+ markers.remove();
738
+ mouseHandler.destroy();
739
+ tooltip.setVisible(false);
740
+ unsetDrawCursor(scene);
741
+ });
742
+ var _self = this;
743
+ var scene = this._scene;
744
+ var primitives = scene.primitives;
745
+ var tooltip = this._tooltip;
746
+ var minPoints = isPolygon ? 3 : 2;
747
+ var poly;
748
+ if (isPolygon) {
749
+ poly = new DrawHelper.PolygonPrimitive(options);
750
+ }
751
+ else {
752
+ poly = new DrawHelper.PolylinePrimitive(options);
753
+ }
754
+ poly.asynchronous = false;
755
+ primitives.add(poly);
756
+ var positions = [];
757
+ var markers = new _.BillboardGroup(this, defaultBillboard);
758
+ var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
759
+ setDrawCursor(scene);
760
+ // Now wait for start
761
+ mouseHandler.setInputAction(function (movement) {
762
+ if (movement.position != null) {
763
+ var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
764
+ if (cartesian) {
765
+ // first click
766
+ if (positions.length == 0) {
767
+ positions.push(cartesian.clone());
768
+ markers.addBillboard(positions[0]);
769
+ }
770
+ if (positions.length >= minPoints) {
771
+ poly.positions = positions;
772
+ poly._createPrimitive = true;
773
+ }
774
+ // add new point to polygon
775
+ // this one will move with the mouse
776
+ positions.push(cartesian);
777
+ // add marker at the new position
778
+ markers.addBillboard(cartesian);
779
+ }
780
+ }
781
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
782
+ mouseHandler.setInputAction(function (movement) {
783
+ var position = movement.endPosition;
784
+ if (position != null) {
785
+ if (positions.length == 0) {
786
+ tooltip.showAt(position, '<p>Click to add first point</p>');
787
+ }
788
+ else {
789
+ var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
790
+ if (cartesian) {
791
+ positions.pop();
792
+ // make sure it is slightly different
793
+ cartesian.y += 1 + Math.random();
794
+ positions.push(cartesian);
795
+ if (positions.length >= minPoints) {
796
+ poly.positions = positions;
797
+ poly._createPrimitive = true;
798
+ }
799
+ // update marker
800
+ markers.getBillboard(positions.length - 1).position = cartesian;
801
+ // show tooltip
802
+ tooltip.showAt(position, '<p>Click to add new point (' +
803
+ positions.length +
804
+ ')</p>' +
805
+ (positions.length > minPoints
806
+ ? '<p>Double click to finish drawing</p>'
807
+ : ''));
808
+ }
809
+ }
810
+ }
811
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
812
+ mouseHandler.setInputAction(function (movement) {
813
+ var position = movement.position;
814
+ if (position != null) {
815
+ if (positions.length < minPoints + 2) {
816
+ return;
817
+ }
818
+ else {
819
+ var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
820
+ if (cartesian) {
821
+ unsetDrawCursor(scene);
822
+ _self.stopDrawing();
823
+ if (typeof options.callback == 'function') {
824
+ // remove overlapping ones
825
+ var index = positions.length - 1;
826
+ options.callback(positions);
827
+ }
828
+ }
829
+ }
830
+ }
831
+ }, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
832
+ };
833
+ function getExtentCorners(value) {
834
+ return ellipsoid.cartographicArrayToCartesianArray([
835
+ Cesium.Rectangle.northwest(value),
836
+ Cesium.Rectangle.northeast(value),
837
+ Cesium.Rectangle.southeast(value),
838
+ Cesium.Rectangle.southwest(value),
839
+ ]);
840
+ }
841
+ // MC_CHANGE add to change draw mode cursor
842
+ function setDrawCursor(scene) {
843
+ if (scene) {
844
+ scene.canvas.style.cursor = 'crosshair';
845
+ }
846
+ }
847
+ // MC_CHANGE add to restore regular mode
848
+ function unsetDrawCursor(scene) {
849
+ if (scene) {
850
+ scene.canvas.style.cursor = '';
851
+ }
852
+ }
853
+ _.prototype.startDrawingExtent = function (options) {
854
+ var options = copyOptions(options, defaultSurfaceOptions);
855
+ this.startDrawing(function () {
856
+ if (extent != null) {
857
+ primitives.remove(extent);
858
+ }
859
+ //MC_CHANGE if added
860
+ if (markers != null) {
861
+ markers.remove();
862
+ }
863
+ mouseHandler.destroy();
864
+ tooltip.setVisible(false);
865
+ unsetDrawCursor(scene);
866
+ });
867
+ var _self = this;
868
+ var scene = this._scene;
869
+ var primitives = this._scene.primitives;
870
+ var tooltip = this._tooltip;
871
+ var firstPoint = null;
872
+ var extent = null;
873
+ var markers = null;
874
+ var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
875
+ setDrawCursor(scene);
876
+ function updateExtent(value) {
877
+ if (extent == null) {
878
+ //MC_CHANGE
879
+ extent = new DrawHelper.ExtentPrimitive({
880
+ extent: value,
881
+ material: options.material,
882
+ });
883
+ //extent = new Cesium.RectanglePrimitive();
884
+ extent.asynchronous = false;
885
+ primitives.add(extent);
886
+ }
887
+ extent.setExtent(value);
888
+ // update the markers
889
+ var corners = getExtentCorners(value);
890
+ // create if they do not yet exist
891
+ if (markers == null) {
892
+ markers = new _.BillboardGroup(_self, defaultBillboard);
893
+ markers.addBillboards(corners);
894
+ }
895
+ else {
896
+ markers.updateBillboardsPositions(corners);
897
+ }
898
+ }
899
+ // Now wait for start
900
+ mouseHandler.setInputAction(function (movement) {
901
+ if (movement.position != null) {
902
+ var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
903
+ if (cartesian) {
904
+ if (extent == null) {
905
+ // create the rectangle
906
+ firstPoint = ellipsoid.cartesianToCartographic(cartesian);
907
+ var value = getExtent(firstPoint, firstPoint);
908
+ updateExtent(value);
909
+ }
910
+ else {
911
+ _self.stopDrawing();
912
+ if (typeof options.callback == 'function') {
913
+ options.callback(getExtent(firstPoint, ellipsoid.cartesianToCartographic(cartesian)));
914
+ }
915
+ }
916
+ }
917
+ }
918
+ }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
919
+ mouseHandler.setInputAction(function (movement) {
920
+ var position = movement.endPosition;
921
+ if (position != null) {
922
+ if (extent == null) {
923
+ tooltip.showAt(position, '<p>Click to start drawing rectangle</p>');
924
+ }
925
+ else {
926
+ var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
927
+ if (cartesian) {
928
+ var value = getExtent(firstPoint, ellipsoid.cartesianToCartographic(cartesian));
929
+ updateExtent(value);
930
+ tooltip.showAt(position, '<p>Drag to change rectangle extent</p><p>Click again to finish drawing</p>');
931
+ }
932
+ }
933
+ }
934
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
935
+ };
936
+ _.prototype.startDrawingCircle = function (options) {
937
+ var options = copyOptions(options, defaultSurfaceOptions);
938
+ this.startDrawing(function cleanUp() {
939
+ if (circle != null) {
940
+ primitives.remove(circle);
941
+ }
942
+ markers.remove();
943
+ mouseHandler.destroy();
944
+ tooltip.setVisible(false);
945
+ });
946
+ var _self = this;
947
+ var scene = this._scene;
948
+ var primitives = this._scene.primitives;
949
+ var tooltip = this._tooltip;
950
+ var circle = null;
951
+ var markers = null;
952
+ var mouseHandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
953
+ // Now wait for start
954
+ mouseHandler.setInputAction(function (movement) {
955
+ if (movement.position != null) {
956
+ var cartesian = scene.camera.pickEllipsoid(movement.position, ellipsoid);
957
+ if (cartesian) {
958
+ if (circle == null) {
959
+ // create the circle
960
+ circle = new _.CirclePrimitive({
961
+ center: cartesian,
962
+ radius: 0,
963
+ asynchronous: false,
964
+ material: options.material,
965
+ });
966
+ primitives.add(circle);
967
+ markers = new _.BillboardGroup(_self, defaultBillboard);
968
+ markers.addBillboards([cartesian]);
969
+ }
970
+ else {
971
+ if (typeof options.callback == 'function') {
972
+ options.callback(circle.getCenter(), circle.getRadius());
973
+ }
974
+ _self.stopDrawing();
975
+ }
976
+ }
977
+ }
978
+ }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
979
+ mouseHandler.setInputAction(function (movement) {
980
+ var position = movement.endPosition;
981
+ if (position != null) {
982
+ if (circle == null) {
983
+ tooltip.showAt(position, '<p>Click to start drawing the circle</p>');
984
+ }
985
+ else {
986
+ var cartesian = scene.camera.pickEllipsoid(position, ellipsoid);
987
+ if (cartesian) {
988
+ circle.setRadius(Cesium.Cartesian3.distance(circle.getCenter(), cartesian));
989
+ markers.updateBillboardsPositions(cartesian);
990
+ tooltip.showAt(position, '<p>Move mouse to change circle radius</p><p>Click again to finish drawing</p>');
991
+ }
992
+ }
993
+ }
994
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
995
+ };
996
+ _.prototype.enhancePrimitives = function () {
997
+ var drawHelper = this;
998
+ Cesium.Billboard.prototype.setEditable = function () {
999
+ if (this._editable) {
1000
+ return;
1001
+ }
1002
+ this._editable = true;
1003
+ var billboard = this;
1004
+ var _self = this;
1005
+ function enableRotation(enable) {
1006
+ drawHelper._scene.screenSpaceCameraController.enableRotate = enable;
1007
+ }
1008
+ setListener(billboard, 'leftDown', function (position) {
1009
+ // TODO - start the drag handlers here
1010
+ // create handlers for mouseOut and leftUp for the billboard and a mouseMove
1011
+ function onDrag(position) {
1012
+ billboard.position = position;
1013
+ _self.executeListeners({ name: 'drag', positions: position });
1014
+ }
1015
+ function onDragEnd(position) {
1016
+ handler.destroy();
1017
+ enableRotation(true);
1018
+ _self.executeListeners({ name: 'dragEnd', positions: position });
1019
+ }
1020
+ var handler = new Cesium.ScreenSpaceEventHandler(drawHelper._scene.canvas);
1021
+ handler.setInputAction(function (movement) {
1022
+ var cartesian = drawHelper._scene.camera.pickEllipsoid(movement.endPosition, ellipsoid);
1023
+ if (cartesian) {
1024
+ onDrag(cartesian);
1025
+ }
1026
+ else {
1027
+ onDragEnd(cartesian);
1028
+ }
1029
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
1030
+ handler.setInputAction(function (movement) {
1031
+ onDragEnd(drawHelper._scene.camera.pickEllipsoid(movement.position, ellipsoid));
1032
+ }, Cesium.ScreenSpaceEventType.LEFT_UP);
1033
+ enableRotation(false);
1034
+ });
1035
+ enhanceWithListeners(billboard);
1036
+ };
1037
+ function setHighlighted(highlighted) {
1038
+ var scene = drawHelper._scene;
1039
+ // if no change
1040
+ // if already highlighted, the outline polygon will be available
1041
+ if (this._highlighted && this._highlighted == highlighted) {
1042
+ return;
1043
+ }
1044
+ // disable if already in edit mode
1045
+ if (this._editMode === true) {
1046
+ return;
1047
+ }
1048
+ this._highlighted = highlighted;
1049
+ // highlight by creating an outline polygon matching the polygon points
1050
+ if (highlighted) {
1051
+ // make sure all other shapes are not highlighted
1052
+ drawHelper.setHighlighted(this);
1053
+ this._strokeColor = this.strokeColor;
1054
+ this.setStrokeStyle(Cesium.Color.fromCssColorString('white'), this.strokeWidth);
1055
+ }
1056
+ else {
1057
+ if (this._strokeColor) {
1058
+ this.setStrokeStyle(this._strokeColor, this.strokeWidth);
1059
+ }
1060
+ else {
1061
+ this.setStrokeStyle(undefined, undefined);
1062
+ }
1063
+ }
1064
+ }
1065
+ function setEditMode(editMode) {
1066
+ // if no change
1067
+ if (this._editMode == editMode) {
1068
+ return;
1069
+ }
1070
+ // make sure all other shapes are not in edit mode before starting the editing of this shape
1071
+ drawHelper.disableAllHighlights();
1072
+ // display markers
1073
+ if (editMode) {
1074
+ drawHelper.setEdited(this);
1075
+ var scene = drawHelper._scene;
1076
+ var _self = this;
1077
+ // create the markers and handlers for the editing
1078
+ if (this._markers == null) {
1079
+ var markers = new _.BillboardGroup(drawHelper, dragBillboard);
1080
+ var editMarkers = new _.BillboardGroup(drawHelper, dragHalfBillboard);
1081
+ // function for updating the edit markers around a certain point
1082
+ function updateHalfMarkers(index, positions) {
1083
+ // update the half markers before and after the index
1084
+ var editIndex = index - 1 < 0 ? positions.length - 1 : index - 1;
1085
+ if (editIndex < editMarkers.countBillboards()) {
1086
+ editMarkers.getBillboard(editIndex).position = calculateHalfMarkerPosition(editIndex);
1087
+ }
1088
+ editIndex = index;
1089
+ if (editIndex < editMarkers.countBillboards()) {
1090
+ editMarkers.getBillboard(editIndex).position = calculateHalfMarkerPosition(editIndex);
1091
+ }
1092
+ }
1093
+ function onEdited() {
1094
+ _self.executeListeners({
1095
+ name: 'onEdited',
1096
+ positions: _self.positions,
1097
+ });
1098
+ }
1099
+ var handleMarkerChanges = {
1100
+ dragHandlers: {
1101
+ onDrag: function (index, position) {
1102
+ _self.positions[index] = position;
1103
+ updateHalfMarkers(index, _self.positions);
1104
+ _self._createPrimitive = true;
1105
+ },
1106
+ onDragEnd: function (index, position) {
1107
+ _self._createPrimitive = true;
1108
+ onEdited();
1109
+ },
1110
+ },
1111
+ onDoubleClick: function (index) {
1112
+ if (_self.positions.length < 4) {
1113
+ return;
1114
+ }
1115
+ // remove the point and the corresponding markers
1116
+ _self.positions.splice(index, 1);
1117
+ _self._createPrimitive = true;
1118
+ markers.removeBillboard(index);
1119
+ editMarkers.removeBillboard(index);
1120
+ updateHalfMarkers(index, _self.positions);
1121
+ onEdited();
1122
+ },
1123
+ tooltip: function () {
1124
+ if (_self.positions.length > 3) {
1125
+ return 'Double click to remove this point';
1126
+ }
1127
+ },
1128
+ };
1129
+ // add billboards and keep an ordered list of them for the polygon edges
1130
+ markers.addBillboards(_self.positions, handleMarkerChanges);
1131
+ this._markers = markers;
1132
+ function calculateHalfMarkerPosition(index) {
1133
+ var positions = _self.positions;
1134
+ return ellipsoid.cartographicToCartesian(new Cesium.EllipsoidGeodesic(ellipsoid.cartesianToCartographic(positions[index]), ellipsoid.cartesianToCartographic(positions[index < positions.length - 1 ? index + 1 : 0])).interpolateUsingFraction(0.5));
1135
+ }
1136
+ var halfPositions = [];
1137
+ var index = 0;
1138
+ var length = _self.positions.length + (this.isPolygon ? 0 : -1);
1139
+ for (; index < length; index++) {
1140
+ halfPositions.push(calculateHalfMarkerPosition(index));
1141
+ }
1142
+ var handleEditMarkerChanges = {
1143
+ dragHandlers: {
1144
+ onDragStart: function (index, position) {
1145
+ // add a new position to the polygon but not a new marker yet
1146
+ this.index = index + 1;
1147
+ _self.positions.splice(this.index, 0, position);
1148
+ _self._createPrimitive = true;
1149
+ },
1150
+ onDrag: function (index, position) {
1151
+ _self.positions[this.index] = position;
1152
+ _self._createPrimitive = true;
1153
+ },
1154
+ onDragEnd: function (index, position) {
1155
+ // create new sets of makers for editing
1156
+ markers.insertBillboard(this.index, position, handleMarkerChanges);
1157
+ editMarkers.getBillboard(this.index - 1).position = calculateHalfMarkerPosition(this.index - 1);
1158
+ editMarkers.insertBillboard(this.index, calculateHalfMarkerPosition(this.index), handleEditMarkerChanges);
1159
+ _self._createPrimitive = true;
1160
+ onEdited();
1161
+ },
1162
+ },
1163
+ tooltip: function () {
1164
+ return 'Drag to create a new point';
1165
+ },
1166
+ };
1167
+ editMarkers.addBillboards(halfPositions, handleEditMarkerChanges);
1168
+ this._editMarkers = editMarkers;
1169
+ // add a handler for clicking in the globe
1170
+ this._globeClickhandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
1171
+ this._globeClickhandler.setInputAction(function (movement) {
1172
+ var pickedObject = scene.pick(movement.position);
1173
+ if (!(pickedObject && pickedObject.primitive)) {
1174
+ _self.setEditMode(false);
1175
+ }
1176
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1177
+ // set on top of the polygon
1178
+ markers.setOnTop();
1179
+ editMarkers.setOnTop();
1180
+ }
1181
+ this._editMode = true;
1182
+ }
1183
+ else {
1184
+ if (this._markers != null) {
1185
+ this._markers.remove();
1186
+ this._editMarkers.remove();
1187
+ this._markers = null;
1188
+ this._editMarkers = null;
1189
+ this._globeClickhandler.destroy();
1190
+ }
1191
+ this._editMode = false;
1192
+ }
1193
+ }
1194
+ DrawHelper.PolylinePrimitive.prototype.setEditable = function () {
1195
+ if (this.setEditMode) {
1196
+ return;
1197
+ }
1198
+ var polyline = this;
1199
+ polyline.isPolygon = false;
1200
+ polyline.asynchronous = false;
1201
+ drawHelper.registerEditableShape(polyline);
1202
+ polyline.setEditMode = setEditMode;
1203
+ var originalWidth = this.width;
1204
+ polyline.setHighlighted = function (highlighted) {
1205
+ // disable if already in edit mode
1206
+ if (this._editMode === true) {
1207
+ return;
1208
+ }
1209
+ if (highlighted) {
1210
+ drawHelper.setHighlighted(this);
1211
+ this.setWidth(originalWidth * 2);
1212
+ }
1213
+ else {
1214
+ this.setWidth(originalWidth);
1215
+ }
1216
+ };
1217
+ polyline.getExtent = function () {
1218
+ return Cesium.Extent.fromCartographicArray(ellipsoid.cartesianArrayToCartographicArray(this.positions));
1219
+ };
1220
+ enhanceWithListeners(polyline);
1221
+ polyline.setEditMode(false);
1222
+ };
1223
+ DrawHelper.PolygonPrimitive.prototype.setEditable = function () {
1224
+ var polygon = this;
1225
+ polygon.asynchronous = false;
1226
+ var scene = drawHelper._scene;
1227
+ drawHelper.registerEditableShape(polygon);
1228
+ polygon.setEditMode = setEditMode;
1229
+ polygon.setHighlighted = setHighlighted;
1230
+ enhanceWithListeners(polygon);
1231
+ polygon.setEditMode(false);
1232
+ };
1233
+ DrawHelper.ExtentPrimitive.prototype.setEditable = function () {
1234
+ if (this.setEditMode) {
1235
+ return;
1236
+ }
1237
+ var extent = this;
1238
+ var scene = drawHelper._scene;
1239
+ drawHelper.registerEditableShape(extent);
1240
+ extent.asynchronous = false;
1241
+ extent.setEditMode = function (editMode) {
1242
+ // if no change
1243
+ if (this._editMode == editMode) {
1244
+ return;
1245
+ }
1246
+ drawHelper.disableAllHighlights();
1247
+ // display markers
1248
+ if (editMode) {
1249
+ // make sure all other shapes are not in edit mode before starting the editing of this shape
1250
+ drawHelper.setEdited(this);
1251
+ // create the markers and handlers for the editing
1252
+ if (this._markers == null) {
1253
+ var markers = new _.BillboardGroup(drawHelper, dragBillboard);
1254
+ function onEdited() {
1255
+ extent.executeListeners({
1256
+ name: 'onEdited',
1257
+ extent: extent.extent,
1258
+ });
1259
+ }
1260
+ var handleMarkerChanges = {
1261
+ dragHandlers: {
1262
+ onDrag: function (index, position) {
1263
+ var corner = markers.getBillboard((index + 2) % 4).position;
1264
+ extent.setExtent(getExtent(ellipsoid.cartesianToCartographic(corner), ellipsoid.cartesianToCartographic(position)));
1265
+ markers.updateBillboardsPositions(getExtentCorners(extent.extent));
1266
+ },
1267
+ onDragEnd: function (index, position) {
1268
+ onEdited();
1269
+ },
1270
+ },
1271
+ tooltip: function () {
1272
+ return 'Drag to change the corners of this extent';
1273
+ },
1274
+ };
1275
+ markers.addBillboards(getExtentCorners(extent.extent), handleMarkerChanges);
1276
+ this._markers = markers;
1277
+ // add a handler for clicking in the globe
1278
+ this._globeClickhandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
1279
+ this._globeClickhandler.setInputAction(function (movement) {
1280
+ var pickedObject = scene.pick(movement.position);
1281
+ // disable edit if pickedobject is different or not an object
1282
+ if (!(pickedObject &&
1283
+ !pickedObject.isDestroyed() &&
1284
+ pickedObject.primitive)) {
1285
+ extent.setEditMode(false);
1286
+ }
1287
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1288
+ // set on top of the polygon
1289
+ markers.setOnTop();
1290
+ }
1291
+ this._editMode = true;
1292
+ }
1293
+ else {
1294
+ if (this._markers != null) {
1295
+ this._markers.remove();
1296
+ this._markers = null;
1297
+ this._globeClickhandler.destroy();
1298
+ }
1299
+ this._editMode = false;
1300
+ }
1301
+ };
1302
+ extent.setHighlighted = setHighlighted;
1303
+ enhanceWithListeners(extent);
1304
+ extent.setEditMode(false);
1305
+ };
1306
+ _.EllipsePrimitive.prototype.setEditable = function () {
1307
+ if (this.setEditMode) {
1308
+ return;
1309
+ }
1310
+ var ellipse = this;
1311
+ var scene = drawHelper._scene;
1312
+ ellipse.asynchronous = false;
1313
+ drawHelper.registerEditableShape(ellipse);
1314
+ ellipse.setEditMode = function (editMode) {
1315
+ // if no change
1316
+ if (this._editMode == editMode) {
1317
+ return;
1318
+ }
1319
+ drawHelper.disableAllHighlights();
1320
+ // display markers
1321
+ if (editMode) {
1322
+ // make sure all other shapes are not in edit mode before starting the editing of this shape
1323
+ drawHelper.setEdited(this);
1324
+ var _self = this;
1325
+ // create the markers and handlers for the editing
1326
+ if (this._markers == null) {
1327
+ var markers = new _.BillboardGroup(drawHelper, dragBillboard);
1328
+ function getMarkerPositions() {
1329
+ return Cesium.Shapes.computeEllipseBoundary(ellipsoid, ellipse.getCenter(), ellipse.getSemiMajorAxis(), ellipse.getSemiMinorAxis(), ellipse.getRotation() + Math.PI / 2, Math.PI / 2.0).splice(0, 4);
1330
+ }
1331
+ function onEdited() {
1332
+ ellipse.executeListeners({
1333
+ name: 'onEdited',
1334
+ center: ellipse.getCenter(),
1335
+ semiMajorAxis: ellipse.getSemiMajorAxis(),
1336
+ semiMinorAxis: ellipse.getSemiMinorAxis(),
1337
+ rotation: 0,
1338
+ });
1339
+ }
1340
+ var handleMarkerChanges = {
1341
+ dragHandlers: {
1342
+ onDrag: function (index, position) {
1343
+ var distance = Cesium.Cartesian3.distance(ellipse.getCenter(), position);
1344
+ if (index % 2 == 0) {
1345
+ ellipse.setSemiMajorAxis(distance);
1346
+ }
1347
+ else {
1348
+ ellipse.setSemiMinorAxis(distance);
1349
+ }
1350
+ markers.updateBillboardsPositions(getMarkerPositions());
1351
+ },
1352
+ onDragEnd: function (index, position) {
1353
+ onEdited();
1354
+ },
1355
+ },
1356
+ tooltip: function () {
1357
+ return 'Drag to change the excentricity and radius';
1358
+ },
1359
+ };
1360
+ markers.addBillboards(getMarkerPositions(), handleMarkerChanges);
1361
+ this._markers = markers;
1362
+ // add a handler for clicking in the globe
1363
+ this._globeClickhandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
1364
+ this._globeClickhandler.setInputAction(function (movement) {
1365
+ var pickedObject = scene.pick(movement.position);
1366
+ if (!(pickedObject && pickedObject.primitive)) {
1367
+ _self.setEditMode(false);
1368
+ }
1369
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1370
+ // set on top of the polygon
1371
+ markers.setOnTop();
1372
+ }
1373
+ this._editMode = true;
1374
+ }
1375
+ else {
1376
+ if (this._markers != null) {
1377
+ this._markers.remove();
1378
+ this._markers = null;
1379
+ this._globeClickhandler.destroy();
1380
+ }
1381
+ this._editMode = false;
1382
+ }
1383
+ };
1384
+ ellipse.setHighlighted = setHighlighted;
1385
+ enhanceWithListeners(ellipse);
1386
+ ellipse.setEditMode(false);
1387
+ };
1388
+ _.CirclePrimitive.prototype.getCircleCartesianCoordinates = function (granularity) {
1389
+ var geometry = Cesium.CircleOutlineGeometry.createGeometry(new Cesium.CircleOutlineGeometry({
1390
+ ellipsoid: ellipsoid,
1391
+ center: this.getCenter(),
1392
+ radius: this.getRadius(),
1393
+ granularity: granularity,
1394
+ }));
1395
+ var count = 0, value, values = [];
1396
+ for (; count < geometry.attributes.position.values.length; count += 3) {
1397
+ value = geometry.attributes.position.values;
1398
+ values.push(new Cesium.Cartesian3(value[count], value[count + 1], value[count + 2]));
1399
+ }
1400
+ return values;
1401
+ };
1402
+ _.CirclePrimitive.prototype.setEditable = function () {
1403
+ if (this.setEditMode) {
1404
+ return;
1405
+ }
1406
+ var circle = this;
1407
+ var scene = drawHelper._scene;
1408
+ circle.asynchronous = false;
1409
+ drawHelper.registerEditableShape(circle);
1410
+ circle.setEditMode = function (editMode) {
1411
+ // if no change
1412
+ if (this._editMode == editMode) {
1413
+ return;
1414
+ }
1415
+ drawHelper.disableAllHighlights();
1416
+ // display markers
1417
+ if (editMode) {
1418
+ // make sure all other shapes are not in edit mode before starting the editing of this shape
1419
+ drawHelper.setEdited(this);
1420
+ var _self = this;
1421
+ // create the markers and handlers for the editing
1422
+ if (this._markers == null) {
1423
+ var markers = new _.BillboardGroup(drawHelper, dragBillboard);
1424
+ function getMarkerPositions() {
1425
+ return _self.getCircleCartesianCoordinates(Cesium.Math.PI_OVER_TWO);
1426
+ }
1427
+ function onEdited() {
1428
+ circle.executeListeners({
1429
+ name: 'onEdited',
1430
+ center: circle.getCenter(),
1431
+ radius: circle.getRadius(),
1432
+ });
1433
+ }
1434
+ var handleMarkerChanges = {
1435
+ dragHandlers: {
1436
+ onDrag: function (index, position) {
1437
+ circle.setRadius(Cesium.Cartesian3.distance(circle.getCenter(), position));
1438
+ markers.updateBillboardsPositions(getMarkerPositions());
1439
+ },
1440
+ onDragEnd: function (index, position) {
1441
+ onEdited();
1442
+ },
1443
+ },
1444
+ tooltip: function () {
1445
+ return 'Drag to change the radius';
1446
+ },
1447
+ };
1448
+ markers.addBillboards(getMarkerPositions(), handleMarkerChanges);
1449
+ this._markers = markers;
1450
+ // add a handler for clicking in the globe
1451
+ this._globeClickhandler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
1452
+ this._globeClickhandler.setInputAction(function (movement) {
1453
+ var pickedObject = scene.pick(movement.position);
1454
+ if (!(pickedObject && pickedObject.primitive)) {
1455
+ _self.setEditMode(false);
1456
+ }
1457
+ }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
1458
+ // set on top of the polygon
1459
+ markers.setOnTop();
1460
+ }
1461
+ this._editMode = true;
1462
+ }
1463
+ else {
1464
+ if (this._markers != null) {
1465
+ this._markers.remove();
1466
+ this._markers = null;
1467
+ this._globeClickhandler.destroy();
1468
+ }
1469
+ this._editMode = false;
1470
+ }
1471
+ };
1472
+ circle.setHighlighted = setHighlighted;
1473
+ enhanceWithListeners(circle);
1474
+ circle.setEditMode(false);
1475
+ };
1476
+ };
1477
+ _.DrawHelperWidget = (function () {
1478
+ // constructor
1479
+ function _(drawHelper, options) {
1480
+ // container must be specified
1481
+ if (!Cesium.defined(options.container)) {
1482
+ throw new Cesium.DeveloperError('Container is required');
1483
+ }
1484
+ var drawOptions = {
1485
+ markerIcon: './assets/img/glyphicons_242_google_maps.png',
1486
+ polylineIcon: './assets/img/glyphicons_097_vector_path_line.png',
1487
+ polygonIcon: './assets/img/glyphicons_096_vector_path_polygon.png',
1488
+ circleIcon: './assets/img/glyphicons_095_vector_path_circle.png',
1489
+ extentIcon: './assets/img/glyphicons_094_vector_path_square.png',
1490
+ clearIcon: './assets/img/glyphicons_067_cleaning.png',
1491
+ polylineDrawingOptions: defaultPolylineOptions,
1492
+ polygonDrawingOptions: defaultPolygonOptions,
1493
+ extentDrawingOptions: defaultExtentOptions,
1494
+ circleDrawingOptions: defaultCircleOptions,
1495
+ };
1496
+ fillOptions(options, drawOptions);
1497
+ var _self = this;
1498
+ var toolbar = document.createElement('DIV');
1499
+ toolbar.className = 'toolbar';
1500
+ options.container.appendChild(toolbar);
1501
+ function addIcon(id, url, title, callback) {
1502
+ var div = document.createElement('DIV');
1503
+ div.className = 'button';
1504
+ div.title = title;
1505
+ toolbar.appendChild(div);
1506
+ div.onclick = callback;
1507
+ var span = document.createElement('SPAN');
1508
+ div.appendChild(span);
1509
+ var image = document.createElement('IMG');
1510
+ image.src = url;
1511
+ span.appendChild(image);
1512
+ return div;
1513
+ }
1514
+ var scene = drawHelper._scene;
1515
+ addIcon('marker', options.markerIcon, 'Click to start drawing a 2D marker', function () {
1516
+ drawHelper.startDrawingMarker({
1517
+ callback: function (position) {
1518
+ _self.executeListeners({
1519
+ name: 'markerCreated',
1520
+ position: position,
1521
+ });
1522
+ },
1523
+ });
1524
+ });
1525
+ addIcon('polyline', options.polylineIcon, 'Click to start drawing a 2D polyline', function () {
1526
+ drawHelper.startDrawingPolyline({
1527
+ callback: function (positions) {
1528
+ _self.executeListeners({
1529
+ name: 'polylineCreated',
1530
+ positions: positions,
1531
+ });
1532
+ },
1533
+ });
1534
+ });
1535
+ addIcon('polygon', options.polygonIcon, 'Click to start drawing a 2D polygon', function () {
1536
+ drawHelper.startDrawingPolygon({
1537
+ callback: function (positions) {
1538
+ _self.executeListeners({
1539
+ name: 'polygonCreated',
1540
+ positions: positions,
1541
+ });
1542
+ },
1543
+ });
1544
+ });
1545
+ addIcon('extent', options.extentIcon, 'Click to start drawing an Extent', function () {
1546
+ drawHelper.startDrawingExtent({
1547
+ callback: function (extent) {
1548
+ _self.executeListeners({ name: 'extentCreated', extent: extent });
1549
+ },
1550
+ });
1551
+ });
1552
+ addIcon('circle', options.circleIcon, 'Click to start drawing a Circle', function () {
1553
+ drawHelper.startDrawingCircle({
1554
+ callback: function (center, radius) {
1555
+ _self.executeListeners({
1556
+ name: 'circleCreated',
1557
+ center: center,
1558
+ radius: radius,
1559
+ });
1560
+ },
1561
+ });
1562
+ });
1563
+ // add a clear button at the end
1564
+ // add a divider first
1565
+ var div = document.createElement('DIV');
1566
+ div.className = 'divider';
1567
+ toolbar.appendChild(div);
1568
+ addIcon('clear', options.clearIcon, 'Remove all primitives', function () {
1569
+ scene.primitives.removeAll();
1570
+ });
1571
+ enhanceWithListeners(this);
1572
+ }
1573
+ return _;
1574
+ })();
1575
+ _.prototype.addToolbar = function (container, options) {
1576
+ options = copyOptions(options, { container: container });
1577
+ return new _.DrawHelperWidget(this, options);
1578
+ };
1579
+ function getExtent(mn, mx) {
1580
+ var e = new Cesium.Rectangle();
1581
+ // Re-order so west < east and south < north
1582
+ e.west = Math.min(mn.longitude, mx.longitude);
1583
+ e.east = Math.max(mn.longitude, mx.longitude);
1584
+ e.south = Math.min(mn.latitude, mx.latitude);
1585
+ e.north = Math.max(mn.latitude, mx.latitude);
1586
+ // Check for approx equal (shouldn't require abs due to re-order)
1587
+ var epsilon = Cesium.Math.EPSILON7;
1588
+ if (e.east - e.west < epsilon) {
1589
+ e.east += epsilon * 2.0;
1590
+ }
1591
+ if (e.north - e.south < epsilon) {
1592
+ e.north += epsilon * 2.0;
1593
+ }
1594
+ return e;
1595
+ }
1596
+ function createTooltip(frameDiv) {
1597
+ var tooltip = function (frameDiv) {
1598
+ var div = document.createElement('DIV');
1599
+ div.className = 'twipsy right';
1600
+ var arrow = document.createElement('DIV');
1601
+ arrow.className = 'twipsy-arrow';
1602
+ div.appendChild(arrow);
1603
+ var title = document.createElement('DIV');
1604
+ title.className = 'twipsy-inner';
1605
+ div.appendChild(title);
1606
+ this._div = div;
1607
+ this._title = title;
1608
+ // add to frame div and display coordinates
1609
+ frameDiv.appendChild(div);
1610
+ };
1611
+ tooltip.prototype.setVisible = function (visible) {
1612
+ this._div.style.display = visible ? 'block' : 'none';
1613
+ };
1614
+ tooltip.prototype.showAt = function (position, message) {
1615
+ if (position && message) {
1616
+ this.setVisible(true);
1617
+ this._title.innerHTML = message;
1618
+ this._div.style.left = position.x + 10 + 'px';
1619
+ this._div.style.top = position.y - this._div.clientHeight / 2 + 'px';
1620
+ }
1621
+ };
1622
+ return new tooltip(frameDiv);
1623
+ }
1624
+ function getDisplayLatLngString(cartographic, precision) {
1625
+ return (cartographic.longitude.toFixed(precision || 3) +
1626
+ ', ' +
1627
+ cartographic.latitude.toFixed(precision || 3));
1628
+ }
1629
+ function clone(from, to) {
1630
+ if (from == null || typeof from != 'object')
1631
+ return from;
1632
+ if (from.constructor != Object && from.constructor != Array)
1633
+ return from;
1634
+ if (from.constructor == Date ||
1635
+ from.constructor == RegExp ||
1636
+ from.constructor == Function ||
1637
+ from.constructor == String ||
1638
+ from.constructor == Number ||
1639
+ from.constructor == Boolean)
1640
+ return new from.constructor(from);
1641
+ to = to || new from.constructor();
1642
+ for (var name in from) {
1643
+ to[name] =
1644
+ typeof to[name] == 'undefined' ? clone(from[name], null) : to[name];
1645
+ }
1646
+ return to;
1647
+ }
1648
+ function fillOptions(options, defaultOptions) {
1649
+ options = options || {};
1650
+ var option;
1651
+ for (option in defaultOptions) {
1652
+ if (options[option] === undefined) {
1653
+ options[option] = clone(defaultOptions[option]);
1654
+ }
1655
+ }
1656
+ }
1657
+ // shallow copy
1658
+ function copyOptions(options, defaultOptions) {
1659
+ var newOptions = clone(options), option;
1660
+ for (option in defaultOptions) {
1661
+ if (newOptions[option] === undefined) {
1662
+ newOptions[option] = clone(defaultOptions[option]);
1663
+ }
1664
+ }
1665
+ return newOptions;
1666
+ }
1667
+ function setListener(primitive, type, callback) {
1668
+ primitive[type] = callback;
1669
+ }
1670
+ function enhanceWithListeners(element) {
1671
+ element._listeners = {};
1672
+ element.addListener = function (name, callback) {
1673
+ this._listeners[name] = this._listeners[name] || [];
1674
+ this._listeners[name].push(callback);
1675
+ return this._listeners[name].length;
1676
+ };
1677
+ element.executeListeners = function (event, defaultCallback) {
1678
+ if (this._listeners[event.name] &&
1679
+ this._listeners[event.name].length > 0) {
1680
+ var index = 0;
1681
+ for (; index < this._listeners[event.name].length; index++) {
1682
+ this._listeners[event.name][index](event);
1683
+ }
1684
+ }
1685
+ else {
1686
+ if (defaultCallback) {
1687
+ defaultCallback(event);
1688
+ }
1689
+ }
1690
+ };
1691
+ }
1692
+ return _;
1693
+ })();
1694
+ exports.DrawHelper = DrawHelper;