Add support for georss:box parsing, and parsing of summary as fallback for

'content'.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@9049 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-03-14 17:05:38 +00:00
parent 13833e0a67
commit 2a8015775b
2 changed files with 38 additions and 2 deletions

View File

@@ -110,6 +110,10 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
var where = this.getElementsByTagNameNS(item,
this.georssns,
"where");
var box = this.getElementsByTagNameNS(item,
this.georssns,
"box");
if (point.length > 0 || (lat.length > 0 && lon.length > 0)) {
var location;
if (point.length > 0) {
@@ -153,6 +157,28 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
}
var feature = this.gmlParser.parseFeature(where[0]);
geometry = feature.geometry;
} else if (box.length > 0) {
var coords = OpenLayers.String.trim(box[0].firstChild.nodeValue).split(/\s+/);
var components = [];
var point;
if (coords.length > 3) {
point = new OpenLayers.Geometry.Point(parseFloat(coords[1]),
parseFloat(coords[0]));
components.push(point);
point = new OpenLayers.Geometry.Point(parseFloat(coords[1]),
parseFloat(coords[2]));
components.push(point);
point = new OpenLayers.Geometry.Point(parseFloat(coords[3]),
parseFloat(coords[2]));
components.push(point);
point = new OpenLayers.Geometry.Point(parseFloat(coords[3]),
parseFloat(coords[0]));
components.push(point);
point = new OpenLayers.Geometry.Point(parseFloat(coords[1]),
parseFloat(coords[0]));
components.push(point);
}
geometry = new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(components)]);
}
if (geometry && this.internalProjection && this.externalProjection) {
@@ -182,8 +208,8 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
/* First try RSS descriptions, then Atom summaries */
var description = this.getChildValue(
item, "*", "description",
this.getChildValue(item, "*", "content", this.featureDescription)
);
this.getChildValue(item, "*", "content",
this.getChildValue(item, "*", "summary", this.featureDescription)));
/* If no link URL is found in the first child node, try the
href attribute */