Rename _ol_format_MVT_ to MVT

This commit is contained in:
Tim Schaub
2017-12-17 02:00:48 -07:00
parent e77ef118ea
commit cdf7b3276b
8 changed files with 60 additions and 60 deletions

View File

@@ -1,6 +1,6 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_format_MVT_ from '../src/ol/format/MVT.js';
import MVT from '../src/ol/format/MVT.js';
import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js';
import {get as getProjection} from '../src/ol/proj.js';
import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js';
@@ -37,7 +37,7 @@ var map = new _ol_Map_({
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
'© <a href="https://www.openstreetmap.org/copyright">' +
'OpenStreetMap contributors</a>',
format: new _ol_format_MVT_(),
format: new MVT(),
tileGrid: new _ol_tilegrid_TileGrid_({
extent: getProjection('EPSG:3857').getExtent(),
resolutions: resolutions,

View File

@@ -1,6 +1,6 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_format_MVT_ from '../src/ol/format/MVT.js';
import MVT from '../src/ol/format/MVT.js';
import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js';
import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js';
@@ -20,7 +20,7 @@ var map = new _ol_Map_({
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
'© <a href="https://www.openstreetmap.org/copyright">' +
'OpenStreetMap contributors</a>',
format: new _ol_format_MVT_(),
format: new MVT(),
url: 'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
'{z}/{x}/{y}.vector.pbf?access_token=' + key
}),

View File

@@ -1,6 +1,6 @@
import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import _ol_format_MVT_ from '../src/ol/format/MVT.js';
import MVT from '../src/ol/format/MVT.js';
import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js';
import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js';
@@ -12,7 +12,7 @@ var map = new _ol_Map_({
}),
layers: [new _ol_layer_VectorTile_({
source: new _ol_source_VectorTile_({
format: new _ol_format_MVT_(),
format: new MVT(),
url: 'https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer/tile/{z}/{y}/{x}.pbf'
})
})]

View File

@@ -30,7 +30,7 @@ import _ol_render_Feature_ from '../render/Feature.js';
* @param {olx.format.MVTOptions=} opt_options Options.
* @api
*/
var _ol_format_MVT_ = function(opt_options) {
var MVT = function(opt_options) {
FeatureFormat.call(this);
@@ -79,14 +79,14 @@ var _ol_format_MVT_ = function(opt_options) {
};
inherits(_ol_format_MVT_, FeatureFormat);
inherits(MVT, FeatureFormat);
/**
* Reader callbacks for parsing the PBF.
* @type {Object.<string, function(number, Object, ol.ext.PBF)>}
*/
_ol_format_MVT_.pbfReaders_ = {
MVT.pbfReaders_ = {
layers: function(tag, layers, pbf) {
if (tag === 3) {
var layer = {
@@ -95,7 +95,7 @@ _ol_format_MVT_.pbfReaders_ = {
features: []
};
var end = pbf.readVarint() + pbf.pos;
pbf.readFields(_ol_format_MVT_.pbfReaders_.layer, layer, end);
pbf.readFields(MVT.pbfReaders_.layer, layer, end);
layer.length = layer.features.length;
if (layer.length) {
layers[layer.name] = layer;
@@ -157,7 +157,7 @@ _ol_format_MVT_.pbfReaders_ = {
* @param {number} i Index of the feature in the raw layer's `features` array.
* @return {Object} Raw feature.
*/
_ol_format_MVT_.readRawFeature_ = function(pbf, layer, i) {
MVT.readRawFeature_ = function(pbf, layer, i) {
pbf.pos = layer.features[i];
var end = pbf.readVarint() + pbf.pos;
@@ -166,7 +166,7 @@ _ol_format_MVT_.readRawFeature_ = function(pbf, layer, i) {
type: 0,
properties: {}
};
pbf.readFields(_ol_format_MVT_.pbfReaders_.feature, feature, end);
pbf.readFields(MVT.pbfReaders_.feature, feature, end);
return feature;
};
@@ -181,7 +181,7 @@ _ol_format_MVT_.readRawFeature_ = function(pbf, layer, i) {
* @param {Array.<number>} flatCoordinates Array to store flat coordinates in.
* @param {Array.<number>} ends Array to store ends in.
*/
_ol_format_MVT_.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends) {
MVT.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends) {
pbf.pos = feature.geometry;
var end = pbf.readVarint() + pbf.pos;
@@ -245,7 +245,7 @@ _ol_format_MVT_.readRawGeometry_ = function(pbf, feature, flatCoordinates, ends)
* geometry.
* @return {ol.geom.GeometryType} The geometry type.
*/
_ol_format_MVT_.getGeometryType_ = function(type, numEnds) {
MVT.getGeometryType_ = function(type, numEnds) {
/** @type {ol.geom.GeometryType} */
var geometryType;
if (type === 1) {
@@ -270,7 +270,7 @@ _ol_format_MVT_.getGeometryType_ = function(type, numEnds) {
* @param {olx.format.ReadOptions=} opt_options Read options.
* @return {ol.Feature|ol.render.Feature} Feature.
*/
_ol_format_MVT_.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
var type = rawFeature.type;
if (type === 0) {
return null;
@@ -283,9 +283,9 @@ _ol_format_MVT_.prototype.createFeature_ = function(pbf, rawFeature, opt_options
var flatCoordinates = [];
var ends = [];
_ol_format_MVT_.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends);
MVT.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends);
var geometryType = _ol_format_MVT_.getGeometryType_(type, ends.length);
var geometryType = MVT.getGeometryType_(type, ends.length);
if (this.featureClass_ === _ol_render_Feature_) {
feature = new this.featureClass_(geometryType, flatCoordinates, ends, values, id);
@@ -336,7 +336,7 @@ _ol_format_MVT_.prototype.createFeature_ = function(pbf, rawFeature, opt_options
* @inheritDoc
* @api
*/
_ol_format_MVT_.prototype.getLastExtent = function() {
MVT.prototype.getLastExtent = function() {
return this.extent_;
};
@@ -344,7 +344,7 @@ _ol_format_MVT_.prototype.getLastExtent = function() {
/**
* @inheritDoc
*/
_ol_format_MVT_.prototype.getType = function() {
MVT.prototype.getType = function() {
return _ol_format_FormatType_.ARRAY_BUFFER;
};
@@ -353,11 +353,11 @@ _ol_format_MVT_.prototype.getType = function() {
* @inheritDoc
* @api
*/
_ol_format_MVT_.prototype.readFeatures = function(source, opt_options) {
MVT.prototype.readFeatures = function(source, opt_options) {
var layers = this.layers_;
var pbf = new PBF(/** @type {ArrayBuffer} */ (source));
var pbfLayers = pbf.readFields(_ol_format_MVT_.pbfReaders_.layers, {});
var pbfLayers = pbf.readFields(MVT.pbfReaders_.layers, {});
/** @type {Array.<ol.Feature|ol.render.Feature>} */
var features = [];
var pbfLayer;
@@ -369,7 +369,7 @@ _ol_format_MVT_.prototype.readFeatures = function(source, opt_options) {
var rawFeature;
for (var i = 0, ii = pbfLayer.length; i < ii; ++i) {
rawFeature = _ol_format_MVT_.readRawFeature_(pbf, pbfLayer, i);
rawFeature = MVT.readRawFeature_(pbf, pbfLayer, i);
features.push(this.createFeature_(pbf, rawFeature));
}
this.extent_ = pbfLayer ? [0, 0, pbfLayer.extent, pbfLayer.extent] : null;
@@ -383,7 +383,7 @@ _ol_format_MVT_.prototype.readFeatures = function(source, opt_options) {
* @inheritDoc
* @api
*/
_ol_format_MVT_.prototype.readProjection = function(source) {
MVT.prototype.readProjection = function(source) {
return this.defaultDataProjection;
};
@@ -393,7 +393,7 @@ _ol_format_MVT_.prototype.readProjection = function(source) {
* @param {Array.<string>} layers Layers.
* @api
*/
_ol_format_MVT_.prototype.setLayers = function(layers) {
MVT.prototype.setLayers = function(layers) {
this.layers_ = layers;
};
@@ -402,33 +402,33 @@ _ol_format_MVT_.prototype.setLayers = function(layers) {
* Not implemented.
* @override
*/
_ol_format_MVT_.prototype.readFeature = function() {};
MVT.prototype.readFeature = function() {};
/**
* Not implemented.
* @override
*/
_ol_format_MVT_.prototype.readGeometry = function() {};
MVT.prototype.readGeometry = function() {};
/**
* Not implemented.
* @override
*/
_ol_format_MVT_.prototype.writeFeature = function() {};
MVT.prototype.writeFeature = function() {};
/**
* Not implemented.
* @override
*/
_ol_format_MVT_.prototype.writeGeometry = function() {};
MVT.prototype.writeGeometry = function() {};
/**
* Not implemented.
* @override
*/
_ol_format_MVT_.prototype.writeFeatures = function() {};
export default _ol_format_MVT_;
MVT.prototype.writeFeatures = function() {};
export default MVT;

View File

@@ -1,7 +1,7 @@
import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_View_ from '../../../../src/ol/View.js';
import _ol_format_MVT_ from '../../../../src/ol/format/MVT.js';
import MVT from '../../../../src/ol/format/MVT.js';
import Point from '../../../../src/ol/geom/Point.js';
import _ol_layer_Vector_ from '../../../../src/ol/layer/Vector.js';
import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js';
@@ -70,7 +70,7 @@ describe('ol.rendering.layer.VectorTile', function() {
beforeEach(function() {
source = new _ol_source_VectorTile_({
format: new _ol_format_MVT_(),
format: new MVT(),
tileGrid: _ol_tilegrid_.createXYZ(),
url: 'rendering/ol/data/tiles/mvt/{z}-{x}-{y}.vector.pbf',
transition: 0

View File

@@ -1,6 +1,6 @@
import _ol_Feature_ from '../../../../src/ol/Feature.js';
import * as _ol_extent_ from '../../../../src/ol/extent.js';
import _ol_format_MVT_ from '../../../../src/ol/format/MVT.js';
import MVT from '../../../../src/ol/format/MVT.js';
import Point from '../../../../src/ol/geom/Point.js';
import Polygon from '../../../../src/ol/geom/Polygon.js';
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
@@ -23,19 +23,19 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
describe('#readFeatures', function() {
it('uses ol.render.Feature as feature class by default', function() {
var format = new _ol_format_MVT_({layers: ['water']});
var format = new MVT({layers: ['water']});
var features = format.readFeatures(data);
expect(features[0]).to.be.a(_ol_render_Feature_);
});
it('parses only specified layers', function() {
var format = new _ol_format_MVT_({layers: ['water']});
var format = new MVT({layers: ['water']});
var features = format.readFeatures(data);
expect(features.length).to.be(10);
});
it('parses geometries correctly', function() {
var format = new _ol_format_MVT_({
var format = new MVT({
featureClass: _ol_Feature_,
layers: ['poi_label']
});
@@ -60,14 +60,14 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
it('parses id property', function() {
// ol.Feature
var format = new _ol_format_MVT_({
var format = new MVT({
featureClass: _ol_Feature_,
layers: ['building']
});
var features = format.readFeatures(data);
expect(features[0].getId()).to.be(2);
// ol.render.Feature
format = new _ol_format_MVT_({
format = new MVT({
layers: ['building']
});
features = format.readFeatures(data);
@@ -75,7 +75,7 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
});
it('sets the extent of the last readFeatures call', function() {
var format = new _ol_format_MVT_();
var format = new MVT();
format.readFeatures(data);
var extent = format.getLastExtent();
expect(_ol_extent_.getWidth(extent)).to.be(4096);
@@ -89,7 +89,7 @@ describe('ol.format.MVT', function() {
describe('#createFeature_', function() {
it('accepts a geometryName', function() {
var format = new _ol_format_MVT_({
var format = new MVT({
featureClass: _ol_Feature_,
geometryName: 'myGeom'
});
@@ -103,13 +103,13 @@ describe('ol.format.MVT', function() {
name: 'layer1'
}
};
var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_;
_ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
var readRawGeometry_ = MVT.readRawGeometry_;
MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
flatCoordinates.push(0, 0);
ends.push(2);
};
var feature = format.createFeature_({}, rawFeature);
_ol_format_MVT_.readRawGeometry_ = readRawGeometry_;
MVT.readRawGeometry_ = readRawGeometry_;
var geometry = feature.getGeometry();
expect(geometry).to.be.a(Point);
expect(feature.get('myGeom')).to.equal(geometry);
@@ -117,7 +117,7 @@ describe('ol.format.MVT', function() {
});
it('detects a Polygon', function() {
var format = new _ol_format_MVT_({
var format = new MVT({
featureClass: _ol_Feature_
});
var rawFeature = {
@@ -127,20 +127,20 @@ describe('ol.format.MVT', function() {
name: 'layer1'
}
};
var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_;
_ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
var readRawGeometry_ = MVT.readRawGeometry_;
MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
flatCoordinates.push(0, 0, 3, 0, 3, 3, 3, 0, 0, 0);
flatCoordinates.push(1, 1, 1, 2, 2, 2, 2, 1, 1, 1);
ends.push(10, 20);
};
var feature = format.createFeature_({}, rawFeature);
_ol_format_MVT_.readRawGeometry_ = readRawGeometry_;
MVT.readRawGeometry_ = readRawGeometry_;
var geometry = feature.getGeometry();
expect(geometry).to.be.a(Polygon);
});
it('detects a MultiPolygon', function() {
var format = new _ol_format_MVT_({
var format = new MVT({
featureClass: _ol_Feature_
});
var rawFeature = {
@@ -150,20 +150,20 @@ describe('ol.format.MVT', function() {
name: 'layer1'
}
};
var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_;
_ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
var readRawGeometry_ = MVT.readRawGeometry_;
MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
flatCoordinates.push(0, 0, 1, 0, 1, 1, 1, 0, 0, 0);
flatCoordinates.push(1, 1, 2, 1, 2, 2, 2, 1, 1, 1);
ends.push(10, 20);
};
var feature = format.createFeature_({}, rawFeature);
_ol_format_MVT_.readRawGeometry_ = readRawGeometry_;
MVT.readRawGeometry_ = readRawGeometry_;
var geometry = feature.getGeometry();
expect(geometry).to.be.a(MultiPolygon);
});
it('creates ol.render.Feature instances', function() {
var format = new _ol_format_MVT_();
var format = new MVT();
var rawFeature = {
type: 3,
properties: {
@@ -173,10 +173,10 @@ describe('ol.format.MVT', function() {
name: 'layer1'
}
};
var readRawGeometry_ = _ol_format_MVT_.readRawGeometry_;
var readRawGeometry_ = MVT.readRawGeometry_;
var createdFlatCoordinates;
var createdEnds;
_ol_format_MVT_.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
MVT.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
flatCoordinates.push(0, 0, 1, 0, 1, 1, 1, 0, 0, 0);
flatCoordinates.push(1, 1, 2, 1, 2, 2, 2, 1, 1, 1);
createdFlatCoordinates = flatCoordinates;
@@ -184,7 +184,7 @@ describe('ol.format.MVT', function() {
createdEnds = ends;
};
var feature = format.createFeature_({}, rawFeature);
_ol_format_MVT_.readRawGeometry_ = readRawGeometry_;
MVT.readRawGeometry_ = readRawGeometry_;
expect(feature).to.be.a(_ol_render_Feature_);
expect(feature.getType()).to.be('Polygon');
expect(feature.getFlatCoordinates()).to.equal(createdFlatCoordinates);

View File

@@ -7,7 +7,7 @@ import _ol_VectorImageTile_ from '../../../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../../../src/ol/VectorTile.js';
import _ol_View_ from '../../../../../src/ol/View.js';
import * as _ol_extent_ from '../../../../../src/ol/extent.js';
import _ol_format_MVT_ from '../../../../../src/ol/format/MVT.js';
import MVT from '../../../../../src/ol/format/MVT.js';
import Point from '../../../../../src/ol/geom/Point.js';
import _ol_layer_VectorTile_ from '../../../../../src/ol/layer/VectorTile.js';
import {get as getProjection, fromLonLat} from '../../../../../src/ol/proj.js';
@@ -68,7 +68,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
};
inherits(TileClass, _ol_VectorTile_);
source = new _ol_source_VectorTile_({
format: new _ol_format_MVT_(),
format: new MVT(),
tileClass: TileClass,
tileGrid: _ol_tilegrid_.createXYZ()
});
@@ -350,7 +350,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
document.body.appendChild(target);
var extent = [1824704.739223726, 6141868.096770482, 1827150.7241288517, 6144314.081675608];
var source = new _ol_source_VectorTile_({
format: new _ol_format_MVT_(),
format: new MVT(),
url: 'spec/ol/data/14-8938-5680.vector.pbf',
minZoom: 14,
maxZoom: 14

View File

@@ -2,7 +2,7 @@ import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_View_ from '../../../../src/ol/View.js';
import _ol_VectorImageTile_ from '../../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../../src/ol/VectorTile.js';
import _ol_format_MVT_ from '../../../../src/ol/format/MVT.js';
import MVT from '../../../../src/ol/format/MVT.js';
import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js';
import {get as getProjection} from '../../../../src/ol/proj.js';
import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js';
@@ -11,7 +11,7 @@ import _ol_tilegrid_TileGrid_ from '../../../../src/ol/tilegrid/TileGrid.js';
describe('ol.source.VectorTile', function() {
var format = new _ol_format_MVT_();
var format = new MVT();
var source = new _ol_source_VectorTile_({
format: format,
tilePixelRatio: 8,