diff --git a/examples/drag-and-drop-image-vector.js b/examples/drag-and-drop-image-vector.js index 117531e788..683bfa987b 100644 --- a/examples/drag-and-drop-image-vector.js +++ b/examples/drag-and-drop-image-vector.js @@ -4,7 +4,7 @@ import GPX from '../src/ol/format/GPX.js'; import GeoJSON from '../src/ol/format/GeoJSON.js'; import IGC from '../src/ol/format/IGC.js'; import KML from '../src/ol/format/KML.js'; -import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; +import TopoJSON from '../src/ol/format/TopoJSON.js'; import _ol_interaction_ from '../src/ol/interaction.js'; import DragAndDrop from '../src/ol/interaction/DragAndDrop.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; @@ -89,7 +89,7 @@ var dragAndDropInteraction = new DragAndDrop({ GeoJSON, IGC, KML, - _ol_format_TopoJSON_ + TopoJSON ] }); diff --git a/examples/drag-and-drop.js b/examples/drag-and-drop.js index 63b321c3dc..7b92870ef4 100644 --- a/examples/drag-and-drop.js +++ b/examples/drag-and-drop.js @@ -4,7 +4,7 @@ import GPX from '../src/ol/format/GPX.js'; import GeoJSON from '../src/ol/format/GeoJSON.js'; import IGC from '../src/ol/format/IGC.js'; import KML from '../src/ol/format/KML.js'; -import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; +import TopoJSON from '../src/ol/format/TopoJSON.js'; import _ol_interaction_ from '../src/ol/interaction.js'; import DragAndDrop from '../src/ol/interaction/DragAndDrop.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; @@ -89,7 +89,7 @@ var dragAndDropInteraction = new DragAndDrop({ GeoJSON, IGC, KML, - _ol_format_TopoJSON_ + TopoJSON ] }); diff --git a/examples/osm-vector-tiles.js b/examples/osm-vector-tiles.js index 2d879efcef..78eec202b8 100644 --- a/examples/osm-vector-tiles.js +++ b/examples/osm-vector-tiles.js @@ -1,6 +1,6 @@ import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; -import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; +import TopoJSON from '../src/ol/format/TopoJSON.js'; import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; import {fromLonLat} from '../src/ol/proj.js'; import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; @@ -64,7 +64,7 @@ var map = new _ol_Map_({ source: new _ol_source_VectorTile_({ attributions: '© OpenStreetMap contributors, Who’s On First, ' + 'Natural Earth, and openstreetmapdata.com', - format: new _ol_format_TopoJSON_({ + format: new TopoJSON({ layerName: 'layer', layers: ['water', 'roads', 'buildings'] }), diff --git a/examples/topojson.js b/examples/topojson.js index 2d302eaa4c..e38db9bbbd 100644 --- a/examples/topojson.js +++ b/examples/topojson.js @@ -1,6 +1,6 @@ import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; -import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js'; +import TopoJSON from '../src/ol/format/TopoJSON.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_layer_Vector_ from '../src/ol/layer/Vector.js'; import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js'; @@ -29,7 +29,7 @@ var style = new _ol_style_Style_({ var vector = new _ol_layer_Vector_({ source: new _ol_source_Vector_({ url: 'data/topojson/world-110m.json', - format: new _ol_format_TopoJSON_({ + format: new TopoJSON({ // don't want to render the full world polygon (stored as 'land' layer), // which repeats all countries layers: ['countries'] diff --git a/src/ol/format/TopoJSON.js b/src/ol/format/TopoJSON.js index 1992cace94..6a19c80ed7 100644 --- a/src/ol/format/TopoJSON.js +++ b/src/ol/format/TopoJSON.js @@ -22,7 +22,7 @@ import {get as getProjection} from '../proj.js'; * @param {olx.format.TopoJSONOptions=} opt_options Options. * @api */ -var _ol_format_TopoJSON_ = function(opt_options) { +var TopoJSON = function(opt_options) { var options = opt_options ? opt_options : {}; @@ -49,7 +49,7 @@ var _ol_format_TopoJSON_ = function(opt_options) { }; -inherits(_ol_format_TopoJSON_, JSONFeature); +inherits(TopoJSON, JSONFeature); /** @@ -61,7 +61,7 @@ inherits(_ol_format_TopoJSON_, JSONFeature); * @return {Array.} Coordinates array. * @private */ -_ol_format_TopoJSON_.concatenateArcs_ = function(indices, arcs) { +TopoJSON.concatenateArcs_ = function(indices, arcs) { /** @type {Array.} */ var coordinates = []; var index, arc; @@ -99,10 +99,10 @@ _ol_format_TopoJSON_.concatenateArcs_ = function(indices, arcs) { * @return {ol.geom.Point} Geometry. * @private */ -_ol_format_TopoJSON_.readPointGeometry_ = function(object, scale, translate) { +TopoJSON.readPointGeometry_ = function(object, scale, translate) { var coordinates = object.coordinates; if (scale && translate) { - _ol_format_TopoJSON_.transformVertex_(coordinates, scale, translate); + TopoJSON.transformVertex_(coordinates, scale, translate); } return new Point(coordinates); }; @@ -117,13 +117,13 @@ _ol_format_TopoJSON_.readPointGeometry_ = function(object, scale, translate) { * @return {ol.geom.MultiPoint} Geometry. * @private */ -_ol_format_TopoJSON_.readMultiPointGeometry_ = function(object, scale, +TopoJSON.readMultiPointGeometry_ = function(object, scale, translate) { var coordinates = object.coordinates; var i, ii; if (scale && translate) { for (i = 0, ii = coordinates.length; i < ii; ++i) { - _ol_format_TopoJSON_.transformVertex_(coordinates[i], scale, translate); + TopoJSON.transformVertex_(coordinates[i], scale, translate); } } return new MultiPoint(coordinates); @@ -138,8 +138,8 @@ _ol_format_TopoJSON_.readMultiPointGeometry_ = function(object, scale, * @return {ol.geom.LineString} Geometry. * @private */ -_ol_format_TopoJSON_.readLineStringGeometry_ = function(object, arcs) { - var coordinates = _ol_format_TopoJSON_.concatenateArcs_(object.arcs, arcs); +TopoJSON.readLineStringGeometry_ = function(object, arcs) { + var coordinates = TopoJSON.concatenateArcs_(object.arcs, arcs); return new LineString(coordinates); }; @@ -152,11 +152,11 @@ _ol_format_TopoJSON_.readLineStringGeometry_ = function(object, arcs) { * @return {ol.geom.MultiLineString} Geometry. * @private */ -_ol_format_TopoJSON_.readMultiLineStringGeometry_ = function(object, arcs) { +TopoJSON.readMultiLineStringGeometry_ = function(object, arcs) { var coordinates = []; var i, ii; for (i = 0, ii = object.arcs.length; i < ii; ++i) { - coordinates[i] = _ol_format_TopoJSON_.concatenateArcs_(object.arcs[i], arcs); + coordinates[i] = TopoJSON.concatenateArcs_(object.arcs[i], arcs); } return new MultiLineString(coordinates); }; @@ -170,11 +170,11 @@ _ol_format_TopoJSON_.readMultiLineStringGeometry_ = function(object, arcs) { * @return {ol.geom.Polygon} Geometry. * @private */ -_ol_format_TopoJSON_.readPolygonGeometry_ = function(object, arcs) { +TopoJSON.readPolygonGeometry_ = function(object, arcs) { var coordinates = []; var i, ii; for (i = 0, ii = object.arcs.length; i < ii; ++i) { - coordinates[i] = _ol_format_TopoJSON_.concatenateArcs_(object.arcs[i], arcs); + coordinates[i] = TopoJSON.concatenateArcs_(object.arcs[i], arcs); } return new Polygon(coordinates); }; @@ -188,7 +188,7 @@ _ol_format_TopoJSON_.readPolygonGeometry_ = function(object, arcs) { * @return {ol.geom.MultiPolygon} Geometry. * @private */ -_ol_format_TopoJSON_.readMultiPolygonGeometry_ = function(object, arcs) { +TopoJSON.readMultiPolygonGeometry_ = function(object, arcs) { var coordinates = []; var polyArray, ringCoords, j, jj; var i, ii; @@ -198,7 +198,7 @@ _ol_format_TopoJSON_.readMultiPolygonGeometry_ = function(object, arcs) { ringCoords = []; for (j = 0, jj = polyArray.length; j < jj; ++j) { // for each ring - ringCoords[j] = _ol_format_TopoJSON_.concatenateArcs_(polyArray[j], arcs); + ringCoords[j] = TopoJSON.concatenateArcs_(polyArray[j], arcs); } coordinates[i] = ringCoords; } @@ -221,13 +221,13 @@ _ol_format_TopoJSON_.readMultiPolygonGeometry_ = function(object, arcs) { * @return {Array.} Array of features. * @private */ -_ol_format_TopoJSON_.readFeaturesFromGeometryCollection_ = function( +TopoJSON.readFeaturesFromGeometryCollection_ = function( collection, arcs, scale, translate, property, name, opt_options) { var geometries = collection.geometries; var features = []; var i, ii; for (i = 0, ii = geometries.length; i < ii; ++i) { - features[i] = _ol_format_TopoJSON_.readFeatureFromGeometry_( + features[i] = TopoJSON.readFeatureFromGeometry_( geometries[i], arcs, scale, translate, property, name, opt_options); } return features; @@ -248,11 +248,11 @@ _ol_format_TopoJSON_.readFeaturesFromGeometryCollection_ = function( * @return {ol.Feature} Feature. * @private */ -_ol_format_TopoJSON_.readFeatureFromGeometry_ = function(object, arcs, +TopoJSON.readFeatureFromGeometry_ = function(object, arcs, scale, translate, property, name, opt_options) { var geometry; var type = object.type; - var geometryReader = _ol_format_TopoJSON_.GEOMETRY_READERS_[type]; + var geometryReader = TopoJSON.GEOMETRY_READERS_[type]; if ((type === 'Point') || (type === 'MultiPoint')) { geometry = geometryReader(object, scale, translate); } else { @@ -286,13 +286,13 @@ _ol_format_TopoJSON_.readFeatureFromGeometry_ = function(object, arcs, * @return {Array.} Features. * @api */ -_ol_format_TopoJSON_.prototype.readFeatures; +TopoJSON.prototype.readFeatures; /** * @inheritDoc */ -_ol_format_TopoJSON_.prototype.readFeaturesFromObject = function( +TopoJSON.prototype.readFeaturesFromObject = function( object, opt_options) { if (object.type == 'Topology') { var topoJSONTopology = /** @type {TopoJSONTopology} */ (object); @@ -304,7 +304,7 @@ _ol_format_TopoJSON_.prototype.readFeaturesFromObject = function( } var arcs = topoJSONTopology.arcs; if (transform) { - _ol_format_TopoJSON_.transformArcs_(arcs, scale, translate); + TopoJSON.transformArcs_(arcs, scale, translate); } /** @type {Array.} */ var features = []; @@ -319,12 +319,12 @@ _ol_format_TopoJSON_.prototype.readFeaturesFromObject = function( feature = /** @type {TopoJSONGeometryCollection} */ (topoJSONFeatures[objectName]); features.push.apply(features, - _ol_format_TopoJSON_.readFeaturesFromGeometryCollection_( + TopoJSON.readFeaturesFromGeometryCollection_( feature, arcs, scale, translate, property, objectName, opt_options)); } else { feature = /** @type {TopoJSONGeometry} */ (topoJSONFeatures[objectName]); - features.push(_ol_format_TopoJSON_.readFeatureFromGeometry_( + features.push(TopoJSON.readFeatureFromGeometry_( feature, arcs, scale, translate, property, objectName, opt_options)); } } @@ -344,10 +344,10 @@ _ol_format_TopoJSON_.prototype.readFeaturesFromObject = function( * @param {Array.} translate Translation for each dimension. * @private */ -_ol_format_TopoJSON_.transformArcs_ = function(arcs, scale, translate) { +TopoJSON.transformArcs_ = function(arcs, scale, translate) { var i, ii; for (i = 0, ii = arcs.length; i < ii; ++i) { - _ol_format_TopoJSON_.transformArc_(arcs[i], scale, translate); + TopoJSON.transformArc_(arcs[i], scale, translate); } }; @@ -360,7 +360,7 @@ _ol_format_TopoJSON_.transformArcs_ = function(arcs, scale, translate) { * @param {Array.} translate Translation for each dimension. * @private */ -_ol_format_TopoJSON_.transformArc_ = function(arc, scale, translate) { +TopoJSON.transformArc_ = function(arc, scale, translate) { var x = 0; var y = 0; var vertex; @@ -371,7 +371,7 @@ _ol_format_TopoJSON_.transformArc_ = function(arc, scale, translate) { y += vertex[1]; vertex[0] = x; vertex[1] = y; - _ol_format_TopoJSON_.transformVertex_(vertex, scale, translate); + TopoJSON.transformVertex_(vertex, scale, translate); } }; @@ -385,7 +385,7 @@ _ol_format_TopoJSON_.transformArc_ = function(arc, scale, translate) { * @param {Array.} translate Translation for each dimension. * @private */ -_ol_format_TopoJSON_.transformVertex_ = function(vertex, scale, translate) { +TopoJSON.transformVertex_ = function(vertex, scale, translate) { vertex[0] = vertex[0] * scale[0] + translate[0]; vertex[1] = vertex[1] * scale[1] + translate[1]; }; @@ -399,13 +399,13 @@ _ol_format_TopoJSON_.transformVertex_ = function(vertex, scale, translate) { * @override * @api */ -_ol_format_TopoJSON_.prototype.readProjection; +TopoJSON.prototype.readProjection; /** * @inheritDoc */ -_ol_format_TopoJSON_.prototype.readProjectionFromObject = function(object) { +TopoJSON.prototype.readProjectionFromObject = function(object) { return this.defaultDataProjection; }; @@ -415,13 +415,13 @@ _ol_format_TopoJSON_.prototype.readProjectionFromObject = function(object) { * @private * @type {Object.} */ -_ol_format_TopoJSON_.GEOMETRY_READERS_ = { - 'Point': _ol_format_TopoJSON_.readPointGeometry_, - 'LineString': _ol_format_TopoJSON_.readLineStringGeometry_, - 'Polygon': _ol_format_TopoJSON_.readPolygonGeometry_, - 'MultiPoint': _ol_format_TopoJSON_.readMultiPointGeometry_, - 'MultiLineString': _ol_format_TopoJSON_.readMultiLineStringGeometry_, - 'MultiPolygon': _ol_format_TopoJSON_.readMultiPolygonGeometry_ +TopoJSON.GEOMETRY_READERS_ = { + 'Point': TopoJSON.readPointGeometry_, + 'LineString': TopoJSON.readLineStringGeometry_, + 'Polygon': TopoJSON.readPolygonGeometry_, + 'MultiPoint': TopoJSON.readMultiPointGeometry_, + 'MultiLineString': TopoJSON.readMultiLineStringGeometry_, + 'MultiPolygon': TopoJSON.readMultiPolygonGeometry_ }; @@ -429,33 +429,33 @@ _ol_format_TopoJSON_.GEOMETRY_READERS_ = { * Not implemented. * @inheritDoc */ -_ol_format_TopoJSON_.prototype.writeFeatureObject = function(feature, opt_options) {}; +TopoJSON.prototype.writeFeatureObject = function(feature, opt_options) {}; /** * Not implemented. * @inheritDoc */ -_ol_format_TopoJSON_.prototype.writeFeaturesObject = function(features, opt_options) {}; +TopoJSON.prototype.writeFeaturesObject = function(features, opt_options) {}; /** * Not implemented. * @inheritDoc */ -_ol_format_TopoJSON_.prototype.writeGeometryObject = function(geometry, opt_options) {}; +TopoJSON.prototype.writeGeometryObject = function(geometry, opt_options) {}; /** * Not implemented. * @override */ -_ol_format_TopoJSON_.prototype.readGeometryFromObject = function() {}; +TopoJSON.prototype.readGeometryFromObject = function() {}; /** * Not implemented. * @override */ -_ol_format_TopoJSON_.prototype.readFeatureFromObject = function() {}; -export default _ol_format_TopoJSON_; +TopoJSON.prototype.readFeatureFromObject = function() {}; +export default TopoJSON; diff --git a/test/spec/ol/format/topojson.test.js b/test/spec/ol/format/topojson.test.js index 90eb5756f1..69ff8fd9c0 100644 --- a/test/spec/ol/format/topojson.test.js +++ b/test/spec/ol/format/topojson.test.js @@ -3,7 +3,7 @@ import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js'; import Polygon from '../../../../src/ol/geom/Polygon.js'; import FeatureFormat from '../../../../src/ol/format/Feature.js'; import {transform} from '../../../../src/ol/proj.js'; -import _ol_format_TopoJSON_ from '../../../../src/ol/format/TopoJSON.js'; +import TopoJSON from '../../../../src/ol/format/TopoJSON.js'; var aruba = { type: 'Topology', @@ -42,13 +42,13 @@ describe('ol.format.TopoJSON', function() { var format; before(function() { - format = new _ol_format_TopoJSON_(); + format = new TopoJSON(); }); describe('constructor', function() { it('creates a new format', function() { expect(format).to.be.a(FeatureFormat); - expect(format).to.be.a(_ol_format_TopoJSON_); + expect(format).to.be.a(TopoJSON); }); }); @@ -176,7 +176,7 @@ describe('ol.format.TopoJSON', function() { it('sets the topology\'s child names as feature property', function(done) { afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) { - var format = new _ol_format_TopoJSON_({ + var format = new TopoJSON({ layerName: 'layer' }); var features = format.readFeatures(text); @@ -188,7 +188,7 @@ describe('ol.format.TopoJSON', function() { it('only parses features from specified topology\'s children', function(done) { afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) { - var format = new _ol_format_TopoJSON_({ + var format = new TopoJSON({ layers: ['land'] }); var features = format.readFeatures(text);