itowns 2.44.3-next.9 → 2.45.0

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 (214) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +20 -6
  3. package/examples/config.json +1 -0
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/jsm/.eslintrc.cjs +0 -38
  43. package/lib/Controls/FirstPersonControls.js +0 -308
  44. package/lib/Controls/FlyControls.js +0 -175
  45. package/lib/Controls/GlobeControls.js +0 -1162
  46. package/lib/Controls/PlanarControls.js +0 -1025
  47. package/lib/Controls/StateControl.js +0 -429
  48. package/lib/Controls/StreetControls.js +0 -392
  49. package/lib/Converter/Feature2Mesh.js +0 -615
  50. package/lib/Converter/Feature2Texture.js +0 -170
  51. package/lib/Converter/convertToTile.js +0 -75
  52. package/lib/Converter/textureConverter.js +0 -44
  53. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  54. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  55. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  56. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  57. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  58. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  59. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  60. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  61. package/lib/Core/AnimationPlayer.js +0 -142
  62. package/lib/Core/CopcNode.js +0 -174
  63. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  64. package/lib/Core/EntwinePointTileNode.js +0 -126
  65. package/lib/Core/Feature.js +0 -490
  66. package/lib/Core/Geographic/CoordStars.js +0 -80
  67. package/lib/Core/Geographic/Coordinates.js +0 -320
  68. package/lib/Core/Geographic/Crs.js +0 -175
  69. package/lib/Core/Geographic/Extent.js +0 -534
  70. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  71. package/lib/Core/Label.js +0 -222
  72. package/lib/Core/MainLoop.js +0 -211
  73. package/lib/Core/Math/Ellipsoid.js +0 -144
  74. package/lib/Core/Picking.js +0 -255
  75. package/lib/Core/PointCloudNode.js +0 -42
  76. package/lib/Core/Potree2Node.js +0 -206
  77. package/lib/Core/Potree2PointAttributes.js +0 -139
  78. package/lib/Core/PotreeNode.js +0 -101
  79. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  80. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  81. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  82. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  83. package/lib/Core/Prefab/GlobeView.js +0 -161
  84. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  85. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  86. package/lib/Core/Prefab/PlanarView.js +0 -62
  87. package/lib/Core/Prefab/TileBuilder.js +0 -80
  88. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  89. package/lib/Core/Scheduler/Cache.js +0 -256
  90. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  91. package/lib/Core/Scheduler/Scheduler.js +0 -294
  92. package/lib/Core/Style.js +0 -1121
  93. package/lib/Core/System/Capabilities.js +0 -63
  94. package/lib/Core/Tile/Tile.js +0 -219
  95. package/lib/Core/Tile/TileGrid.js +0 -46
  96. package/lib/Core/TileGeometry.js +0 -40
  97. package/lib/Core/TileMesh.js +0 -109
  98. package/lib/Core/View.js +0 -1109
  99. package/lib/Layer/C3DTilesLayer.js +0 -456
  100. package/lib/Layer/ColorLayer.js +0 -128
  101. package/lib/Layer/CopcLayer.js +0 -58
  102. package/lib/Layer/ElevationLayer.js +0 -107
  103. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  104. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  105. package/lib/Layer/GeoidLayer.js +0 -80
  106. package/lib/Layer/GeometryLayer.js +0 -202
  107. package/lib/Layer/InfoLayer.js +0 -64
  108. package/lib/Layer/LabelLayer.js +0 -456
  109. package/lib/Layer/Layer.js +0 -304
  110. package/lib/Layer/LayerUpdateState.js +0 -89
  111. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  112. package/lib/Layer/OGC3DTilesLayer.js +0 -412
  113. package/lib/Layer/OrientedImageLayer.js +0 -222
  114. package/lib/Layer/PointCloudLayer.js +0 -359
  115. package/lib/Layer/Potree2Layer.js +0 -164
  116. package/lib/Layer/PotreeLayer.js +0 -65
  117. package/lib/Layer/RasterLayer.js +0 -27
  118. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  119. package/lib/Layer/TiledGeometryLayer.js +0 -403
  120. package/lib/Loader/LASLoader.js +0 -193
  121. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  122. package/lib/Loader/Potree2Loader.js +0 -207
  123. package/lib/Main.js +0 -115
  124. package/lib/MainBundle.js +0 -4
  125. package/lib/Parser/B3dmParser.js +0 -174
  126. package/lib/Parser/CameraCalibrationParser.js +0 -94
  127. package/lib/Parser/GDFParser.js +0 -72
  128. package/lib/Parser/GTXParser.js +0 -75
  129. package/lib/Parser/GeoJsonParser.js +0 -212
  130. package/lib/Parser/GpxParser.js +0 -25
  131. package/lib/Parser/ISGParser.js +0 -71
  132. package/lib/Parser/KMLParser.js +0 -25
  133. package/lib/Parser/LASParser.js +0 -137
  134. package/lib/Parser/MapBoxUrlParser.js +0 -83
  135. package/lib/Parser/PntsParser.js +0 -131
  136. package/lib/Parser/Potree2BinParser.js +0 -92
  137. package/lib/Parser/PotreeBinParser.js +0 -106
  138. package/lib/Parser/PotreeCinParser.js +0 -29
  139. package/lib/Parser/ShapefileParser.js +0 -78
  140. package/lib/Parser/VectorTileParser.js +0 -202
  141. package/lib/Parser/XbilParser.js +0 -119
  142. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  143. package/lib/Parser/iGLTFLoader.js +0 -168
  144. package/lib/Process/3dTilesProcessing.js +0 -304
  145. package/lib/Process/FeatureProcessing.js +0 -76
  146. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  147. package/lib/Process/ObjectRemovalHelper.js +0 -97
  148. package/lib/Process/handlerNodeError.js +0 -23
  149. package/lib/Provider/3dTilesProvider.js +0 -149
  150. package/lib/Provider/DataSourceProvider.js +0 -8
  151. package/lib/Provider/Fetcher.js +0 -229
  152. package/lib/Provider/PointCloudProvider.js +0 -45
  153. package/lib/Provider/TileProvider.js +0 -16
  154. package/lib/Provider/URLBuilder.js +0 -116
  155. package/lib/Renderer/Camera.js +0 -281
  156. package/lib/Renderer/Color.js +0 -56
  157. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  158. package/lib/Renderer/CommonMaterial.js +0 -31
  159. package/lib/Renderer/Label2DRenderer.js +0 -190
  160. package/lib/Renderer/LayeredMaterial.js +0 -243
  161. package/lib/Renderer/OBB.js +0 -153
  162. package/lib/Renderer/OrientedImageCamera.js +0 -118
  163. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  164. package/lib/Renderer/PointsMaterial.js +0 -485
  165. package/lib/Renderer/RasterTile.js +0 -209
  166. package/lib/Renderer/RenderMode.js +0 -31
  167. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  168. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  169. package/lib/Renderer/SphereHelper.js +0 -23
  170. package/lib/Renderer/WebXR.js +0 -51
  171. package/lib/Renderer/c3DEngine.js +0 -214
  172. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  173. package/lib/Source/C3DTilesIonSource.js +0 -54
  174. package/lib/Source/C3DTilesSource.js +0 -30
  175. package/lib/Source/CopcSource.js +0 -115
  176. package/lib/Source/EntwinePointTileSource.js +0 -62
  177. package/lib/Source/FileSource.js +0 -189
  178. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  179. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  180. package/lib/Source/OGC3DTilesSource.js +0 -21
  181. package/lib/Source/OrientedImageSource.js +0 -59
  182. package/lib/Source/Potree2Source.js +0 -167
  183. package/lib/Source/PotreeSource.js +0 -82
  184. package/lib/Source/Source.js +0 -223
  185. package/lib/Source/TMSSource.js +0 -145
  186. package/lib/Source/VectorTilesSource.js +0 -178
  187. package/lib/Source/WFSSource.js +0 -168
  188. package/lib/Source/WMSSource.js +0 -133
  189. package/lib/Source/WMTSSource.js +0 -86
  190. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  191. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  192. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  193. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  194. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  195. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  196. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  197. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  198. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  199. package/lib/Utils/CameraUtils.js +0 -555
  200. package/lib/Utils/DEMUtils.js +0 -350
  201. package/lib/Utils/FeaturesUtils.js +0 -156
  202. package/lib/Utils/Gradients.js +0 -16
  203. package/lib/Utils/OrientationUtils.js +0 -457
  204. package/lib/Utils/ThreeUtils.js +0 -115
  205. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  206. package/lib/Utils/gui/Main.js +0 -7
  207. package/lib/Utils/gui/Minimap.js +0 -154
  208. package/lib/Utils/gui/Navigation.js +0 -245
  209. package/lib/Utils/gui/Scale.js +0 -107
  210. package/lib/Utils/gui/Searchbar.js +0 -234
  211. package/lib/Utils/gui/Widget.js +0 -80
  212. package/lib/Utils/placeObjectOnGround.js +0 -137
  213. package/lib/Worker/LASLoaderWorker.js +0 -19
  214. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,178 +0,0 @@
