itowns 2.44.3-next.40 → 2.44.3-next.42

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 (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,182 +0,0 @@
1
- import { featureFilter } from '@maplibre/maplibre-gl-style-spec';
2
- import StyleOptions from "../Core/StyleOptions.js";
3
- import TMSSource from "./TMSSource.js";
4
- import URLBuilder from "../Provider/URLBuilder.js";
5
- import Fetcher from "../Provider/Fetcher.js";
6
- import urlParser from "../Parser/MapBoxUrlParser.js";
7
- function toTMSUrl(url) {
8
- return url.replace(/\{/g, '${');
9
- }
10
- function mergeCollections(collections) {
11
- const collection = collections[0];
12
- collections.forEach((col, index) => {
13
- if (index === 0) {
14
- return;
15
- }
16
- col.features.forEach(feature => {
17
- collection.features.push(feature);
18
- });
19
- });
20
- return collection;
21
- }
22
-
23
- // A deprecated (but still in use) Mapbox spec allows using 'ref' as a propertie to reference an other layer
24
- // instead of duplicating the following properties: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'
25
- function getPropertiesFromRefLayer(layers, layer) {
26
- const refLayer = layers.filter(l => l.id === layer.ref)[0];
27
- ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'].forEach(prop => {
28
- layer[prop] = refLayer[prop];
29
- });
30
- }
31
-
32
- /**
33
- * VectorTilesSource are object containing informations on how to fetch vector
34
- * tiles resources.
35
- *
36
- * @property {function} filter - function to filter vector tiles layers, the
37
- * parameter function is a layer.
38
- * @property {boolean} [symbolToCircle=false] - If true, all symbols from a tile
39
- * will be considered as circle, and render as circles.
40
- */
41
- class VectorTilesSource extends TMSSource {
42
- /**
43
- * @param {Object} source - An object that can contain all properties of a
44
- * VectorTilesSource and {@link Source}.
45
- * @param {string|Object} source.style - The URL of the JSON style, of the
46
- * JSON style directly.
47
- * @param {string} [source.sprite] - The base URL to load informations about
48
- * the sprite of the style. If this is set, it overrides the `sprite` value
49
- * of the `source.style`. A style's sprite property supplies a URL template
50
- * for loading small images.
51
- * ```js
52
- * {
53
- * sprite: 'http//:xxxxx/maps/sprites/'
54
- * }
55
- * ```
56
- * A valid sprite source must supply two types of files:
57
- * * An index file, which is a JSON document containing a description of each image contained in the sprite.
58
- * * Image files, which are PNG images containing the sprite data.
59
- *
60
- * For more specification : [the Mapbox sprite Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/sprite/)
61
- *
62
- * @param {string} [source.url] - The base URL to load the tiles. If no url
63
- * is specified, it reads it from the loaded style. Read [the Mapbox Style
64
- * Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/)
65
- * for more informations.
66
- * @param {string} [source.accessToken] - Mapbox access token
67
- */
68
- constructor(source) {
69
- source.format = 'application/x-protobuf;type=mapbox-vector';
70
- source.crs = 'EPSG:3857';
71
- source.isInverted = true;
72
- source.url = source.url || '.';
73
- super(source);
74
- const ffilter = source.filter || (() => true);
75
- this.urls = [];
76
- this.layers = {};
77
- this.styles = {};
78
- let promise;
79
- this.isVectorTileSource = true;
80
- this.accessToken = source.accessToken;
81
- let mvtStyleUrl;
82
- if (source.style) {
83
- if (typeof source.style == 'string') {
84
- mvtStyleUrl = urlParser.normalizeStyleURL(source.style, this.accessToken);
85
- promise = Fetcher.json(mvtStyleUrl, this.networkOptions);
86
- } else {
87
- promise = Promise.resolve(source.style);
88
- }
89
- } else {
90
- throw new Error('New VectorTilesSource: style is required');
91
- }
92
- this.whenReady = promise.then(mvtStyle => {
93
- this.jsonStyle = mvtStyle;
94
- let baseurl = source.sprite || mvtStyle.sprite;
95
- if (baseurl) {
96
- baseurl = new URL(baseurl, mvtStyleUrl).toString();
97
- const spriteUrl = urlParser.normalizeSpriteURL(baseurl, '', '.json', this.accessToken);
98
- return Fetcher.json(spriteUrl, this.networkOptions).then(sprites => {
99
- this.sprites = sprites;
100
- const imgUrl = urlParser.normalizeSpriteURL(baseurl, '', '.png', this.accessToken);
101
- this.sprites.source = imgUrl;
102
- return mvtStyle;
103
- });
104
- }
105
- return mvtStyle;
106
- }).then(mvtStyle => {
107
- mvtStyle.layers.forEach((layer, order) => {
108
- layer.sourceUid = this.uid;
109
- if (layer.type === 'background') {
110
- this.backgroundLayer = layer;
111
- } else if (ffilter(layer)) {
112
- if (layer['source-layer'] === undefined) {
113
- getPropertiesFromRefLayer(mvtStyle.layers, layer);
114
- }
115
- const style = StyleOptions.setFromVectorTileLayer(layer, this.sprites, this.symbolToCircle);
116
- this.styles[layer.id] = style;
117
- if (!this.layers[layer['source-layer']]) {
118
- this.layers[layer['source-layer']] = [];
119
- }
120
- this.layers[layer['source-layer']].push({
121
- id: layer.id,
122
- order,
123
- filterExpression: featureFilter(layer.filter)
124
- });
125
- }
126
- });
127
- if (this.url == '.') {
128
- const TMSUrlList = Object.values(mvtStyle.sources).map(sourceVT => {
129
- if (sourceVT.url) {
130
- sourceVT.url = new URL(sourceVT.url, mvtStyleUrl).toString();
131
- const urlSource = urlParser.normalizeSourceURL(sourceVT.url, this.accessToken);
132
- return Fetcher.json(urlSource, this.networkOptions).then(tileJSON => {
133
- if (tileJSON.tiles[0]) {
134
- tileJSON.tiles[0] = decodeURIComponent(new URL(tileJSON.tiles[0], urlSource).toString());
135
- return toTMSUrl(tileJSON.tiles[0]);
136
- }
137
- });
138
- } else if (sourceVT.tiles) {
139
- return Promise.resolve(toTMSUrl(sourceVT.tiles[0]));
140
- }
141
- return Promise.reject();
142
- });
143
- return Promise.all(TMSUrlList);
144
- }
145
- return Promise.resolve([toTMSUrl(this.url)]);
146
- }).then(TMSUrlList => {
147
- this.urls = Array.from(new Set(TMSUrlList));
148
- });
149
- }
150
- urlFromExtent(tile, url) {
151
- return URLBuilder.xyz(tile, {
152
- tileMatrixCallback: this.tileMatrixCallback,
153
- url
154
- });
155
- }
156
- onLayerAdded(options) {
157
- super.onLayerAdded(options);
158
- if (options.out.style) {
159
- if (options.out.isFeatureGeometryLayer && options.out.accurate) {
160
- console.warn('With VectorTilesSource and FeatureGeometryLayer, the accurate option is always false');
161
- options.out.accurate = false;
162
- }
163
- }
164
- }
165
- loadData(extent, out) {
166
- const cache = this._featuresCaches[out.crs];
167
- const key = this.getDataKey(extent);
168
- // try to get parsed data from cache
169
- let features = cache.get(key);
170
- if (!features) {
171
- // otherwise fetch/parse the data
172
- features = Promise.all(this.urls.map(url => this.fetcher(this.urlFromExtent(extent, url), this.networkOptions).then(file => this.parser(file, {
173
- out,
174
- in: this,
175
- extent
176
- })))).then(collections => mergeCollections(collections)).catch(err => this.handlingError(err));
177
- cache.set(key, features);
178
- }
179
- return features;
180
- }
181
- }
182
- export default VectorTilesSource;
@@ -1,170 +0,0 @@
1
- import Source from "./Source.js";
2
- import URLBuilder from "../Provider/URLBuilder.js";
3
- import Extent from "../Core/Geographic/Extent.js";
4
- const _extent = new Extent('EPSG:4326');
5
-
6
- /**
7
- * An object defining the source of resources to get from a
8
- * [WFS](http://www.opengeospatial.org/standards/wfs) server. It inherits
9
- * from {@link Source}.
10
- *
11
- * @extends Source
12
- *
13
- * @property {boolean} isWFSSource - Used to checkout whether this source is a
14
- * WFSSource. Default is true. You should not change this, as it is used
15
- * internally for optimisation.
16
- * @property {string} typeName - The name of the feature to get, used in the
17
- * generation of the url.
18
- * @property {string} version - The version of the WFS server to request on.
19
- * Default value is '2.0.2'.
20
- * @property {Object} zoom - Object containing the minimum and maximum values of
21
- * the level, to zoom in the source.
22
- * @property {number} zoom.min - The minimum level of the source. Default value
23
- * is 0.
24
- * @property {number} zoom.max - The maximum level of the source. Default value
25
- * is 21.
26
- * @property {string} bboxDigits - The bbox digits precision used in URL
27
- * @property {Object} vendorSpecific - An object containing vendor specific
28
- * parameters. See for example a [list of these parameters for GeoServer]{@link
29
- * https://docs.geoserver.org/latest/en/user/services/wfs/vendor.html}. This
30
- * object is read simply with the `key` being the name of the parameter and
31
- * `value` being the value of the parameter. If used, this property should be
32
- * set in the constructor parameters.
33
- *
34
- * @example
35
- * // Add color layer with WFS source
36
- * // Create the source
37
- * const wfsSource = new itowns.WFSSource({
38
- * url: 'https://data.geopf.fr/wfs/ows?',
39
- * version: '2.0.0',
40
- * typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable',
41
- * crs: 'EPSG:4326',
42
- * extent: {
43
- * west: 4.568,
44
- * east: 5.18,
45
- * south: 45.437,
46
- * north: 46.03,
47
- * },
48
- * zoom: { min: 14, max: 14 },
49
- * format: 'application/json',
50
- * });
51
- *
52
- * // Create the layer
53
- * const colorlayer = new itowns.ColorLayer('color_build', {
54
- * style: {
55
- * fill: 'red',
56
- * fillOpacity: 0.5,
57
- * stroke: 'white',
58
- * },
59
- * source: wfsSource,
60
- * });
61
- *
62
- * // Add the layer
63
- * view.addLayer(colorlayer);
64
- *
65
- * @example
66
- * // Add geometry layer with WFS source
67
- * // Create the source
68
- * const wfsSource = new itowns.WFSSource({
69
- * url: 'https://data.geopf.fr/wfs/ows?',
70
- * version: '2.0.0',
71
- * typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable',
72
- * crs: 'EPSG:4326',
73
- * extent: {
74
- * west: 4.568,
75
- * east: 5.18,
76
- * south: 45.437,
77
- * north: 46.03,
78
- * },
79
- * zoom: { min: 14, max: 14 },
80
- * format: 'application/json',
81
- * });
82
- *
83
- * // Create the layer
84
- * const geometryLayer = new itowns.FeatureGeometryLayer('mesh_build', {
85
- * style: {
86
- * fill: {
87
- * color: new itowns.THREE.Color(0xffcc00),
88
- * base_altitude: (p) => p.altitude,
89
- * extrusion_height: (p) => p.height,
90
- * }
91
- * },
92
- * source: wfsSource,
93
- * zoom: { min: 14 },
94
- * };
95
- *
96
- * // Add the layer
97
- * view.addLayer(geometryLayer);
98
- */
99
- class WFSSource extends Source {
100
- /**
101
- * @param {Object} source - An object that can contain all properties of a
102
- * WFSSource and {@link Source}. `url`, `typeName` and `crs` are
103
- * mandatory.
104
- */
105
- constructor(source) {
106
- if (source.projection) {
107
- console.warn('WFSSource projection parameter is deprecated, use crs instead.');
108
- source.crs = source.crs || source.projection;
109
- }
110
- if (!source.typeName) {
111
- throw new Error('source.typeName is required in wfs source.');
112
- }
113
- if (!source.crs) {
114
- throw new Error('source.crs is required in wfs source');
115
- }
116
- source.format = source.format || 'application/json';
117
- super(source);
118
- this.isWFSSource = true;
119
- this.typeName = source.typeName;
120
- this.version = source.version || '2.0.2';
121
- this.bboxDigits = source.bboxDigits;
122
- this.zoom = {
123
- min: 0,
124
- max: Infinity
125
- };
126
- const urlObj = new URL(source.url);
127
- urlObj.searchParams.set('SERVICE', 'WFS');
128
- urlObj.searchParams.set('REQUEST', 'GetFeature');
129
- urlObj.searchParams.set('typeName', this.typeName);
130
- urlObj.searchParams.set('VERSION', this.version);
131
- urlObj.searchParams.set('SRSNAME', this.crs);
132
- urlObj.searchParams.set('outputFormat', this.format);
133
- urlObj.searchParams.set('BBOX', `%bbox,${this.crs}`);
134
- this.vendorSpecific = source.vendorSpecific;
135
- for (const name in this.vendorSpecific) {
136
- if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
137
- urlObj.searchParams.set(name, this.vendorSpecific[name]);
138
- }
139
- }
140
- this.url = decodeURIComponent(urlObj.toString());
141
- }
142
- handlingError(err) {
143
- if (err.response && err.response.status == 400) {
144
- return err.response.text().then(text => {
145
- const getCapUrl = `${this.url}SERVICE=WFS&REQUEST=GetCapabilities&VERSION=${this.version}`;
146
- const xml = new DOMParser().parseFromString(text, 'application/xml');
147
- const errorElem = xml.querySelector('Exception');
148
- const errorCode = errorElem.getAttribute('exceptionCode');
149
- const errorMessage = errorElem.querySelector('ExceptionText').textContent;
150
- console.error(`Source ${this.typeName}: bad request when fetching data. Server says: "${errorCode}: ${errorMessage}". \nReviewing ${getCapUrl} may help.`, err);
151
- });
152
- }
153
- return super.handlingError(err);
154
- }
155
- getDataKey(extent) {
156
- if (extent.isTile) {
157
- return super.getDataKey(extent);
158
- } else {
159
- return `z${extent.zoom}s${extent.south}w${extent.west}`;
160
- }
161
- }
162
- urlFromExtent(extentOrTile) {
163
- const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
164
- return URLBuilder.bbox(extent, this);
165
- }
166
- extentInsideLimit(extent) {
167
- return this.extent.intersectsExtent(extent);
168
- }
169
- }
170
- export default WFSSource;
@@ -1,168 +0,0 @@
1
- import Source from "./Source.js";
2
- import URLBuilder from "../Provider/URLBuilder.js";
3
- import Extent from "../Core/Geographic/Extent.js";
4
- import * as CRS from "../Core/Geographic/Crs.js";
5
- const _extent = new Extent('EPSG:4326');
6
-
7
- /**
8
- * Proj provides an optional param to define axis order and orientation for a
9
- * given projection. 'enu' for instance stands for east, north, up.
10
- * Elevation is not needed here. The two first characters are sufficient to map
11
- * proj axis to iTowns bbox order formalism.
12
- * 'enu' corresponds to 'wsen' because bbox starts by lower value coordinates
13
- * and preserves axis ordering, here long/lat.
14
- */
15
- const projAxisToBboxMappings = {
16
- en: 'wsen',
17
- es: 'wnes',
18
- wn: 'eswn',
19
- ws: 'enws',
20
- ne: 'swne',
21
- se: 'nwse',
22
- nw: 'senw',
23
- sw: 'nesw'
24
- };
25
-
26
- /**
27
- * Provides the bbox axis order matching provided proj4 axis
28
- * @param {string} projAxis the CRS axis order as defined in proj4
29
- * @returns {string} the corresponding bbox axis order to use for WMS 1.3.0
30
- */
31
- function projAxisToWmsBbox(projAxis) {
32
- return projAxis && projAxisToBboxMappings[projAxis.slice(0, 2)] || 'wsen';
33
- }
34
-
35
- /**
36
- * An object defining the source of images to get from a
37
- * [WMS](http://www.opengeospatial.org/standards/wms) server. It inherits
38
- * from {@link Source}.
39
- *
40
- * @extends Source
41
- *
42
- * @property {boolean} isWMSSource - Used to checkout whether this source is a
43
- * WMSSource. Default is true. You should not change this, as it is used
44
- * internally for optimisation.
45
- * @property {string} name - The name of the layer, used in the generation of
46
- * the url.
47
- * @property {string} version - The version of the WMS server to request on.
48
- * Default value is '1.3.0'.
49
- * @property {string} style - The style to query on the WMS server. Default
50
- * value is 'normal'.
51
- * @property {number} width - The width of the image to fetch, in pixel.
52
- * Default value is the height if set or 256.
53
- * @property {number} height - The height of the image to fetch, in pixel.
54
- * Default value is the width if set or 256.
55
- * @property {string} axisOrder - The order of the axis, that helps building the
56
- * BBOX to put in the url requesting a resource. Default value is 'wsen', other
57
- * value can be 'swne'.
58
- * @property {boolean} transparent - Tells if the image to fetch needs
59
- * transparency support. Default value is false.
60
- * @property {Object} zoom - Object containing the minimum and maximum values of
61
- * the level, to zoom in the source.
62
- * @property {number} zoom.min - The minimum level of the source. Default value
63
- * is 0.
64
- * @property {number} zoom.max - The maximum level of the source. Default value
65
- * is 21.
66
- * @property {string} bboxDigits - The bbox digits precision used in URL
67
- * @property {Object} vendorSpecific - An object containing vendor specific
68
- * parameters. See for example a [list of these parameters for GeoServer](
69
- * https://docs.geoserver.org/latest/en/user/services/wms/vendor.html). This
70
- * object is read simply with the `key` being the name of the parameter and
71
- * `value` being the value of the parameter. If used, this property should be
72
- * set in the constructor parameters.
73
- *
74
- * @example
75
- * // Create the source
76
- * const wmsSource = new itowns.WMSSource({
77
- * url: 'https://server.geo/wms',
78
- * version: '1.3.0',
79
- * name: 'REGION.2016',
80
- * style: '',
81
- * crs: 'EPSG:3857',
82
- * extent: {
83
- * west: '-6880639.13557728',
84
- * east: '6215707.87974825',
85
- * south: '-2438399.00148845',
86
- * north: '7637050.03850605',
87
- * },
88
- * transparent: true,
89
- * });
90
- *
91
- * // Create the layer
92
- * const colorlayer = new itowns.ColorLayer('Region', {
93
- * source: wmsSource,
94
- * });
95
- *
96
- * // Add the layer
97
- * view.addLayer(colorlayer);
98
- */
99
- class WMSSource extends Source {
100
- /**
101
- * @param {Object} source - An object that can contain all properties of
102
- * WMSSource and {@link Source}. `url`, `name`, `extent` and `crs`
103
- * are mandatory.
104
- */
105
- constructor(source) {
106
- if (!source.name) {
107
- throw new Error('source.name is required.');
108
- }
109
- if (!source.extent) {
110
- throw new Error('source.extent is required');
111
- }
112
- if (!source.crs && !source.projection) {
113
- throw new Error('source.crs is required');
114
- }
115
- source.format = source.format || 'image/png';
116
- super(source);
117
- this.isWMSSource = true;
118
- this.name = source.name;
119
- this.zoom = {
120
- min: 0,
121
- max: Infinity
122
- };
123
- this.style = source.style || '';
124
- this.width = source.width || source.height || 256;
125
- this.height = source.height || source.width || 256;
126
- this.version = source.version || '1.3.0';
127
- this.transparent = source.transparent || false;
128
- this.bboxDigits = source.bboxDigits;
129
- if (source.axisOrder) {
130
- this.axisOrder = source.axisOrder;
131
- } else if (this.version === '1.3.0') {
132
- // If not set, axis order depends on WMS version
133
- // Version 1.3.0 depends on CRS axis order as defined in epsg.org database
134
- this.axisOrder = projAxisToWmsBbox(CRS.axisOrder(this.crs));
135
- } else {
136
- // Versions 1.X.X mandate long/lat order, east-north orientation
137
- this.axisOrder = 'wsen';
138
- }
139
- const crsPropName = this.version === '1.3.0' ? 'CRS' : 'SRS';
140
- const urlObj = new URL(this.url);
141
- urlObj.searchParams.set('SERVICE', 'WMS');
142
- urlObj.searchParams.set('REQUEST', 'GetMap');
143
- urlObj.searchParams.set('LAYERS', this.name);
144
- urlObj.searchParams.set('VERSION', this.version);
145
- urlObj.searchParams.set('STYLES', this.style);
146
- urlObj.searchParams.set('FORMAT', this.format);
147
- urlObj.searchParams.set('TRANSPARENT', this.transparent);
148
- urlObj.searchParams.set('BBOX', '%bbox');
149
- urlObj.searchParams.set(crsPropName, this.crs);
150
- urlObj.searchParams.set('WIDTH', this.width);
151
- urlObj.searchParams.set('HEIGHT', this.height);
152
- this.vendorSpecific = source.vendorSpecific;
153
- for (const name in this.vendorSpecific) {
154
- if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
155
- urlObj.searchParams.set(name, this.vendorSpecific[name]);
156
- }
157
- }
158
- this.url = decodeURIComponent(urlObj.toString());
159
- }
160
- urlFromExtent(extentOrTile) {
161
- const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
162
- return URLBuilder.bbox(extent, this);
163
- }
164
- extentInsideLimit(extent) {
165
- return this.extent.intersectsExtent(extent);
166
- }
167
- }
168
- export default WMSSource;
@@ -1,92 +0,0 @@
1
- import TMSSource from "./TMSSource.js";
2
-
3
- /**
4
- * An object defining the source of resources to get from a
5
- * [WMTS](http://www.opengeospatial.org/standards/wmts) server. It inherits
6
- * from {@link TMSSource}.
7
- *
8
- * @extends TMSSource
9
- *
10
- * @property {boolean} isWMTSSource - Used to checkout whether this source is a
11
- * WMTSSource. Default is true. You should not change this, as it is used
12
- * internally for optimisation.
13
- * @property {string} name - The name of the layer, used in the generation of
14
- * the url.
15
- * @property {string} version - The version of the WMTS server to request on.
16
- * Default value is '1.0.0'.
17
- * @property {string} style - The style to query on the WMTS server. Default
18
- * value is 'normal'.
19
- * @property {string} crs - The crs projection in which to fetch the data.
20
- * @property {string} tileMatrixSet - Tile matrix set of the layer, used in the
21
- * generation of the url. Default value is 'WGS84'.
22
- * @property {Object} tileMatrixSetLimits - Limits of the tile matrix set. Each
23
- * limit has for key its level number, and their properties are the
24
- * `minTileRow`, `maxTileRow`, `minTileCol` and `maxTileCol`.
25
- * @property {number} tileMatrixSetLimits.minTileRow - Minimum row for tiles at
26
- * the specified level.
27
- * @property {number} tileMatrixSetLimits.maxTileRow - Maximum row for tiles at
28
- * the specified level.
29
- * @property {number} tileMatrixSetLimits.minTileCol - Minimum column for tiles
30
- * at the specified level.
31
- * @property {number} tileMatrixSetLimits.maxTileCol - Maximum column for tiles
32
- * at the specified level.
33
- * @property {Object} zoom - Object containing the minimum and maximum values of
34
- * the level, to zoom in the source.
35
- * @property {number} zoom.min - The minimum level of the source. Default value
36
- * is 2.
37
- * @property {number} zoom.max - The maximum level of the source. Default value
38
- * is 20.
39
- * @property {Object} vendorSpecific - An object containing vendor specific
40
- * parameters. This object is read simply with the `key` being the name of the
41
- * parameter and `value` being the value of the parameter. If used, this
42
- * property should be set in the constructor parameters.
43
- *
44
- * @example
45
- * // Create the source
46
- * const wmtsSource = new itowns.WMTSSource({
47
- * name: 'DARK',
48
- * tileMatrixSet: 'PM',
49
- * url: 'http://server.geo/wmts',
50
- * format: 'image/jpg',
51
- * });
52
- *
53
- * // Create the layer
54
- * const colorLayer = new itowns.ColorLayer('darkmap', {
55
- * source: wmtsSource,
56
- * });
57
- *
58
- * // Add the layer
59
- * view.addLayer(colorLayer);
60
- */
61
- class WMTSSource extends TMSSource {
62
- /**
63
- * @param {Object} source - An object that can contain all properties of a
64
- * WMTSSource and {@link Source}. Only `url`, `name` and `crs` are mandatory.
65
- */
66
- constructor(source) {
67
- if (!source.name) {
68
- throw new Error('New WMTSSource: name is required');
69
- }
70
- super(source);
71
- this.isWMTSSource = true;
72
- const urlObj = new URL(this.url);
73
- urlObj.searchParams.set('LAYER', source.name);
74
- urlObj.searchParams.set('FORMAT', this.format);
75
- urlObj.searchParams.set('SERVICE', 'WMTS');
76
- urlObj.searchParams.set('VERSION', source.version || '1.0.0');
77
- urlObj.searchParams.set('REQUEST', 'GetTile');
78
- urlObj.searchParams.set('STYLE', source.style || 'normal');
79
- urlObj.searchParams.set('TILEMATRIXSET', source.tileMatrixSet);
80
- urlObj.searchParams.set('TILEMATRIX', '%TILEMATRIX');
81
- urlObj.searchParams.set('TILEROW', '%ROW');
82
- urlObj.searchParams.set('TILECOL', '%COL');
83
- this.vendorSpecific = source.vendorSpecific;
84
- for (const name in this.vendorSpecific) {
85
- if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
86
- urlObj.searchParams.set(name, this.vendorSpecific[name]);
87
- }
88
- }
89
- this.url = decodeURIComponent(urlObj.toString());
90
- }
91
- }
92
- export default WMTSSource;
@@ -1,69 +0,0 @@
1
- class WebGL {
2
- static isWebGL2Available() {
3
- try {
4
- const canvas = document.createElement('canvas');
5
- return !!(window.WebGL2RenderingContext && canvas.getContext('webgl2'));
6
- } catch (e) {
7
- return false;
8
- }
9
- }
10
- static isColorSpaceAvailable(colorSpace) {
11
- try {
12
- const canvas = document.createElement('canvas');
13
- const ctx = window.WebGL2RenderingContext && canvas.getContext('webgl2');
14
- ctx.drawingBufferColorSpace = colorSpace;
15
- return ctx.drawingBufferColorSpace === colorSpace; // deepscan-disable-line SAME_OPERAND_VALUE
16
- } catch (e) {
17
- return false;
18
- }
19
- }
20
- static getWebGL2ErrorMessage() {
21
- return this.getErrorMessage(2);
22
- }
23
- static getErrorMessage(version) {
24
- const contexts = {
25
- 1: window.WebGLRenderingContext,
26
- 2: window.WebGL2RenderingContext
27
- };
28
- let message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
29
- const element = document.createElement('div');
30
- element.id = 'webglmessage';
31
- element.style.fontFamily = 'monospace';
32
- element.style.fontSize = '13px';
33
- element.style.fontWeight = 'normal';
34
- element.style.textAlign = 'center';
35
- element.style.background = '#fff';
36
- element.style.color = '#000';
37
- element.style.padding = '1.5em';
38
- element.style.width = '400px';
39
- element.style.margin = '5em auto 0';
40
- if (contexts[version]) {
41
- message = message.replace('$0', 'graphics card');
42
- } else {
43
- message = message.replace('$0', 'browser');
44
- }
45
- message = message.replace('$1', {
46
- 1: 'WebGL',
47
- 2: 'WebGL 2'
48
- }[version]);
49
- element.innerHTML = message;
50
- return element;
51
- }
52
-
53
- // @deprecated, r168
54
-
55
- static isWebGLAvailable() {
56
- console.warn('isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.');
57
- try {
58
- const canvas = document.createElement('canvas');
59
- return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')));
60
- } catch (e) {
61
- return false;
62
- }
63
- }
64
- static getWebGLErrorMessage() {
65
- console.warn('getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead.');
66
- return this.getErrorMessage(1);
67
- }
68
- }
69
- export default WebGL;