Compare commits
5 Commits
v6.0.0-bet
...
v6.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7464cedff7 | ||
|
|
51c49e36bc | ||
|
|
b29099a278 | ||
|
|
08c494dd11 | ||
|
|
c0a2549285 |
10952
package-lock.json
generated
Normal file
10952
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ol",
|
||||
"version": "6.0.0-beta.10",
|
||||
"version": "6.0.0-beta.11",
|
||||
"description": "OpenLayers mapping library",
|
||||
"keywords": [
|
||||
"map",
|
||||
|
||||
@@ -357,7 +357,7 @@ if (require.main === module) {
|
||||
option('puppeteer-args', {
|
||||
describe: 'Additional args for Puppeteer',
|
||||
type: 'array',
|
||||
default: process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : []
|
||||
default: process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'] : []
|
||||
}).
|
||||
parse();
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import {get} from '../proj.js';
|
||||
* @property {string} [geometryName='geometry'] Geometry name to use when creating features.
|
||||
* @property {string} [layerName='layer'] Name of the feature attribute that holds the layer name.
|
||||
* @property {Array<string>} [layers] Layers to read features from. If not provided, features will be read from all
|
||||
* @property {string} [idProperty] Optional property that will be assigned as the feature id and removed from the properties.
|
||||
* layers.
|
||||
*/
|
||||
|
||||
@@ -84,6 +85,12 @@ class MVT extends FeatureFormat {
|
||||
*/
|
||||
this.layers_ = options.layers ? options.layers : null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.idProperty_ = options.idProperty;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,8 +171,16 @@ class MVT extends FeatureFormat {
|
||||
}
|
||||
|
||||
let feature;
|
||||
const id = rawFeature.id;
|
||||
const values = rawFeature.properties;
|
||||
|
||||
let id;
|
||||
if (!this.idProperty_) {
|
||||
id = rawFeature.id;
|
||||
} else {
|
||||
id = values[this.idProperty_];
|
||||
delete values[this.idProperty_];
|
||||
}
|
||||
|
||||
values[this.layerName_] = rawFeature.layer.name;
|
||||
|
||||
const flatCoordinates = [];
|
||||
|
||||
@@ -78,6 +78,44 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
expect(features[0].getId()).to.be(2);
|
||||
});
|
||||
|
||||
it('accepts custom idProperty', function() {
|
||||
const format = new MVT({
|
||||
featureClass: Feature,
|
||||
layers: ['poi_label'],
|
||||
idProperty: 'osm_id'
|
||||
});
|
||||
const features = format.readFeatures(data, options);
|
||||
|
||||
const first = features[0];
|
||||
expect(first.getId()).to.be(1000000057590683);
|
||||
expect(first.get('osm_id')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('accepts custom idProperty (render features)', function() {
|
||||
const format = new MVT({
|
||||
layers: ['poi_label'],
|
||||
idProperty: 'osm_id'
|
||||
});
|
||||
|
||||
const features = format.readFeatures(data, options);
|
||||
|
||||
const first = features[0];
|
||||
expect(first.getId()).to.be(1000000057590683);
|
||||
expect(first.get('osm_id')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('works if you provide a bogus idProperty', function() {
|
||||
const format = new MVT({
|
||||
layers: ['poi_label'],
|
||||
idProperty: 'bogus'
|
||||
});
|
||||
|
||||
const features = format.readFeatures(data, options);
|
||||
|
||||
const first = features[0];
|
||||
expect(first.getId()).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user