diff --git a/changelog.md b/changelog.md
index a85742de45..2732d2f356 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,25 @@
+
+## [2.36.2](https://github.com/iTowns/itowns/compare/v2.36.1...v2.36.2) (2021-11-29)
+
+
+### Bug Fixes
+
+* **VectorTileSource:** error if vector tile layer style is undefined. ([b535583](https://github.com/iTowns/itowns/commit/b535583))
+
+
+### Code Refactoring
+
+* **Coordinates/Extent:** rename dimension and distance methods. ([6a436ac](https://github.com/iTowns/itowns/commit/6a436ac))
+* **examples:** replace geoservice keys. ([b81738c](https://github.com/iTowns/itowns/commit/b81738c))
+* **Feature:** defaults buildExtent parameter to true for 2d structure ([3182075](https://github.com/iTowns/itowns/commit/3182075))
+
+
+### Workflow and chores
+
+* release v2.36.2 ([54c2128](https://github.com/iTowns/itowns/commit/54c2128))
+
+
+
## [2.36.1](https://github.com/iTowns/itowns/compare/v2.36.0...v2.36.1) (2021-11-22)
diff --git a/examples/js/plugins/CSVnVRTParser.js b/examples/js/plugins/CSVnVRTParser.js
index 51c5aa238b..e906789a21 100644
--- a/examples/js/plugins/CSVnVRTParser.js
+++ b/examples/js/plugins/CSVnVRTParser.js
@@ -18,7 +18,6 @@
* }).then(function _(res) {
* res.csv = Papa.parse(res.csv.trim()).data;
* return CSVnVRTParser.parse(res, { out: {
- * buildExtent: true,
* crs: 'EPSG:4326'
* }
* });
diff --git a/examples/layers/JSONLayers/Administrative.json b/examples/layers/JSONLayers/Administrative.json
index 5484f3a98a..7b523a29e7 100644
--- a/examples/layers/JSONLayers/Administrative.json
+++ b/examples/layers/JSONLayers/Administrative.json
@@ -6,7 +6,7 @@
"transparent": true,
"source": {
"crs": "EPSG:3857",
- "url": "https://wxs.ign.fr/3ht7xcw6f7nciopo16etuqp2/geoportail/wmts",
+ "url": "https://wxs.ign.fr/administratif/geoportail/wmts",
"format": "image/png",
"name": "LIMITES_ADMINISTRATIVES_EXPRESS.LATEST",
"style": "normal",
diff --git a/examples/layers/JSONLayers/Cada.json b/examples/layers/JSONLayers/Cada.json
index ceb2314649..09bf63ac5d 100644
--- a/examples/layers/JSONLayers/Cada.json
+++ b/examples/layers/JSONLayers/Cada.json
@@ -5,7 +5,7 @@
"opacity": 1,
"transparent": true,
"source": {
- "url": "https://wxs.ign.fr/3ht7xcw6f7nciopo16etuqp2/geoportail/wmts",
+ "url": "https://wxs.ign.fr/parcellaire/geoportail/wmts",
"crs": "EPSG:3857",
"networkOptions": {
"crossOrigin": "omit"
diff --git a/examples/layers/JSONLayers/EtatMajor.json b/examples/layers/JSONLayers/EtatMajor.json
index 8bdf8f4125..7c94fb018f 100644
--- a/examples/layers/JSONLayers/EtatMajor.json
+++ b/examples/layers/JSONLayers/EtatMajor.json
@@ -4,7 +4,7 @@
"transparent": true,
"source": {
"crs": "EPSG:3857",
- "url": "http://wxs.ign.fr/va5orxd0pgzvq3jxutqfuy0b/geoportail/wmts",
+ "url": "http://wxs.ign.fr/cartes/geoportail/wmts",
"networkOptions": {
"crossOrigin": "anonymous"
},
diff --git a/examples/layers/JSONLayers/IGN_MNT.json b/examples/layers/JSONLayers/IGN_MNT.json
index 53f50a5ef7..60e27ed9d4 100644
--- a/examples/layers/JSONLayers/IGN_MNT.json
+++ b/examples/layers/JSONLayers/IGN_MNT.json
@@ -8,7 +8,7 @@
}
},
"source": {
- "url": "https://wxs.ign.fr/3ht7xcw6f7nciopo16etuqp2/geoportail/wmts",
+ "url": "https://wxs.ign.fr/altimetrie/geoportail/wmts",
"crs": "EPSG:4326",
"format": "image/x-bil;bits=32",
"attribution" : {
diff --git a/examples/layers/JSONLayers/IGN_MNT_HIGHRES.json b/examples/layers/JSONLayers/IGN_MNT_HIGHRES.json
index f505816b59..88af0c1402 100644
--- a/examples/layers/JSONLayers/IGN_MNT_HIGHRES.json
+++ b/examples/layers/JSONLayers/IGN_MNT_HIGHRES.json
@@ -8,7 +8,7 @@
}
},
"source": {
- "url": "https://wxs.ign.fr/3ht7xcw6f7nciopo16etuqp2/geoportail/wmts",
+ "url": "https://wxs.ign.fr/altimetrie/geoportail/wmts",
"crs": "EPSG:4326",
"format": "image/x-bil;bits=32",
"attribution" : {
diff --git a/examples/layers/JSONLayers/WORLD_DTM.json b/examples/layers/JSONLayers/WORLD_DTM.json
index 2932e6e2bf..16f24be928 100644
--- a/examples/layers/JSONLayers/WORLD_DTM.json
+++ b/examples/layers/JSONLayers/WORLD_DTM.json
@@ -11,7 +11,7 @@
"source": {
"format": "image/x-bil;bits=32",
"crs": "EPSG:4326",
- "url": "https://wxs.ign.fr/3ht7xcw6f7nciopo16etuqp2/geoportail/wmts",
+ "url": "https://wxs.ign.fr/altimetrie/geoportail/wmts",
"name": "ELEVATION.ELEVATIONGRIDCOVERAGE.SRTM3",
"tileMatrixSet": "WGS84G",
"tileMatrixSetLimits": {
diff --git a/examples/misc_custom_label.html b/examples/misc_custom_label.html
index eaa3ac417a..592a484c59 100644
--- a/examples/misc_custom_label.html
+++ b/examples/misc_custom_label.html
@@ -124,8 +124,6 @@
// create new featureCollection
const collection = new itowns.FeatureCollection({
crs: view.tileLayer.extent.crs,
- buildExtent: true,
- structure: '2d',
});
// create new feature
diff --git a/examples/plugins_vrt.html b/examples/plugins_vrt.html
index d714985986..e054d0242d 100644
--- a/examples/plugins_vrt.html
+++ b/examples/plugins_vrt.html
@@ -50,7 +50,6 @@
}).then(function _(res) {
res.csv = Papa.parse(res.csv.trim()).data;
return CSVnVRTParser.parse(res, { out: {
- buildExtent: true,
crs: view.tileLayer.extent.crs,
}});
}).then(function _(features) {
diff --git a/examples/source_file_geojson_raster.html b/examples/source_file_geojson_raster.html
index 946493b762..70b22c5483 100644
--- a/examples/source_file_geojson_raster.html
+++ b/examples/source_file_geojson_raster.html
@@ -109,9 +109,6 @@
// Here, we pass a FeatureBuildingOptions (http://www.itowns-project.org/itowns/docs/#api/Base/FeatureBuildingOptions)
out: {
crs: view.tileLayer.extent.crs,
- buildExtent: true,
- mergeFeatures: true,
- structure: '2d',
},
});
}).then(function _(features) {
diff --git a/examples/source_file_shapefile.html b/examples/source_file_shapefile.html
index f03815db00..5413766e5d 100644
--- a/examples/source_file_shapefile.html
+++ b/examples/source_file_shapefile.html
@@ -50,7 +50,6 @@
return itowns.ShapefileParser.parse(res, {
out: {
crs: view.tileLayer.extent.crs,
- buildExtent: true,
}
});
}).then(function _(features) {
diff --git a/package-lock.json b/package-lock.json
index 3010a34754..c1392f13d8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "itowns",
- "version": "2.36.1",
+ "version": "2.36.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "itowns",
- "version": "2.36.0",
+ "version": "2.36.2",
"license": "(CECILL-B OR MIT)",
"dependencies": {
"@loaders.gl/las": "^3.0.12",
diff --git a/package.json b/package.json
index 984896f7e3..187732dccb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "itowns",
- "version": "2.36.1",
+ "version": "2.36.2",
"description": "A JS/WebGL framework for 3D geospatial data visualization",
"main": "lib/Main.js",
"scripts": {
diff --git a/src/Core/Feature.js b/src/Core/Feature.js
index 2e36a7506b..64c993328d 100644
--- a/src/Core/Feature.js
+++ b/src/Core/Feature.js
@@ -41,17 +41,18 @@ const typeToStyleProperty = ['point', 'stroke', 'fill'];
/**
* @property {string} crs - The CRS to convert the input coordinates to.
+ * @property {string} [structure='2d'] - data structure type : 2d or 3d.
+ * If the structure is 3d, the feature have 3 dimensions by vertices positions and
+ * a normal for each vertices.
* @property {Extent|boolean} [filteringExtent=undefined] - Optional filter to reject
- * features outside of extent. Extent filetring is file extent if filteringExtent is true.
- * @property {boolean} [buildExtent=false] - If true the geometry will
+ * features outside of extent. Extent filtering is file extent if filteringExtent is true.
+ * @property {boolean} [buildExtent] - If true the geometry will
* have an extent property containing the area covered by the geometry.
+ * Default value is false if `structure` parameter is set to '3d', and true otherwise.
* True if the layer does not inherit from {@link GeometryLayer}.
* @property {string} forcedExtentCrs - force feature extent crs if buildExtent is true.
* @property {function} [filter] - Filter function to remove features
- * @property {boolean} [mergeFeatures=true] - If true all geometries are merged by type and multi-type
- * @property {string} [structure='2d'] - data structure type : 2d or 3d.
- * If the structure is 3d, the feature have 3 dimensions by vertices positions and
- * a normal for each vertices.
+ * @property {boolean} [mergeFeatures=true] - If true all geometries are merged by type and multi-type.
* @property {Style} style - The style to inherit when creating
* style for all new features.
*
@@ -361,7 +362,6 @@ export class FeatureCollection extends THREE.Object3D {
this.crs = CRS.formatToEPSG(options.crs);
this.features = [];
this.mergeFeatures = options.mergeFeatures === undefined ? true : options.mergeFeatures;
- this.extent = options.buildExtent ? defaultExtent(options.forcedExtentCrs || this.crs) : undefined;
this.size = options.structure == '3d' ? 3 : 2;
this.filterExtent = options.filterExtent;
this.style = options.style;
@@ -370,6 +370,7 @@ export class FeatureCollection extends THREE.Object3D {
this.center = new Coordinates('EPSG:4326', 0, 0);
if (this.size == 2) {
+ this.extent = options.buildExtent === false ? undefined : defaultExtent(options.forcedExtentCrs || this.crs);
this._setLocalSystem = (center) => {
// set local system center
center.as('EPSG:4326', this.center);
@@ -381,6 +382,7 @@ export class FeatureCollection extends THREE.Object3D {
};
this._transformToLocalSystem = transformToLocalSystem2D;
} else {
+ this.extent = options.buildExtent ? defaultExtent(options.forcedExtentCrs || this.crs) : undefined;
this._setLocalSystem = (center) => {
// set local system center
center.as('EPSG:4326', this.center);
diff --git a/src/Core/Geographic/Coordinates.js b/src/Core/Geographic/Coordinates.js
index 70ad97ff5f..d445915ad9 100644
--- a/src/Core/Geographic/Coordinates.js
+++ b/src/Core/Geographic/Coordinates.js
@@ -218,17 +218,17 @@ class Coordinates {
}
/**
- * Calculate geodesic distance between this coordinates and `coord`.
- * **Geodesic distance** is calculated in an ellispoid space as the distance
+ * Calculate geodetic distance between this coordinates and `coord`.
+ * **Geodetic distance** is calculated in an ellispoid space as the shortest distance
* across the curved surface of the world.
*
* => As the crow flies/ Orthodromy
*
* @param {Coordinates} coord The coordinate
- * @return {number} geodesic distance
+ * @return {number} geodetic distance
*
*/
- geodesicDistanceTo(coord) {
+ geodeticDistanceTo(coord) {
this.as('EPSG:4326', coord0);
coord.as('EPSG:4326', coord1);
return ellipsoid.geodesicDistance(coord0, coord1);
@@ -241,7 +241,7 @@ class Coordinates {
* @return {number} earth euclidean distance
*
*/
- earthEuclideanDistanceTo(coord) {
+ spatialEuclideanDistanceTo(coord) {
this.as('EPSG:4978', coord0).toVector3(v0);
coord.as('EPSG:4978', coord1).toVector3(v1);
return v0.distanceTo(v1);
diff --git a/src/Core/Geographic/Extent.js b/src/Core/Geographic/Extent.js
index 9ba2f1ce89..b4e8ca14de 100644
--- a/src/Core/Geographic/Extent.js
+++ b/src/Core/Geographic/Extent.js
@@ -258,7 +258,7 @@ class Extent {
* @return {THREE.Vector2}
*/
dimensions(target = new THREE.Vector2()) {
- console.warn('Extent.dimensions is deprecated, use planarDimensions, geodesicDimensions or geodesicChordDimensions');
+ console.warn('Extent.dimensions is deprecated, use planarDimensions, geodeticDimensions or spatialEuclideanDimensions');
target.x = Math.abs(this.east - this.west);
target.y = Math.abs(this.north - this.south);
return target;
@@ -277,14 +277,14 @@ class Extent {
}
/**
- * Geodesic dimensions are two planar distances west/east and south/north.
- * Geodesic distance is calculated in an ellispoid space as the distance
+ * Geodetic dimensions are two planar distances west/east and south/north.
+ * Geodetic distance is calculated in an ellispoid space as the distance
* across the curved surface of the world.
*
* @param {THREE.Vector2} [target=new THREE.Vector2()] The target
- * @return {THREE.Vector2} Planar dimensions
+ * @return {THREE.Vector2} geodetic dimensions
*/
- geodesicDimensions(target = new THREE.Vector2()) {
+ geodeticDimensions(target = new THREE.Vector2()) {
// set 3 corners extent
cNorthWest.crs = this.crs;
cSouthWest.crs = this.crs;
@@ -294,18 +294,18 @@ class Extent {
cSouthWest.setFromValues(this.west, this.south, 0);
cNorthEast.setFromValues(this.east, this.north, 0);
- // calcul geodesic distance northWest/northEast and northWest/southWest
- return target.set(cNorthWest.geodesicDistanceTo(cNorthEast), cNorthWest.geodesicDistanceTo(cSouthWest));
+ // calcul geodetic distance northWest/northEast and northWest/southWest
+ return target.set(cNorthWest.geodeticDistanceTo(cNorthEast), cNorthWest.geodeticDistanceTo(cSouthWest));
}
/**
- * Earth euclidean dimensions are two earth euclidean distances between west/east and south/north.
- * Earth euclidean distance chord is calculated in a ellispoid space.
+ * Spatial euclidean dimensions are two spatial euclidean distances between west/east corner and south/north corner.
+ * Spatial euclidean distance chord is calculated in a ellispoid space.
*
* @param {THREE.Vector2} [target=new THREE.Vector2()] The target
- * @return {THREE.Vector2} Earth euclidean dimensions
+ * @return {THREE.Vector2} spatial euclidean dimensions
*/
- earthEuclideanDimensions(target = new THREE.Vector2()) {
+ spatialEuclideanDimensions(target = new THREE.Vector2()) {
// set 3 corners extent
cNorthWest.crs = this.crs;
cSouthWest.crs = this.crs;
@@ -316,7 +316,7 @@ class Extent {
cNorthEast.setFromValues(this.east, this.north, 0);
// calcul chord distance northWest/northEast and northWest/southWest
- return target.set(cNorthWest.earthEuclideanDistanceTo(cNorthEast), cNorthWest.earthEuclideanDistanceTo(cSouthWest));
+ return target.set(cNorthWest.spatialEuclideanDistanceTo(cNorthEast), cNorthWest.spatialEuclideanDistanceTo(cSouthWest));
}
/**
diff --git a/src/Main.js b/src/Main.js
index d6837379fe..ea95087d25 100644
--- a/src/Main.js
+++ b/src/Main.js
@@ -1,5 +1,5 @@
const conf = {
- version: '2.36.1',
+ version: '2.36.2',
};
export const REVISION = conf.version;
diff --git a/src/Parser/ShapefileParser.js b/src/Parser/ShapefileParser.js
index 368419617a..4821ffb04c 100644
--- a/src/Parser/ShapefileParser.js
+++ b/src/Parser/ShapefileParser.js
@@ -32,7 +32,6 @@ import { deprecatedParsingOptionsToNewOne } from 'Core/Deprecated/Undeprecator';
* },
* out: {
* crs: view.tileLayer.extent.crs,
- * buildExtent: true,
* }
* });
* }).then(function _(geojson) {
diff --git a/src/Source/FileSource.js b/src/Source/FileSource.js
index e5026f0060..daca2923a0 100644
--- a/src/Source/FileSource.js
+++ b/src/Source/FileSource.js
@@ -79,13 +79,8 @@ import CRS from 'Core/Geographic/Crs';
* itowns.Fetcher.json('https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/09-ariege/departement-09-ariege.geojson')
* .then(function _(geojson) {
* return itowns.GeoJsonParser.parse(geojson, {
- * in: { in: 'EPSG:4326' },
- * out: {
- * crs: view.tileLayer.extent.crs,
- * buildExtent: true,
- * mergeFeatures: true,
- * structure: '2d',
- * },
+ * in: { crs: 'EPSG:4326' },
+ * out: { crs: view.tileLayer.extent.crs },
* });
* }).then(function _(features) {
* ariege.source = new itowns.FileSource({
diff --git a/src/Source/VectorTilesSource.js b/src/Source/VectorTilesSource.js
index 0f3788375c..2d204b1522 100644
--- a/src/Source/VectorTilesSource.js
+++ b/src/Source/VectorTilesSource.js
@@ -129,9 +129,11 @@ class VectorTilesSource extends TMSSource {
onLayerAdded(options) {
super.onLayerAdded(options);
- const keys = Object.keys(this.styles);
+ if (options.out.style) {
+ const keys = Object.keys(this.styles);
- keys.forEach((k) => { this.styles[k].parent = options.out.style; });
+ keys.forEach((k) => { this.styles[k].parent = options.out.style; });
+ }
}
}
diff --git a/test/functional/source_file_geojson_raster.js b/test/functional/source_file_geojson_raster.js
index cc14e662a0..352c9ea772 100644
--- a/test/functional/source_file_geojson_raster.js
+++ b/test/functional/source_file_geojson_raster.js
@@ -30,7 +30,7 @@ describe('source_file_geojson_raster', function _() {
const promises = [];
const layers = view.getLayers(l => l.source && l.source.isFileSource);
for (let i = 0; i < layers.length; i++) {
- promises.push(layers[i].source.loadData({}, { crs: 'EPSG:4326' }));
+ promises.push(layers[i].source.loadData({}, { crs: 'EPSG:4326', buildExtent: false }));
}
return Promise.all(promises).then(fa => fa.filter(f => itowns
diff --git a/test/unit/coordinate.js b/test/unit/coordinate.js
index 77f965a1dc..035f9515f9 100644
--- a/test/unit/coordinate.js
+++ b/test/unit/coordinate.js
@@ -112,17 +112,17 @@ describe('Coordinates', function () {
const coord0 = new Coordinates('EPSG:4326', 0, 45, 0);
const coord1 = new Coordinates('EPSG:4326', 1.83421, 46.2579066, 0);
- const distance = coord0.geodesicDistanceTo(coord1) / 1000;
+ const distance = coord0.geodeticDistanceTo(coord1) / 1000;
assert.ok(Math.abs(distance - 200) < 0.01);
- assert.equal(distance, coord1.geodesicDistanceTo(coord0) / 1000);
+ assert.equal(distance, coord1.geodeticDistanceTo(coord0) / 1000);
});
it('should correctly return earth euclidean distance to other coordinates', function () {
const coord0 = new Coordinates('EPSG:4326', 0, 45, 0);
const coord1 = new Coordinates('EPSG:4326', 1.83421, 46.2579066, 0);
- const distance = coord0.earthEuclideanDistanceTo(coord1);
+ const distance = coord0.spatialEuclideanDistanceTo(coord1);
assert.equal(distance, 199991.80319097277);
- assert.equal(distance, coord1.earthEuclideanDistanceTo(coord0));
+ assert.equal(distance, coord1.spatialEuclideanDistanceTo(coord0));
});
});
diff --git a/test/unit/extent.js b/test/unit/extent.js
index 2468cc032f..c95d7fe2a4 100644
--- a/test/unit/extent.js
+++ b/test/unit/extent.js
@@ -120,7 +120,7 @@ describe('Extent', function () {
const extent = new Extent('EPSG:4326', 3, 3.01, 46, 46.01);
const dimensions = new Vector2();
- extent.earthEuclideanDimensions(dimensions);
+ extent.spatialEuclideanDimensions(dimensions);
assert.equal(dimensions.x, 774.4934293643765);
assert.equal(dimensions.y, 1111.5141604285038);
});
@@ -129,7 +129,7 @@ describe('Extent', function () {
const extent = new Extent('EPSG:4326', 3, 3.01, 46, 46.01);
const dimensions = new Vector2();
- extent.geodesicDimensions(dimensions);
+ extent.geodeticDimensions(dimensions);
assert.equal(dimensions.x, 773.2375602074535);
assert.equal(dimensions.y, 1113.3197697640906);
});
diff --git a/test/unit/feature.js b/test/unit/feature.js
index eb3cfb0b91..614331f710 100644
--- a/test/unit/feature.js
+++ b/test/unit/feature.js
@@ -30,7 +30,7 @@ describe('Feature', function () {
it('Should instance Features with options', function () {
const collection_A = new FeatureCollection(options_A);
- const collection_B = new FeatureCollection({ crs: 'EPSG:4326' });
+ const collection_B = new FeatureCollection({ crs: 'EPSG:4326', buildExtent: false });
const featureLine_A = collection_A.requestFeatureByType(FEATURE_TYPES.LINE);
const featureLine_B = collection_B.requestFeatureByType(FEATURE_TYPES.LINE);
diff --git a/test/unit/geojson.js b/test/unit/geojson.js
index baa17fdaab..4e007523bc 100644
--- a/test/unit/geojson.js
+++ b/test/unit/geojson.js
@@ -32,7 +32,6 @@ describe('GeoJsonParser', function () {
},
out: {
crs: 'EPSG:3946',
- buildExtent: true,
filteringExtent: new Extent('EPSG:3946', 10, 20, 10, 20),
},
}).then((collection) => {
diff --git a/test/unit/label.js b/test/unit/label.js
index 785b608b4d..b7f5488d61 100644
--- a/test/unit/label.js
+++ b/test/unit/label.js
@@ -23,7 +23,7 @@ describe('LabelLayer', function () {
};
layer.style.text.field = 'content';
- collection = new FeatureCollection({ crs: 'EPSG:4326', buildExtent: true });
+ collection = new FeatureCollection({ crs: 'EPSG:4326' });
const feature = collection.requestFeatureByType(FEATURE_TYPES.POINT);
const geometry = feature.bindNewGeometry();
geometry.startSubGeometry(0, feature);