[OpenLayers-Commits] r5090 - in sandbox/ominiverdi/openlayers: examples lib/OpenLayers/Control

commits at openlayers.org commits at openlayers.org
Thu Nov 1 12:00:51 EDT 2007


Author: ominiverdi
Date: 2007-11-01 12:00:41 -0400 (Thu, 01 Nov 2007)
New Revision: 5090

Added:
   sandbox/ominiverdi/openlayers/examples/wms_manager_stile.html
   sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/SLDManager.js
Log:
SLD manager, first step

Added: sandbox/ominiverdi/openlayers/examples/wms_manager_stile.html
===================================================================
--- sandbox/ominiverdi/openlayers/examples/wms_manager_stile.html	                        (rev 0)
+++ sandbox/ominiverdi/openlayers/examples/wms_manager_stile.html	2007-11-01 16:00:41 UTC (rev 5090)
@@ -0,0 +1,105 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <style type="text/css">
+        #map {
+            width: 800px;
+            height: 475px;
+            border: 1px solid black;
+        }
+		#queryOut {
+			width:800px;
+          	height: 200px;
+			border: 1px solid black;
+			position:absolute;
+			left:10px;
+			top:500px;
+			overflow:auto;
+		}
+    </style>
+	
+    <script src="../lib/OpenLayers.js"></script>
+	<script src="../lib/OpenLayers/Format/JSON.js"></script>
+	<script src="../lib/OpenLayers/Control/SLDManager.js"></script>
+
+    <script type="text/javascript">
+        <!--
+        
+        var map;
+		var WMSToolbar;
+		var SLDManager;
+
+        function init(){
+			OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";//ominiverdi.org
+			//OpenLayers.ProxyHost="proxy.cgi?url=";//dev.openlayers.org
+           // OpenLayers.ProxyHost="http://www.openlayers.org/proxy/?url=";//www.openlayers.org
+           
+		    map = new OpenLayers.Map( $('map') );
+           
+			var aWMSServers=new Array(
+				['kappu','http://192.168.1.8:8080/geoserver/wms?'],
+				['FAO - GAUL','http://149.139.8.29/cgi-bin/wms.sh'],
+				["OpenLayers WMS-C",  "http://labs.metacarta.com/wms-c/Basic.py?"],
+				['OpenLayers WMS','http://labs.metacarta.com/cgi-bin/mapserv?map=/www/labs/map/vmap0.map'],//content type: application/vnd.ogc.wms_xml
+				['World - NASA Blue Marble Next Generation','http://wms.jpl.nasa.gov/wms.cgi?'],
+				['World - esa','http://mapserv2.esrin.esa.it/cubestor/cubeserv/cubeserv.cgi?'],// no layers shown in list
+				['World - Demis World Map','http://www2.demis.nl/mapserver/Request.asp?'],
+				['Tilecache at OpenPlans','http://sigma.openplans.org/tilecache-1.3/tilecache.py?'],
+				['FAO','http://193.43.36.137/ows/14110'],
+				['NATO','http://geos2.nurc.nato.int/geoserver/wms'],
+				['Kappa','http://149.139.8.29/geoserver/wms?'],
+				//[ 'Mumbay - freemap','http://mumbai.freemap.in/tiles?'],
+				['CubeWerx','http://demo.cubewerx.com/demo/cubeserv/cubeserv.cgi?config=main&'],
+				['QGIS WMS server at ethz.ch','http://karlinapp.ethz.ch/fcgi-bin/qgis_wms_dir/europe/qgis_wms_serv.fcgi?'],
+				['AU - Aims Australia','http://adc.aims.gov.au:9555/atlas/SstWmsServer?'],
+				['BR - Unidades de Conservacao do Brasil (dados preliminares)','http://mapas.mma.gov.br/cgi-bin/mapserv?map=/opt/www/html/webservices/ucs.map&'],
+				['SP - IGN','http://www.idee.es/wms/IDEE-Base/IDEE-Base'],
+				['SP - Catalunya - ICC Web Map Service','http://shagrat.icc.es/lizardtech/iserv/ows?'],
+				['SP - Junta Andalucia','http://www.andaluciajunta.es/IDEAndalucia/IDEAwms/wms/MTA100v?'],
+				['SP - Aragon', 'http://sitar.aragon.es/AragonWMS?'],
+				['SP - Asturias','http://www.cartografia.asturias.es/wmsortofotos/request.asp?'],
+				['SP - Comunidad Valenciana - Conselleria de Territori i Habitatge, GVA - Servici WMS: wms_senderos','http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_senderos?'],
+				//['SP - Comunidad Valenciana ','http://icvmapas.cetesi.gva.es/wms?'],//only spanish projection
+				//['SP - Castilla La Mancha','http://161.67.10.126/cgi-bin/mapserv?map=/usr/local/webmapping/ideclm/mapserver/ideclm.map'],//only spanish projection
+				//['SP - Cantabria','http://www.idee.es/wms/WMS-Cantabria/WMS-Cantabria?'],
+				['SP - Euskadi (Pais Vasco)','http://www1.euskadi.net/servlet/com.esri.wms.Esrimap?ServiceName=GVasco']
+				//['SP - La Rioja','http://wms.larioja.org/request.asp']
+				
+				
+				
+				//['Localhost','http://localhost/cgi-bin/mapserv?map=mapfile/worldata.map']
+				//['OpenPlans WMS','http://sigma.openplans.org:3128/geoserver/wms']
+				
+			);
+
+            map.addControl( new OpenLayers.Control.WMSManager(aWMSServers ) );
+			
+			
+			
+			map.addControl(new OpenLayers.Control.SLDManager($('queryOut')));
+			
+			
+            //map.addControl(new OpenLayers.Control.NavToolbar());
+			var queryTarget = $('queryOut');
+			WMSToolbar = new OpenLayers.Control.WMSToolbar({queryTarget: queryTarget});
+			map.addControl(WMSToolbar);
+			//alert(WMSToolbar.div.id);
+			//WMSToolbar.style.display = "none";
+			map.addControl(new OpenLayers.Control.WMSPermalink());
+			map.addControl(new OpenLayers.Control.WMSExporter());
+			map.addControl(new OpenLayers.Control.WMCExporter());
+			
+			//map.addControl(new OpenLayers.Control.OverviewMap());
+			
+			
+        }
+		
+        
+        // -->
+    </script>
+  </head>
+  <body onload="init()">
+	<div id="map"></div>
+	<div id="queryOut"></div>
+	
+  </body>
+</html>

