itowns 2.45.1-next.0 → 2.45.1-next.1
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.
- package/dist/455.js +2 -0
- package/dist/455.js.map +1 -0
- package/dist/debug.js +3 -0
- package/dist/debug.js.LICENSE.txt +13 -0
- package/dist/debug.js.map +1 -0
- package/dist/itowns.js +3 -0
- package/dist/itowns.js.LICENSE.txt +5 -0
- package/dist/itowns.js.map +1 -0
- package/dist/itowns_lasparser.js +2 -0
- package/dist/itowns_lasparser.js.map +1 -0
- package/dist/itowns_lasworker.js +2 -0
- package/dist/itowns_lasworker.js.map +1 -0
- package/dist/itowns_potree2worker.js +2 -0
- package/dist/itowns_potree2worker.js.map +1 -0
- package/dist/itowns_widgets.js +2 -0
- package/dist/itowns_widgets.js.map +1 -0
- package/lib/Controls/FirstPersonControls.js +308 -0
- package/lib/Controls/FlyControls.js +175 -0
- package/lib/Controls/GlobeControls.js +1178 -0
- package/lib/Controls/PlanarControls.js +1025 -0
- package/lib/Controls/StateControl.js +432 -0
- package/lib/Controls/StreetControls.js +392 -0
- package/lib/Converter/Feature2Mesh.js +612 -0
- package/lib/Converter/Feature2Texture.js +174 -0
- package/lib/Converter/convertToTile.js +70 -0
- package/lib/Converter/textureConverter.js +43 -0
- package/lib/Core/3DTiles/C3DTBatchTable.js +131 -0
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +96 -0
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +156 -0
- package/lib/Core/3DTiles/C3DTExtensions.js +97 -0
- package/lib/Core/3DTiles/C3DTFeature.js +110 -0
- package/lib/Core/3DTiles/C3DTilesEnums.js +20 -0
- package/lib/Core/3DTiles/C3DTileset.js +99 -0
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +100 -0
- package/lib/Core/AnimationPlayer.js +142 -0
- package/lib/Core/CopcNode.js +174 -0
- package/lib/Core/Deprecated/Undeprecator.js +74 -0
- package/lib/Core/EntwinePointTileNode.js +126 -0
- package/lib/Core/Feature.js +488 -0
- package/lib/Core/Geographic/GeoidGrid.js +108 -0
- package/lib/Core/Label.js +222 -0
- package/lib/Core/MainLoop.js +209 -0
- package/lib/Core/Picking.js +255 -0
- package/lib/Core/PointCloudNode.js +42 -0
- package/lib/Core/Potree2Node.js +206 -0
- package/lib/Core/Potree2PointAttributes.js +139 -0
- package/lib/Core/PotreeNode.js +101 -0
- package/lib/Core/Prefab/Globe/Atmosphere.js +293 -0
- package/lib/Core/Prefab/Globe/GlobeLayer.js +152 -0
- package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +110 -0
- package/lib/Core/Prefab/Globe/SkyShader.js +78 -0
- package/lib/Core/Prefab/GlobeView.js +155 -0
- package/lib/Core/Prefab/Planar/PlanarLayer.js +59 -0
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +71 -0
- package/lib/Core/Prefab/PlanarView.js +62 -0
- package/lib/Core/Prefab/TileBuilder.js +82 -0
- package/lib/Core/Prefab/computeBufferTileGeometry.js +248 -0
- package/lib/Core/Scheduler/Cache.js +17 -0
- package/lib/Core/Scheduler/CancelledCommandException.js +15 -0
- package/lib/Core/Scheduler/Scheduler.js +294 -0
- package/lib/Core/Style.js +660 -0
- package/lib/Core/StyleOptions.js +486 -0
- package/lib/Core/System/Capabilities.js +63 -0
- package/lib/Core/Tile/Tile.js +205 -0
- package/lib/Core/Tile/TileGrid.js +49 -0
- package/lib/Core/TileGeometry.js +124 -0
- package/lib/Core/TileMesh.js +108 -0
- package/lib/Core/View.js +1115 -0
- package/lib/Layer/C3DTilesLayer.js +459 -0
- package/lib/Layer/ColorLayer.js +154 -0
- package/lib/Layer/CopcLayer.js +63 -0
- package/lib/Layer/ElevationLayer.js +139 -0
- package/lib/Layer/EntwinePointTileLayer.js +71 -0
- package/lib/Layer/FeatureGeometryLayer.js +77 -0
- package/lib/Layer/GeoidLayer.js +80 -0
- package/lib/Layer/GeometryLayer.js +233 -0
- package/lib/Layer/InfoLayer.js +64 -0
- package/lib/Layer/LabelLayer.js +469 -0
- package/lib/Layer/Layer.js +335 -0
- package/lib/Layer/LayerUpdateState.js +89 -0
- package/lib/Layer/LayerUpdateStrategy.js +80 -0
- package/lib/Layer/OGC3DTilesLayer.js +543 -0
- package/lib/Layer/OrientedImageLayer.js +227 -0
- package/lib/Layer/PointCloudLayer.js +405 -0
- package/lib/Layer/Potree2Layer.js +171 -0
- package/lib/Layer/PotreeLayer.js +72 -0
- package/lib/Layer/RasterLayer.js +37 -0
- package/lib/Layer/ReferencingLayerProperties.js +62 -0
- package/lib/Layer/TiledGeometryLayer.js +459 -0
- package/lib/Loader/LASLoader.js +193 -0
- package/lib/Loader/Potree2BrotliLoader.js +261 -0
- package/lib/Loader/Potree2Loader.js +207 -0
- package/lib/Main.js +113 -0
- package/lib/MainBundle.js +4 -0
- package/lib/Parser/B3dmParser.js +174 -0
- package/lib/Parser/CameraCalibrationParser.js +94 -0
- package/lib/Parser/GDFParser.js +72 -0
- package/lib/Parser/GTXParser.js +75 -0
- package/lib/Parser/GeoJsonParser.js +212 -0
- package/lib/Parser/GpxParser.js +25 -0
- package/lib/Parser/ISGParser.js +71 -0
- package/lib/Parser/KMLParser.js +25 -0
- package/lib/Parser/LASParser.js +137 -0
- package/lib/Parser/MapBoxUrlParser.js +83 -0
- package/lib/Parser/PntsParser.js +131 -0
- package/lib/Parser/Potree2BinParser.js +92 -0
- package/lib/Parser/PotreeBinParser.js +106 -0
- package/lib/Parser/PotreeCinParser.js +29 -0
- package/lib/Parser/ShapefileParser.js +78 -0
- package/lib/Parser/VectorTileParser.js +215 -0
- package/lib/Parser/XbilParser.js +120 -0
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +1386 -0
- package/lib/Parser/iGLTFLoader.js +168 -0
- package/lib/Process/3dTilesProcessing.js +304 -0
- package/lib/Process/FeatureProcessing.js +76 -0
- package/lib/Process/LayeredMaterialNodeProcessing.js +229 -0
- package/lib/Process/ObjectRemovalHelper.js +97 -0
- package/lib/Process/handlerNodeError.js +23 -0
- package/lib/Provider/3dTilesProvider.js +149 -0
- package/lib/Provider/DataSourceProvider.js +24 -0
- package/lib/Provider/Fetcher.js +233 -0
- package/lib/Provider/PointCloudProvider.js +45 -0
- package/lib/Provider/TileProvider.js +16 -0
- package/lib/Provider/URLBuilder.js +116 -0
- package/lib/Renderer/Camera.js +281 -0
- package/lib/Renderer/Color.js +56 -0
- package/lib/Renderer/ColorLayersOrdering.js +115 -0
- package/lib/Renderer/CommonMaterial.js +31 -0
- package/lib/Renderer/Label2DRenderer.js +192 -0
- package/lib/Renderer/LayeredMaterial.js +243 -0
- package/lib/Renderer/OBB.js +150 -0
- package/lib/Renderer/OrientedImageCamera.js +118 -0
- package/lib/Renderer/OrientedImageMaterial.js +167 -0
- package/lib/Renderer/PointsMaterial.js +485 -0
- package/lib/Renderer/RasterTile.js +243 -0
- package/lib/Renderer/RenderMode.js +31 -0
- package/lib/Renderer/Shader/ShaderChunk.js +160 -0
- package/lib/Renderer/Shader/ShaderUtils.js +47 -0
- package/lib/Renderer/SphereHelper.js +17 -0
- package/lib/Renderer/WebXR.js +51 -0
- package/lib/Renderer/c3DEngine.js +214 -0
- package/lib/Source/C3DTilesGoogleSource.js +74 -0
- package/lib/Source/C3DTilesIonSource.js +54 -0
- package/lib/Source/C3DTilesSource.js +30 -0
- package/lib/Source/CopcSource.js +126 -0
- package/lib/Source/EntwinePointTileSource.js +72 -0
- package/lib/Source/FileSource.js +188 -0
- package/lib/Source/OGC3DTilesGoogleSource.js +29 -0
- package/lib/Source/OGC3DTilesIonSource.js +34 -0
- package/lib/Source/OGC3DTilesSource.js +21 -0
- package/lib/Source/OrientedImageSource.js +59 -0
- package/lib/Source/Potree2Source.js +167 -0
- package/lib/Source/PotreeSource.js +82 -0
- package/lib/Source/Source.js +202 -0
- package/lib/Source/TMSSource.js +144 -0
- package/lib/Source/VectorTilesSource.js +182 -0
- package/lib/Source/WFSSource.js +170 -0
- package/lib/Source/WMSSource.js +167 -0
- package/lib/Source/WMTSSource.js +92 -0
- package/lib/ThreeExtended/capabilities/WebGL.js +69 -0
- package/lib/ThreeExtended/libs/ktx-parse.module.js +506 -0
- package/lib/ThreeExtended/libs/zstddec.module.js +29 -0
- package/lib/ThreeExtended/loaders/DDSLoader.js +200 -0
- package/lib/ThreeExtended/loaders/DRACOLoader.js +400 -0
- package/lib/ThreeExtended/loaders/GLTFLoader.js +2879 -0
- package/lib/ThreeExtended/loaders/KTX2Loader.js +709 -0
- package/lib/ThreeExtended/math/ColorSpaces.js +59 -0
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +846 -0
- package/lib/ThreeExtended/utils/WorkerPool.js +70 -0
- package/lib/Utils/CameraUtils.js +554 -0
- package/lib/Utils/DEMUtils.js +350 -0
- package/lib/Utils/FeaturesUtils.js +156 -0
- package/lib/Utils/Gradients.js +16 -0
- package/lib/Utils/ThreeUtils.js +115 -0
- package/lib/Utils/gui/C3DTilesStyle.js +218 -0
- package/lib/Utils/gui/Main.js +7 -0
- package/lib/Utils/gui/Minimap.js +152 -0
- package/lib/Utils/gui/Navigation.js +245 -0
- package/lib/Utils/gui/Scale.js +104 -0
- package/lib/Utils/gui/Searchbar.js +234 -0
- package/lib/Utils/gui/Widget.js +80 -0
- package/lib/Utils/placeObjectOnGround.js +136 -0
- package/lib/Worker/LASLoaderWorker.js +19 -0
- package/lib/Worker/Potree2Worker.js +21 -0
- package/package.json +2 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import Source from "./Source.js";
|
|
2
|
+
import URLBuilder from "../Provider/URLBuilder.js";
|
|
3
|
+
import { Extent, CRS } from '@itowns/geographic';
|
|
4
|
+
const _extent = new Extent('EPSG:4326');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Proj provides an optional param to define axis order and orientation for a
|
|
8
|
+
* given projection. 'enu' for instance stands for east, north, up.
|
|
9
|
+
* Elevation is not needed here. The two first characters are sufficient to map
|
|
10
|
+
* proj axis to iTowns bbox order formalism.
|
|
11
|
+
* 'enu' corresponds to 'wsen' because bbox starts by lower value coordinates
|
|
12
|
+
* and preserves axis ordering, here long/lat.
|
|
13
|
+
*/
|
|
14
|
+
const projAxisToBboxMappings = {
|
|
15
|
+
en: 'wsen',
|
|
16
|
+
es: 'wnes',
|
|
17
|
+
wn: 'eswn',
|
|
18
|
+
ws: 'enws',
|
|
19
|
+
ne: 'swne',
|
|
20
|
+
se: 'nwse',
|
|
21
|
+
nw: 'senw',
|
|
22
|
+
sw: 'nesw'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Provides the bbox axis order matching provided proj4 axis
|
|
27
|
+
* @param {string} projAxis the CRS axis order as defined in proj4
|
|
28
|
+
* @returns {string} the corresponding bbox axis order to use for WMS 1.3.0
|
|
29
|
+
*/
|
|
30
|
+
function projAxisToWmsBbox(projAxis) {
|
|
31
|
+
return projAxis && projAxisToBboxMappings[projAxis.slice(0, 2)] || 'wsen';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* An object defining the source of images to get from a
|
|
36
|
+
* [WMS](http://www.opengeospatial.org/standards/wms) server. It inherits
|
|
37
|
+
* from {@link Source}.
|
|
38
|
+
*
|
|
39
|
+
* @extends Source
|
|
40
|
+
*
|
|
41
|
+
* @property {boolean} isWMSSource - Used to checkout whether this source is a
|
|
42
|
+
* WMSSource. Default is true. You should not change this, as it is used
|
|
43
|
+
* internally for optimisation.
|
|
44
|
+
* @property {string} name - The name of the layer, used in the generation of
|
|
45
|
+
* the url.
|
|
46
|
+
* @property {string} version - The version of the WMS server to request on.
|
|
47
|
+
* Default value is '1.3.0'.
|
|
48
|
+
* @property {string} style - The style to query on the WMS server. Default
|
|
49
|
+
* value is 'normal'.
|
|
50
|
+
* @property {number} width - The width of the image to fetch, in pixel.
|
|
51
|
+
* Default value is the height if set or 256.
|
|
52
|
+
* @property {number} height - The height of the image to fetch, in pixel.
|
|
53
|
+
* Default value is the width if set or 256.
|
|
54
|
+
* @property {string} axisOrder - The order of the axis, that helps building the
|
|
55
|
+
* BBOX to put in the url requesting a resource. Default value is 'wsen', other
|
|
56
|
+
* value can be 'swne'.
|
|
57
|
+
* @property {boolean} transparent - Tells if the image to fetch needs
|
|
58
|
+
* transparency support. Default value is false.
|
|
59
|
+
* @property {Object} zoom - Object containing the minimum and maximum values of
|
|
60
|
+
* the level, to zoom in the source.
|
|
61
|
+
* @property {number} zoom.min - The minimum level of the source. Default value
|
|
62
|
+
* is 0.
|
|
63
|
+
* @property {number} zoom.max - The maximum level of the source. Default value
|
|
64
|
+
* is 21.
|
|
65
|
+
* @property {string} bboxDigits - The bbox digits precision used in URL
|
|
66
|
+
* @property {Object} vendorSpecific - An object containing vendor specific
|
|
67
|
+
* parameters. See for example a [list of these parameters for GeoServer](
|
|
68
|
+
* https://docs.geoserver.org/latest/en/user/services/wms/vendor.html). This
|
|
69
|
+
* object is read simply with the `key` being the name of the parameter and
|
|
70
|
+
* `value` being the value of the parameter. If used, this property should be
|
|
71
|
+
* set in the constructor parameters.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Create the source
|
|
75
|
+
* const wmsSource = new itowns.WMSSource({
|
|
76
|
+
* url: 'https://server.geo/wms',
|
|
77
|
+
* version: '1.3.0',
|
|
78
|
+
* name: 'REGION.2016',
|
|
79
|
+
* style: '',
|
|
80
|
+
* crs: 'EPSG:3857',
|
|
81
|
+
* extent: {
|
|
82
|
+
* west: '-6880639.13557728',
|
|
83
|
+
* east: '6215707.87974825',
|
|
84
|
+
* south: '-2438399.00148845',
|
|
85
|
+
* north: '7637050.03850605',
|
|
86
|
+
* },
|
|
87
|
+
* transparent: true,
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* // Create the layer
|
|
91
|
+
* const colorlayer = new itowns.ColorLayer('Region', {
|
|
92
|
+
* source: wmsSource,
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // Add the layer
|
|
96
|
+
* view.addLayer(colorlayer);
|
|
97
|
+
*/
|
|
98
|
+
class WMSSource extends Source {
|
|
99
|
+
/**
|
|
100
|
+
* @param {Object} source - An object that can contain all properties of
|
|
101
|
+
* WMSSource and {@link Source}. `url`, `name`, `extent` and `crs`
|
|
102
|
+
* are mandatory.
|
|
103
|
+
*/
|
|
104
|
+
constructor(source) {
|
|
105
|
+
if (!source.name) {
|
|
106
|
+
throw new Error('source.name is required.');
|
|
107
|
+
}
|
|
108
|
+
if (!source.extent) {
|
|
109
|
+
throw new Error('source.extent is required');
|
|
110
|
+
}
|
|
111
|
+
if (!source.crs && !source.projection) {
|
|
112
|
+
throw new Error('source.crs is required');
|
|
113
|
+
}
|
|
114
|
+
source.format = source.format || 'image/png';
|
|
115
|
+
super(source);
|
|
116
|
+
this.isWMSSource = true;
|
|
117
|
+
this.name = source.name;
|
|
118
|
+
this.zoom = {
|
|
119
|
+
min: 0,
|
|
120
|
+
max: Infinity
|
|
121
|
+
};
|
|
122
|
+
this.style = source.style || '';
|
|
123
|
+
this.width = source.width || source.height || 256;
|
|
124
|
+
this.height = source.height || source.width || 256;
|
|
125
|
+
this.version = source.version || '1.3.0';
|
|
126
|
+
this.transparent = source.transparent || false;
|
|
127
|
+
this.bboxDigits = source.bboxDigits;
|
|
128
|
+
if (source.axisOrder) {
|
|
129
|
+
this.axisOrder = source.axisOrder;
|
|
130
|
+
} else if (this.version === '1.3.0') {
|
|
131
|
+
// If not set, axis order depends on WMS version
|
|
132
|
+
// Version 1.3.0 depends on CRS axis order as defined in epsg.org database
|
|
133
|
+
this.axisOrder = projAxisToWmsBbox(CRS.axisOrder(this.crs));
|
|
134
|
+
} else {
|
|
135
|
+
// Versions 1.X.X mandate long/lat order, east-north orientation
|
|
136
|
+
this.axisOrder = 'wsen';
|
|
137
|
+
}
|
|
138
|
+
const crsPropName = this.version === '1.3.0' ? 'CRS' : 'SRS';
|
|
139
|
+
const urlObj = new URL(this.url);
|
|
140
|
+
urlObj.searchParams.set('SERVICE', 'WMS');
|
|
141
|
+
urlObj.searchParams.set('REQUEST', 'GetMap');
|
|
142
|
+
urlObj.searchParams.set('LAYERS', this.name);
|
|
143
|
+
urlObj.searchParams.set('VERSION', this.version);
|
|
144
|
+
urlObj.searchParams.set('STYLES', this.style);
|
|
145
|
+
urlObj.searchParams.set('FORMAT', this.format);
|
|
146
|
+
urlObj.searchParams.set('TRANSPARENT', this.transparent);
|
|
147
|
+
urlObj.searchParams.set('BBOX', '%bbox');
|
|
148
|
+
urlObj.searchParams.set(crsPropName, this.crs);
|
|
149
|
+
urlObj.searchParams.set('WIDTH', this.width);
|
|
150
|
+
urlObj.searchParams.set('HEIGHT', this.height);
|
|
151
|
+
this.vendorSpecific = source.vendorSpecific;
|
|
152
|
+
for (const name in this.vendorSpecific) {
|
|
153
|
+
if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
|
|
154
|
+
urlObj.searchParams.set(name, this.vendorSpecific[name]);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
this.url = decodeURIComponent(urlObj.toString());
|
|
158
|
+
}
|
|
159
|
+
urlFromExtent(extentOrTile) {
|
|
160
|
+
const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
|
|
161
|
+
return URLBuilder.bbox(extent, this);
|
|
162
|
+
}
|
|
163
|
+
extentInsideLimit(extent) {
|
|
164
|
+
return this.extent.intersectsExtent(extent);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export default WMSSource;
|
|
@@ -0,0 +1,92 @@
|
|
|
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;
|
|
@@ -0,0 +1,69 @@
|
|
|
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;
|