Add support for GeoJSON Bounding Box/Envelope, r=crschmidt (closes #1878)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@8582 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -47,6 +47,15 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
*/
|
||||
attributes: null,
|
||||
|
||||
/**
|
||||
* Property: bounds
|
||||
* {<OpenLayers.Bounds>} The box bounding that feature's geometry, that
|
||||
* property can be set by an <OpenLayers.Format> object when
|
||||
* deserializing the feature, so in most cases it represents an
|
||||
* information set by the server.
|
||||
*/
|
||||
bounds: null,
|
||||
|
||||
/**
|
||||
* Property: state
|
||||
* {String}
|
||||
|
||||
@@ -178,15 +178,19 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
* {<OpenLayers.Feature.Vector>} A feature.
|
||||
*/
|
||||
parseFeature: function(obj) {
|
||||
var feature, geometry, attributes;
|
||||
var feature, geometry, attributes, bbox;
|
||||
attributes = (obj.properties) ? obj.properties : {};
|
||||
bbox = (obj.geometry && obj.geometry.bbox) || obj.bbox;
|
||||
try {
|
||||
geometry = this.parseGeometry(obj.geometry);
|
||||
geometry = this.parseGeometry(obj.geometry);
|
||||
} catch(err) {
|
||||
// deal with bad geometries
|
||||
throw err;
|
||||
}
|
||||
feature = new OpenLayers.Feature.Vector(geometry, attributes);
|
||||
if(bbox) {
|
||||
feature.bounds = OpenLayers.Bounds.fromArray(bbox);
|
||||
}
|
||||
if(obj.id) {
|
||||
feature.fid = obj.id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user