GeoRSS.js
Summary
No overview generated for 'GeoRSS.js'
mapbuilder.loadScript(baseDir+"/model/ModelBase.js");
function GeoRSS(modelNode, parent) {
ModelBase.apply(this, new Array(modelNode, parent));
this.initItems = function(objRef) {
var items = objRef.doc.selectNodes("rdf:RDF/rss:item");
if( items.length == 0 ) {
items = objRef.doc.selectNodes("atom:feed/atom:entry");
}
for (var i=0; i<items.length; ++i) {
var item = items[i];
item.setAttribute("divid", "RSS_Item_"+mbIds.getId());
}
}
this.getFeatureNodes = function() {
return this.doc.selectNodes(this.nodeSelectXpath);
}
this.getFeatureName = function(featureNode) {
var labelNode = featureNode.selectSingleNode("rss:title");
if( labelNode == null )
labelNode = featureNode.selectSingleNode("atom:title");
return labelNode?getNodeValue(labelNode):mbGetMessage("noRssTitle");
}
this.getFeatureId = function(featureNode) {
var id = featureNode.getAttribute("divid")
if( id )
return id;
return "no_id";
}
this.getFeaturePoint = function(featureNode) {
if (featureNode.selectSingleNode("geo:long")) {
var pointX = getNodeValue(featureNode.selectSingleNode("geo:long"));
var pointY = getNodeValue(featureNode.selectSingleNode("geo:lat"));
return new Array(pointX, pointY);
} else {
var pos = featureNode.selectSingleNode("georss:where/gml:Point/gml:pos")
if( pos != null ) {
var coordstr = getNodeValue(pos);
var coords = coordstr.split(" ")
var pointX = coords[0]
var pointY = coords[1]
return new Array(pointX, pointY);
} else {
return new Array(0,0); //or some other error to return?
}
}
}
this.getFeatureGeometry = function(featureNode) {
if (featureNode.selectSingleNode("geo:long")) {
var pointX = getNodeValue(featureNode.selectSingleNode("geo:long"));
var pointY = getNodeValue(featureNode.selectSingleNode("geo:lat"));
return "POINT " + pointX + "," + pointY;
}
var pos = featureNode.selectSingleNode("georss:where/gml:Point/gml:pos")
if( pos != null ) {
var coordstr = getNodeValue(pos);
return "POINT " + coordstr;
}
var posList = featureNode.selectSingleNode("georss:where/gml:LineString/gml:posList")
if( posList != null ) { //WARNING: could overflow so get all nodes
var children = posList.childNodes;
var count = children.length;
var text="";
for( var i=0; i<count; i++ ) {
text += children[i].nodeValue;
}
return "LINESTRING " + text;
}
var posList = featureNode.selectSingleNode("georss:where/gml:Polygon/gml:exterior/gml:LinearRing")
if( posList != null ) {
var coordstr = getNodeValue(posList);
return "POLYGON " + coordstr;
}
alert(mbGetMessage("invalidGmlGeom"));
return null
}
this.getFeatureGml = function(featureNode) {
var where = featureNode.selectSingleNode("georss:where")
if( where != null ) {
var gml = where.firstChild;
return gml;
} else {
return null;
}
}
this.getFeatureIcon = function( featureNode ) {
if( featureNode == null )
return null;
var icon = featureNode.selectSingleNode("atom:icon");
if (icon != undefined) {
return getNodeValue(icon);
} else {
return null;
}
}
}
Documentation generated by
JSDoc on Sun Apr 27 20:30:54 2008