itowns 2.44.3-next.3 → 2.44.3-next.31
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/CODING.md +1 -1
- package/CONTRIBUTORS.md +1 -0
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.LICENSE.txt +0 -2
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/3dtiles_loader.html +109 -45
- package/examples/config.json +3 -10
- package/examples/entwine_3d_loader.html +3 -1
- package/examples/entwine_simple_loader.html +1 -1
- package/examples/images/itowns_logo.svg +123 -0
- package/examples/js/plugins/COGParser.js +1 -1
- package/examples/jsm/OGC3DTilesHelper.js +1 -1
- package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
- package/examples/source_file_geojson_3d.html +0 -1
- package/examples/source_file_kml_raster_usgs.html +0 -1
- package/examples/source_stream_wfs_raster.html +0 -7
- package/examples/vector_tile_mapbox_raster.html +91 -0
- package/lib/Controls/GlobeControls.js +45 -28
- package/lib/Controls/StateControl.js +5 -2
- package/lib/Converter/Feature2Mesh.js +10 -4
- package/lib/Converter/Feature2Texture.js +6 -1
- package/lib/Converter/convertToTile.js +3 -8
- package/lib/Converter/textureConverter.js +3 -4
- package/lib/Core/Deprecated/Undeprecator.js +0 -1
- package/lib/Core/Feature.js +1 -2
- package/lib/Core/Geographic/Coordinates.js +143 -132
- package/lib/Core/Geographic/Crs.js +140 -145
- package/lib/Core/Geographic/Extent.js +72 -267
- package/lib/Core/Geographic/GeoidGrid.js +1 -1
- package/lib/Core/Math/Ellipsoid.js +62 -21
- package/lib/Core/Prefab/Globe/Atmosphere.js +4 -8
- package/lib/Core/Prefab/Globe/GlobeLayer.js +22 -15
- package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +111 -0
- package/lib/Core/Prefab/GlobeView.js +2 -7
- package/lib/Core/Prefab/Planar/PlanarLayer.js +17 -11
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +43 -43
- package/lib/Core/Prefab/TileBuilder.js +27 -32
- package/lib/Core/Prefab/computeBufferTileGeometry.js +189 -130
- package/lib/Core/Style.js +60 -42
- package/lib/Core/Tile/Tile.js +219 -0
- package/lib/Core/Tile/TileGrid.js +43 -0
- package/lib/Core/TileGeometry.js +112 -28
- package/lib/Core/TileMesh.js +3 -3
- package/lib/Core/View.js +15 -8
- package/lib/Layer/C3DTilesLayer.js +20 -16
- package/lib/Layer/ColorLayer.js +35 -9
- package/lib/Layer/CopcLayer.js +5 -0
- package/lib/Layer/ElevationLayer.js +39 -7
- package/lib/Layer/EntwinePointTileLayer.js +12 -5
- package/lib/Layer/FeatureGeometryLayer.js +20 -6
- package/lib/Layer/GeometryLayer.js +42 -11
- package/lib/Layer/LabelLayer.js +45 -27
- package/lib/Layer/Layer.js +83 -57
- package/lib/Layer/OGC3DTilesLayer.js +81 -30
- package/lib/Layer/OrientedImageLayer.js +11 -5
- package/lib/Layer/PointCloudLayer.js +74 -30
- package/lib/Layer/Potree2Layer.js +7 -2
- package/lib/Layer/PotreeLayer.js +8 -3
- package/lib/Layer/RasterLayer.js +12 -2
- package/lib/Layer/TiledGeometryLayer.js +69 -13
- package/lib/Main.js +2 -2
- package/lib/Parser/GeoJsonParser.js +1 -1
- package/lib/Parser/VectorTileParser.js +42 -29
- package/lib/Parser/XbilParser.js +14 -2
- package/lib/Provider/Fetcher.js +5 -1
- package/lib/Provider/URLBuilder.js +22 -11
- package/lib/Renderer/Camera.js +1 -1
- package/lib/Renderer/Label2DRenderer.js +9 -7
- package/lib/Renderer/OBB.js +11 -13
- package/lib/Renderer/PointsMaterial.js +1 -1
- package/lib/Renderer/RasterTile.js +1 -2
- package/lib/Renderer/SphereHelper.js +0 -6
- package/lib/Source/CopcSource.js +13 -2
- package/lib/Source/EntwinePointTileSource.js +14 -4
- package/lib/Source/FileSource.js +1 -4
- package/lib/Source/Source.js +1 -4
- package/lib/Source/TMSSource.js +10 -9
- package/lib/Source/VectorTilesSource.js +32 -22
- package/lib/Source/WFSSource.js +15 -10
- package/lib/Source/WMSSource.js +56 -18
- package/lib/Source/WMTSSource.js +13 -7
- package/lib/Utils/CameraUtils.js +1 -1
- package/lib/Utils/gui/C3DTilesStyle.js +2 -3
- package/lib/Utils/placeObjectOnGround.js +0 -1
- package/package.json +13 -6
- package/examples/3dtiles_25d.html +0 -120
- package/examples/3dtiles_basic.html +0 -94
- package/examples/3dtiles_batch_table.html +0 -86
- package/examples/3dtiles_ion.html +0 -126
- package/examples/3dtiles_pointcloud.html +0 -95
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import proj4 from 'proj4';
|
|
2
2
|
proj4.defs('EPSG:4978', '+proj=geocent +datum=WGS84 +units=m +no_defs');
|
|
3
|
+
|
|
4
|
+
// Redefining proj4 global projections to match epsg.org database axis order.
|
|
5
|
+
// See https://github.com/iTowns/itowns/pull/2465#issuecomment-2517024859
|
|
6
|
+
proj4.defs('EPSG:4326').axis = 'neu';
|
|
7
|
+
proj4.defs('EPSG:4269').axis = 'neu';
|
|
8
|
+
proj4.defs('WGS84').axis = 'neu';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A projection as a CRS identifier string. This identifier references a
|
|
12
|
+
* projection definition previously defined with
|
|
13
|
+
* [`proj4.defs`](https://github.com/proj4js/proj4js#named-projections).
|
|
14
|
+
*/
|
|
15
|
+
|
|
3
16
|
function isString(s) {
|
|
4
17
|
return typeof s === 'string' || s instanceof String;
|
|
5
18
|
}
|
|
@@ -8,168 +21,150 @@ function mustBeString(crs) {
|
|
|
8
21
|
throw new Error(`Crs parameter value must be a string: '${crs}'`);
|
|
9
22
|
}
|
|
10
23
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function formatToEPSG(crs) {
|
|
22
|
-
mustBeString(crs);
|
|
23
|
-
return isEpsg(crs) ? crs : `EPSG:${crs.match(/\d+/)[0]}`;
|
|
24
|
-
}
|
|
25
|
-
const UNIT = {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* System units supported for a coordinate system. See
|
|
27
|
+
* [proj](https://proj4.org/en/9.5/operations/conversions/unitconvert.html#angular-units).
|
|
28
|
+
* Note that only degree and meters units are supported for now.
|
|
29
|
+
*/
|
|
30
|
+
export const UNIT = {
|
|
31
|
+
/**
|
|
32
|
+
* Angular unit in degree.
|
|
33
|
+
*/
|
|
26
34
|
DEGREE: 1,
|
|
27
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Distance unit in meter.
|
|
37
|
+
*/
|
|
38
|
+
METER: 2,
|
|
39
|
+
/**
|
|
40
|
+
* Distance unit in foot.
|
|
41
|
+
*/
|
|
42
|
+
FOOT: 3
|
|
28
43
|
};
|
|
29
|
-
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks that the CRS is EPSG:4326.
|
|
47
|
+
* @internal
|
|
48
|
+
*
|
|
49
|
+
* @param crs - The CRS to test.
|
|
50
|
+
*/
|
|
51
|
+
export function is4326(crs) {
|
|
30
52
|
return crs === 'EPSG:4326';
|
|
31
53
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
const projection = proj4.defs(crs);
|
|
35
|
-
return !projection ? false : projection.projName == 'geocent';
|
|
36
|
-
}
|
|
37
|
-
function _unitFromProj4Unit(projunit) {
|
|
38
|
-
if (projunit === 'degrees') {
|
|
54
|
+
function unitFromProj4Unit(proj) {
|
|
55
|
+
if (proj.units === 'degrees') {
|
|
39
56
|
return UNIT.DEGREE;
|
|
40
|
-
} else if (
|
|
57
|
+
} else if (proj.units === 'm' || proj.units === 'meter') {
|
|
58
|
+
return UNIT.METER;
|
|
59
|
+
} else if (proj.units === 'foot') {
|
|
60
|
+
return UNIT.FOOT;
|
|
61
|
+
} else if (proj.units === undefined && proj.to_meter === undefined) {
|
|
62
|
+
// See https://proj.org/en/9.4/usage/projections.html [17/10/2024]
|
|
63
|
+
// > The default unit for projected coordinates is the meter.
|
|
41
64
|
return UNIT.METER;
|
|
42
65
|
} else {
|
|
43
66
|
return undefined;
|
|
44
67
|
}
|
|
45
68
|
}
|
|
46
|
-
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Returns the horizontal coordinates system units associated with this CRS.
|
|
72
|
+
*
|
|
73
|
+
* @param crs - The CRS to extract the unit from.
|
|
74
|
+
* @returns Either `UNIT.METER`, `UNIT.DEGREE`, `UNIT.FOOT` or `undefined`.
|
|
75
|
+
*/
|
|
76
|
+
export function getUnit(crs) {
|
|
47
77
|
mustBeString(crs);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
case 'EPSG:4978':
|
|
52
|
-
return UNIT.METER;
|
|
53
|
-
default:
|
|
54
|
-
{
|
|
55
|
-
const p = proj4.defs(formatToEPSG(crs));
|
|
56
|
-
if (!p) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
return _unitFromProj4Unit(p.units);
|
|
60
|
-
}
|
|
78
|
+
const p = proj4.defs(crs);
|
|
79
|
+
if (!p) {
|
|
80
|
+
return undefined;
|
|
61
81
|
}
|
|
82
|
+
return unitFromProj4Unit(p);
|
|
62
83
|
}
|
|
63
|
-
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Asserts that the CRS is using metric units.
|
|
87
|
+
*
|
|
88
|
+
* @param crs - The CRS to check.
|
|
89
|
+
* @throws {@link Error} if the CRS is not valid.
|
|
90
|
+
*/
|
|
91
|
+
export function isMetricUnit(crs) {
|
|
92
|
+
return getUnit(crs) === UNIT.METER;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Asserts that the CRS is geographic.
|
|
97
|
+
*
|
|
98
|
+
* @param crs - The CRS to check.
|
|
99
|
+
* @throws {@link Error} if the CRS is not valid.
|
|
100
|
+
*/
|
|
101
|
+
export function isGeographic(crs) {
|
|
102
|
+
return getUnit(crs) === UNIT.DEGREE;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Asserts that the CRS is geocentric.
|
|
107
|
+
*
|
|
108
|
+
* @param crs - The CRS to test.
|
|
109
|
+
* @returns false if the crs isn't defined.
|
|
110
|
+
*/
|
|
111
|
+
export function isGeocentric(crs) {
|
|
64
112
|
mustBeString(crs);
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
113
|
+
const projection = proj4.defs(crs);
|
|
114
|
+
return !projection ? false : projection.projName == 'geocent';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Asserts that the CRS is valid, meaning it has been previously defined and
|
|
119
|
+
* includes an unit.
|
|
120
|
+
*
|
|
121
|
+
* @param crs - The CRS to test.
|
|
122
|
+
* @throws {@link Error} if the crs is not valid.
|
|
123
|
+
*/
|
|
124
|
+
export function isValid(crs) {
|
|
125
|
+
const proj = proj4.defs(crs);
|
|
126
|
+
if (!proj) {
|
|
127
|
+
throw new Error(`Undefined crs '${crs}'. Add it with proj4.defs('${crs}', string)`);
|
|
128
|
+
}
|
|
129
|
+
if (!unitFromProj4Unit(proj)) {
|
|
130
|
+
throw new Error(`No valid unit found for crs '${crs}', found ${proj.units}`);
|
|
68
131
|
}
|
|
69
|
-
return u;
|
|
70
132
|
}
|
|
71
133
|
|
|
72
134
|
/**
|
|
73
|
-
*
|
|
135
|
+
* Gives a reasonable epsilon for this CRS.
|
|
74
136
|
*
|
|
75
|
-
* @
|
|
137
|
+
* @param crs - The CRS to use.
|
|
138
|
+
* @returns 0.01 if the CRS is EPSG:4326, 0.001 otherwise.
|
|
76
139
|
*/
|
|
77
|
-
export
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
* @return {boolean}
|
|
109
|
-
* @throws {Error} if the CRS is not valid.
|
|
110
|
-
*/
|
|
111
|
-
isMetricUnit(crs) {
|
|
112
|
-
return toUnit(crs) == UNIT.METER;
|
|
113
|
-
},
|
|
114
|
-
/**
|
|
115
|
-
* Get the unit to use with the CRS.
|
|
116
|
-
*
|
|
117
|
-
* @param {string} crs - The CRS to get the unit from.
|
|
118
|
-
* @return {number} Either `UNIT.METER`, `UNIT.DEGREE` or `undefined`.
|
|
119
|
-
*/
|
|
120
|
-
toUnit,
|
|
121
|
-
/**
|
|
122
|
-
* Is the CRS EPSG:4326 ?
|
|
123
|
-
*
|
|
124
|
-
* @param {string} crs - The CRS to test.
|
|
125
|
-
* @return {boolean}
|
|
126
|
-
*/
|
|
127
|
-
is4326,
|
|
128
|
-
/**
|
|
129
|
-
* Is the CRS geocentric ?
|
|
130
|
-
* if crs isn't defined the method returns false.
|
|
131
|
-
*
|
|
132
|
-
* @param {string} crs - The CRS to test.
|
|
133
|
-
* @return {boolean}
|
|
134
|
-
*/
|
|
135
|
-
isGeocentric,
|
|
136
|
-
/**
|
|
137
|
-
* Give a reasonnable epsilon to use with this CRS.
|
|
138
|
-
*
|
|
139
|
-
* @param {string} crs - The CRS to use.
|
|
140
|
-
* @return {number} 0.01 if the CRS is EPSG:4326, 0.001 otherwise.
|
|
141
|
-
*/
|
|
142
|
-
reasonnableEpsilon(crs) {
|
|
143
|
-
if (is4326(crs)) {
|
|
144
|
-
return 0.01;
|
|
145
|
-
} else {
|
|
146
|
-
return 0.001;
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
/**
|
|
150
|
-
* format crs to European Petroleum Survey Group notation : EPSG:XXXX.
|
|
151
|
-
*
|
|
152
|
-
* @param {string} crs The crs to format
|
|
153
|
-
* @return {string} formated crs
|
|
154
|
-
*/
|
|
155
|
-
formatToEPSG,
|
|
156
|
-
/**
|
|
157
|
-
* format crs to tile matrix set notation : TMS:XXXX.
|
|
158
|
-
*
|
|
159
|
-
* @param {string} crs The crs to format
|
|
160
|
-
* @return {string} formated crs
|
|
161
|
-
*/
|
|
162
|
-
formatToTms,
|
|
163
|
-
isTms,
|
|
164
|
-
isEpsg,
|
|
165
|
-
tms_3857: 'TMS:3857',
|
|
166
|
-
tms_4326: 'TMS:4326',
|
|
167
|
-
/**
|
|
168
|
-
* Define a proj4 projection as a string and reference.
|
|
169
|
-
*
|
|
170
|
-
* @param {string} code code is the projection's SRS code (only used internally by the Proj4js library)
|
|
171
|
-
* @param {string} proj4def is the Proj4 definition string for the projection to use
|
|
172
|
-
* @return {undefined}
|
|
173
|
-
*/
|
|
174
|
-
defs: (code, proj4def) => proj4.defs(code, proj4def)
|
|
175
|
-
};
|
|
140
|
+
export function reasonableEpsilon(crs) {
|
|
141
|
+
if (is4326(crs)) {
|
|
142
|
+
return 0.01;
|
|
143
|
+
} else {
|
|
144
|
+
return 0.001;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns the axis parameter defined in proj4 for the provided crs.
|
|
150
|
+
* Might be undefined depending on crs definition.
|
|
151
|
+
*
|
|
152
|
+
* @param crs - The CRS to get axis from.
|
|
153
|
+
* @returns the matching proj4 axis string, 'enu' for instance (east, north, up)
|
|
154
|
+
*/
|
|
155
|
+
export function axisOrder(crs) {
|
|
156
|
+
mustBeString(crs);
|
|
157
|
+
const projection = proj4.defs(crs);
|
|
158
|
+
return !projection ? undefined : projection.axis;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Defines a proj4 projection as a named alias.
|
|
163
|
+
* This function is a specialized wrapper over the
|
|
164
|
+
* [`proj4.defs`](https://github.com/proj4js/proj4js#named-projections)
|
|
165
|
+
* function.
|
|
166
|
+
*
|
|
167
|
+
* @param code - Named alias of the currently defined projection.
|
|
168
|
+
* @param proj4def - Proj4 or WKT string of the defined projection.
|
|
169
|
+
*/
|
|
170
|
+
export const defs = (code, proj4def) => proj4.defs(code, proj4def);
|