itowns 2.44.3-next.4 → 2.44.3-next.41

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 (217) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  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/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -608
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -726
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/TileGeometry.js +0 -40
  100. package/lib/Core/TileMesh.js +0 -108
  101. package/lib/Core/View.js +0 -1109
  102. package/lib/Layer/C3DTilesLayer.js +0 -455
  103. package/lib/Layer/ColorLayer.js +0 -128
  104. package/lib/Layer/CopcLayer.js +0 -58
  105. package/lib/Layer/ElevationLayer.js +0 -107
  106. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  107. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  108. package/lib/Layer/GeoidLayer.js +0 -80
  109. package/lib/Layer/GeometryLayer.js +0 -202
  110. package/lib/Layer/InfoLayer.js +0 -64
  111. package/lib/Layer/LabelLayer.js +0 -452
  112. package/lib/Layer/Layer.js +0 -304
  113. package/lib/Layer/LayerUpdateState.js +0 -89
  114. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  115. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  116. package/lib/Layer/OrientedImageLayer.js +0 -222
  117. package/lib/Layer/PointCloudLayer.js +0 -359
  118. package/lib/Layer/Potree2Layer.js +0 -164
  119. package/lib/Layer/PotreeLayer.js +0 -65
  120. package/lib/Layer/RasterLayer.js +0 -27
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  122. package/lib/Layer/TiledGeometryLayer.js +0 -403
  123. package/lib/Loader/LASLoader.js +0 -193
  124. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  125. package/lib/Loader/Potree2Loader.js +0 -207
  126. package/lib/Main.js +0 -115
  127. package/lib/MainBundle.js +0 -4
  128. package/lib/Parser/B3dmParser.js +0 -174
  129. package/lib/Parser/CameraCalibrationParser.js +0 -94
  130. package/lib/Parser/GDFParser.js +0 -72
  131. package/lib/Parser/GTXParser.js +0 -75
  132. package/lib/Parser/GeoJsonParser.js +0 -212
  133. package/lib/Parser/GpxParser.js +0 -25
  134. package/lib/Parser/ISGParser.js +0 -71
  135. package/lib/Parser/KMLParser.js +0 -25
  136. package/lib/Parser/LASParser.js +0 -137
  137. package/lib/Parser/MapBoxUrlParser.js +0 -83
  138. package/lib/Parser/PntsParser.js +0 -131
  139. package/lib/Parser/Potree2BinParser.js +0 -92
  140. package/lib/Parser/PotreeBinParser.js +0 -106
  141. package/lib/Parser/PotreeCinParser.js +0 -29
  142. package/lib/Parser/ShapefileParser.js +0 -78
  143. package/lib/Parser/VectorTileParser.js +0 -202
  144. package/lib/Parser/XbilParser.js +0 -108
  145. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  146. package/lib/Parser/iGLTFLoader.js +0 -168
  147. package/lib/Process/3dTilesProcessing.js +0 -304
  148. package/lib/Process/FeatureProcessing.js +0 -76
  149. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  150. package/lib/Process/ObjectRemovalHelper.js +0 -97
  151. package/lib/Process/handlerNodeError.js +0 -23
  152. package/lib/Provider/3dTilesProvider.js +0 -149
  153. package/lib/Provider/DataSourceProvider.js +0 -8
  154. package/lib/Provider/Fetcher.js +0 -229
  155. package/lib/Provider/PointCloudProvider.js +0 -45
  156. package/lib/Provider/TileProvider.js +0 -16
  157. package/lib/Provider/URLBuilder.js +0 -105
  158. package/lib/Renderer/Camera.js +0 -281
  159. package/lib/Renderer/Color.js +0 -56
  160. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  161. package/lib/Renderer/CommonMaterial.js +0 -31
  162. package/lib/Renderer/Label2DRenderer.js +0 -190
  163. package/lib/Renderer/LayeredMaterial.js +0 -243
  164. package/lib/Renderer/OBB.js +0 -153
  165. package/lib/Renderer/OrientedImageCamera.js +0 -118
  166. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  167. package/lib/Renderer/PointsMaterial.js +0 -485
  168. package/lib/Renderer/RasterTile.js +0 -209
  169. package/lib/Renderer/RenderMode.js +0 -31
  170. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  171. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  172. package/lib/Renderer/SphereHelper.js +0 -23
  173. package/lib/Renderer/WebXR.js +0 -51
  174. package/lib/Renderer/c3DEngine.js +0 -214
  175. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  176. package/lib/Source/C3DTilesIonSource.js +0 -54
  177. package/lib/Source/C3DTilesSource.js +0 -30
  178. package/lib/Source/CopcSource.js +0 -115
  179. package/lib/Source/EntwinePointTileSource.js +0 -62
  180. package/lib/Source/FileSource.js +0 -189
  181. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  182. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  183. package/lib/Source/OGC3DTilesSource.js +0 -21
  184. package/lib/Source/OrientedImageSource.js +0 -59
  185. package/lib/Source/Potree2Source.js +0 -167
  186. package/lib/Source/PotreeSource.js +0 -82
  187. package/lib/Source/Source.js +0 -223
  188. package/lib/Source/TMSSource.js +0 -143
  189. package/lib/Source/VectorTilesSource.js +0 -178
  190. package/lib/Source/WFSSource.js +0 -165
  191. package/lib/Source/WMSSource.js +0 -130
  192. package/lib/Source/WMTSSource.js +0 -86
  193. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  194. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  195. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  196. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  197. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  198. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  199. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  200. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  201. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  202. package/lib/Utils/CameraUtils.js +0 -555
  203. package/lib/Utils/DEMUtils.js +0 -350
  204. package/lib/Utils/FeaturesUtils.js +0 -156
  205. package/lib/Utils/Gradients.js +0 -16
  206. package/lib/Utils/OrientationUtils.js +0 -457
  207. package/lib/Utils/ThreeUtils.js +0 -115
  208. package/lib/Utils/gui/C3DTilesStyle.js +0 -216
  209. package/lib/Utils/gui/Main.js +0 -7
  210. package/lib/Utils/gui/Minimap.js +0 -154
  211. package/lib/Utils/gui/Navigation.js +0 -245
  212. package/lib/Utils/gui/Scale.js +0 -107
  213. package/lib/Utils/gui/Searchbar.js +0 -234
  214. package/lib/Utils/gui/Widget.js +0 -80
  215. package/lib/Utils/placeObjectOnGround.js +0 -137
  216. package/lib/Worker/LASLoaderWorker.js +0 -19
  217. 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(extent, url) {
139
- return URLBuilder.xyz(extent, {
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,165 +0,0 @@
1
- import Source from "./Source.js";
2
- import URLBuilder from "../Provider/URLBuilder.js";
3
- import CRS from "../Core/Geographic/Crs.js";
4
-
5
- /**
6
- * An object defining the source of resources to get from a
7
- * [WFS](http://www.opengeospatial.org/standards/wfs) server. It inherits
8
- * from {@link Source}.
9
- *
10
- * @extends Source
11
- *
12
- * @property {boolean} isWFSSource - Used to checkout whether this source is a
13
- * WFSSource. Default is true. You should not change this, as it is used
14
- * internally for optimisation.
15
- * @property {string} typeName - The name of the feature to get, used in the
16
- * generation of the url.
17
- * @property {string} version - The version of the WFS server to request on.
18
- * Default value is '2.0.2'.
19
- * @property {Object} zoom - Object containing the minimum and maximum values of
20
- * the level, to zoom in the source.
21
- * @property {number} zoom.min - The minimum level of the source. Default value
22
- * is 0.
23
- * @property {number} zoom.max - The maximum level of the source. Default value
24
- * is 21.
25
- * @property {string} bboxDigits - The bbox digits precision used in URL
26
- * @property {Object} vendorSpecific - An object containing vendor specific
27
- * parameters. See for example a [list of these parameters for GeoServer]{@link
28
- * https://docs.geoserver.org/latest/en/user/services/wfs/vendor.html}. This
29
- * object is read simply with the `key` being the name of the parameter and
30
- * `value` being the value of the parameter. If used, this property should be
31
- * set in the constructor parameters.
32
- *
33
- * @example
34
- * // Add color layer with WFS source
35
- * // Create the source
36
- * const wfsSource = new itowns.WFSSource({
37
- * url: 'https://data.geopf.fr/wfs/ows?',
38
- * version: '2.0.0',
39
- * typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable',
40
- * crs: 'EPSG:4326',
41
- * extent: {
42
- * west: 4.568,
43
- * east: 5.18,
44
- * south: 45.437,
45
- * north: 46.03,
46
- * },
47
- * zoom: { min: 14, max: 14 },
48
- * format: 'application/json',
49
- * });
50
- *
51
- * // Create the layer
52
- * const colorlayer = new itowns.ColorLayer('color_build', {
53
- * style: {
54
- * fill: 'red',
55
- * fillOpacity: 0.5,
56
- * stroke: 'white',
57
- * },
58
- * source: wfsSource,
59
- * });
60
- *
61
- * // Add the layer
62
- * view.addLayer(colorlayer);
63
- *
64
- * @example
65
- * // Add geometry layer with WFS source
66
- * // Create the source
67
- * const wfsSource = new itowns.WFSSource({
68
- * url: 'https://data.geopf.fr/wfs/ows?',
69
- * version: '2.0.0',
70
- * typeName: 'BDTOPO_BDD_WLD_WGS84G:bati_remarquable',
71
- * crs: 'EPSG:4326',
72
- * extent: {
73
- * west: 4.568,
74
- * east: 5.18,
75
- * south: 45.437,
76
- * north: 46.03,
77
- * },
78
- * zoom: { min: 14, max: 14 },
79
- * format: 'application/json',
80
- * });
81
- *
82
- * // Create the layer
83
- * const geometryLayer = new itowns.FeatureGeometryLayer('mesh_build', {
84
- * style: {
85
- * fill: {
86
- * color: new itowns.THREE.Color(0xffcc00),
87
- * base_altitude: (p) => p.altitude,
88
- * extrusion_height: (p) => p.height,
89
- * }
90
- * },
91
- * source: wfsSource,
92
- * zoom: { min: 14 },
93
- * };
94
- *
95
- * // Add the layer
96
- * view.addLayer(geometryLayer);
97
- */
98
- class WFSSource extends Source {
99
- /**
100
- * @param {Object} source - An object that can contain all properties of a
101
- * WFSSource and {@link Source}. `url`, `typeName` and `crs` are
102
- * mandatory.
103
- */
104
- constructor(source) {
105
- if (source.projection) {
106
- console.warn('WFSSource projection parameter is deprecated, use crs instead.');
107
- source.crs = source.crs || source.projection;
108
- }
109
- if (!source.typeName) {
110
- throw new Error('source.typeName is required in wfs source.');
111
- }
112
- if (!source.crs) {
113
- throw new Error('source.crs is required in wfs source');
114
- }
115
- source.format = source.format || 'application/json';
116
- super(source);
117
- this.isWFSSource = true;
118
- this.typeName = source.typeName;
119
- this.version = source.version || '2.0.2';
120
- this.bboxDigits = source.bboxDigits;
121
-
122
- // Add ? at the end of the url if it is not already in the given URL
123
- if (!this.url.endsWith('?')) {
124
- this.url = `${this.url}?`;
125
- }
126
- this.url = `${source.url}SERVICE=WFS&REQUEST=GetFeature&typeName=${this.typeName}&VERSION=${this.version}&SRSNAME=${this.crs}&outputFormat=${this.format}&BBOX=%bbox,${this.crs}`;
127
- this.zoom = {
128
- min: 0,
129
- max: Infinity
130
- };
131
- this.vendorSpecific = source.vendorSpecific;
132
- for (const name in this.vendorSpecific) {
133
- if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
134
- this.url = `${this.url}&${name}=${this.vendorSpecific[name]}`;
135
- }
136
- }
137
- }
138
- handlingError(err) {
139
- if (err.response && err.response.status == 400) {
140
- return err.response.text().then(text => {
141
- const getCapUrl = `${this.url}SERVICE=WFS&REQUEST=GetCapabilities&VERSION=${this.version}`;
142
- const xml = new DOMParser().parseFromString(text, 'application/xml');
143
- const errorElem = xml.querySelector('Exception');
144
- const errorCode = errorElem.getAttribute('exceptionCode');
145
- const errorMessage = errorElem.querySelector('ExceptionText').textContent;
146
- console.error(`Source ${this.typeName}: bad request when fetching data. Server says: "${errorCode}: ${errorMessage}". \nReviewing ${getCapUrl} may help.`, err);
147
- });
148
- }
149
- return super.handlingError(err);
150
- }
151
- requestToKey(extent) {
152
- if (CRS.isTms(extent.crs)) {
153
- return super.requestToKey(extent);
154
- } else {
155
- return [extent.zoom, extent.south, extent.west];
156
- }
157
- }
158
- urlFromExtent(extent) {
159
- return URLBuilder.bbox(extent, this);
160
- }
161
- extentInsideLimit(extent) {
162
- return this.extent.intersectsExtent(extent);
163
- }
164
- }
165
- export default WFSSource;
@@ -1,130 +0,0 @@
1
- import Source from "./Source.js";
2
- import URLBuilder from "../Provider/URLBuilder.js";
3
-
4
- /**
5
- * An object defining the source of images to get from a
6
- * [WMS](http://www.opengeospatial.org/standards/wms) server. It inherits
7
- * from {@link Source}.
8
- *
9
- * @extends Source
10
- *
11
- * @property {boolean} isWMSSource - Used to checkout whether this source is a
12
- * WMSSource. Default is true. You should not change this, as it is used
13
- * internally for optimisation.
14
- * @property {string} name - The name of the layer, used in the generation of
15
- * the url.
16
- * @property {string} version - The version of the WMS server to request on.
17
- * Default value is '1.3.0'.
18
- * @property {string} style - The style to query on the WMS server. Default
19
- * value is 'normal'.
20
- * @property {number} width - The width of the image to fetch, in pixel.
21
- * Default value is the height if set or 256.
22
- * @property {number} height - The height of the image to fetch, in pixel.
23
- * Default value is the width if set or 256.
24
- * @property {string} axisOrder - The order of the axis, that helps building the
25
- * BBOX to put in the url requesting a resource. Default value is 'wsen', other
26
- * value can be 'swne'.
27
- * @property {boolean} transparent - Tells if the image to fetch needs
28
- * transparency support. Default value is false.
29
- * @property {Object} zoom - Object containing the minimum and maximum values of
30
- * the level, to zoom in the source.
31
- * @property {number} zoom.min - The minimum level of the source. Default value
32
- * is 0.
33
- * @property {number} zoom.max - The maximum level of the source. Default value
34
- * is 21.
35
- * @property {string} bboxDigits - The bbox digits precision used in URL
36
- * @property {Object} vendorSpecific - An object containing vendor specific
37
- * parameters. See for example a [list of these parameters for GeoServer](
38
- * https://docs.geoserver.org/latest/en/user/services/wms/vendor.html). This
39
- * object is read simply with the `key` being the name of the parameter and
40
- * `value` being the value of the parameter. If used, this property should be
41
- * set in the constructor parameters.
42
- *
43
- * @example
44
- * // Create the source
45
- * const wmsSource = new itowns.WMSSource({
46
- * url: 'https://server.geo/wms',
47
- * version: '1.3.0',
48
- * name: 'REGION.2016',
49
- * style: '',
50
- * crs: 'EPSG:3857',
51
- * extent: {
52
- * west: '-6880639.13557728',
53
- * east: '6215707.87974825',
54
- * south: '-2438399.00148845',
55
- * north: '7637050.03850605',
56
- * },
57
- * transparent: true,
58
- * });
59
- *
60
- * // Create the layer
61
- * const colorlayer = new itowns.ColorLayer('Region', {
62
- * source: wmsSource,
63
- * });
64
- *
65
- * // Add the layer
66
- * view.addLayer(colorlayer);
67
- */
68
- class WMSSource extends Source {
69
- /**
70
- * @param {Object} source - An object that can contain all properties of
71
- * WMSSource and {@link Source}. `url`, `name`, `extent` and `crs`
72
- * are mandatory.
73
- */
74
- constructor(source) {
75
- if (!source.name) {
76
- throw new Error('source.name is required.');
77
- }
78
- if (!source.extent) {
79
- throw new Error('source.extent is required');
80
- }
81
- if (!source.crs && !source.projection) {
82
- throw new Error('source.crs is required');
83
- }
84
- source.format = source.format || 'image/png';
85
- super(source);
86
- this.isWMSSource = true;
87
- this.name = source.name;
88
- this.zoom = {
89
- min: 0,
90
- max: Infinity
91
- };
92
- this.style = source.style || '';
93
- this.width = source.width || source.height || 256;
94
- this.height = source.height || source.width || 256;
95
- this.version = source.version || '1.3.0';
96
- this.transparent = source.transparent || false;
97
- this.bboxDigits = source.bboxDigits;
98
- if (!source.axisOrder) {
99
- // 4326 (lat/long) axis order depends on the WMS version used
100
- if (this.crs == 'EPSG:4326') {
101
- // EPSG 4326 x = lat, long = y
102
- // version 1.1.0 long/lat while version 1.3.0 mandates xy (so lat,long)
103
- this.axisOrder = this.version === '1.1.0' ? 'wsen' : 'swne';
104
- } else {
105
- // xy,xy order
106
- this.axisOrder = 'wsen';
107
- }
108
- }
109
- const crsPropName = this.version === '1.3.0' ? 'CRS' : 'SRS';
110
-
111
- // Add ? at the end of the url if it is not already in the given URL
112
- if (!this.url.endsWith('?')) {
113
- this.url = `${this.url}?`;
114
- }
115
- 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}`;
116
- this.vendorSpecific = source.vendorSpecific;
117
- for (const name in this.vendorSpecific) {
118
- if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
119
- this.url = `${this.url}&${name}=${this.vendorSpecific[name]}`;
120
- }
121
- }
122
- }
123
- urlFromExtent(extent) {
124
- return URLBuilder.bbox(extent, this);
125
- }
126
- extentInsideLimit(extent) {
127
- return this.extent.intersectsExtent(extent);
128
- }
129
- }
130
- 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;