Fix GeoJSON.readFeaturesFromObject

Only feature collections worked properly.
This commit is contained in:
tsauerwein
2014-08-08 11:14:03 +02:00
parent 281fd3c6a9
commit 3090a0af37
2 changed files with 10 additions and 1 deletions

View File

@@ -398,7 +398,7 @@ 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);

View File

@@ -174,6 +174,15 @@ describe('ol.format.GeoJSON', function() {
expect(features[2].getGeometry()).to.be.an(ol.geom.Polygon);
});
it('can read and transform a point', function() {
var feature = format.readFeatures(pointGeoJSON, {
featureProjection: 'EPSG:3857'
});
expect(feature[0].getGeometry()).to.be.an(ol.geom.Point);
expect(feature[0].getGeometry().getCoordinates()).to.eql(
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
});
it('can read and transform a feature collection', function() {
var features = format.readFeatures(featureCollectionGeoJSON, {
featureProjection: 'EPSG:3857'