diff --git a/src/ol/format/GeoJSON.js b/src/ol/format/GeoJSON.js index 70ed162f8e..dce793aa7b 100644 --- a/src/ol/format/GeoJSON.js +++ b/src/ol/format/GeoJSON.js @@ -65,6 +65,37 @@ var GeoJSON = function(opt_options) { inherits(GeoJSON, JSONFeature); +/** + * @const + * @type {Object.} + */ +var GEOMETRY_READERS = { + 'Point': readPointGeometry, + 'LineString': readLineStringGeometry, + 'Polygon': readPolygonGeometry, + 'MultiPoint': readMultiPointGeometry, + 'MultiLineString': readMultiLineStringGeometry, + 'MultiPolygon': readMultiPolygonGeometry, + 'GeometryCollection': readGeometryCollectionGeometry +}; + + +/** + * @const + * @type {Object.} + */ +var GEOMETRY_WRITERS = { + 'Point': writePointGeometry, + 'LineString': writeLineStringGeometry, + 'Polygon': writePolygonGeometry, + 'MultiPoint': writeMultiPointGeometry, + 'MultiLineString': writeMultiLineStringGeometry, + 'MultiPolygon': writeMultiPolygonGeometry, + 'GeometryCollection': writeGeometryCollectionGeometry, + 'Circle': writeEmptyGeometryCollectionGeometry +}; + + /** * @param {GeoJSONGeometry|GeoJSONGeometryCollection} object Object. * @param {olx.format.ReadOptions=} opt_options Read options. @@ -74,7 +105,7 @@ function readGeometry(object, opt_options) { if (!object) { return null; } - var geometryReader = GeoJSON.GEOMETRY_READERS_[object.type]; + var geometryReader = GEOMETRY_READERS[object.type]; return ( /** @type {ol.geom.Geometry} */ FeatureFormat.transformWithOptions( geometryReader(object), false, opt_options) @@ -160,7 +191,7 @@ function readPolygonGeometry(object) { * @return {GeoJSONGeometry|GeoJSONGeometryCollection} GeoJSON geometry. */ function writeGeometry(geometry, opt_options) { - var geometryWriter = GeoJSON.GEOMETRY_WRITERS_[geometry.getType()]; + var geometryWriter = GEOMETRY_WRITERS[geometry.getType()]; return geometryWriter(/** @type {ol.geom.Geometry} */ ( FeatureFormat.transformWithOptions(geometry, true, opt_options)), opt_options); @@ -283,39 +314,6 @@ function writePolygonGeometry(geometry, opt_options) { } -/** - * @const - * @private - * @type {Object.} - */ -GeoJSON.GEOMETRY_READERS_ = { - 'Point': readPointGeometry, - 'LineString': readLineStringGeometry, - 'Polygon': readPolygonGeometry, - 'MultiPoint': readMultiPointGeometry, - 'MultiLineString': readMultiLineStringGeometry, - 'MultiPolygon': readMultiPolygonGeometry, - 'GeometryCollection': readGeometryCollectionGeometry -}; - - -/** - * @const - * @private - * @type {Object.} - */ -GeoJSON.GEOMETRY_WRITERS_ = { - 'Point': writePointGeometry, - 'LineString': writeLineStringGeometry, - 'Polygon': writePolygonGeometry, - 'MultiPoint': writeMultiPointGeometry, - 'MultiLineString': writeMultiLineStringGeometry, - 'MultiPolygon': writeMultiPolygonGeometry, - 'GeometryCollection': writeGeometryCollectionGeometry, - 'Circle': writeEmptyGeometryCollectionGeometry -}; - - /** * Read a feature from a GeoJSON Feature source. Only works for Feature or * geometry types. Use {@link ol.format.GeoJSON#readFeatures} to read