1
- import { featureFilter } from '@mapbox/mapbox-gl-style-spec';
2
- import Style from "../Core/Style.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
- /**
24
- * VectorTilesSource are object containing informations on how to fetch vector
25
- * tiles resources.
26
- *
27
- * @property {function} filter - function to filter vector tiles layers, the
28
- * parameter function is a layer.
29
- * @property {boolean} [symbolToCircle=false] - If true, all symbols from a tile
30
- * will be considered as circle, and render as circles.
31
- */
32
- class VectorTilesSource extends TMSSource {
33
- /**
34
- * @param {Object} source - An object that can contain all properties of a
35
- * VectorTilesSource and {@link Source}.
36
- * @param {string|Object} source.style - The URL of the JSON style, of the
37
- * JSON style directly.
38
- * @param {string} [source.sprite] - The base URL to load informations about
39
- * the sprite of the style. If this is set, it overrides the `sprite` value
40
- * of the `source.style`. A style's sprite property supplies a URL template
41
- * for loading small images.
42
- * ```js
43
- * {
44
- * sprite: 'http//:xxxxx/maps/sprites/'
45
- * }
46
- * ```
47
- * A valid sprite source must supply two types of files:
48
- * * An index file, which is a JSON document containing a description of each image contained in the sprite.
49
- * * Image files, which are PNG images containing the sprite data.
50
- *
51
- * For more specification : [the Mapbox sprite Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/sprite/)
52
- *
53
- * @param {string} [source.url] - The base URL to load the tiles. If no url
54
- * is specified, it reads it from the loaded style. Read [the Mapbox Style
55
- * Specification](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/)
56
- * for more informations.
57
- * @param {string} [source.accessToken] - Mapbox access token
58
- */
59
- constructor(source) {
60
- source.format = 'application/x-protobuf;type=mapbox-vector';
61
- source.crs = 'EPSG:3857';
62
- source.isInverted = true;
63
- source.url = source.url || '.';
64
- super(source);
65
- const ffilter = source.filter || (() => true);
66
- this.urls = [];
67
- this.layers = {};
68
- this.styles = {};
69
- let promise;
70
- this.isVectorTileSource = true;
71
- this.accessToken = source.accessToken;
72
- if (source.style) {
73
- if (typeof source.style == 'string') {
74
- const styleUrl = urlParser.normalizeStyleURL(source.style, this.accessToken);
75
- promise = Fetcher.json(styleUrl, this.networkOptions);
76
- } else {
77
- promise = Promise.resolve(source.style);
78
- }
79
- } else {
80
- throw new Error('New VectorTilesSource: style is required');
81
- }
82
- this.whenReady = promise.then(style => {
83
- this.jsonStyle = style;
84
- const baseurl = source.sprite || style.sprite;
85
- if (baseurl) {
86
- const spriteUrl = urlParser.normalizeSpriteURL(baseurl, '', '.json', this.accessToken);
87
- return Fetcher.json(spriteUrl, this.networkOptions).then(sprites => {
88
- this.sprites = sprites;
89
- const imgUrl = urlParser.normalizeSpriteURL(baseurl, '', '.png', this.accessToken);
90
- this.sprites.source = imgUrl;
91
- return style;
92
- });
93
- }
94
- return style;
95
- }).then(style => {
96
- style.layers.forEach((layer, order) => {
97
- layer.sourceUid = this.uid;
98
- if (layer.type === 'background') {
99
- this.backgroundLayer = layer;
100
- } else if (ffilter(layer)) {
101
- const style = Style.setFromVectorTileLayer(layer, this.sprites, order, this.symbolToCircle);
102
- this.styles[layer.id] = style;
103
- if (!this.layers[layer['source-layer']]) {
104
- this.layers[layer['source-layer']] = [];
105
- }
106
- this.layers[layer['source-layer']].push({
107
- id: layer.id,
108
- order,
109
- filterExpression: featureFilter(layer.filter),
110
- zoom: {
111
- min: layer.minzoom || 0,
112
- max: layer.maxzoom || 24
113
- }
114
- });
115
- }
116
- });
117
- if (this.url == '.') {
118
- const TMSUrlList = Object.values(style.sources).map(sourceVT => {
119
- if (sourceVT.url) {
120
- const urlSource = urlParser.normalizeSourceURL(sourceVT.url, this.accessToken);
121
- return Fetcher.json(urlSource, this.networkOptions).then(tileJSON => {
122
- if (tileJSON.tiles[0]) {
123
- return toTMSUrl(tileJSON.tiles[0]);
124
- }
125
- });
126
- } else if (sourceVT.tiles) {
127
- return Promise.resolve(toTMSUrl(sourceVT.tiles[0]));
128
- }
129
- return Promise.reject();
130
- });
131
- return Promise.all(TMSUrlList);
132
- }
133
- return Promise.resolve([this.url]);
134
- }).then(TMSUrlList => {
135
- this.urls = Array.from(new Set(TMSUrlList));
136
- });
137
- }
138
- urlFromExtent(tile, url) {
139
- return URLBuilder.xyz(tile, {
140
- tileMatrixCallback: this.tileMatrixCallback,
141
- url
142
- });
143
- }
144
- onLayerAdded(options) {
145
- super.onLayerAdded(options);
146
- if (options.out.style) {
147
- if (options.out.isFeatureGeometryLayer && options.out.accurate) {
148
- console.warn('With VectorTilesSource and FeatureGeometryLayer, the accurate option is always false');
149
- options.out.accurate = false;
150
- }
151
- }
152
- }
153
- loadData(extent, out) {
154
- const cache = this._featuresCaches[out.crs];
155
- const key = this.requestToKey(extent);
156
- // try to get parsed data from cache
157
- let features = cache.getByArray(key);
158
- if (!features) {
159
- // otherwise fetch/parse the data
160
- features = cache.setByArray(Promise.all(this.urls.map(url => this.fetcher(this.urlFromExtent(extent, url), this.networkOptions).then(file => this.parser(file, {
161
- out,
162
- in: this,
163
- extent
164
- })))).then(collections => mergeCollections(collections)).catch(err => this.handlingError(err)), key);
165
-
166
- /* istanbul ignore next */
167
- if (this.onParsedFile) {
168
- features.then(feat => {
169
- this.onParsedFile(feat);
170
- console.warn('Source.onParsedFile was deprecated');
171
- return feat;
172
- });
173
- }
174
- }
175
- return features;
176
- }
177
- }
178
- export default VectorTilesSource;
@@ -1,168 +0,0 @@
1
- import Source from "./Source.js";
2
- import URLBuilder from "../Provider/URLBuilder.js";
3
- import CRS from "../Core/Geographic/Crs.js";
4
- import Extent from "../Core/Geographic/Extent.js";
5
- const _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
6
-
7
- /**
8
- * An object defining the source of resources to get from a
9
- * [WFS](http://www.opengeospatial.org/standards/wfs) server. It inherits
10
- * from {@link Source}.
11
- *
12
- * @extends Source
13
- *
14
- * @property {boolean} isWFSSource - Used to checkout whether this source is a
15
- * WFSSource. Default is true. You should not change this, as it is used
16
- * internally for optimisation.
17
- * @property {string} typeName - The name of the feature to get, used in the
18
- * generation of the url.
19
- * @property {string} version - The version of the WFS server to request on.
20
- * Default value is '2.0.2'.
21
- * @property {Object} zoom - Object containing the minimum and maximum values of
22
- * the level, to zoom in the source.
23
- * @property {number} zoom.min - The minimum level of the source. Default value
24
- * is 0.
25
- * @property {number} zoom.max - The maximum level of the source. Default value
26
- * is 21.
27
- * @property {string} bboxDigits - The bbox digits precision used in URL
28
- * @property {Object} vendorSpecific - An object containing vendor specific
29
- * parameters. See for example a [list of these parameters for GeoServer]{@link
30
- * https://docs.geoserver.org/latest/en/user/services/wfs/vendor.html}. This
31
- * object is read simply with the `key` being the name of the parameter and
32
- * `value` being the value of the parameter. If used, this property should be
33
- * set in the constructor parameters.
34
- *
35
- * @example
36
- * // Add color layer with WFS source
37
- * // Create the source
38
- * const wfsSource = new itowns.WFSSource({
39
- * url: 'https://data.geopf.fr/wfs/ows?',
40
- * version: '2.0.0',
41
- * typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable',
42
- * crs: 'EPSG:4326',
43
- * extent: {
44
- * west: 4.568,
45
- * east: 5.18,
46
- * south: 45.437,
47
- * north: 46.03,
48
- * },
49
- * zoom: { min: 14, max: 14 },
50
- * format: 'application/json',
51
- * });
52
- *
53
- * // Create the layer
54
- * const colorlayer = new itowns.ColorLayer('color_build', {
55
- * style: {
56
- * fill: 'red',
57
- * fillOpacity: 0.5,
58
- * stroke: 'white',
59
- * },
60
- * source: wfsSource,
61
- * });
62
- *
63
- * // Add the layer
64
- * view.addLayer(colorlayer);
65
- *
66
- * @example
67
- * // Add geometry layer with WFS source
68
- * // Create the source
69
- * const wfsSource = new itowns.WFSSource({
70
- * url: 'https://data.geopf.fr/wfs/ows?',
71
- * version: '2.0.0',
72
- * typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable',
73
- * crs: 'EPSG:4326',
74
- * extent: {
75
- * west: 4.568,
76
- * east: 5.18,
77
- * south: 45.437,
78
- * north: 46.03,
79
- * },
80
- * zoom: { min: 14, max: 14 },
81
- * format: 'application/json',
82
- * });
83
- *
84
- * // Create the layer
85
- * const geometryLayer = new itowns.FeatureGeometryLayer('mesh_build', {
86
- * style: {
87
- * fill: {
88
- * color: new itowns.THREE.Color(0xffcc00),
89
- * base_altitude: (p) => p.altitude,
90
- * extrusion_height: (p) => p.height,
91
- * }
92
- * },
93
- * source: wfsSource,
94
- * zoom: { min: 14 },
95
- * };
96
- *
97
- * // Add the layer
98
- * view.addLayer(geometryLayer);
99
- */
100
- class WFSSource extends Source {
101
- /**
102
- * @param {Object} source - An object that can contain all properties of a
103
- * WFSSource and {@link Source}. `url`, `typeName` and `crs` are
104
- * mandatory.
105
- */
106
- constructor(source) {
107
- if (source.projection) {
108
- console.warn('WFSSource projection parameter is deprecated, use crs instead.');
109
- source.crs = source.crs || source.projection;
110
- }
111
- if (!source.typeName) {
112
- throw new Error('source.typeName is required in wfs source.');
113
- }
114
- if (!source.crs) {
115
- throw new Error('source.crs is required in wfs source');
116
- }
117
- source.format = source.format || 'application/json';
118
- super(source);
119
- this.isWFSSource = true;
120
- this.typeName = source.typeName;
121
- this.version = source.version || '2.0.2';
122
- this.bboxDigits = source.bboxDigits;
123
-
124
- // Add ? at the end of the url if it is not already in the given URL
125
- if (!this.url.endsWith('?')) {
126
- this.url = `${this.url}?`;
127
- }
128
- this.url = `${source.url}SERVICE=WFS&REQUEST=GetFeature&typeName=${this.typeName}&VERSION=${this.version}&SRSNAME=${this.crs}&outputFormat=${this.format}&BBOX=%bbox,${this.crs}`;
129
- this.zoom = {
130
- min: 0,
131
- max: Infinity
132
- };
133
- this.vendorSpecific = source.vendorSpecific;
134
- for (const name in this.vendorSpecific) {
135
- if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
136
- this.url = `${this.url}&${name}=${this.vendorSpecific[name]}`;
137
- }
138
- }
139
- }
140
- handlingError(err) {
141
- if (err.response && err.response.status == 400) {
142
- return err.response.text().then(text => {
143
- const getCapUrl = `${this.url}SERVICE=WFS&REQUEST=GetCapabilities&VERSION=${this.version}`;
144
- const xml = new DOMParser().parseFromString(text, 'application/xml');
145
- const errorElem = xml.querySelector('Exception');
146
- const errorCode = errorElem.getAttribute('exceptionCode');
147
- const errorMessage = errorElem.querySelector('ExceptionText').textContent;
148
- console.error(`Source ${this.typeName}: bad request when fetching data. Server says: "${errorCode}: ${errorMessage}". \nReviewing ${getCapUrl} may help.`, err);
149
- });
150
- }
151
- return super.handlingError(err);
152
- }
153
- requestToKey(extent) {
154
- if (CRS.isTms(extent.crs)) {
155
- return super.requestToKey(extent);
156
- } else {
157
- return [extent.zoom, extent.south, extent.west];
158
- }
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 WFSSource;
@@ -1,133 +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', [0, 0, 0, 0]);
5
-
6
- /**
7
- * An object defining the source of images to get from a
8
- * [WMS](http://www.opengeospatial.org/standards/wms) server. It inherits
9
- * from {@link Source}.
10
- *
11
- * @extends Source
12
- *
13
- * @property {boolean} isWMSSource - Used to checkout whether this source is a
14
- * WMSSource. Default is true. You should not change this, as it is used
15
- * internally for optimisation.
16
- * @property {string} name - The name of the layer, used in the generation of
17
- * the url.
18
- * @property {string} version - The version of the WMS server to request on.
19
- * Default value is '1.3.0'.
20
- * @property {string} style - The style to query on the WMS server. Default
21
- * value is 'normal'.
22
- * @property {number} width - The width of the image to fetch, in pixel.
23
- * Default value is the height if set or 256.
24
- * @property {number} height - The height of the image to fetch, in pixel.
25
- * Default value is the width if set or 256.
26
- * @property {string} axisOrder - The order of the axis, that helps building the
27
- * BBOX to put in the url requesting a resource. Default value is 'wsen', other
28
- * value can be 'swne'.
29
- * @property {boolean} transparent - Tells if the image to fetch needs
30
- * transparency support. Default value is false.
31
- * @property {Object} zoom - Object containing the minimum and maximum values of
32
- * the level, to zoom in the source.
33
- * @property {number} zoom.min - The minimum level of the source. Default value
34
- * is 0.
35
- * @property {number} zoom.max - The maximum level of the source. Default value
36
- * is 21.
37
- * @property {string} bboxDigits - The bbox digits precision used in URL
38
- * @property {Object} vendorSpecific - An object containing vendor specific
39
- * parameters. See for example a [list of these parameters for GeoServer](
40
- * https://docs.geoserver.org/latest/en/user/services/wms/vendor.html). This
41
- * object is read simply with the `key` being the name of the parameter and
42
- * `value` being the value of the parameter. If used, this property should be
43
- * set in the constructor parameters.
44
- *
45
- * @example
46
- * // Create the source
47
- * const wmsSource = new itowns.WMSSource({
48
- * url: 'https://server.geo/wms',
49
- * version: '1.3.0',
50
- * name: 'REGION.2016',
51
- * style: '',
52
- * crs: 'EPSG:3857',
53
- * extent: {
54
- * west: '-6880639.13557728',
55
- * east: '6215707.87974825',
56
- * south: '-2438399.00148845',
57
- * north: '7637050.03850605',
58
- * },
59
- * transparent: true,
60
- * });
61
- *
62
- * // Create the layer
63
- * const colorlayer = new itowns.ColorLayer('Region', {
64
- * source: wmsSource,
65
- * });
66
- *
67
- * // Add the layer
68
- * view.addLayer(colorlayer);
69
- */
70
- class WMSSource extends Source {
71
- /**
72
- * @param {Object} source - An object that can contain all properties of
73
- * WMSSource and {@link Source}. `url`, `name`, `extent` and `crs`
74
- * are mandatory.
75
- */
76
- constructor(source) {
77
- if (!source.name) {
78
- throw new Error('source.name is required.');
79
- }
80
- if (!source.extent) {
81
- throw new Error('source.extent is required');
82
- }
83
- if (!source.crs && !source.projection) {
84
- throw new Error('source.crs is required');
85
- }
86
- source.format = source.format || 'image/png';
87
- super(source);
88
- this.isWMSSource = true;
89
- this.name = source.name;
90
- this.zoom = {
91
- min: 0,
92
- max: Infinity
93
- };
94
- this.style = source.style || '';
95
- this.width = source.width || source.height || 256;
96
- this.height = source.height || source.width || 256;
97
- this.version = source.version || '1.3.0';
98
- this.transparent = source.transparent || false;
99
- this.bboxDigits = source.bboxDigits;
100
- if (!source.axisOrder) {
101
- // 4326 (lat/long) axis order depends on the WMS version used
102
- if (this.crs == 'EPSG:4326') {
103
- // EPSG 4326 x = lat, long = y
104
- // version 1.1.0 long/lat while version 1.3.0 mandates xy (so lat,long)
105
- this.axisOrder = this.version === '1.1.0' ? 'wsen' : 'swne';
106
- } else {
107
- // xy,xy order
108
- this.axisOrder = 'wsen';
109
- }
110
- }
111
- const crsPropName = this.version === '1.3.0' ? 'CRS' : 'SRS';
112
-
113
- // Add ? at the end of the url if it is not already in the given URL
114
- if (!this.url.endsWith('?')) {
115
- this.url = `${this.url}?`;
116
- }
117
- this.url = `${this.url}SERVICE=WMS&REQUEST=GetMap&LAYERS=${this.name}&VERSION=${this.version}&STYLES=${this.style}&FORMAT=${this.format}&TRANSPARENT=${this.transparent}&BBOX=%bbox&${crsPropName}=${this.crs}&WIDTH=${this.width}&HEIGHT=${this.height}`;
118
- this.vendorSpecific = source.vendorSpecific;
119
- for (const name in this.vendorSpecific) {
120
- if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
121
- this.url = `${this.url}&${name}=${this.vendorSpecific[name]}`;
122
- }
123
- }
124
- }
125
- urlFromExtent(extentOrTile) {
126
- const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
127
- return URLBuilder.bbox(extent, this);
128
- }
129
- extentInsideLimit(extent) {
130
- return this.extent.intersectsExtent(extent);
131
- }
132
- }
133
- export default WMSSource;
@@ -1,86 +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
-
73
- // Add ? at the end of the url if it is not already in the given URL
74
- if (!this.url.endsWith('?')) {
75
- this.url = `${this.url}?`;
76
- }
77
- this.url = `${this.url}` + `LAYER=${source.name}` + `&FORMAT=${this.format}` + '&SERVICE=WMTS' + `&VERSION=${source.version || '1.0.0'}` + '&REQUEST=GetTile' + `&STYLE=${source.style || 'normal'}` + `&TILEMATRIXSET=${source.tileMatrixSet}` + '&TILEMATRIX=%TILEMATRIX&TILEROW=%ROW&TILECOL=%COL';
78
- this.vendorSpecific = source.vendorSpecific;
79
- for (const name in this.vendorSpecific) {
80
- if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
81
- this.url = `${this.url}&${name}=${this.vendorSpecific[name]}`;
82
- }
83
- }
84
- }
85
- }
86
- 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;