Added: sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/SLDManager.js
===================================================================
--- sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/SLDManager.js	                        (rev 0)
+++ sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/SLDManager.js	2007-11-01 16:00:41 UTC (rev 5090)
@@ -0,0 +1,317 @@
+/* Copyright (c) 2006-2007 MetaCarta, Inc., published under the BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/release-license.txt 
+ * for the full text of the license. */
+
+/** 
+ * @class
+ *  
+ * @author Lorenzo Becchi (ominiverdi.org)
+ * @projectDescription ticket #687
+ * 
+ * @requires OpenLayers/Control.js
+ * @requires OpenLayers/Format/JSON.js
+ */
+OpenLayers.Control.SLDManager = OpenLayers.Class.create();
+OpenLayers.Control.SLDManager.prototype = 
+  OpenLayers.Class.inherit( OpenLayers.Control, {
+
+    /** @type String */
+    div: null,
+    
+
+  // DOM Elements
+  
+
+	
+ 
+    /**
+    * @constructor
+    */
+    initialize: function(targetObj,options) {
+        OpenLayers.Control.prototype.initialize.apply(this, arguments);
+		OpenLayers.Format.JSON.prototype.initialize.apply(this, [options]);
+		this.div = targetObj;
+		
+    },
+
+    /**
+     *  
+     */    
+    destroy: function() {
+        
+        OpenLayers.Event.stopObservingElement(this.div);
+
+        
+        OpenLayers.Control.prototype.destroy.apply(this, arguments);
+    },
+
+    /**
+    * @returns A reference to the DIV DOMElement containing the switcher tabs
+    * @type DOMElement
+    */  
+    draw: function() {
+        OpenLayers.Control.prototype.draw.apply(this);
+		
+		
+		
+        // create layout divs
+       // this.loadContents();
+
+        // set mode to minimize
+        //this.minimizeControl();
+        //this.showControls();
+		
+        // populate div with current info
+        //this.redraw();    
+		
+		//this.switchPanel();
+		//this.maximizeControl();
+        return this.div;
+    },
+
+    /** user specifies either "base" or "data". we then clear all the 
+     *    corresponding listeners, the div, and reinitialize a new array.
+     * 
+     * @private
+     * 
+     * @param {String} layersType Ei
+     */
+    clearLayersArray: function(layersType) {
+        var layers = this[layersType + "Layers"];
+        if (layers) {
+            for(var i=0; i < layers.length; i++) {
+                var layer = layers[i];
+                OpenLayers.Event.stopObservingElement(layer.inputElem);
+                OpenLayers.Event.stopObservingElement(layer.labelSpan);
+            }
+        }
+        this[layersType + "LayersDiv"].innerHTML = "";
+        this[layersType + "Layers"] = [];
+    },
+
+
+    /** Goes through and takes the current state of the Map and rebuilds the
+     *   control to display that state. Groups base layers into a radio-button
+     *   group and lists each data layer with a checkbox.
+     * 
+     * @returns A reference to the DIV DOMElement containing the control
+     * @type DOMElement
+     */  
+    redraw: function(sldButton) {
+		/*
+		 * sldButton.map = this.map;
+			sldButton.layer = selectedLayer;
+			sldButton.SLDManager = SLDManager;
+		 */
+        //clear out previous layers 
+        sldButton.SLDManager.div.innerHTML = "";
+        
+		var SLDinterface = document.createElement('div');
+		SLDinterface.className = 'SLDinterface';
+		sldButton.SLDManager.div.appendChild(SLDinterface);
+		
+		var SLDmessanger = document.createElement('div');
+		SLDmessanger.className = 'SLDmessanger';
+		SLDmessanger.innerHTML = 'Click on button to retrieve styles';
+        sldButton.SLDManager.div.appendChild(SLDmessanger);
+		
+		var SLDblackboard = document.createElement('div');
+		SLDblackboard.className = 'SLDblackboard';
+		SLDblackboard.innerHTML = 'SLDblackboard';
+        sldButton.SLDManager.div.appendChild(SLDblackboard);
+		
+		var StyleSeeker = document.createElement('button');
+		StyleSeeker.className = 'StyleSeeker';
+		StyleSeeker.innerHTML = 'get Styles';
+		StyleSeeker.SLDManager = SLDManager;
+		StyleSeeker.onclick = function(){this.SLDManager.getStyles()};
+        sldButton.SLDManager.div.appendChild(StyleSeeker);
+		
+		sldButton.SLDManager.SLDmessanger = SLDmessanger;
+		sldButton.SLDManager.SLDblackboard = SLDblackboard;
+		sldButton.SLDManager.map = sldButton.map;
+		sldButton.SLDManager.layer = sldButton.layer;
+		
+		
+        return sldButton.SLDManager.div;
+    },
+
+
+
+
+    
+	
+	 /** 
+     * @private
+     *
+     * @param {Event} evt
+     */
+    getSldservice: function(evt) {
+         this.SLDblackboard.innerHTML ='';
+		 /*
+		 var select = this;
+		 if((select)) var url = select[select.selectedIndex].value;
+		 else url ="";
+		 
+		 if(url.length>0) {
+			 this.baseURL = url;
+		 } else {
+			 alert('no server selected. please select one.');
+			 return;
+		 } 
+	    if (this.baseURL.indexOf('?') == -1)
+	    {
+	        this.baseURL = this.baseURL + '?';
+	    }
+	    else
+	    {
+	        if (this.baseURL.charAt( this.baseURL.length - 1 ) == '&')
+	            this.baseURL = this.baseURL.slice( 0, -1 );
+	    }
+		
+	    this.baseURL = this.baseURL+ "&service=WMS";
+	    this.baseURL = this.baseURL +  "&version=1.1.1";
+	    this.baseURL = this.baseURL + "&request=GetCapabilities";
+	    */
+		
+		this.SLDmessanger.innerHTML = "Loading Layers list... please wait...";
+        //$('SLDManagerOutput').innerHTML = this.baseURL;
+		//alert(this.baseURL);
+		this.baseURL = 'http://192.168.1.8:8080/geoserver/sldservice/'+ this.layer;
+        OpenLayers.loadURL(this.baseURL, null, this, this.parseSldservice);
+    },
+	
+		 /** 
+     * @private
+     *
+     * @param {Event} evt
+     */
+    parseSldservice:  function(ajaxRequest) {
+		var text = ajaxRequest.responseText;
+		
+		var data = OpenLayers.Format.JSON.prototype.read(text);
+		alert(data);
+		console.log(data);
+        return data;
+    },
+	
+	 /**
+     * APIMethod: read
+     * Deserialize an OpenLayers JSON string.
+     *
+     * Parameters:
+     * str - {String} An OLON string
+     * filter - {Function} A function which will be called for every key and
+     *     value at every level of the final result. Each value will be
+     *     replaced by the result of the filter function. This can be used to
+     *     reform generic objects into instances of classes, or to transform
+     *     date strings into Date objects.
+     *     
+     * Returns:
+     * {Object} An object, array, string, or number.
+     */
+    readJSON: function(str, filter) {
+        var data = OpenLayers.Format.JSON.prototype.read(str, filter);
+        var instance = OpenLayers.Class.deserialize(data);
+        return instance;
+    },
+	
+	
+	
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Control.SLDManager"
+});
+
+
+ /** Sarissa derived getText
+     *  
+     * @private
+     *
+     * @param {Node} XML node
+     * @param {int} deep recursion  
+     */
+	OpenLayers.Ajax.getText = function(oNode, deep){
+	    var s = "";
+	    var nodes = oNode.childNodes;
+	    for(var i=0; i < nodes.length; i++){
+	        var node = nodes[i];
+	        var nodeType = node.nodeType;
+	        if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){
+	            s += node.data;
+	        } else if(deep == true
+	                    && (nodeType == Node.ELEMENT_NODE
+	                        || nodeType == Node.DOCUMENT_NODE
+	                        || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){
+	            s += OpenLayers.Ajax.getText.getText(node, true);
+	        };
+	    };
+	    return s;
+	};
+	
+	/** Sarissa derived getParseErrorText
+     *  
+     * @private
+     *
+     * @param {Document} oDoc The target DOM document
+     * @returns The parsing error description of the target Document in
+     *          human readable form (preformated text)
+     */
+	OpenLayers.Ajax.PARSED_OK = "Document contains no parsing errors";
+	OpenLayers.Ajax.PARSED_EMPTY = "Document is empty";
+	OpenLayers.Ajax.PARSED_UNKNOWN_ERROR = "Not well-formed or other error";
+	
+	OpenLayers.Ajax.getParseErrorText = function(oDoc){
+		//this is only the IE version from Sarissa	
+	   var parseErrorText = OpenLayers.Ajax.PARSED_OK;
+        if(oDoc && oDoc.parseError && oDoc.parseError.errorCode && oDoc.parseError.errorCode != 0){
+            parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason + 
+                "\nLocation: " + oDoc.parseError.url + 
+                "\nLine Number " + oDoc.parseError.line + ", Column " + 
+                oDoc.parseError.linepos + 
+                ":\n" + oDoc.parseError.srcText +
+                "\n";
+            for(var i = 0;  i < oDoc.parseError.linepos;i++){
+                parseErrorText += "-";
+            };
+            parseErrorText +=  "^\n";
+        }
+        else if(oDoc.documentElement == null){
+            parseErrorText = OpenLayers.Ajax.PARSED_EMPTY;
+        };
+        return parseErrorText;
+	};
+	
+	/** 
+	 * Sarissa derived Escape
+	 * Escape the given string chacters that correspond to the five predefined XML entities
+	 * @param sXml the string to escape
+	 */
+	OpenLayers.Ajax.escape = function(sXml){
+	    return sXml.replace(/&/g, "&amp;")
+	        .replace(/</g, "&lt;")
+	        .replace(/>/g, "&gt;")
+	        .replace(/"/g, "&quot;")
+	        .replace(/'/g, "&apos;");
+	};
+	/** 
+	 * Sarissa derived Unescape
+	 * Unescape the given string. This turns the occurences of the predefined XML 
+	 * entities to become the characters they represent correspond to the five predefined XML entities
+	 * @param sXml the string to unescape
+	 */
+	OpenLayers.Ajax.unescape = function(sXml){
+	    return sXml.replace(/&apos;/g,"'")
+	        .replace(/&quot;/g,"\"")
+	        .replace(/&gt;/g,">")
+	        .replace(/&lt;/g,"<")
+	        .replace(/&amp;/g,"&");
+	};
+	
+	/** 
+	 * Sarissa node values definition
+	 * 
+	 */
+	if(!window.Node || !Node.ELEMENT_NODE){
+	    Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5,  ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12};
+	};



More information about the Commits mailing list