diff --git a/src/Converter/textureConverter.js b/src/Converter/textureConverter.js
index 3f8db06f2f..ad68f33131 100644
--- a/src/Converter/textureConverter.js
+++ b/src/Converter/textureConverter.js
@@ -29,7 +29,7 @@ export default {
extentDestination.as(CRS.formatToEPSG(layer.crs), extentTexture);
texture = Feature2Texture.createTextureFromFeature(data, extentTexture, 256, layer.style, backgroundColor);
- texture.parsedData = data;
+ texture.features = data;
texture.extent = extentDestination;
} else if (data.isTexture) {
texture = data;
diff --git a/src/Core/View.js b/src/Core/View.js
index 5c237ffd3b..f5fe0f0462 100644
--- a/src/Core/View.js
+++ b/src/Core/View.js
@@ -783,14 +783,14 @@ class View extends THREE.EventDispatcher {
for (const materialLayer of tile.object.material.getLayers(layers)) {
for (const texture of materialLayer.textures) {
- if (!texture.parsedData) {
+ if (!texture.features) {
continue;
}
- precision = CRS.isMetricUnit(texture.parsedData.crs) ? precisions.M : precisions.D;
+ precision = CRS.isMetricUnit(texture.features.crs) ? precisions.M : precisions.D;
result[materialLayer.id] = result[materialLayer.id].concat(
- FeaturesUtils.filterFeaturesUnderCoordinate(coordinates, texture.parsedData, precision));
+ FeaturesUtils.filterFeaturesUnderCoordinate(coordinates, texture.features, precision));
}
}
}
diff --git a/src/Layer/Layer.js b/src/Layer/Layer.js
index 6513ff887c..2bd1091aeb 100644
--- a/src/Layer/Layer.js
+++ b/src/Layer/Layer.js
@@ -223,7 +223,7 @@ class Layer extends THREE.EventDispatcher {
data = Promise.resolve(this.convert(feature, to));
} else {
data = this.source.loadData(from, this.parsingOptions)
- .then(parsedData => this.convert(parsedData, to), (err) => {
+ .then(feat => this.convert(feat, to), (err) => {
throw err;
});
}
diff --git a/src/Parser/ShapefileParser.js b/src/Parser/ShapefileParser.js
index ea745d7dfb..901c2edd57 100644
--- a/src/Parser/ShapefileParser.js
+++ b/src/Parser/ShapefileParser.js
@@ -31,7 +31,7 @@ import GeoJsonParser from 'Parser/GeoJsonParser';
* crsOut: view.tileLayer.extent.crs,
* });
* }).then(function _(geojson) {
- * var source = new FileSource({ parsedData: geojson });
+ * var source = new FileSource({ features: geojson });
* var layer = new ColorLayer('velib', { source });
* view.addLayer(layer);
* });
diff --git a/src/Process/LayeredMaterialNodeProcessing.js b/src/Process/LayeredMaterialNodeProcessing.js
index 9a19a55fd5..23925d91a0 100644
--- a/src/Process/LayeredMaterialNodeProcessing.js
+++ b/src/Process/LayeredMaterialNodeProcessing.js
@@ -29,14 +29,14 @@ function refinementCommandCancellationFn(cmd) {
return !cmd.requester.material.visible;
}
-function buildCommand(view, layer, extentsSource, extentsDestination, requester, parsedData) {
+function buildCommand(view, layer, extentsSource, extentsDestination, requester, features) {
return {
view,
layer,
extentsSource,
extentsDestination,
requester,
- parsedData,
+ features,
priority: materialCommandQueuePriorityFunction(requester.material),
earlyDropFunction: refinementCommandCancellationFn,
};
@@ -152,8 +152,8 @@ export function updateLayeredMaterialNodeImagery(context, layer, node, parent) {
}
node.layerUpdateState[layer.id].newTry();
- const parsedData = nodeLayer.textures.map(t => layer.isValidData(t.parsedData));
- const command = buildCommand(context.view, layer, extentsSource, extentsDestination, node, parsedData);
+ const features = nodeLayer.textures.map(t => layer.isValidData(t.features));
+ const command = buildCommand(context.view, layer, extentsSource, extentsDestination, node, features);
return context.scheduler.execute(command).then(
(result) => {
diff --git a/src/Provider/DataSourceProvider.js b/src/Provider/DataSourceProvider.js
index 8a4d4ab168..7a265b041d 100644
--- a/src/Provider/DataSourceProvider.js
+++ b/src/Provider/DataSourceProvider.js
@@ -1,7 +1,7 @@
export default {
executeCommand(command) {
const layer = command.layer;
- const features = command.parsedData || [];
+ const features = command.features || [];
const src = command.extentsSource;
const dst = command.extentsDestination || src;
diff --git a/src/Source/FileSource.js b/src/Source/FileSource.js
index 540640d9cb..ff13ef7305 100644
--- a/src/Source/FileSource.js
+++ b/src/Source/FileSource.js
@@ -14,7 +14,7 @@ const ext = new Extent('EPSG:4326', [0, 0, 0, 0]);
*
fetch the file, and give the data to the source using the `fetchedData`
* property.
* fetch the file, parse it and git the parsed data to the source using the
- * `parsedData` property.
+ * `features` property.
*
* See the examples below for real use cases.
*
@@ -25,7 +25,7 @@ const ext = new Extent('EPSG:4326', [0, 0, 0, 0]);
* internally for optimisation.
* @property {*} fetchedData - Once the file has been loaded, the resulting data
* is stored in this property.
- * @property {*} parsedData - Once the file has been loaded and parsed, the
+ * @property {*} features - Once the file has been loaded and parsed, the
* resulting data is stored in this property.
*
* @example Simple: create a source, a layer, and let iTowns taking
@@ -88,10 +88,10 @@ const ext = new Extent('EPSG:4326', [0, 0, 0, 0]);
* withNormal: false,
* withAltitude: false,
* });
- * }).then(function _(parsedData) {
+ * }).then(function _(features) {
* ariege.source = new itowns.FileSource({
* crs: 'EPSG:4326',
- * parsedData,
+ * features,
* });
*
* return view.addLayer(ariegeLayer);
@@ -101,43 +101,48 @@ class FileSource extends Source {
/**
* @param {Object} source - An object that can contain all properties of a
* FileSource and {@link Source}. Only `crs` is mandatory, but if it
- * presents in `parsedData` under the property `crs`, it is fine.
+ * presents in `features` under the property `crs`, it is fine.
*
* @constructor
*/
constructor(source) {
+ /* istanbul ignore next */
+ if (source.parsedData) {
+ console.warn('FileSource parsedData parameter is deprecated, use features instead of.');
+ source.features = source.features || source.parsedData;
+ }
/* istanbul ignore next */
if (source.projection) {
console.warn('FileSource projection parameter is deprecated, use crs instead.');
source.crs = source.crs || source.projection;
}
if (!source.crs) {
- if (source.parsedData && source.parsedData.crs) {
- source.crs = source.parsedData.crs;
+ if (source.features && source.features.crs) {
+ source.crs = source.features.crs;
} else {
throw new Error('source.crs is required in FileSource');
}
}
- if (!source.url && !source.fetchedData && !source.parsedData) {
- throw new Error(`url, fetchedData and parsedData are not set in
+ if (!source.url && !source.fetchedData && !source.features) {
+ throw new Error(`url, fetchedData and features are not set in
FileSource; at least one needs to be present`);
}
- // the fake url is for when we use the fetchedData or parsedData mode
+ // the fake url is for when we use the fetchedData or features mode
source.url = source.url || 'fake-file-url';
super(source);
this.isFileSource = true;
this.fetchedData = source.fetchedData;
- if (!this.fetchedData && !source.parsedData) {
+ if (!this.fetchedData && !source.features) {
this.whenReady = this.fetcher(this.urlFromExtent(), this.networkOptions).then((f) => {
this.fetchedData = f;
});
- } else if (source.parsedData) {
- this._parsedDatasCaches[source.parsedData.crs] = new Cache();
- this._parsedDatasCaches[source.parsedData.crs].setByArray(Promise.resolve(source.parsedData), [0]);
+ } else if (source.features) {
+ this._featuresCaches[source.features.crs] = new Cache();
+ this._featuresCaches[source.features.crs].setByArray(Promise.resolve(source.features), [0]);
}
this.whenReady.then(() => this.fetchedData);
@@ -151,13 +156,13 @@ class FileSource extends Source {
onLayerAdded(options) {
super.onLayerAdded(options);
- let parsedData = this._parsedDatasCaches[options.crsOut].getByArray([0]);
- if (!parsedData) {
+ let features = this._featuresCaches[options.crsOut].getByArray([0]);
+ if (!features) {
options.buildExtent = true;
- parsedData = this.parser(this.fetchedData, options);
- this._parsedDatasCaches[options.crsOut].setByArray(parsedData, [0]);
+ features = this.parser(this.fetchedData, options);
+ this._featuresCaches[options.crsOut].setByArray(features, [0]);
}
- parsedData.then((data) => {
+ features.then((data) => {
this.extent = data.extent;
if (data.isFeatureCollection) {
data.setParentStyle(options.style);
@@ -174,7 +179,7 @@ class FileSource extends Source {
* @return {FeatureCollection|Texture} The parsed data.
*/
loadData(extent, options) {
- return this._parsedDatasCaches[options.crsOut].getByArray([0]);
+ return this._featuresCaches[options.crsOut].getByArray([0]);
}
extentInsideLimit(extent) {
diff --git a/src/Source/Source.js b/src/Source/Source.js
index 24d48f3707..dbef7917dc 100644
--- a/src/Source/Source.js
+++ b/src/Source/Source.js
@@ -127,7 +127,7 @@ class Source {
this.crs = source.crs;
this.attribution = source.attribution;
this.whenReady = Promise.resolve();
- this._parsedDatasCaches = {};
+ this._featuresCaches = {};
if (source.extent && !(source.extent.isExtent)) {
this.extent = new Extent(this.crs, source.extent);
} else {
@@ -165,23 +165,23 @@ class Source {
* @return {FeatureCollection|Texture} The parsed data.
*/
loadData(extent, options) {
- const cache = this._parsedDatasCaches[options.crsOut];
+ const cache = this._featuresCaches[options.crsOut];
// try to get parsed data from cache
- let parsedData = cache.getByArray(this.requestToKey(extent));
- if (!parsedData) {
+ let features = cache.getByArray(this.requestToKey(extent));
+ if (!features) {
// otherwise fetch/parse the data
- parsedData = cache.setByArray(fetchSourceData(this, extent).then(fetchedData => this.parser(fetchedData, options),
+ features = cache.setByArray(fetchSourceData(this, extent).then(fetchedData => this.parser(fetchedData, options),
err => this.handlingError(err)), this.requestToKey(extent));
/* istanbul ignore next */
if (this.onParsedFile) {
- parsedData.then((feature) => {
- this.onParsedFile(feature);
+ features.then((feat) => {
+ this.onParsedFile(feat);
console.warn('Source.onParsedFile was deprecated');
- return feature;
+ return feat;
});
}
}
- return parsedData;
+ return features;
}
/**
@@ -191,8 +191,8 @@ class Source {
*/
onLayerAdded(options) {
// Added new cache by crs
- if (!this._parsedDatasCaches[options.crsOut]) {
- this._parsedDatasCaches[options.crsOut] = new Cache();
+ if (!this._featuresCaches[options.crsOut]) {
+ this._featuresCaches[options.crsOut] = new Cache();
}
}
@@ -203,10 +203,10 @@ class Source {
*/
onLayerRemoved(options = {}) {
// delete unused cache
- const unusedCache = this._parsedDatasCaches[options.unusedCrs];
+ const unusedCache = this._featuresCaches[options.unusedCrs];
if (unusedCache) {
unusedCache.clear();
- delete this._parsedDatasCaches[options.unusedCrs];
+ delete this._featuresCaches[options.unusedCrs];
}
}