diff --git a/lib/OpenLayers/Feature/MetaCarta.js b/lib/OpenLayers/Feature/MetaCarta.js new file mode 100644 index 0000000000..dcfdfba0a7 --- /dev/null +++ b/lib/OpenLayers/Feature/MetaCarta.js @@ -0,0 +1,222 @@ + + +/** Parse a feature from an XML node +* MC specific at the moment +*/ +OpenLayers.Feature.MetaCarta = Class.create(); +OpenLayers.Feature.MetaCarta.prototype= { + + // Object + listeners:null, + + // ol.Size + size:null, + + // ol.LatLon + _latlon:null, + + // str + id:"", + fid:null, + srsName:null, + title:null, + location:null, + docurl:null, + extract:null, + geoExtract:null, + relevance:null, + geoRelevance:null, + markerImage:null, + + initialize: function(fNode) { + this.listeners = new Object(); + + var docpt = OpenLayers.getNodes(fNode, "docpoint")[0]; + this.fid = docpt.getAttribute('fid'); + this.id = this.fid; + + var node = OpenLayers.getNodes(docpt, "position")[0]; + node = OpenLayers.getNodes(node, "gml:Point")[0]; + this.srsName = node.getAttribute('srsName'); + var temp = OpenLayers.getTagText(node, "gml:coordinates"); + this._latlon = ol.LatLon.fromString(temp); + + this.title = OpenLayers.getTagText(docpt, "title"); + this.location = OpenLayers.getTagText(docpt, "locationName"); + this.docurl = OpenLayers.getTagText(docpt, "documentUrl"); + this.extract = OpenLayers.getTagText(docpt, "extract"); + this.geoExtract = OpenLayers.getTagText(docpt, "geoextract"); + this.relevance = OpenLayers.getTagText(docpt, "relevance"); + this.geoRelevance = OpenLayers.getTagText(docpt, "georelevance"); + + this.markerImage = OpenLayers.getTagText(docpt, "markerImage"); + this.size = new ol.Size(20, 25); // TODO: Fix this hard coded value. + }, + + destroy: function() { + this.listeners = null; + this.fid = null; + this.id = null; + this.srsName = null; + this._latlon = null; + this.title = null; + this.location = null; + this.docurl = null; + this.extract = null; + this.geoExtract = null; + this.relevance = null; + this.geoRelevance = null; + this.markerImage = null; + this.size = null; + }, + + toString:function() { + var s = this.title + " relevance:" + this.relevance + + " [" + this.geoRelevance + "]"; + s += " Fid [" + this.fid + "] @ " + this._latlon.toString(); + s += " Location [" + this.geoExtract + "]"; + return s; + }, + + /* MARKER DATA INTERFACE FUNCTIONS: + * + * getLatLon(), getImage() + * + */ + + /** + * ret(ol.Point) + */ + getLatLon:function() { return this._latlon.copyOf(); }, + + + /** + * ret(ol.Point) + */ + getImage:function() { return this.markerImage; }, + + + /** html content based on feature information + * + * ret(str): + */ + getContentHTML:function() { + + var contentHTML = ""; + + contentHTML += "
" + + contentHTML += "
" + contentHTML += "" + contentHTML += this.title; + contentHTML += "" + contentHTML += "
" + contentHTML += "
" + + + contentHTML += "" + contentHTML += "Location:"; + contentHTML += this.location; + contentHTML += " (" + this.geoRelevance + ")"; + contentHTML += "" + contentHTML += "
"; + contentHTML += "
" + + contentHTML += "" + contentHTML += "Extract:"; + contentHTML += "" + contentHTML += "
"; + contentHTML += "" + contentHTML += this.extract; + contentHTML += "" + + contentHTML += "
" + + return contentHTML; + }, + + /** html content based on feature information + * + * ret(str): + */ + getDivListHTML:function() { + + var divHTML = ''; + + divHTML += '
'; + divHTML += ''; + divHTML += this.title; + divHTML += '
'; + divHTML += this.extract; + divHTML += '
'; + + return divHTML; + }, + + ///////////////////////////////// + who:function(){return ("Feature.js");} //last + +}; + +/** +* @param {Array} nodes +* @param {str} tagName +* +* @return {Array} +*/ +OpenLayers._getNodes=function(nodes, tagName) { + var retArray = new Array(); + for (var i=0;i 0)) + { + if (!index) { + index=0; + } + if (result[index].childNodes.length > 1) { + return result.childNodes[1].nodeValue; + } + else if (result[index].childNodes.length == 1) { + return result[index].firstChild.nodeValue; + } + } else { + return ""; + } +}; + diff --git a/lib/OpenLayers/Tile/WFS.js b/lib/OpenLayers/Tile/WFS.js index 81b812c870..434035daab 100644 --- a/lib/OpenLayers/Tile/WFS.js +++ b/lib/OpenLayers/Tile/WFS.js @@ -89,7 +89,7 @@ OpenLayers.Tile.WFS.prototype = for (var i=0; i < resultFeatures.length; i++) { //make new Feature - var feature = new ol.Feature(resultFeatures[i]); + var feature = new OpenLayers.Feature(resultFeatures[i]); this.features.append(feature); //make new Icon