Merge pull request #2407 from ahocevar/format-projection
Options for feature readers and writers to support transforms
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
goog.provide('ol.format.Feature');
|
||||
|
||||
goog.require('goog.functions');
|
||||
goog.require('goog.array');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.proj');
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +18,12 @@ goog.require('goog.functions');
|
||||
* @constructor
|
||||
*/
|
||||
ol.format.Feature = function() {
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {ol.proj.Projection}
|
||||
*/
|
||||
this.defaultDataProjection = null;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +33,50 @@ ol.format.Feature = function() {
|
||||
ol.format.Feature.prototype.getExtensions = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* Adds the data projection to the read options.
|
||||
* @param {Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @return {olx.format.ReadOptions|undefined} Options.
|
||||
* @protected
|
||||
*/
|
||||
ol.format.Feature.prototype.getReadOptions = function(
|
||||
source, opt_options) {
|
||||
var options;
|
||||
if (goog.isDef(opt_options)) {
|
||||
options = {
|
||||
dataProjection: goog.isDef(opt_options.dataProjection) ?
|
||||
opt_options.dataProjection : this.readProjection(source),
|
||||
featureProjection: opt_options.featureProjection
|
||||
};
|
||||
}
|
||||
return this.adaptOptions(options);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the `defaultDataProjection` on the options, if no `dataProjection`
|
||||
* is set.
|
||||
* @param {olx.format.WriteOptions|olx.format.ReadOptions|undefined} options
|
||||
* Options.
|
||||
* @protected
|
||||
* @return {olx.format.WriteOptions|olx.format.ReadOptions|undefined}
|
||||
* Updated options.
|
||||
*/
|
||||
ol.format.Feature.prototype.adaptOptions = function(
|
||||
options) {
|
||||
var updatedOptions;
|
||||
if (goog.isDef(options)) {
|
||||
updatedOptions = {
|
||||
featureProjection: options.featureProjection,
|
||||
dataProjection: goog.isDefAndNotNull(options.dataProjection) ?
|
||||
options.dataProjection : this.defaultDataProjection
|
||||
};
|
||||
}
|
||||
return updatedOptions;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.format.FormatType} Format.
|
||||
*/
|
||||
@@ -35,6 +87,7 @@ ol.format.Feature.prototype.getType = goog.abstractMethod;
|
||||
* Read a single feature from a source.
|
||||
*
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.Feature} Feature.
|
||||
*/
|
||||
ol.format.Feature.prototype.readFeature = goog.abstractMethod;
|
||||
@@ -44,6 +97,7 @@ ol.format.Feature.prototype.readFeature = goog.abstractMethod;
|
||||
* Read all features from a source.
|
||||
*
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
*/
|
||||
ol.format.Feature.prototype.readFeatures = goog.abstractMethod;
|
||||
@@ -53,6 +107,7 @@ ol.format.Feature.prototype.readFeatures = goog.abstractMethod;
|
||||
* Read a single geometry from a source.
|
||||
*
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
ol.format.Feature.prototype.readGeometry = goog.abstractMethod;
|
||||
@@ -71,6 +126,7 @@ ol.format.Feature.prototype.readProjection = goog.abstractMethod;
|
||||
* Encode a feature in this format.
|
||||
*
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @return {ArrayBuffer|Node|Object|string} Result.
|
||||
*/
|
||||
ol.format.Feature.prototype.writeFeature = goog.abstractMethod;
|
||||
@@ -80,6 +136,7 @@ ol.format.Feature.prototype.writeFeature = goog.abstractMethod;
|
||||
* Encode an array of features in this format.
|
||||
*
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @return {ArrayBuffer|Node|Object|string} Result.
|
||||
*/
|
||||
ol.format.Feature.prototype.writeFeatures = goog.abstractMethod;
|
||||
@@ -89,6 +146,41 @@ ol.format.Feature.prototype.writeFeatures = goog.abstractMethod;
|
||||
* Write a single geometry in this format.
|
||||
*
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @return {ArrayBuffer|Node|Object|string} Node.
|
||||
*/
|
||||
ol.format.Feature.prototype.writeGeometry = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry|ol.Extent} geometry Geometry.
|
||||
* @param {boolean} write Set to true for writing, false for reading.
|
||||
* @param {(olx.format.WriteOptions|olx.format.ReadOptions)=} opt_options
|
||||
* Options.
|
||||
* @return {ol.geom.Geometry|ol.Extent} Transformed geometry.
|
||||
* @protected
|
||||
*/
|
||||
ol.format.Feature.transformWithOptions = function(
|
||||
geometry, write, opt_options) {
|
||||
var featureProjection = goog.isDef(opt_options) ?
|
||||
ol.proj.get(opt_options.featureProjection) : null;
|
||||
var dataProjection = goog.isDef(opt_options) ?
|
||||
ol.proj.get(opt_options.dataProjection) : null;
|
||||
if (!goog.isNull(featureProjection) && !goog.isNull(dataProjection) &&
|
||||
!ol.proj.equivalent(featureProjection, dataProjection)) {
|
||||
if (geometry instanceof ol.geom.Geometry) {
|
||||
return (write ? geometry.clone() : geometry).transform(
|
||||
write ? featureProjection : dataProjection,
|
||||
write ? dataProjection : featureProjection);
|
||||
} else {
|
||||
// FIXME this is necessary because ol.format.GML treats extents
|
||||
// as geometries
|
||||
return ol.proj.transformExtent(
|
||||
write ? goog.array.clone(geometry) : geometry,
|
||||
write ? featureProjection : dataProjection,
|
||||
write ? dataProjection : featureProjection);
|
||||
}
|
||||
} else {
|
||||
return geometry;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@ goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.JSONFeature');
|
||||
goog.require('ol.geom.GeometryCollection');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
@@ -36,11 +37,11 @@ ol.format.GeoJSON = function(opt_options) {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.proj.Projection}
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultProjection_ = ol.proj.get(options.defaultProjection ?
|
||||
options.defaultProjection : 'EPSG:4326');
|
||||
this.defaultDataProjection = ol.proj.get(
|
||||
goog.isDefAndNotNull(options.defaultDataProjection) ?
|
||||
options.defaultDataProjection : 'EPSG:4326');
|
||||
|
||||
|
||||
/**
|
||||
@@ -64,28 +65,39 @@ ol.format.GeoJSON.EXTENSIONS_ = ['.geojson'];
|
||||
|
||||
/**
|
||||
* @param {GeoJSONObject} object Object.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @private
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
ol.format.GeoJSON.readGeometry_ = function(object) {
|
||||
ol.format.GeoJSON.readGeometry_ = function(object, opt_options) {
|
||||
if (goog.isNull(object)) {
|
||||
return null;
|
||||
}
|
||||
var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type];
|
||||
goog.asserts.assert(goog.isDef(geometryReader));
|
||||
return geometryReader(object);
|
||||
return /** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(
|
||||
geometryReader(object), false, opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {GeoJSONGeometryCollection} object Object.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @private
|
||||
* @return {ol.geom.GeometryCollection} Geometry collection.
|
||||
*/
|
||||
ol.format.GeoJSON.readGeometryCollectionGeometry_ = function(object) {
|
||||
ol.format.GeoJSON.readGeometryCollectionGeometry_ = function(
|
||||
object, opt_options) {
|
||||
goog.asserts.assert(object.type == 'GeometryCollection');
|
||||
var geometries = goog.array.map(
|
||||
object.geometries, ol.format.GeoJSON.readGeometry_);
|
||||
var geometries = goog.array.map(object.geometries,
|
||||
/**
|
||||
* @param {GeoJSONObject} geometry Geometry.
|
||||
* @return {ol.geom.Geometry} geometry Geometry.
|
||||
*/
|
||||
function(geometry) {
|
||||
return ol.format.GeoJSON.readGeometry_(geometry, opt_options);
|
||||
});
|
||||
return new ol.geom.GeometryCollection(geometries);
|
||||
};
|
||||
|
||||
@@ -158,13 +170,15 @@ ol.format.GeoJSON.readPolygonGeometry_ = function(object) {
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} GeoJSON geometry.
|
||||
*/
|
||||
ol.format.GeoJSON.writeGeometry_ = function(geometry) {
|
||||
ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) {
|
||||
var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()];
|
||||
goog.asserts.assert(goog.isDef(geometryWriter));
|
||||
return geometryWriter(geometry);
|
||||
return geometryWriter(/** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)));
|
||||
};
|
||||
|
||||
|
||||
@@ -183,13 +197,17 @@ ol.format.GeoJSON.writeEmptyGeometryCollectionGeometry_ = function(geometry) {
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @private
|
||||
* @return {GeoJSONGeometryCollection} GeoJSON geometry collection.
|
||||
*/
|
||||
ol.format.GeoJSON.writeGeometryCollectionGeometry_ = function(geometry) {
|
||||
ol.format.GeoJSON.writeGeometryCollectionGeometry_ = function(
|
||||
geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.GeometryCollection);
|
||||
var geometries = goog.array.map(
|
||||
geometry.getGeometriesArray(), ol.format.GeoJSON.writeGeometry_);
|
||||
geometry.getGeometriesArray(), function(geometry) {
|
||||
return ol.format.GeoJSON.writeGeometry_(geometry, opt_options);
|
||||
});
|
||||
return /** @type {GeoJSONGeometryCollection} */ ({
|
||||
'type': 'GeometryCollection',
|
||||
'geometries': geometries
|
||||
@@ -330,6 +348,7 @@ ol.format.GeoJSON.prototype.getExtensions = function() {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
@@ -342,6 +361,7 @@ ol.format.GeoJSON.prototype.readFeature;
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -351,10 +371,12 @@ ol.format.GeoJSON.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GeoJSON.prototype.readFeatureFromObject = function(object) {
|
||||
ol.format.GeoJSON.prototype.readFeatureFromObject = function(
|
||||
object, opt_options) {
|
||||
var geoJSONFeature = /** @type {GeoJSONFeature} */ (object);
|
||||
goog.asserts.assert(geoJSONFeature.type == 'Feature');
|
||||
var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry);
|
||||
var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry,
|
||||
opt_options);
|
||||
var feature = new ol.Feature();
|
||||
if (goog.isDef(this.geometryName_)) {
|
||||
feature.setGeometryName(this.geometryName_);
|
||||
@@ -373,10 +395,11 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function(object) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GeoJSON.prototype.readFeaturesFromObject = function(object) {
|
||||
ol.format.GeoJSON.prototype.readFeaturesFromObject = function(
|
||||
object, opt_options) {
|
||||
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
||||
if (geoJSONObject.type == 'Feature') {
|
||||
return [this.readFeatureFromObject(object)];
|
||||
return [this.readFeatureFromObject(object, opt_options)];
|
||||
} else if (geoJSONObject.type == 'FeatureCollection') {
|
||||
var geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */
|
||||
(object);
|
||||
@@ -385,7 +408,8 @@ ol.format.GeoJSON.prototype.readFeaturesFromObject = function(object) {
|
||||
var geoJSONFeatures = geoJSONFeatureCollection.features;
|
||||
var i, ii;
|
||||
for (i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {
|
||||
features.push(this.readFeatureFromObject(geoJSONFeatures[i]));
|
||||
features.push(this.readFeatureFromObject(geoJSONFeatures[i],
|
||||
opt_options));
|
||||
}
|
||||
return features;
|
||||
} else {
|
||||
@@ -400,6 +424,7 @@ ol.format.GeoJSON.prototype.readFeaturesFromObject = function(object) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
* @api
|
||||
*/
|
||||
@@ -409,9 +434,10 @@ ol.format.GeoJSON.prototype.readGeometry;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GeoJSON.prototype.readGeometryFromObject = function(object) {
|
||||
ol.format.GeoJSON.prototype.readGeometryFromObject = function(
|
||||
object, opt_options) {
|
||||
return ol.format.GeoJSON.readGeometry_(
|
||||
/** @type {GeoJSONGeometry} */ (object));
|
||||
/** @type {GeoJSONGeometry} */ (object), opt_options);
|
||||
};
|
||||
|
||||
|
||||
@@ -446,7 +472,7 @@ ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return this.defaultProjection_;
|
||||
return this.defaultDataProjection;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -456,6 +482,7 @@ ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) {
|
||||
*
|
||||
* @function
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {olx.format.WriteOptions} options Write options.
|
||||
* @return {GeoJSONFeature} GeoJSON.
|
||||
* @api
|
||||
*/
|
||||
@@ -465,7 +492,8 @@ ol.format.GeoJSON.prototype.writeFeature;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GeoJSON.prototype.writeFeatureObject = function(feature) {
|
||||
ol.format.GeoJSON.prototype.writeFeatureObject = function(
|
||||
feature, opt_options) {
|
||||
var object = {
|
||||
'type': 'Feature'
|
||||
};
|
||||
@@ -476,7 +504,8 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(feature) {
|
||||
var geometry = feature.getGeometry();
|
||||
if (goog.isDefAndNotNull(geometry)) {
|
||||
goog.object.set(
|
||||
object, 'geometry', ol.format.GeoJSON.writeGeometry_(geometry));
|
||||
object, 'geometry',
|
||||
ol.format.GeoJSON.writeGeometry_(geometry, opt_options));
|
||||
}
|
||||
var properties = feature.getProperties();
|
||||
goog.object.remove(properties, 'geometry');
|
||||
@@ -492,6 +521,7 @@ ol.format.GeoJSON.prototype.writeFeatureObject = function(feature) {
|
||||
*
|
||||
* @function
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions} options Write options.
|
||||
* @return {GeoJSONObject} GeoJSON.
|
||||
* @api
|
||||
*/
|
||||
@@ -501,11 +531,12 @@ ol.format.GeoJSON.prototype.writeFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GeoJSON.prototype.writeFeaturesObject = function(features) {
|
||||
ol.format.GeoJSON.prototype.writeFeaturesObject =
|
||||
function(features, opt_options) {
|
||||
var objects = [];
|
||||
var i, ii;
|
||||
for (i = 0, ii = features.length; i < ii; ++i) {
|
||||
objects.push(this.writeFeatureObject(features[i]));
|
||||
objects.push(this.writeFeatureObject(features[i], opt_options));
|
||||
}
|
||||
return /** @type {GeoJSONFeatureCollection} */ ({
|
||||
'type': 'FeatureCollection',
|
||||
@@ -519,6 +550,7 @@ ol.format.GeoJSON.prototype.writeFeaturesObject = function(features) {
|
||||
*
|
||||
* @function
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions} options Write options.
|
||||
* @return {GeoJSONGeometry|GeoJSONGeometryCollection} GeoJSON.
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// FIXME Envelopes should not be treated as geometries! readEnvelope_ is part
|
||||
// of GEOMETRY_PARSERS_ and methods using GEOMETRY_PARSERS_ do not expect
|
||||
// envelopes/extents, only geometries!
|
||||
goog.provide('ol.format.GML');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
@@ -8,6 +11,7 @@ goog.require('goog.string');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.XMLFeature');
|
||||
goog.require('ol.format.XSD');
|
||||
goog.require('ol.geom.Geometry');
|
||||
@@ -162,7 +166,8 @@ ol.format.GML.readGeometry = function(node, objectStack) {
|
||||
var geometry = ol.xml.pushParseAndPop(/** @type {ol.geom.Geometry} */(null),
|
||||
ol.format.GML.GEOMETRY_PARSERS_, node, objectStack);
|
||||
if (goog.isDefAndNotNull(geometry)) {
|
||||
return geometry;
|
||||
return /** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(geometry, false, context));
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1037,9 +1042,10 @@ ol.format.GML.RING_PARSERS_ = {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GML.prototype.readGeometryFromNode = function(node) {
|
||||
var geometry = ol.format.GML.readGeometry(node, [{}]);
|
||||
return (goog.isDef(geometry)) ? geometry : null;
|
||||
ol.format.GML.prototype.readGeometryFromNode = function(node, opt_options) {
|
||||
var geometry = ol.format.GML.readGeometry(node,
|
||||
[this.getReadOptions(node, goog.isDef(opt_options) ? opt_options : {})]);
|
||||
return (goog.isDef(geometry) ? geometry : null);
|
||||
};
|
||||
|
||||
|
||||
@@ -1048,6 +1054,7 @@ ol.format.GML.prototype.readGeometryFromNode = function(node) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -1057,12 +1064,24 @@ ol.format.GML.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GML.prototype.readFeaturesFromNode = function(node) {
|
||||
var objectStack = [{
|
||||
ol.format.GML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
var options = {
|
||||
'featureType': this.featureType_,
|
||||
'featureNS': this.featureNS_
|
||||
}];
|
||||
return ol.format.GML.readFeatures_(node, objectStack);
|
||||
};
|
||||
if (goog.isDef(opt_options)) {
|
||||
goog.object.extend(options, this.getReadOptions(node, opt_options));
|
||||
}
|
||||
return ol.format.GML.readFeatures_(node, [options]);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GML.prototype.readProjectionFromNode = function(node) {
|
||||
return ol.proj.get(goog.isDef(this.srsName_) ? this.srsName_ :
|
||||
node.firstElementChild.getAttribute('srsName'));
|
||||
};
|
||||
|
||||
|
||||
@@ -1443,9 +1462,22 @@ ol.format.GML.writeGeometry = function(node, geometry, objectStack) {
|
||||
goog.asserts.assert(goog.isObject(context));
|
||||
var item = goog.object.clone(context);
|
||||
item.node = node;
|
||||
var value;
|
||||
if (goog.isArray(geometry)) {
|
||||
if (goog.isDef(context.dataProjection)) {
|
||||
value = ol.proj.transformExtent(
|
||||
geometry, context.featureProjection, context.dataProjection);
|
||||
} else {
|
||||
value = geometry;
|
||||
}
|
||||
} else {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Geometry);
|
||||
value =
|
||||
ol.format.Feature.transformWithOptions(geometry, true, context);
|
||||
}
|
||||
ol.xml.pushSerializeAndPop(/** @type {ol.xml.NodeStackItem} */
|
||||
(item), ol.format.GML.GEOMETRY_SERIALIZERS_,
|
||||
ol.format.GML.GEOMETRY_NODE_FACTORY_, [geometry], objectStack);
|
||||
ol.format.GML.GEOMETRY_NODE_FACTORY_, [value], objectStack);
|
||||
};
|
||||
|
||||
|
||||
@@ -1673,14 +1705,15 @@ ol.format.GML.GEOMETRY_NODE_FACTORY_ = function(value, objectStack,
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GML.prototype.writeGeometryNode = function(geometry) {
|
||||
ol.format.GML.prototype.writeGeometryNode = function(geometry, opt_options) {
|
||||
var geom = ol.xml.createElementNS('http://www.opengis.net/gml', 'geom');
|
||||
var context = {node: geom, srsName: this.srsName_,
|
||||
curve: this.curve_, surface: this.surface_,
|
||||
multiSurface: this.multiSurface_, multiCurve: this.multiCurve_};
|
||||
ol.xml.pushSerializeAndPop(/** @type {ol.xml.NodeStackItem} */
|
||||
(context), ol.format.GML.GEOMETRY_SERIALIZERS_,
|
||||
ol.format.GML.GEOMETRY_NODE_FACTORY_, [geometry], []);
|
||||
if (goog.isDef(opt_options)) {
|
||||
goog.object.extend(context, opt_options);
|
||||
}
|
||||
ol.format.GML.writeGeometry(geom, geometry, [context]);
|
||||
return geom;
|
||||
};
|
||||
|
||||
@@ -1690,6 +1723,7 @@ ol.format.GML.prototype.writeGeometryNode = function(geometry) {
|
||||
*
|
||||
* @function
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Options.
|
||||
* @return {Node} Result.
|
||||
* @api
|
||||
*/
|
||||
@@ -1699,7 +1733,7 @@ ol.format.GML.prototype.writeFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GML.prototype.writeFeaturesNode = function(features) {
|
||||
ol.format.GML.prototype.writeFeaturesNode = function(features, opt_options) {
|
||||
var node = ol.xml.createElementNS('http://www.opengis.net/gml',
|
||||
'featureMembers');
|
||||
ol.xml.setAttributeNS(node, 'http://www.w3.org/2001/XMLSchema-instance',
|
||||
@@ -1713,6 +1747,9 @@ ol.format.GML.prototype.writeFeaturesNode = function(features) {
|
||||
featureNS: this.featureNS_,
|
||||
featureType: this.featureType_
|
||||
};
|
||||
if (goog.isDef(opt_options)) {
|
||||
goog.object.extend(context, opt_options);
|
||||
}
|
||||
ol.format.GML.writeFeatureMembers_(node, features, [context]);
|
||||
return node;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.dom.NodeType');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.XMLFeature');
|
||||
goog.require('ol.format.XSD');
|
||||
goog.require('ol.geom.LineString');
|
||||
@@ -30,6 +31,11 @@ ol.format.GPX = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = ol.proj.get('EPSG:4326');
|
||||
|
||||
/**
|
||||
* @type {function(ol.Feature, Node)|undefined}
|
||||
* @private
|
||||
@@ -175,6 +181,7 @@ ol.format.GPX.parseTrkSeg_ = function(node, objectStack) {
|
||||
ol.format.GPX.readRte_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'rte');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var values = ol.xml.pushParseAndPop({
|
||||
'flatCoordinates': []
|
||||
}, ol.format.GPX.RTE_PARSERS_, node, objectStack);
|
||||
@@ -186,6 +193,7 @@ ol.format.GPX.readRte_ = function(node, objectStack) {
|
||||
goog.object.remove(values, 'flatCoordinates');
|
||||
var geometry = new ol.geom.LineString(null);
|
||||
geometry.setFlatCoordinates(ol.geom.GeometryLayout.XYZM, flatCoordinates);
|
||||
ol.format.Feature.transformWithOptions(geometry, false, options);
|
||||
var feature = new ol.Feature(geometry);
|
||||
feature.setProperties(values);
|
||||
return feature;
|
||||
@@ -201,6 +209,7 @@ ol.format.GPX.readRte_ = function(node, objectStack) {
|
||||
ol.format.GPX.readTrk_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'trk');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var values = ol.xml.pushParseAndPop({
|
||||
'flatCoordinates': [],
|
||||
'ends': []
|
||||
@@ -216,6 +225,7 @@ ol.format.GPX.readTrk_ = function(node, objectStack) {
|
||||
var geometry = new ol.geom.MultiLineString(null);
|
||||
geometry.setFlatCoordinates(
|
||||
ol.geom.GeometryLayout.XYZM, flatCoordinates, ends);
|
||||
ol.format.Feature.transformWithOptions(geometry, false, options);
|
||||
var feature = new ol.Feature(geometry);
|
||||
feature.setProperties(values);
|
||||
return feature;
|
||||
@@ -231,6 +241,7 @@ ol.format.GPX.readTrk_ = function(node, objectStack) {
|
||||
ol.format.GPX.readWpt_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'wpt');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var values = ol.xml.pushParseAndPop(
|
||||
{}, ol.format.GPX.WPT_PARSERS_, node, objectStack);
|
||||
if (!goog.isDef(values)) {
|
||||
@@ -239,6 +250,7 @@ ol.format.GPX.readWpt_ = function(node, objectStack) {
|
||||
var coordinates = ol.format.GPX.appendCoordinate_([], node, values);
|
||||
var geometry = new ol.geom.Point(
|
||||
coordinates, ol.geom.GeometryLayout.XYZM);
|
||||
ol.format.Feature.transformWithOptions(geometry, false, options);
|
||||
var feature = new ol.Feature(geometry);
|
||||
feature.setProperties(values);
|
||||
return feature;
|
||||
@@ -415,6 +427,7 @@ ol.format.GPX.prototype.handleReadExtensions_ = function(features) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
@@ -424,7 +437,7 @@ ol.format.GPX.prototype.readFeature;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GPX.prototype.readFeatureFromNode = function(node) {
|
||||
ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
if (!goog.array.contains(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return null;
|
||||
@@ -433,7 +446,7 @@ ol.format.GPX.prototype.readFeatureFromNode = function(node) {
|
||||
if (!goog.isDef(featureReader)) {
|
||||
return null;
|
||||
}
|
||||
var feature = featureReader(node, []);
|
||||
var feature = featureReader(node, [this.getReadOptions(node, opt_options)]);
|
||||
if (!goog.isDef(feature)) {
|
||||
return null;
|
||||
}
|
||||
@@ -447,6 +460,7 @@ ol.format.GPX.prototype.readFeatureFromNode = function(node) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -456,7 +470,7 @@ ol.format.GPX.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GPX.prototype.readFeaturesFromNode = function(node) {
|
||||
ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
if (!goog.array.contains(ol.format.GPX.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return [];
|
||||
@@ -464,7 +478,7 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node) {
|
||||
if (node.localName == 'gpx') {
|
||||
var features = ol.xml.pushParseAndPop(
|
||||
/** @type {Array.<ol.Feature>} */ ([]), ol.format.GPX.GPX_PARSERS_,
|
||||
node, []);
|
||||
node, [this.getReadOptions(node, opt_options)]);
|
||||
if (goog.isDef(features)) {
|
||||
this.handleReadExtensions_(features);
|
||||
return features;
|
||||
@@ -491,7 +505,7 @@ ol.format.GPX.prototype.readProjection;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GPX.prototype.readProjectionFromDocument = function(doc) {
|
||||
return ol.proj.get('EPSG:4326');
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
|
||||
@@ -499,7 +513,7 @@ ol.format.GPX.prototype.readProjectionFromDocument = function(doc) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GPX.prototype.readProjectionFromNode = function(node) {
|
||||
return ol.proj.get('EPSG:4326');
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
|
||||
@@ -574,11 +588,14 @@ ol.format.GPX.writeWptType_ = function(node, coordinate, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.writeRte_ = function(node, feature, objectStack) {
|
||||
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
|
||||
var properties = feature.getProperties();
|
||||
var context = {node: node, 'properties': properties};
|
||||
var geometry = feature.getGeometry();
|
||||
if (goog.isDef(geometry)) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString);
|
||||
geometry = /** @type {ol.geom.LineString} */
|
||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||
goog.object.set(context, 'geometryLayout', geometry.getLayout());
|
||||
goog.object.set(properties, 'rtept', geometry.getCoordinates());
|
||||
}
|
||||
@@ -598,11 +615,14 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.writeTrk_ = function(node, feature, objectStack) {
|
||||
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
|
||||
var properties = feature.getProperties();
|
||||
var context = {node: node, 'properties': properties};
|
||||
var geometry = feature.getGeometry();
|
||||
if (goog.isDef(geometry)) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString);
|
||||
geometry = /** @type {ol.geom.MultiLineString} */
|
||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||
goog.object.set(properties, 'trkseg', geometry.getLineStrings());
|
||||
}
|
||||
var parentNode = objectStack[objectStack.length - 1].node;
|
||||
@@ -636,12 +656,15 @@ ol.format.GPX.writeTrkSeg_ = function(node, lineString, objectStack) {
|
||||
* @private
|
||||
*/
|
||||
ol.format.GPX.writeWpt_ = function(node, feature, objectStack) {
|
||||
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context));
|
||||
goog.object.set(context, 'properties', feature.getProperties());
|
||||
var geometry = feature.getGeometry();
|
||||
if (goog.isDef(geometry)) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.Point);
|
||||
geometry = /** @type {ol.geom.Point} */
|
||||
(ol.format.Feature.transformWithOptions(geometry, true, options));
|
||||
goog.object.set(context, 'geometryLayout', geometry.getLayout());
|
||||
ol.format.GPX.writeWptType_(node, geometry.getCoordinates(), objectStack);
|
||||
}
|
||||
@@ -845,6 +868,7 @@ ol.format.GPX.GPX_SERIALIZERS_ = ol.xml.makeStructureNS(
|
||||
*
|
||||
* @function
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @return {Node} Result.
|
||||
* @api
|
||||
*/
|
||||
@@ -854,11 +878,12 @@ ol.format.GPX.prototype.writeFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.GPX.prototype.writeFeaturesNode = function(features) {
|
||||
ol.format.GPX.prototype.writeFeaturesNode = function(features, opt_options) {
|
||||
//FIXME Serialize metadata
|
||||
var gpx = ol.xml.createElementNS('http://www.topografix.com/GPX/1/1', 'gpx');
|
||||
|
||||
ol.xml.pushSerializeAndPop(/** @type {ol.xml.NodeStackItem} */
|
||||
({node: gpx}), ol.format.GPX.GPX_SERIALIZERS_,
|
||||
ol.format.GPX.GPX_NODE_FACTORY_, features, []);
|
||||
ol.format.GPX.GPX_NODE_FACTORY_, features, [opt_options]);
|
||||
return gpx;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.newlines');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.TextFeature');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.proj');
|
||||
@@ -38,6 +39,11 @@ ol.format.IGC = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = ol.proj.get('EPSG:4326');
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.format.IGCZ}
|
||||
@@ -95,6 +101,7 @@ ol.format.IGC.prototype.getExtensions = function() {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
@@ -104,7 +111,7 @@ ol.format.IGC.prototype.readFeature;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.IGC.prototype.readFeatureFromText = function(text) {
|
||||
ol.format.IGC.prototype.readFeatureFromText = function(text, opt_options) {
|
||||
var altitudeMode = this.altitudeMode_;
|
||||
var lines = goog.string.newlines.splitLines(text);
|
||||
/** @type {Object.<string, string>} */
|
||||
@@ -169,7 +176,8 @@ ol.format.IGC.prototype.readFeatureFromText = function(text) {
|
||||
var layout = altitudeMode == ol.format.IGCZ.NONE ?
|
||||
ol.geom.GeometryLayout.XYM : ol.geom.GeometryLayout.XYZM;
|
||||
lineString.setFlatCoordinates(layout, flatCoordinates);
|
||||
var feature = new ol.Feature(lineString);
|
||||
var feature = new ol.Feature(ol.format.Feature.transformWithOptions(
|
||||
lineString, false, opt_options));
|
||||
feature.setProperties(properties);
|
||||
return feature;
|
||||
};
|
||||
@@ -181,6 +189,7 @@ ol.format.IGC.prototype.readFeatureFromText = function(text) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -190,8 +199,8 @@ ol.format.IGC.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.IGC.prototype.readFeaturesFromText = function(text) {
|
||||
var feature = this.readFeatureFromText(text);
|
||||
ol.format.IGC.prototype.readFeaturesFromText = function(text, opt_options) {
|
||||
var feature = this.readFeatureFromText(text, opt_options);
|
||||
if (!goog.isNull(feature)) {
|
||||
return [feature];
|
||||
} else {
|
||||
@@ -215,5 +224,5 @@ ol.format.IGC.prototype.readProjection;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.IGC.prototype.readProjectionFromText = function(text) {
|
||||
return ol.proj.get('EPSG:4326');
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
@@ -51,21 +51,24 @@ ol.format.JSONFeature.prototype.getType = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.JSONFeature.prototype.readFeature = function(source) {
|
||||
return this.readFeatureFromObject(this.getObject_(source));
|
||||
ol.format.JSONFeature.prototype.readFeature = function(source, opt_options) {
|
||||
return this.readFeatureFromObject(
|
||||
this.getObject_(source), this.getReadOptions(source, opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.JSONFeature.prototype.readFeatures = function(source) {
|
||||
return this.readFeaturesFromObject(this.getObject_(source));
|
||||
ol.format.JSONFeature.prototype.readFeatures = function(source, opt_options) {
|
||||
return this.readFeaturesFromObject(
|
||||
this.getObject_(source), this.getReadOptions(source, opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object} object Object.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {ol.Feature} Feature.
|
||||
*/
|
||||
@@ -74,6 +77,7 @@ ol.format.JSONFeature.prototype.readFeatureFromObject = goog.abstractMethod;
|
||||
|
||||
/**
|
||||
* @param {Object} object Object.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
*/
|
||||
@@ -83,13 +87,15 @@ ol.format.JSONFeature.prototype.readFeaturesFromObject = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.JSONFeature.prototype.readGeometry = function(source) {
|
||||
return this.readGeometryFromObject(this.getObject_(source));
|
||||
ol.format.JSONFeature.prototype.readGeometry = function(source, opt_options) {
|
||||
return this.readGeometryFromObject(
|
||||
this.getObject_(source), this.getReadOptions(source, opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Object} object Object.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
@@ -115,13 +121,14 @@ ol.format.JSONFeature.prototype.readProjectionFromObject = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.JSONFeature.prototype.writeFeature = function(feature) {
|
||||
return this.writeFeatureObject(feature);
|
||||
ol.format.JSONFeature.prototype.writeFeature = function(feature, opt_options) {
|
||||
return this.writeFeatureObject(feature, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
@@ -131,13 +138,15 @@ ol.format.JSONFeature.prototype.writeFeatureObject = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.JSONFeature.prototype.writeFeatures = function(features) {
|
||||
return this.writeFeaturesObject(features);
|
||||
ol.format.JSONFeature.prototype.writeFeatures = function(
|
||||
features, opt_options) {
|
||||
return this.writeFeaturesObject(features, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
@@ -147,13 +156,15 @@ ol.format.JSONFeature.prototype.writeFeaturesObject = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.JSONFeature.prototype.writeGeometry = function(geometry) {
|
||||
return this.writeGeometryObject(geometry);
|
||||
ol.format.JSONFeature.prototype.writeGeometry = function(
|
||||
geometry, opt_options) {
|
||||
return this.writeGeometryObject(geometry, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {Object} Object.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@ goog.require('ol.Feature');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.XMLFeature');
|
||||
goog.require('ol.format.XSD');
|
||||
goog.require('ol.geom.Geometry');
|
||||
@@ -71,6 +72,11 @@ ol.format.KML = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = ol.proj.get('EPSG:4326');
|
||||
|
||||
var defaultStyle = goog.isDef(options.defaultStyle) ?
|
||||
options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_;
|
||||
|
||||
@@ -1434,6 +1440,10 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
|
||||
if (!goog.isNull(id)) {
|
||||
feature.setId(id);
|
||||
}
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
if (goog.isDefAndNotNull(object.geometry)) {
|
||||
ol.format.Feature.transformWithOptions(object.geometry, false, options);
|
||||
}
|
||||
feature.setProperties(object);
|
||||
if (this.extractStyles_) {
|
||||
feature.setStyle(this.featureStyleFunction_);
|
||||
@@ -1497,6 +1507,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
@@ -1506,13 +1517,14 @@ ol.format.KML.prototype.readFeature;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.KML.prototype.readFeatureFromNode = function(node) {
|
||||
ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
if (!goog.array.contains(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return null;
|
||||
}
|
||||
goog.asserts.assert(node.localName == 'Placemark');
|
||||
var feature = this.readPlacemark_(node, []);
|
||||
var feature = this.readPlacemark_(
|
||||
node, [this.getReadOptions(node, opt_options)]);
|
||||
if (goog.isDef(feature)) {
|
||||
return feature;
|
||||
} else {
|
||||
@@ -1526,6 +1538,7 @@ ol.format.KML.prototype.readFeatureFromNode = function(node) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -1535,7 +1548,7 @@ ol.format.KML.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.KML.prototype.readFeaturesFromNode = function(node) {
|
||||
ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
if (!goog.array.contains(ol.format.KML.NAMESPACE_URIS_, node.namespaceURI)) {
|
||||
return [];
|
||||
@@ -1543,14 +1556,16 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node) {
|
||||
var features;
|
||||
var localName = ol.xml.getLocalName(node);
|
||||
if (localName == 'Document' || localName == 'Folder') {
|
||||
features = this.readDocumentOrFolder_(node, []);
|
||||
features = this.readDocumentOrFolder_(
|
||||
node, [this.getReadOptions(node, opt_options)]);
|
||||
if (goog.isDef(features)) {
|
||||
return features;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
} else if (localName == 'Placemark') {
|
||||
var feature = this.readPlacemark_(node, []);
|
||||
var feature = this.readPlacemark_(
|
||||
node, [this.getReadOptions(node, opt_options)]);
|
||||
if (goog.isDef(feature)) {
|
||||
return [feature];
|
||||
} else {
|
||||
@@ -1561,7 +1576,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node) {
|
||||
var n;
|
||||
for (n = node.firstElementChild; !goog.isNull(n);
|
||||
n = n.nextElementSibling) {
|
||||
var fs = this.readFeaturesFromNode(n);
|
||||
var fs = this.readFeaturesFromNode(n, opt_options);
|
||||
if (goog.isDef(fs)) {
|
||||
goog.array.extend(features, fs);
|
||||
}
|
||||
@@ -1655,7 +1670,7 @@ ol.format.KML.prototype.readProjection;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.KML.prototype.readProjectionFromDocument = function(doc) {
|
||||
return ol.proj.get('EPSG:4326');
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
|
||||
@@ -1663,7 +1678,7 @@ ol.format.KML.prototype.readProjectionFromDocument = function(doc) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.KML.prototype.readProjectionFromNode = function(node) {
|
||||
return ol.proj.get('EPSG:4326');
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
|
||||
@@ -1963,9 +1978,14 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
|
||||
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
|
||||
|
||||
// serialize geometry
|
||||
var options = /** @type {olx.format.WriteOptions} */ (objectStack[0]);
|
||||
var geometry = feature.getGeometry();
|
||||
if (goog.isDefAndNotNull(geometry)) {
|
||||
geometry =
|
||||
ol.format.Feature.transformWithOptions(geometry, true, options);
|
||||
}
|
||||
ol.xml.pushSerializeAndPop(context, ol.format.KML.PLACEMARK_SERIALIZERS_,
|
||||
ol.format.KML.GEOMETRY_NODE_FACTORY_,
|
||||
[feature.getGeometry()], objectStack);
|
||||
ol.format.KML.GEOMETRY_NODE_FACTORY_, [geometry], objectStack);
|
||||
};
|
||||
|
||||
|
||||
@@ -2504,6 +2524,7 @@ ol.format.KML.OUTER_BOUNDARY_NODE_FACTORY_ =
|
||||
*
|
||||
* @function
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Options.
|
||||
* @return {Node} Result.
|
||||
* @api
|
||||
*/
|
||||
@@ -2513,7 +2534,7 @@ ol.format.KML.prototype.writeFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.KML.prototype.writeFeaturesNode = function(features) {
|
||||
ol.format.KML.prototype.writeFeaturesNode = function(features, opt_options) {
|
||||
var kml = ol.xml.createElementNS(ol.format.KML.NAMESPACE_URIS_[4], 'kml');
|
||||
var xmlnsUri = 'http://www.w3.org/2000/xmlns/';
|
||||
var xmlSchemaInstanceUri = 'http://www.w3.org/2001/XMLSchema-instance';
|
||||
@@ -2533,6 +2554,6 @@ ol.format.KML.prototype.writeFeaturesNode = function(features) {
|
||||
var orderedKeys = ol.format.KML.KML_SEQUENCE_[kml.namespaceURI];
|
||||
var values = ol.xml.makeSequence(properties, orderedKeys);
|
||||
ol.xml.pushSerializeAndPop(context, ol.format.KML.KML_SERIALIZERS_,
|
||||
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, [], orderedKeys);
|
||||
ol.xml.OBJECT_PROPERTY_NODE_FACTORY, values, [opt_options], orderedKeys);
|
||||
return kml;
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.dom.NodeType');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.XMLFeature');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.Point');
|
||||
@@ -26,6 +27,11 @@ goog.require('ol.xml');
|
||||
*/
|
||||
ol.format.OSMXML = function() {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = ol.proj.get('EPSG:4326');
|
||||
};
|
||||
goog.inherits(ol.format.OSMXML, ol.format.XMLFeature);
|
||||
|
||||
@@ -54,6 +60,7 @@ ol.format.OSMXML.prototype.getExtensions = function() {
|
||||
ol.format.OSMXML.readNode_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'node');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
|
||||
var id = node.getAttribute('id');
|
||||
var coordinates = /** @type {Array.<number>} */ ([
|
||||
@@ -67,6 +74,7 @@ ol.format.OSMXML.readNode_ = function(node, objectStack) {
|
||||
}, ol.format.OSMXML.NODE_PARSERS_, node, objectStack);
|
||||
if (!goog.object.isEmpty(values.tags)) {
|
||||
var geometry = new ol.geom.Point(coordinates);
|
||||
ol.format.Feature.transformWithOptions(geometry, false, options);
|
||||
var feature = new ol.Feature(geometry);
|
||||
feature.setId(id);
|
||||
feature.setProperties(values.tags);
|
||||
@@ -83,6 +91,7 @@ ol.format.OSMXML.readNode_ = function(node, objectStack) {
|
||||
ol.format.OSMXML.readWay_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'way');
|
||||
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
|
||||
var id = node.getAttribute('id');
|
||||
var values = ol.xml.pushParseAndPop({
|
||||
ndrefs: [],
|
||||
@@ -104,6 +113,7 @@ ol.format.OSMXML.readWay_ = function(node, objectStack) {
|
||||
geometry = new ol.geom.LineString(null);
|
||||
geometry.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates);
|
||||
}
|
||||
ol.format.Feature.transformWithOptions(geometry, false, options);
|
||||
var feature = new ol.Feature(geometry);
|
||||
feature.setId(id);
|
||||
feature.setProperties(values.tags);
|
||||
@@ -189,6 +199,7 @@ ol.format.OSMXML.NODE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -198,13 +209,14 @@ ol.format.OSMXML.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.OSMXML.prototype.readFeaturesFromNode = function(node) {
|
||||
ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
var options = this.getReadOptions(node, opt_options);
|
||||
if (node.localName == 'osm') {
|
||||
var state = ol.xml.pushParseAndPop({
|
||||
nodes: {},
|
||||
features: []
|
||||
}, ol.format.OSMXML.PARSERS_, node, []);
|
||||
}, ol.format.OSMXML.PARSERS_, node, [options]);
|
||||
if (goog.isDef(state.features)) {
|
||||
return state.features;
|
||||
}
|
||||
@@ -228,7 +240,7 @@ ol.format.OSMXML.prototype.readProjection;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.OSMXML.prototype.readProjectionFromDocument = function(doc) {
|
||||
return ol.proj.get('EPSG:4326');
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
|
||||
@@ -236,5 +248,5 @@ ol.format.OSMXML.prototype.readProjectionFromDocument = function(doc) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.OSMXML.prototype.readProjectionFromNode = function(node) {
|
||||
return ol.proj.get('EPSG:4326');
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ goog.provide('ol.format.Polyline');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.TextFeature');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.flat.inflate');
|
||||
@@ -22,6 +23,11 @@ ol.format.Polyline = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = ol.proj.get('EPSG:4326');
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -248,6 +254,7 @@ ol.format.Polyline.encodeUnsignedInteger = function(num) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
@@ -257,8 +264,8 @@ ol.format.Polyline.prototype.readFeature;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.readFeatureFromText = function(text) {
|
||||
var geometry = this.readGeometryFromText(text);
|
||||
ol.format.Polyline.prototype.readFeatureFromText = function(text, opt_options) {
|
||||
var geometry = this.readGeometryFromText(text, opt_options);
|
||||
return new ol.Feature(geometry);
|
||||
};
|
||||
|
||||
@@ -269,6 +276,7 @@ ol.format.Polyline.prototype.readFeatureFromText = function(text) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -278,8 +286,9 @@ ol.format.Polyline.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.readFeaturesFromText = function(text) {
|
||||
var feature = this.readFeatureFromText(text);
|
||||
ol.format.Polyline.prototype.readFeaturesFromText =
|
||||
function(text, opt_options) {
|
||||
var feature = this.readFeatureFromText(text, opt_options);
|
||||
return [feature];
|
||||
};
|
||||
|
||||
@@ -289,6 +298,7 @@ ol.format.Polyline.prototype.readFeaturesFromText = function(text) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
* @api
|
||||
*/
|
||||
@@ -298,11 +308,16 @@ ol.format.Polyline.prototype.readGeometry;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.readGeometryFromText = function(text) {
|
||||
ol.format.Polyline.prototype.readGeometryFromText =
|
||||
function(text, opt_options) {
|
||||
var flatCoordinates = ol.format.Polyline.decodeDeltas(text, 2, this.factor_);
|
||||
var coordinates = ol.geom.flat.inflate.coordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, 2);
|
||||
return new ol.geom.LineString(coordinates);
|
||||
|
||||
return /** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(
|
||||
new ol.geom.LineString(coordinates), false,
|
||||
this.adaptOptions(opt_options)));
|
||||
};
|
||||
|
||||
|
||||
@@ -321,17 +336,17 @@ ol.format.Polyline.prototype.readProjection;
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.readProjectionFromText = function(text) {
|
||||
return ol.proj.get('EPSG:4326');
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.writeFeatureText = function(feature) {
|
||||
ol.format.Polyline.prototype.writeFeatureText = function(feature, opt_options) {
|
||||
var geometry = feature.getGeometry();
|
||||
if (goog.isDefAndNotNull(geometry)) {
|
||||
return this.writeGeometryText(geometry);
|
||||
return this.writeGeometryText(geometry, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return '';
|
||||
@@ -342,9 +357,10 @@ ol.format.Polyline.prototype.writeFeatureText = function(feature) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.writeFeaturesText = function(features) {
|
||||
ol.format.Polyline.prototype.writeFeaturesText =
|
||||
function(features, opt_options) {
|
||||
goog.asserts.assert(features.length == 1);
|
||||
return this.writeFeatureText(features[0]);
|
||||
return this.writeFeatureText(features[0], opt_options);
|
||||
};
|
||||
|
||||
|
||||
@@ -353,6 +369,7 @@ ol.format.Polyline.prototype.writeFeaturesText = function(features) {
|
||||
*
|
||||
* @function
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @return {string} Geometry.
|
||||
* @api
|
||||
*/
|
||||
@@ -362,8 +379,12 @@ ol.format.Polyline.prototype.writeGeometry;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.Polyline.prototype.writeGeometryText = function(geometry) {
|
||||
ol.format.Polyline.prototype.writeGeometryText =
|
||||
function(geometry, opt_options) {
|
||||
goog.asserts.assertInstanceof(geometry, ol.geom.LineString);
|
||||
geometry = /** @type {ol.geom.LineString} */
|
||||
(ol.format.Feature.transformWithOptions(
|
||||
geometry, true, this.adaptOptions(opt_options)));
|
||||
var flatCoordinates = geometry.getFlatCoordinates();
|
||||
var stride = geometry.getStride();
|
||||
return ol.format.Polyline.encodeDeltas(flatCoordinates, stride, this.factor_);
|
||||
|
||||
@@ -47,13 +47,15 @@ ol.format.TextFeature.prototype.getType = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.TextFeature.prototype.readFeature = function(source) {
|
||||
return this.readFeatureFromText(this.getText_(source));
|
||||
ol.format.TextFeature.prototype.readFeature = function(source, opt_options) {
|
||||
return this.readFeatureFromText(
|
||||
this.getText_(source), this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {ol.Feature} Feature.
|
||||
*/
|
||||
@@ -63,13 +65,15 @@ ol.format.TextFeature.prototype.readFeatureFromText = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.TextFeature.prototype.readFeatures = function(source) {
|
||||
return this.readFeaturesFromText(this.getText_(source));
|
||||
ol.format.TextFeature.prototype.readFeatures = function(source, opt_options) {
|
||||
return this.readFeaturesFromText(
|
||||
this.getText_(source), this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
*/
|
||||
@@ -79,13 +83,15 @@ ol.format.TextFeature.prototype.readFeaturesFromText = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.TextFeature.prototype.readGeometry = function(source) {
|
||||
return this.readGeometryFromText(this.getText_(source));
|
||||
ol.format.TextFeature.prototype.readGeometry = function(source, opt_options) {
|
||||
return this.readGeometryFromText(
|
||||
this.getText_(source), this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} text Text.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @protected
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
@@ -111,13 +117,14 @@ ol.format.TextFeature.prototype.readProjectionFromText = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.TextFeature.prototype.writeFeature = function(feature) {
|
||||
return this.writeFeatureText(feature);
|
||||
ol.format.TextFeature.prototype.writeFeature = function(feature, opt_options) {
|
||||
return this.writeFeatureText(feature, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
@@ -127,13 +134,15 @@ ol.format.TextFeature.prototype.writeFeatureText = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.TextFeature.prototype.writeFeatures = function(features) {
|
||||
return this.writeFeaturesText(features);
|
||||
ol.format.TextFeature.prototype.writeFeatures = function(
|
||||
features, opt_options) {
|
||||
return this.writeFeaturesText(features, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
@@ -143,13 +152,15 @@ ol.format.TextFeature.prototype.writeFeaturesText = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.TextFeature.prototype.writeGeometry = function(geometry) {
|
||||
return this.writeGeometryText(geometry);
|
||||
ol.format.TextFeature.prototype.writeGeometry = function(
|
||||
geometry, opt_options) {
|
||||
return this.writeGeometryText(geometry, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @protected
|
||||
* @return {string} Text.
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ goog.provide('ol.format.TopoJSON');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.JSONFeature');
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.MultiLineString');
|
||||
@@ -30,11 +31,11 @@ ol.format.TopoJSON = function(opt_options) {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.proj.Projection}
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultProjection_ =
|
||||
ol.proj.get(options.defaultProjection || 'EPSG:4326');
|
||||
this.defaultDataProjection = ol.proj.get(
|
||||
goog.isDefAndNotNull(options.defaultDataProjection) ?
|
||||
options.defaultDataProjection : 'EPSG:4326');
|
||||
|
||||
};
|
||||
goog.inherits(ol.format.TopoJSON, ol.format.JSONFeature);
|
||||
@@ -217,17 +218,18 @@ ol.format.TopoJSON.prototype.getExtensions = function() {
|
||||
* @param {Array.<Array.<ol.Coordinate>>} arcs Array of arcs.
|
||||
* @param {Array.<number>} scale Scale for each dimension.
|
||||
* @param {Array.<number>} translate Translation for each dimension.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Array of features.
|
||||
* @private
|
||||
*/
|
||||
ol.format.TopoJSON.readFeaturesFromGeometryCollection_ = function(
|
||||
collection, arcs, scale, translate) {
|
||||
collection, arcs, scale, translate, 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_(
|
||||
geometries[i], arcs, scale, translate);
|
||||
geometries[i], arcs, scale, translate, opt_options);
|
||||
}
|
||||
return features;
|
||||
};
|
||||
@@ -240,11 +242,12 @@ ol.format.TopoJSON.readFeaturesFromGeometryCollection_ = function(
|
||||
* @param {Array.<Array.<ol.Coordinate>>} arcs Array of arcs.
|
||||
* @param {Array.<number>} scale Scale for each dimension.
|
||||
* @param {Array.<number>} translate Translation for each dimension.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.Feature} Feature.
|
||||
* @private
|
||||
*/
|
||||
ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
||||
scale, translate) {
|
||||
scale, translate, opt_options) {
|
||||
var geometry;
|
||||
var type = object.type;
|
||||
var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type];
|
||||
@@ -255,7 +258,8 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
|
||||
geometry = geometryReader(object, arcs);
|
||||
}
|
||||
var feature = new ol.Feature();
|
||||
feature.setGeometry(geometry);
|
||||
feature.setGeometry(/** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(geometry, false, opt_options)));
|
||||
if (goog.isDef(object.id)) {
|
||||
feature.setId(object.id);
|
||||
}
|
||||
@@ -280,7 +284,8 @@ ol.format.TopoJSON.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.TopoJSON.prototype.readFeaturesFromObject = function(object) {
|
||||
ol.format.TopoJSON.prototype.readFeaturesFromObject = function(
|
||||
object, opt_options) {
|
||||
if (object.type == 'Topology') {
|
||||
var topoJSONTopology = /** @type {TopoJSONTopology} */ (object);
|
||||
var transform, scale = null, translate = null;
|
||||
@@ -305,12 +310,12 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function(object) {
|
||||
(topoJSONFeatures[i]);
|
||||
features.push.apply(features,
|
||||
ol.format.TopoJSON.readFeaturesFromGeometryCollection_(
|
||||
feature, arcs, scale, translate));
|
||||
feature, arcs, scale, translate, opt_options));
|
||||
} else {
|
||||
feature = /** @type {TopoJSONGeometry} */
|
||||
(topoJSONFeatures[i]);
|
||||
features.push(ol.format.TopoJSON.readFeatureFromGeometry_(
|
||||
feature, arcs, scale, translate));
|
||||
feature, arcs, scale, translate, opt_options));
|
||||
}
|
||||
}
|
||||
return features;
|
||||
@@ -385,7 +390,7 @@ ol.format.TopoJSON.transformVertex_ = function(vertex, scale, translate) {
|
||||
* @api
|
||||
*/
|
||||
ol.format.TopoJSON.prototype.readProjection = function(object) {
|
||||
return this.defaultProjection_;
|
||||
return this.defaultDataProjection;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ ol.format.WFS.schemaLocation_ = 'http://www.opengis.net/wfs ' +
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -109,11 +110,14 @@ ol.format.WFS.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WFS.prototype.readFeaturesFromNode = function(node) {
|
||||
var objectStack = [{
|
||||
ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) {
|
||||
var context = {
|
||||
'featureType': this.featureType_,
|
||||
'featureNS': this.featureNS_
|
||||
}];
|
||||
};
|
||||
goog.object.extend(context, this.getReadOptions(node,
|
||||
goog.isDef(opt_options) ? opt_options : {}));
|
||||
var objectStack = [context];
|
||||
var features = ol.xml.pushParseAndPop([],
|
||||
ol.format.GML.FEATURE_COLLECTION_PARSERS, node, objectStack);
|
||||
if (!goog.isDef(features)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ goog.provide('ol.format.WKT');
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.TextFeature');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryCollection');
|
||||
@@ -208,6 +209,7 @@ ol.format.WKT.prototype.parse_ = function(wkt) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
@@ -217,8 +219,8 @@ ol.format.WKT.prototype.readFeature;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WKT.prototype.readFeatureFromText = function(text) {
|
||||
var geom = this.readGeometryFromText(text);
|
||||
ol.format.WKT.prototype.readFeatureFromText = function(text, opt_options) {
|
||||
var geom = this.readGeometryFromText(text, opt_options);
|
||||
if (goog.isDef(geom)) {
|
||||
var feature = new ol.Feature();
|
||||
feature.setGeometry(geom);
|
||||
@@ -233,6 +235,7 @@ ol.format.WKT.prototype.readFeatureFromText = function(text) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
* @api
|
||||
*/
|
||||
@@ -242,9 +245,9 @@ ol.format.WKT.prototype.readFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WKT.prototype.readFeaturesFromText = function(text) {
|
||||
ol.format.WKT.prototype.readFeaturesFromText = function(text, opt_options) {
|
||||
var geometries = [];
|
||||
var geometry = this.readGeometryFromText(text);
|
||||
var geometry = this.readGeometryFromText(text, opt_options);
|
||||
if (this.splitCollection_ &&
|
||||
geometry.getType() == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
|
||||
geometries = (/** @type {ol.geom.GeometryCollection} */ (geometry))
|
||||
@@ -267,6 +270,7 @@ ol.format.WKT.prototype.readFeaturesFromText = function(text) {
|
||||
*
|
||||
* @function
|
||||
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
|
||||
* @param {olx.format.ReadOptions=} opt_options Read options.
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
* @api
|
||||
*/
|
||||
@@ -276,8 +280,14 @@ ol.format.WKT.prototype.readGeometry;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WKT.prototype.readGeometryFromText = function(text) {
|
||||
return this.parse_(text) || null;
|
||||
ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) {
|
||||
var geometry = this.parse_(text);
|
||||
if (goog.isDef(geometry)) {
|
||||
return /** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(geometry, false, opt_options));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -294,6 +304,7 @@ ol.format.WKT.prototype.readProjectionFromText = function(text) {
|
||||
*
|
||||
* @function
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @return {string} WKT string.
|
||||
* @api
|
||||
*/
|
||||
@@ -303,10 +314,10 @@ ol.format.WKT.prototype.writeFeature;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WKT.prototype.writeFeatureText = function(feature) {
|
||||
ol.format.WKT.prototype.writeFeatureText = function(feature, opt_options) {
|
||||
var geometry = feature.getGeometry();
|
||||
if (goog.isDef(geometry)) {
|
||||
return this.writeGeometryText(geometry);
|
||||
return this.writeGeometryText(geometry, opt_options);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
@@ -317,6 +328,7 @@ ol.format.WKT.prototype.writeFeatureText = function(feature) {
|
||||
*
|
||||
* @function
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Write options.
|
||||
* @return {string} WKT string.
|
||||
* @api
|
||||
*/
|
||||
@@ -326,16 +338,16 @@ ol.format.WKT.prototype.writeFeatures;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WKT.prototype.writeFeaturesText = function(features) {
|
||||
ol.format.WKT.prototype.writeFeaturesText = function(features, opt_options) {
|
||||
if (features.length == 1) {
|
||||
return this.writeFeatureText(features[0]);
|
||||
return this.writeFeatureText(features[0], opt_options);
|
||||
}
|
||||
var geometries = [];
|
||||
for (var i = 0, ii = features.length; i < ii; ++i) {
|
||||
geometries.push(features[i].getGeometry());
|
||||
}
|
||||
var collection = new ol.geom.GeometryCollection(geometries);
|
||||
return this.writeGeometryText(collection);
|
||||
return this.writeGeometryText(collection, opt_options);
|
||||
};
|
||||
|
||||
|
||||
@@ -353,8 +365,9 @@ ol.format.WKT.prototype.writeGeometry;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.WKT.prototype.writeGeometryText = function(geometry) {
|
||||
return ol.format.WKT.encode_(geometry);
|
||||
ol.format.WKT.prototype.writeGeometryText = function(geometry, opt_options) {
|
||||
return ol.format.WKT.encode_(/** @type {ol.geom.Geometry} */ (
|
||||
ol.format.Feature.transformWithOptions(geometry, true, opt_options)));
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.dom.NodeType');
|
||||
goog.require('ol.format.Feature');
|
||||
goog.require('ol.format.FormatType');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.xml');
|
||||
|
||||
|
||||
@@ -35,14 +36,15 @@ ol.format.XMLFeature.prototype.getType = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeature = function(source) {
|
||||
ol.format.XMLFeature.prototype.readFeature = function(source, opt_options) {
|
||||
if (ol.xml.isDocument(source)) {
|
||||
return this.readFeatureFromDocument(/** @type {Document} */ (source));
|
||||
return this.readFeatureFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFeatureFromNode(/** @type {Node} */ (source));
|
||||
return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
var doc = ol.xml.load(source);
|
||||
return this.readFeatureFromDocument(doc);
|
||||
return this.readFeatureFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return null;
|
||||
@@ -52,10 +54,12 @@ ol.format.XMLFeature.prototype.readFeature = function(source) {
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @return {ol.Feature} Feature.
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeatureFromDocument = function(doc) {
|
||||
var features = this.readFeaturesFromDocument(doc);
|
||||
ol.format.XMLFeature.prototype.readFeatureFromDocument = function(
|
||||
doc, opt_options) {
|
||||
var features = this.readFeaturesFromDocument(doc, opt_options);
|
||||
if (features.length > 0) {
|
||||
return features[0];
|
||||
} else {
|
||||
@@ -66,6 +70,7 @@ ol.format.XMLFeature.prototype.readFeatureFromDocument = function(doc) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @return {ol.Feature} Feature.
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeatureFromNode = goog.abstractMethod;
|
||||
@@ -74,14 +79,15 @@ ol.format.XMLFeature.prototype.readFeatureFromNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeatures = function(source) {
|
||||
ol.format.XMLFeature.prototype.readFeatures = function(source, opt_options) {
|
||||
if (ol.xml.isDocument(source)) {
|
||||
return this.readFeaturesFromDocument(/** @type {Document} */ (source));
|
||||
return this.readFeaturesFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFeaturesFromNode(/** @type {Node} */ (source));
|
||||
return this.readFeaturesFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
var doc = ol.xml.load(source);
|
||||
return this.readFeaturesFromDocument(doc);
|
||||
return this.readFeaturesFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return [];
|
||||
@@ -91,16 +97,18 @@ ol.format.XMLFeature.prototype.readFeatures = function(source) {
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeaturesFromDocument = function(doc) {
|
||||
ol.format.XMLFeature.prototype.readFeaturesFromDocument = function(
|
||||
doc, opt_options) {
|
||||
/** @type {Array.<ol.Feature>} */
|
||||
var features = [];
|
||||
var n;
|
||||
for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) {
|
||||
if (n.nodeType == goog.dom.NodeType.ELEMENT) {
|
||||
goog.array.extend(features, this.readFeaturesFromNode(n));
|
||||
goog.array.extend(features, this.readFeaturesFromNode(n, opt_options));
|
||||
}
|
||||
}
|
||||
return features;
|
||||
@@ -109,6 +117,7 @@ ol.format.XMLFeature.prototype.readFeaturesFromDocument = function(doc) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
*/
|
||||
@@ -118,14 +127,15 @@ ol.format.XMLFeature.prototype.readFeaturesFromNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readGeometry = function(source) {
|
||||
ol.format.XMLFeature.prototype.readGeometry = function(source, opt_options) {
|
||||
if (ol.xml.isDocument(source)) {
|
||||
return this.readGeometryFromDocument(/** @type {Document} */ (source));
|
||||
return this.readGeometryFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readGeometryFromNode(/** @type {Node} */ (source));
|
||||
return this.readGeometryFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
var doc = ol.xml.load(source);
|
||||
return this.readGeometryFromDocument(doc);
|
||||
return this.readGeometryFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return null;
|
||||
@@ -135,6 +145,7 @@ ol.format.XMLFeature.prototype.readGeometry = function(source) {
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
@@ -143,6 +154,7 @@ ol.format.XMLFeature.prototype.readGeometryFromDocument = goog.abstractMethod;
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
@@ -186,13 +198,14 @@ ol.format.XMLFeature.prototype.readProjectionFromNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeFeature = function(feature) {
|
||||
return this.writeFeatureNode(feature);
|
||||
ol.format.XMLFeature.prototype.writeFeature = function(feature, opt_options) {
|
||||
return this.writeFeatureNode(feature, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {olx.format.WriteOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
@@ -202,13 +215,14 @@ ol.format.XMLFeature.prototype.writeFeatureNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeFeatures = function(features) {
|
||||
return this.writeFeaturesNode(features);
|
||||
ol.format.XMLFeature.prototype.writeFeatures = function(features, opt_options) {
|
||||
return this.writeFeaturesNode(features, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
@@ -218,13 +232,14 @@ ol.format.XMLFeature.prototype.writeFeaturesNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeGeometry = function(geometry) {
|
||||
return this.writeGeometryNode(geometry);
|
||||
ol.format.XMLFeature.prototype.writeGeometry = function(geometry, opt_options) {
|
||||
return this.writeGeometryNode(geometry, this.adaptOptions(opt_options));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ ol.source.GeoJSON = function(opt_options) {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
format: new ol.format.GeoJSON({
|
||||
defaultProjection: options.defaultProjection
|
||||
defaultDataProjection: options.defaultProjection
|
||||
}),
|
||||
logo: options.logo,
|
||||
object: options.object,
|
||||
|
||||
@@ -23,7 +23,7 @@ ol.source.TopoJSON = function(opt_options) {
|
||||
attributions: options.attributions,
|
||||
extent: options.extent,
|
||||
format: new ol.format.TopoJSON({
|
||||
defaultProjection: options.defaultProjection
|
||||
defaultDataProjection: options.defaultProjection
|
||||
}),
|
||||
logo: options.logo,
|
||||
object: options.object,
|
||||
|
||||
Reference in New Issue
Block a user