Pull up most of the changes for what will be 2.5RC4:
* Clone on WMS/MS Untiled, 4760:4761 (Closes #1013) * serviceVersion on TMS, 4720:4721 (Closes #1023) * W3CGeo in Format.GeoRSS, 4768:4769, 4778:4779 (Closes #1024) * GeoJSON Draft4 Update, 4769:4770 (Closes #1028) * pagePosition Regression 4782:4783, (Closes #1034) * example changes 4691:4692 (Closes #1040) * WFS missing registerTileListener 4759:4760 (Closes #1045) * Yahoo API to stop dragging 4792:4793 (Closes #1052) git-svn-id: http://svn.openlayers.org/branches/openlayers/2.5@4794 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -93,9 +93,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
break;
|
||||
case "GeometryCollection":
|
||||
results = [];
|
||||
for(var i=0; i<obj.members.length; ++i) {
|
||||
for(var i=0; i<obj.geometries.length; ++i) {
|
||||
try {
|
||||
results.push(this.parseGeometry(obj.members[i]));
|
||||
results.push(this.parseGeometry(obj.geometries[i]));
|
||||
} catch(err) {
|
||||
results = null;
|
||||
OpenLayers.Console.error(err);
|
||||
@@ -115,9 +115,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
}
|
||||
break;
|
||||
case "FeatureCollection":
|
||||
for(var i=0; i<obj.members.length; ++i) {
|
||||
for(var i=0; i<obj.features.length; ++i) {
|
||||
try {
|
||||
results.push(this.parseFeature(obj.members[i]));
|
||||
results.push(this.parseFeature(obj.features[i]));
|
||||
} catch(err) {
|
||||
results = null;
|
||||
OpenLayers.Console.error(err);
|
||||
@@ -125,9 +125,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
}
|
||||
break;
|
||||
case "GeometryCollection":
|
||||
for(var i=0; i<obj.members.length; ++i) {
|
||||
for(var i=0; i<obj.geometries.length; ++i) {
|
||||
try {
|
||||
var geom = this.parseGeometry(obj.members[i]);
|
||||
var geom = this.parseGeometry(obj.geometries[i]);
|
||||
results.push(new OpenLayers.Feature.Vector(geom));
|
||||
} catch(err) {
|
||||
results = null;
|
||||
@@ -436,28 +436,24 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
"type": null
|
||||
};
|
||||
if(obj instanceof Array) {
|
||||
geojson.members = [];
|
||||
if(obj[0] instanceof OpenLayers.Feature.Vector) {
|
||||
geojson.features = [];
|
||||
} else if (obj[0].CLASS_NAME.search("OpenLayers.Geometry") == 0) {
|
||||
geojson.geometries = [];
|
||||
}
|
||||
for(var i=0; i<obj.length; ++i) {
|
||||
var element = obj[i];
|
||||
if(element instanceof OpenLayers.Feature.Vector) {
|
||||
if(geojson.type == null) {
|
||||
geojson.type = "FeatureCollection";
|
||||
if(element.layer && element.layer.projection) {
|
||||
var proj = element.layer.projection;
|
||||
if(proj.match(/epsg:/i)) {
|
||||
geojson.crs = {
|
||||
"type": "EPSG",
|
||||
"properties": {
|
||||
"code": parseInt(proj.substring(proj.indexOf(":") + 1))
|
||||
}
|
||||
};
|
||||
}
|
||||
this.createCRSObject(element);
|
||||
}
|
||||
} else if(geojson.type != "FeatureCollection") {
|
||||
OpenLayers.Console.error("FeatureCollection only supports collections of features: " + element);
|
||||
break;
|
||||
}
|
||||
geojson.members.push(this.extract.feature.apply(this, [element]));
|
||||
geojson.features.push(this.extract.feature.apply(this, [element]));
|
||||
} else if (element.CLASS_NAME.search("OpenLayers.Geometry") == 0) {
|
||||
if(geojson.type == null) {
|
||||
geojson.type = "GeometryCollection";
|
||||
@@ -465,7 +461,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
OpenLayers.Console.error("GeometryCollection only supports collections of geometries: " + element);
|
||||
break;
|
||||
}
|
||||
geojson.members.push(this.extract.geometry.apply(this, [element]));
|
||||
geojson.geometries.push(this.extract.geometry.apply(this, [element]));
|
||||
}
|
||||
}
|
||||
} else if (obj.CLASS_NAME.search("OpenLayers.Geometry") == 0) {
|
||||
@@ -473,20 +469,38 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
||||
} else if (obj instanceof OpenLayers.Feature.Vector) {
|
||||
geojson = this.extract.feature.apply(this, [obj]);
|
||||
if(obj.layer && obj.layer.projection) {
|
||||
var proj = obj.layer.projection;
|
||||
if(proj.match(/epsg:/i)) {
|
||||
geojson.crs = {
|
||||
"type": "EPSG",
|
||||
"properties": {
|
||||
"code": parseInt(proj.substring(proj.indexOf(":") + 1))
|
||||
}
|
||||
};
|
||||
}
|
||||
this.createCRSObject(obj);
|
||||
}
|
||||
}
|
||||
return OpenLayers.Format.JSON.prototype.write.apply(this,
|
||||
[geojson, pretty]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: createCRSObject
|
||||
* Create the CRS object for an object.
|
||||
*/
|
||||
createCRSObject: function(object) {
|
||||
var proj = object.layer.projection;
|
||||
if (proj.match(/epsg:/i)) {
|
||||
var code = parseInt(proj.substring(proj.indexOf(":") + 1));
|
||||
if (code == 4326) {
|
||||
geojson.crs = {
|
||||
"type": "OGC",
|
||||
"properties": {
|
||||
"urn": "urn:ogc:def:crs:OGC:1.3:CRS84"
|
||||
}
|
||||
};
|
||||
} else {
|
||||
geojson.crs = {
|
||||
"type": "EPSG",
|
||||
"properties": {
|
||||
"code": code
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: extract
|
||||
|
||||
Reference in New Issue
Block a user