Commit this quite-excellent patch from Roald de Wit, which adds:
* the ability to 'flip' the GML format xy ordering on parsing, allowing the GML parser to parse 'real' GML in 4326 when the option is on. * parsing of GML 'envelope' as a Polygon. this is primarily to support the next... * GeoRSS GML read support, using the GML format when neccesary. Includes a comprehensive set of tests, and is really one of the better assembled major patches from a first-time contributor I've ever seen. Thanks for the hard work, Roald! (Closes #1109) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5238 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -58,6 +58,20 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*/
|
||||
featureDescription: "No Description",
|
||||
|
||||
/**
|
||||
* Property: gmlParse
|
||||
* {Object} GML Format object for parsing features
|
||||
* Non-API and only created if necessary
|
||||
*/
|
||||
gmlParser: null,
|
||||
|
||||
/**
|
||||
* APIProperty: xy
|
||||
* {Boolean} Order of the GML coordinate: true:(x,y) or false:(y,x)
|
||||
* For GeoRSS the default is (y,x), therefore: false
|
||||
*/
|
||||
xy: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.GeoRSS
|
||||
* Create a new parser for GeoRSS.
|
||||
@@ -91,38 +105,52 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
var polygon = this.getElementsByTagNameNS(item,
|
||||
this.georssns,
|
||||
"polygon");
|
||||
|
||||
var where = this.getElementsByTagNameNS(item,
|
||||
this.georssns,
|
||||
"where");
|
||||
if (point.length > 0 || (lat.length > 0 && lon.length > 0)) {
|
||||
var location;
|
||||
if (point.length > 0) {
|
||||
var location = OpenLayers.String.trim(
|
||||
location = OpenLayers.String.trim(
|
||||
point[0].firstChild.nodeValue).split(/\s+/);
|
||||
|
||||
if (location.length !=2) {
|
||||
var location = OpenLayers.String.trim(
|
||||
location = OpenLayers.String.trim(
|
||||
point[0].firstChild.nodeValue).split(/\s*,\s*/);
|
||||
}
|
||||
} else {
|
||||
var location = [parseFloat(lat[0].firstChild.nodeValue),
|
||||
location = [parseFloat(lat[0].firstChild.nodeValue),
|
||||
parseFloat(lon[0].firstChild.nodeValue)];
|
||||
}
|
||||
|
||||
var geometry = new OpenLayers.Geometry.Point(parseFloat(location[1]),
|
||||
parseFloat(location[0]));
|
||||
parseFloat(location[0]));
|
||||
|
||||
} else if (line.length > 0) {
|
||||
var coords = OpenLayers.String.trim(line[0].firstChild.nodeValue).split(/\s+/);
|
||||
var components = [];
|
||||
var point;
|
||||
for (var i=0; i < coords.length; i+=2) {
|
||||
var point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]), parseFloat(coords[i]));
|
||||
point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]),
|
||||
parseFloat(coords[i]));
|
||||
components.push(point);
|
||||
}
|
||||
geometry = new OpenLayers.Geometry.LineString(components);
|
||||
} else if (polygon.length > 0) {
|
||||
var coords = OpenLayers.String.trim(polygon[0].firstChild.nodeValue).split(/\s+/);
|
||||
var components = [];
|
||||
var point;
|
||||
for (var i=0; i < coords.length; i+=2) {
|
||||
var point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]), parseFloat(coords[i]));
|
||||
point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]),
|
||||
parseFloat(coords[i]));
|
||||
components.push(point);
|
||||
}
|
||||
geometry = new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(components)]);
|
||||
} else if (where.length > 0) {
|
||||
if (!this.gmlParser) {
|
||||
this.gmlParser = new OpenLayers.Format.GML({'xy': this.xy});
|
||||
}
|
||||
var feature = this.gmlParser.parseFeature(where[0]);
|
||||
geometry = feature.geometry;
|
||||
}
|
||||
return geometry;
|
||||
},
|
||||
@@ -139,6 +167,7 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
*/
|
||||
createFeatureFromItem: function(item) {
|
||||
var geometry = this.createGeometryFromItem(item);
|
||||
|
||||
/* Provide defaults for title and description */
|
||||
var title = this.getChildValue(item, "*", "title", this.featureTitle);
|
||||
|
||||
@@ -340,7 +369,7 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
|
||||
}
|
||||
path = parts.join(" ");
|
||||
} else {
|
||||
path = geometry.y + " " + geometry.x;
|
||||
path = geometry.y + " " + geometry.x;
|
||||
}
|
||||
return this.createTextNode(path);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user