Fix lots of EOL SSTyle line ending problems.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6131 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
146
doc/Jugl.js
146
doc/Jugl.js
@@ -1,74 +1,74 @@
|
|||||||
/**
|
/**
|
||||||
* Jugl.js -- JavaScript Template Attribute Language
|
* Jugl.js -- JavaScript Template Attribute Language
|
||||||
* This code is not yet licensed for release or distribution.
|
* This code is not yet licensed for release or distribution.
|
||||||
*
|
*
|
||||||
* Copyright 2007 Tim Schaub
|
* Copyright 2007 Tim Schaub
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains portions of OpenLayers.js -- OpenLayers Map Viewer Library
|
* Contains portions of OpenLayers.js -- OpenLayers Map Viewer Library
|
||||||
*
|
*
|
||||||
* Copyright 2005-2006 MetaCarta, Inc., released under a modified BSD license.
|
* Copyright 2005-2006 MetaCarta, Inc., released under a modified BSD license.
|
||||||
* Please see http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
* Please see http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||||
* for the full text of the license.
|
* for the full text of the license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains portions of Prototype.js:
|
* Contains portions of Prototype.js:
|
||||||
*
|
*
|
||||||
* Prototype JavaScript framework, version 1.4.0
|
* Prototype JavaScript framework, version 1.4.0
|
||||||
* (c) 2005 Sam Stephenson <sam@conio.net>
|
* (c) 2005 Sam Stephenson <sam@conio.net>
|
||||||
*
|
*
|
||||||
* Prototype is freely distributable under the terms of an MIT-style license.
|
* Prototype is freely distributable under the terms of an MIT-style license.
|
||||||
* For details, see the Prototype web site: http://prototype.conio.net/
|
* For details, see the Prototype web site: http://prototype.conio.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl={singleFile:true};window[uri]=Jugl;})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var singleFile=(typeof window[uri]=="object"&&window[uri].singleFile);var Jugl={prefix:"jugl",namespaceURI:"http://namespace.jugl.org/",scriptName:(!singleFile)?"lib/Jugl.js":"Jugl.js",getScriptLocation:function(){var scriptLocation="";var scriptName=Jugl.scriptName;var scripts=document.getElementsByTagName('script');for(var i=0;i<scripts.length;i++){var src=scripts[i].getAttribute('src');if(src){var index=src.lastIndexOf(scriptName);if((index>-1)&&(index+scriptName.length==src.length)){scriptLocation=src.slice(0,-scriptName.length);break;}}}
|
(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl={singleFile:true};window[uri]=Jugl;})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var singleFile=(typeof window[uri]=="object"&&window[uri].singleFile);var Jugl={prefix:"jugl",namespaceURI:"http://namespace.jugl.org/",scriptName:(!singleFile)?"lib/Jugl.js":"Jugl.js",getScriptLocation:function(){var scriptLocation="";var scriptName=Jugl.scriptName;var scripts=document.getElementsByTagName('script');for(var i=0;i<scripts.length;i++){var src=scripts[i].getAttribute('src');if(src){var index=src.lastIndexOf(scriptName);if((index>-1)&&(index+scriptName.length==src.length)){scriptLocation=src.slice(0,-scriptName.length);break;}}}
|
||||||
return scriptLocation;}};if(!singleFile){var jsfiles=new Array("Jugl/Util.js","Jugl/Class.js","Jugl/Async.js","Jugl/Node.js","Jugl/Attribute.js","Jugl/Console.js","Jugl/Template.js");var allScriptTags="";var host=Jugl.getScriptLocation()+"lib/";for(var i=0;i<jsfiles.length;i++){if(/MSIE/.test(navigator.userAgent)||/Safari/.test(navigator.userAgent)){var currentScriptTag="<script src='"+host+jsfiles[i]+"'></script>";allScriptTags+=currentScriptTag;}else{var s=document.createElement("script");s.src=host+jsfiles[i];var h=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;h.appendChild(s);}}
|
return scriptLocation;}};if(!singleFile){var jsfiles=new Array("Jugl/Util.js","Jugl/Class.js","Jugl/Async.js","Jugl/Node.js","Jugl/Attribute.js","Jugl/Console.js","Jugl/Template.js");var allScriptTags="";var host=Jugl.getScriptLocation()+"lib/";for(var i=0;i<jsfiles.length;i++){if(/MSIE/.test(navigator.userAgent)||/Safari/.test(navigator.userAgent)){var currentScriptTag="<script src='"+host+jsfiles[i]+"'></script>";allScriptTags+=currentScriptTag;}else{var s=document.createElement("script");s.src=host+jsfiles[i];var h=document.getElementsByTagName("head").length?document.getElementsByTagName("head")[0]:document.body;h.appendChild(s);}}
|
||||||
if(allScriptTags){document.write(allScriptTags);}}
|
if(allScriptTags){document.write(allScriptTags);}}
|
||||||
window[uri]=Jugl;})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Class=function(){var Class=function(){this.initialize.apply(this,arguments);}
|
window[uri]=Jugl;})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Class=function(){var Class=function(){this.initialize.apply(this,arguments);}
|
||||||
var extended={};var parent;for(var i=0;i<arguments.length;++i){if(typeof arguments[i]=="function"){parent=arguments[i].prototype;}else{parent=arguments[i];}
|
var extended={};var parent;for(var i=0;i<arguments.length;++i){if(typeof arguments[i]=="function"){parent=arguments[i].prototype;}else{parent=arguments[i];}
|
||||||
Jugl.Util.extend(extended,parent);}
|
Jugl.Util.extend(extended,parent);}
|
||||||
Class.prototype=extended;return Class;};})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Util=new Object();Jugl.Util.extend=function(destination,source){for(property in source){destination[property]=source[property];}
|
Class.prototype=extended;return Class;};})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Util=new Object();Jugl.Util.extend=function(destination,source){for(property in source){destination[property]=source[property];}
|
||||||
return destination;};Jugl.Util.indexOf=function(array,obj){for(var i=0;i<array.length;i++){if(array[i]==obj)return i;}
|
return destination;};Jugl.Util.indexOf=function(array,obj){for(var i=0;i<array.length;i++){if(array[i]==obj)return i;}
|
||||||
return-1;};Jugl.Util.bind=function(method,object){var args=[];for(var i=2;i<arguments.length;++i){args.push(arguments[i]);}
|
return-1;};Jugl.Util.bind=function(method,object){var args=[];for(var i=2;i<arguments.length;++i){args.push(arguments[i]);}
|
||||||
return function(){for(var i=0;i<arguments.length;++i){args.push(arguments[i]);}
|
return function(){for(var i=0;i<arguments.length;++i){args.push(arguments[i]);}
|
||||||
return method.apply(object,args);}};})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){},assert:function(){},dir:function(){},dirxml:function(){},trace:function(){},group:function(){},groupEnd:function(){},time:function(){},timeEnd:function(){},profile:function(){},profileEnd:function(){},count:function(){}};(function(){if(window.console){var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;++i){if(scripts[i].src.indexOf("firebug.js")!=-1){Jugl.Util.extend(Jugl.Console,console);break;}}}})();})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Attribute=Jugl.Class({node:null,element:null,type:null,nodeValue:null,template:null,initialize:function(node,element,type){this.node=node;this.element=element;this.type=type;this.nodeValue=element.nodeValue;this.nodeName=element.nodeName;this.template=node.template;},splitAttributeValue:function(value){value=(value!=null)?value:this.nodeValue;var matches=this.template.regExes.trimSpace.exec(value);var items;if(matches.length==3){items=[matches[1],matches[2]];}
|
return method.apply(object,args);}};})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){},assert:function(){},dir:function(){},dirxml:function(){},trace:function(){},group:function(){},groupEnd:function(){},time:function(){},timeEnd:function(){},profile:function(){},profileEnd:function(){},count:function(){}};(function(){if(window.console){var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;++i){if(scripts[i].src.indexOf("firebug.js")!=-1){Jugl.Util.extend(Jugl.Console,console);break;}}}})();})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Attribute=Jugl.Class({node:null,element:null,type:null,nodeValue:null,template:null,initialize:function(node,element,type){this.node=node;this.element=element;this.type=type;this.nodeValue=element.nodeValue;this.nodeName=element.nodeName;this.template=node.template;},splitAttributeValue:function(value){value=(value!=null)?value:this.nodeValue;var matches=this.template.regExes.trimSpace.exec(value);var items;if(matches.length==3){items=[matches[1],matches[2]];}
|
||||||
return items;},getAttributeValues:function(){var trimmed=this.nodeValue.replace(/[\t\n]/g,"").replace(/;\s*$/,"");var tabbed=trimmed.replace(/;;/g,"\t");var newlined=tabbed.split(";").join("\n");return newlined.replace(/\t/g,";").split(/\n/g);},removeSelf:function(){this.node.removeAttributeNode(this);},process:function(){return this.processAttribute[this.type].apply(this,[]);},evalInScope:function(str){var expression="with(this.node.scope){"+str+"}";return eval(expression);},processAttribute:{"define":function(){var values=this.getAttributeValues();var pair;for(var i=0;i<values.length;++i){pair=this.splitAttributeValue(values[i]);this.node.scope[pair[0]]=this.evalInScope(pair[1]);}
|
return items;},getAttributeValues:function(){var trimmed=this.nodeValue.replace(/[\t\n]/g,"").replace(/;\s*$/,"");var tabbed=trimmed.replace(/;;/g,"\t");var newlined=tabbed.split(";").join("\n");return newlined.replace(/\t/g,";").split(/\n/g);},removeSelf:function(){this.node.removeAttributeNode(this);},process:function(){return this.processAttribute[this.type].apply(this,[]);},evalInScope:function(str){var expression="with(this.node.scope){"+str+"}";return eval(expression);},processAttribute:{"define":function(){var values=this.getAttributeValues();var pair;for(var i=0;i<values.length;++i){pair=this.splitAttributeValue(values[i]);this.node.scope[pair[0]]=this.evalInScope(pair[1]);}
|
||||||
this.removeSelf();return true;},"condition":function(){var proceed;try{proceed=!!(this.evalInScope(this.nodeValue));}catch(err){var message=err.name+": "+err.message+"\n";message+="attribute: "+this.nodeName;Jugl.Console.error(message);Jugl.Console.dirxml(this.node.element);Jugl.Console.log(this.node.scope);}
|
this.removeSelf();return true;},"condition":function(){var proceed;try{proceed=!!(this.evalInScope(this.nodeValue));}catch(err){var message=err.name+": "+err.message+"\n";message+="attribute: "+this.nodeName;Jugl.Console.error(message);Jugl.Console.dirxml(this.node.element);Jugl.Console.log(this.node.scope);}
|
||||||
this.removeSelf();if(!proceed){this.node.removeSelf();}
|
this.removeSelf();if(!proceed){this.node.removeSelf();}
|
||||||
return proceed;},"repeat":function(){var pair=this.splitAttributeValue();var key=pair[0];var list=this.evalInScope(pair[1]);this.removeSelf();if(!(list instanceof Array)){var items=new Array();for(var p in list){items.push(p);}
|
return proceed;},"repeat":function(){var pair=this.splitAttributeValue();var key=pair[0];var list=this.evalInScope(pair[1]);this.removeSelf();if(!(list instanceof Array)){var items=new Array();for(var p in list){items.push(p);}
|
||||||
list=items;}
|
list=items;}
|
||||||
var node;var previousSibling=this.node;var length=list.length;for(var i=0;i<length;++i){node=this.node.clone();node.scope[key]=list[i];node.scope.repeat[key]={index:i,number:i+1,even:!(i%2),odd:!!(i%2),start:(i==0),end:(i==length-1),length:length};previousSibling.insertAfter(node);node.process();previousSibling=node;}
|
var node;var previousSibling=this.node;var length=list.length;for(var i=0;i<length;++i){node=this.node.clone();node.scope[key]=list[i];node.scope.repeat[key]={index:i,number:i+1,even:!(i%2),odd:!!(i%2),start:(i==0),end:(i==length-1),length:length};previousSibling.insertAfter(node);node.process();previousSibling=node;}
|
||||||
this.node.removeSelf();return false;},"content":function(){var str;try{str=this.evalInScope(this.nodeValue);}catch(err){Jugl.Console.error("Failed to eval in node scope: "+
|
this.node.removeSelf();return false;},"content":function(){var str;try{str=this.evalInScope(this.nodeValue);}catch(err){Jugl.Console.error("Failed to eval in node scope: "+
|
||||||
this.nodeValue);throw err;}
|
this.nodeValue);throw err;}
|
||||||
this.removeSelf();var child=new Jugl.Node(this.template,document.createTextNode(str));this.node.removeChildNodes();this.node.appendChild(child);return true;},"replace":function(){var str;try{str=this.evalInScope(this.nodeValue);}catch(err){Jugl.Console.error("Failed to eval in node scope: "+
|
this.removeSelf();var child=new Jugl.Node(this.template,document.createTextNode(str));this.node.removeChildNodes();this.node.appendChild(child);return true;},"replace":function(){var str;try{str=this.evalInScope(this.nodeValue);}catch(err){Jugl.Console.error("Failed to eval in node scope: "+
|
||||||
this.nodeValue);throw err;}
|
this.nodeValue);throw err;}
|
||||||
this.removeSelf();var replacement=new Jugl.Node(this.template,document.createTextNode(str));this.node.insertBefore(replacement);this.node.removeSelf();return true;},"attributes":function(){var values=this.getAttributeValues();var pair,name,value;for(var i=0;i<values.length;++i){pair=this.splitAttributeValue(values[i]);name=pair[0];value=this.evalInScope(pair[1]);if(value!==false){this.node.setAttribute(name,value);}}
|
this.removeSelf();var replacement=new Jugl.Node(this.template,document.createTextNode(str));this.node.insertBefore(replacement);this.node.removeSelf();return true;},"attributes":function(){var values=this.getAttributeValues();var pair,name,value;for(var i=0;i<values.length;++i){pair=this.splitAttributeValue(values[i]);name=pair[0];value=this.evalInScope(pair[1]);if(value!==false){this.node.setAttribute(name,value);}}
|
||||||
this.removeSelf();return true;},"omit-tag":function(){var omit;try{omit=((this.nodeValue=="")||!!(this.evalInScope(this.nodeValue)));}catch(err){Jugl.Console.error("Failed to eval in node scope: "+
|
this.removeSelf();return true;},"omit-tag":function(){var omit;try{omit=((this.nodeValue=="")||!!(this.evalInScope(this.nodeValue)));}catch(err){Jugl.Console.error("Failed to eval in node scope: "+
|
||||||
this.nodeValue);throw err;}
|
this.nodeValue);throw err;}
|
||||||
this.removeSelf();if(omit){var children=this.node.getChildNodes();var child;for(var i=0;i<children.length;++i){this.node.insertBefore(children[i]);}
|
this.removeSelf();if(omit){var children=this.node.getChildNodes();var child;for(var i=0;i<children.length;++i){this.node.insertBefore(children[i]);}
|
||||||
this.node.removeSelf();}}},CLASS_NAME:"Jugl.Attribute"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Template=Jugl.Class({element:null,usingNS:false,xhtmlns:"http://www.w3.org/1999/xhtml",xmldom:null,regExes:null,loaded:false,loading:false,initialize:function(element,options){if(typeof(element)=="string"){element=document.getElementById(element);}
|
this.node.removeSelf();}}},CLASS_NAME:"Jugl.Attribute"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Template=Jugl.Class({element:null,usingNS:false,xhtmlns:"http://www.w3.org/1999/xhtml",xmldom:null,regExes:null,loaded:false,loading:false,initialize:function(element,options){if(typeof(element)=="string"){element=document.getElementById(element);}
|
||||||
if(element){this.element=element;this.loaded=true;}
|
if(element){this.element=element;this.loaded=true;}
|
||||||
this.regExes={trimSpace:(/^\s*(\w+)\s+(.*?)\s*$/)};if(window.ActiveXObject){this.xmldom=new ActiveXObject("Microsoft.XMLDOM");}},process:function(context,clone,toString){if(this.element.getAttributeNodeNS){if(this.element.getAttributeNodeNS(Jugl.xhtmlns,Jugl.prefix)){this.usingNS=true;}}
|
this.regExes={trimSpace:(/^\s*(\w+)\s+(.*?)\s*$/)};if(window.ActiveXObject){this.xmldom=new ActiveXObject("Microsoft.XMLDOM");}},process:function(context,clone,toString){if(this.element.getAttributeNodeNS){if(this.element.getAttributeNodeNS(Jugl.xhtmlns,Jugl.prefix)){this.usingNS=true;}}
|
||||||
var node=new Jugl.Node(this,this.element);if(clone){node=node.clone();}
|
var node=new Jugl.Node(this,this.element);if(clone){node=node.clone();}
|
||||||
if(context){node.scope=context;}
|
if(context){node.scope=context;}
|
||||||
try{node.process();}catch(err){Jugl.Console.error("Failed to process "+
|
try{node.process();}catch(err){Jugl.Console.error("Failed to process "+
|
||||||
this.element+" node");}
|
this.element+" node");}
|
||||||
var data;if(toString){if(node.element.innerHTML){data=node.element.innerHTML;}else{if(this.xmldom){data=node.element.xml;}else{var serializer=new XMLSerializer();data=serializer.serializeToString(node.element);}}}else{data=node.element;}
|
var data;if(toString){if(node.element.innerHTML){data=node.element.innerHTML;}else{if(this.xmldom){data=node.element.xml;}else{var serializer=new XMLSerializer();data=serializer.serializeToString(node.element);}}}else{data=node.element;}
|
||||||
return data;},load:function(url){this.loading=true;var setElement=function(request){var doc=request.responseXML;this.element=doc.documentElement;this.loading=false;this.loaded=true;this.onLoad();}
|
return data;},load:function(url){this.loading=true;var setElement=function(request){var doc=request.responseXML;this.element=doc.documentElement;this.loading=false;this.loaded=true;this.onLoad();}
|
||||||
Jugl.Async.loadUrl(url,setElement,this);},onLoad:function(){},CLASS_NAME:"Jugl.Template"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Node=Jugl.Class({template:null,element:null,scope:null,initialize:function(template,element){this.template=template;this.element=element;this.scope=new Object();this.scope.repeat=new Object();},clone:function(){var element=this.element.cloneNode(true);var node=new Jugl.Node(this.template,element);Jugl.Util.extend(node.scope,this.scope);return node;},getAttribute:function(localName){var element;if(this.element.nodeType==1){if(this.template.usingNS){element=this.element.getAttributeNodeNS(Jugl.namespaceURI,localName);}else{element=this.element.getAttributeNode(Jugl.prefix+":"+
|
Jugl.Async.loadUrl(url,setElement,this);},onLoad:function(){},CLASS_NAME:"Jugl.Template"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Node=Jugl.Class({template:null,element:null,scope:null,initialize:function(template,element){this.template=template;this.element=element;this.scope=new Object();this.scope.repeat=new Object();},clone:function(){var element=this.element.cloneNode(true);var node=new Jugl.Node(this.template,element);Jugl.Util.extend(node.scope,this.scope);return node;},getAttribute:function(localName){var element;if(this.element.nodeType==1){if(this.template.usingNS){element=this.element.getAttributeNodeNS(Jugl.namespaceURI,localName);}else{element=this.element.getAttributeNode(Jugl.prefix+":"+
|
||||||
localName);}
|
localName);}
|
||||||
if(element&&!element.specified){element=false;}}
|
if(element&&!element.specified){element=false;}}
|
||||||
var attribute;if(element){attribute=new Jugl.Attribute(this,element,localName);}else{attribute=element;}
|
var attribute;if(element){attribute=new Jugl.Attribute(this,element,localName);}else{attribute=element;}
|
||||||
return attribute;},setAttribute:function(name,value){this.element.setAttribute(name,value);},removeAttributeNode:function(attribute){this.element.removeAttributeNode(attribute.element);},getChildNodes:function(){var children=[];var node,scope;for(var i=0;i<this.element.childNodes.length;++i){node=new Jugl.Node(this.template,this.element.childNodes[i]);node.scope=Jugl.Util.extend({},this.scope);children.push(node);}
|
return attribute;},setAttribute:function(name,value){this.element.setAttribute(name,value);},removeAttributeNode:function(attribute){this.element.removeAttributeNode(attribute.element);},getChildNodes:function(){var children=[];var node,scope;for(var i=0;i<this.element.childNodes.length;++i){node=new Jugl.Node(this.template,this.element.childNodes[i]);node.scope=Jugl.Util.extend({},this.scope);children.push(node);}
|
||||||
return children;},removeChildNodes:function(){while(this.element.hasChildNodes()){this.element.removeChild(this.element.firstChild);}},removeChild:function(node){this.element.removeChild(node.element);return node;},removeSelf:function(){this.element.parentNode.removeChild(this.element);},appendChild:function(node){this.element.appendChild(node.element);},insertAfter:function(node){var parent=this.element.parentNode;var sibling=this.element.nextSibling;if(sibling){parent.insertBefore(node.element,sibling);}else{parent.appendChild(node.element);}},insertBefore:function(node){var parent=this.element.parentNode;parent.insertBefore(node.element,this.element);},process:function(){var attribute;var keepProcessing=true;var series=["define","condition","repeat"];for(var i=0;i<series.length;++i){attribute=this.getAttribute(series[i]);if(attribute){try{keepProcessing=attribute.process();}catch(err){Jugl.Console.error("Failed to process "+
|
return children;},removeChildNodes:function(){while(this.element.hasChildNodes()){this.element.removeChild(this.element.firstChild);}},removeChild:function(node){this.element.removeChild(node.element);return node;},removeSelf:function(){this.element.parentNode.removeChild(this.element);},appendChild:function(node){this.element.appendChild(node.element);},insertAfter:function(node){var parent=this.element.parentNode;var sibling=this.element.nextSibling;if(sibling){parent.insertBefore(node.element,sibling);}else{parent.appendChild(node.element);}},insertBefore:function(node){var parent=this.element.parentNode;parent.insertBefore(node.element,this.element);},process:function(){var attribute;var keepProcessing=true;var series=["define","condition","repeat"];for(var i=0;i<series.length;++i){attribute=this.getAttribute(series[i]);if(attribute){try{keepProcessing=attribute.process();}catch(err){Jugl.Console.error("Failed to process "+
|
||||||
series[i]+" attribute");throw err;}
|
series[i]+" attribute");throw err;}
|
||||||
if(!keepProcessing){return;}}}
|
if(!keepProcessing){return;}}}
|
||||||
var content=this.getAttribute("content");if(content){try{content.process();}catch(err){Jugl.Console.error("Failed to process content attribute");throw err;}}else{var replace=this.getAttribute("replace");if(replace){try{replace.process();}catch(err){Jugl.Console.error("Failed to process replace attribute");throw err;}}}
|
var content=this.getAttribute("content");if(content){try{content.process();}catch(err){Jugl.Console.error("Failed to process content attribute");throw err;}}else{var replace=this.getAttribute("replace");if(replace){try{replace.process();}catch(err){Jugl.Console.error("Failed to process replace attribute");throw err;}}}
|
||||||
var attributes=this.getAttribute("attributes");if(attributes){try{attributes.process();}catch(err){Jugl.Console.error("Failed to process attributes attribute");throw err;}}
|
var attributes=this.getAttribute("attributes");if(attributes){try{attributes.process();}catch(err){Jugl.Console.error("Failed to process attributes attribute");throw err;}}
|
||||||
if(!content&&!replace){this.processChildNodes();}
|
if(!content&&!replace){this.processChildNodes();}
|
||||||
var omit=this.getAttribute("omit-tag");if(omit){try{omit.process();}catch(err){Jugl.Console.error("Failed to process omit-tag attribute");throw err;}}},processChildNodes:function(){var element,child;var children=this.getChildNodes();for(var i=0;i<children.length;++i){try{children[i].process();}catch(err){Jugl.Console.error("Failed to process "+
|
var omit=this.getAttribute("omit-tag");if(omit){try{omit.process();}catch(err){Jugl.Console.error("Failed to process omit-tag attribute");throw err;}}},processChildNodes:function(){var element,child;var children=this.getChildNodes();for(var i=0;i<children.length;++i){try{children[i].process();}catch(err){Jugl.Console.error("Failed to process "+
|
||||||
children[i]+" node");throw err;}}},CLASS_NAME:"Jugl.Node"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Async={loadTemplate:function(url,onComplete,caller){var createTemplate=function(request){var doc=request.responseXML;var template=new Jugl.Template(doc.documentElement);var complete=Jugl.Util.bind(onComplete,caller);complete(template);}
|
children[i]+" node");throw err;}}},CLASS_NAME:"Jugl.Node"});})();(function(){var uri="http://jugl.tschaub.net/trunk/lib/Jugl.js";var Jugl=window[uri];Jugl.Async={loadTemplate:function(url,onComplete,caller){var createTemplate=function(request){var doc=request.responseXML;var template=new Jugl.Template(doc.documentElement);var complete=Jugl.Util.bind(onComplete,caller);complete(template);}
|
||||||
Jugl.Async.loadUrl(url,createTemplate);},loadUrl:function(url,onComplete,caller){var complete=(caller)?Jugl.Util.bind(onComplete,caller):onComplete;var request=Jugl.Async.createXMLHttpRequest();request.open("GET",url);request.onreadystatechange=function(){if(request.readyState==4){complete(request);}}
|
Jugl.Async.loadUrl(url,createTemplate);},loadUrl:function(url,onComplete,caller){var complete=(caller)?Jugl.Util.bind(onComplete,caller):onComplete;var request=Jugl.Async.createXMLHttpRequest();request.open("GET",url);request.onreadystatechange=function(){if(request.readyState==4){complete(request);}}
|
||||||
request.send(null);},createXMLHttpRequest:function(){if(typeof XMLHttpRequest!="undefined"){return new XMLHttpRequest();}else if(typeof ActiveXObject!="undefined"){return new ActiveXObject("Microsoft.XMLHTTP");}else{throw new Error("XMLHttpRequest not supported");}}};})();
|
request.send(null);},createXMLHttpRequest:function(){if(typeof XMLHttpRequest!="undefined"){return new XMLHttpRequest();}else if(typeof ActiveXObject!="undefined"){return new ActiveXObject("Microsoft.XMLHTTP");}else{throw new Error("XMLHttpRequest not supported");}}};})();
|
||||||
@@ -1,225 +1,225 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>OpenLayers Click Handler Example</title>
|
<title>OpenLayers Click Handler Example</title>
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#map {
|
#map {
|
||||||
width: 340px;
|
width: 340px;
|
||||||
height: 170px;
|
height: 170px;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
}
|
}
|
||||||
#west {
|
#west {
|
||||||
width: 350px;
|
width: 350px;
|
||||||
}
|
}
|
||||||
#east {
|
#east {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 370px;
|
left: 370px;
|
||||||
top: 3em;
|
top: 3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
table td {
|
table td {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
}
|
}
|
||||||
textarea.output {
|
textarea.output {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
width: 250px;
|
width: 250px;
|
||||||
height: 65px;
|
height: 65px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="../lib/Firebug/firebug.js"></script>
|
<script src="../lib/Firebug/firebug.js"></script>
|
||||||
<script src="../lib/OpenLayers.js"></script>
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
|
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
|
||||||
defaultHandlerOptions: {
|
defaultHandlerOptions: {
|
||||||
'single': true,
|
'single': true,
|
||||||
'double': false,
|
'double': false,
|
||||||
'pixelTolerance': 0,
|
'pixelTolerance': 0,
|
||||||
'stopSingle': false,
|
'stopSingle': false,
|
||||||
'stopDouble': false
|
'stopDouble': false
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.handlerOptions = OpenLayers.Util.extend(
|
this.handlerOptions = OpenLayers.Util.extend(
|
||||||
{}, this.defaultHandlerOptions
|
{}, this.defaultHandlerOptions
|
||||||
);
|
);
|
||||||
OpenLayers.Control.prototype.initialize.apply(
|
OpenLayers.Control.prototype.initialize.apply(
|
||||||
this, arguments
|
this, arguments
|
||||||
);
|
);
|
||||||
this.handler = new OpenLayers.Handler.Click(
|
this.handler = new OpenLayers.Handler.Click(
|
||||||
this, {
|
this, {
|
||||||
'click': this.onClick,
|
'click': this.onClick,
|
||||||
'dblclick': this.onDblclick
|
'dblclick': this.onDblclick
|
||||||
}, this.handlerOptions
|
}, this.handlerOptions
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
onClick: function(evt) {
|
onClick: function(evt) {
|
||||||
var output = document.getElementById(this.key + "Output");
|
var output = document.getElementById(this.key + "Output");
|
||||||
var msg = "click " + evt.xy;
|
var msg = "click " + evt.xy;
|
||||||
output.value = output.value + msg + "\r\n";
|
output.value = output.value + msg + "\r\n";
|
||||||
},
|
},
|
||||||
|
|
||||||
onDblclick: function(evt) {
|
onDblclick: function(evt) {
|
||||||
var output = document.getElementById(this.key + "Output");
|
var output = document.getElementById(this.key + "Output");
|
||||||
var msg = "dblclick " + evt.xy;
|
var msg = "dblclick " + evt.xy;
|
||||||
output.value = output.value + msg + "\n";
|
output.value = output.value + msg + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var map, controls;
|
var map, controls;
|
||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
|
|
||||||
map = new OpenLayers.Map('map');
|
map = new OpenLayers.Map('map');
|
||||||
var layer = new OpenLayers.Layer.WMS(
|
var layer = new OpenLayers.Layer.WMS(
|
||||||
"OpenLayers WMS",
|
"OpenLayers WMS",
|
||||||
"http://labs.metacarta.com/wms/vmap0",
|
"http://labs.metacarta.com/wms/vmap0",
|
||||||
{layers: 'basic'}
|
{layers: 'basic'}
|
||||||
);
|
);
|
||||||
map.addLayers([layer]);
|
map.addLayers([layer]);
|
||||||
|
|
||||||
controls = {
|
controls = {
|
||||||
"single": new OpenLayers.Control.Click({
|
"single": new OpenLayers.Control.Click({
|
||||||
hanlerOptions: {
|
hanlerOptions: {
|
||||||
"single": true
|
"single": true
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
"double": new OpenLayers.Control.Click({
|
"double": new OpenLayers.Control.Click({
|
||||||
handlerOptions: {
|
handlerOptions: {
|
||||||
"single": false,
|
"single": false,
|
||||||
"double": true
|
"double": true
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
"both": new OpenLayers.Control.Click({
|
"both": new OpenLayers.Control.Click({
|
||||||
handlerOptions: {
|
handlerOptions: {
|
||||||
"single": true,
|
"single": true,
|
||||||
"double": true
|
"double": true
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
"drag": new OpenLayers.Control.Click({
|
"drag": new OpenLayers.Control.Click({
|
||||||
handlerOptions: {
|
handlerOptions: {
|
||||||
"single": true,
|
"single": true,
|
||||||
"pixelTolerance": null
|
"pixelTolerance": null
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
"stopsingle": new OpenLayers.Control.Click({
|
"stopsingle": new OpenLayers.Control.Click({
|
||||||
handlerOptions: {
|
handlerOptions: {
|
||||||
"single": true,
|
"single": true,
|
||||||
"stopSingle": true
|
"stopSingle": true
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
"stopdouble": new OpenLayers.Control.Click({
|
"stopdouble": new OpenLayers.Control.Click({
|
||||||
handlerOptions: {
|
handlerOptions: {
|
||||||
"single": false,
|
"single": false,
|
||||||
"double": true,
|
"double": true,
|
||||||
"stopDouble": true
|
"stopDouble": true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
var props = document.getElementById("props");
|
var props = document.getElementById("props");
|
||||||
var control;
|
var control;
|
||||||
for(var key in controls) {
|
for(var key in controls) {
|
||||||
control = controls[key];
|
control = controls[key];
|
||||||
// only to route output here
|
// only to route output here
|
||||||
control.key = key;
|
control.key = key;
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
}
|
}
|
||||||
|
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle(key) {
|
function toggle(key) {
|
||||||
var control = controls[key];
|
var control = controls[key];
|
||||||
if(control.active) {
|
if(control.active) {
|
||||||
control.deactivate();
|
control.deactivate();
|
||||||
} else {
|
} else {
|
||||||
control.activate();
|
control.activate();
|
||||||
}
|
}
|
||||||
var status = document.getElementById(key + "Status");
|
var status = document.getElementById(key + "Status");
|
||||||
status.innerHTML = control.active ? "on" : "off";
|
status.innerHTML = control.active ? "on" : "off";
|
||||||
var output = document.getElementById(key + "Output");
|
var output = document.getElementById(key + "Output");
|
||||||
output.value = "";
|
output.value = "";
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="init()">
|
<body onload="init()">
|
||||||
<h1 id="title">Click Handler Example</h1>
|
<h1 id="title">Click Handler Example</h1>
|
||||||
<div id="west">
|
<div id="west">
|
||||||
|
|
||||||
<div id="tags">
|
<div id="tags">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p id="shortdesc">
|
<p id="shortdesc">
|
||||||
This example shows the use of the click handler.
|
This example shows the use of the click handler.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<p>
|
<p>
|
||||||
The click handler can be used to gain more flexibility over handling
|
The click handler can be used to gain more flexibility over handling
|
||||||
click events. The handler can be constructed with options to handle
|
click events. The handler can be constructed with options to handle
|
||||||
only single click events, to handle single and double-click events,
|
only single click events, to handle single and double-click events,
|
||||||
to ignore clicks that include a drag, and to stop propagation of
|
to ignore clicks that include a drag, and to stop propagation of
|
||||||
single and/or double-click events. A single click is a click that
|
single and/or double-click events. A single click is a click that
|
||||||
is not followed by another click for more than 300ms. This delay
|
is not followed by another click for more than 300ms. This delay
|
||||||
is configured with the delay property.
|
is configured with the delay property.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The options to stop single and double clicks have to do with
|
The options to stop single and double clicks have to do with
|
||||||
stopping event propagation on the map events listener queue
|
stopping event propagation on the map events listener queue
|
||||||
(not stopping events from cascading to other elements). The
|
(not stopping events from cascading to other elements). The
|
||||||
ability to stop an event from propagating has to do with the
|
ability to stop an event from propagating has to do with the
|
||||||
order in which listeners are registered. With stopSingle or
|
order in which listeners are registered. With stopSingle or
|
||||||
stopDouble true, a click handler will stop propagation to all
|
stopDouble true, a click handler will stop propagation to all
|
||||||
listeners that were registered (or all handlers that were
|
listeners that were registered (or all handlers that were
|
||||||
activated) before the click handler was activated. So, for
|
activated) before the click handler was activated. So, for
|
||||||
example, activating a click handler with stopDouble true after
|
example, activating a click handler with stopDouble true after
|
||||||
the navigation control is active will stop double-clicks from
|
the navigation control is active will stop double-clicks from
|
||||||
zooming in.
|
zooming in.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="east">
|
<div id="east">
|
||||||
<table>
|
<table>
|
||||||
<caption>Controls with click handlers (toggle on/off to clear output)</caption>
|
<caption>Controls with click handlers (toggle on/off to clear output)</caption>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>single only</td>
|
<td>single only</td>
|
||||||
<td><button id="singleStatus" onclick="toggle('single')">off</button></td>
|
<td><button id="singleStatus" onclick="toggle('single')">off</button></td>
|
||||||
<td><textarea class="output" id="singleOutput"></textarea></td>
|
<td><textarea class="output" id="singleOutput"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>double only</td>
|
<td>double only</td>
|
||||||
<td><button id="doubleStatus" onclick="toggle('double')">off</button></td>
|
<td><button id="doubleStatus" onclick="toggle('double')">off</button></td>
|
||||||
<td><textarea class="output" id="doubleOutput"></textarea></td>
|
<td><textarea class="output" id="doubleOutput"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>both</td>
|
<td>both</td>
|
||||||
<td><button id="bothStatus" onclick="toggle('both')">off</button></td>
|
<td><button id="bothStatus" onclick="toggle('both')">off</button></td>
|
||||||
<td><textarea class="output" id="bothOutput"></textarea></td>
|
<td><textarea class="output" id="bothOutput"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>single with drag</td>
|
<td>single with drag</td>
|
||||||
<td><button id="dragStatus" onclick="toggle('drag')">off</button></td>
|
<td><button id="dragStatus" onclick="toggle('drag')">off</button></td>
|
||||||
<td><textarea class="output" id="dragOutput"></textarea></td>
|
<td><textarea class="output" id="dragOutput"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>single with stop</td>
|
<td>single with stop</td>
|
||||||
<td><button id="stopsingleStatus" onclick="toggle('stopsingle')">off</button></td>
|
<td><button id="stopsingleStatus" onclick="toggle('stopsingle')">off</button></td>
|
||||||
<td><textarea class="output" id="stopsingleOutput"></textarea></td>
|
<td><textarea class="output" id="stopsingleOutput"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>double with stop</td>
|
<td>double with stop</td>
|
||||||
<td><button id="stopdoubleStatus" onclick="toggle('stopdouble')">off</button></td>
|
<td><button id="stopdoubleStatus" onclick="toggle('stopdouble')">off</button></td>
|
||||||
<td><textarea class="output" id="stopdoubleOutput"></textarea></td>
|
<td><textarea class="output" id="stopdoubleOutput"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,105 +1,105 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>Drag Feature Example</title>
|
<title>Drag Feature Example</title>
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#map {
|
#map {
|
||||||
width: 512px;
|
width: 512px;
|
||||||
height: 512px;
|
height: 512px;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
}
|
}
|
||||||
#controls {
|
#controls {
|
||||||
width: 512px;
|
width: 512px;
|
||||||
}
|
}
|
||||||
#controlToggle {
|
#controlToggle {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
#controlToggle li {
|
#controlToggle li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="../lib/OpenLayers.js"></script>
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var map, vectors, controls;
|
var map, vectors, controls;
|
||||||
function init(){
|
function init(){
|
||||||
map = new OpenLayers.Map('map');
|
map = new OpenLayers.Map('map');
|
||||||
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
||||||
|
|
||||||
vectors = new OpenLayers.Layer.Vector("Vector Layer");
|
vectors = new OpenLayers.Layer.Vector("Vector Layer");
|
||||||
|
|
||||||
map.addLayers([wms, vectors]);
|
map.addLayers([wms, vectors]);
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
map.addControl(new OpenLayers.Control.MousePosition());
|
map.addControl(new OpenLayers.Control.MousePosition());
|
||||||
|
|
||||||
controls = {
|
controls = {
|
||||||
point: new OpenLayers.Control.DrawFeature(vectors,
|
point: new OpenLayers.Control.DrawFeature(vectors,
|
||||||
OpenLayers.Handler.Point),
|
OpenLayers.Handler.Point),
|
||||||
line: new OpenLayers.Control.DrawFeature(vectors,
|
line: new OpenLayers.Control.DrawFeature(vectors,
|
||||||
OpenLayers.Handler.Path),
|
OpenLayers.Handler.Path),
|
||||||
polygon: new OpenLayers.Control.DrawFeature(vectors,
|
polygon: new OpenLayers.Control.DrawFeature(vectors,
|
||||||
OpenLayers.Handler.Polygon),
|
OpenLayers.Handler.Polygon),
|
||||||
drag: new OpenLayers.Control.DragFeature(vectors)
|
drag: new OpenLayers.Control.DragFeature(vectors)
|
||||||
};
|
};
|
||||||
|
|
||||||
for(var key in controls) {
|
for(var key in controls) {
|
||||||
map.addControl(controls[key]);
|
map.addControl(controls[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
|
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
|
||||||
document.getElementById('noneToggle').checked = true;
|
document.getElementById('noneToggle').checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleControl(element) {
|
function toggleControl(element) {
|
||||||
for(key in controls) {
|
for(key in controls) {
|
||||||
var control = controls[key];
|
var control = controls[key];
|
||||||
if(element.value == key && element.checked) {
|
if(element.value == key && element.checked) {
|
||||||
control.activate();
|
control.activate();
|
||||||
} else {
|
} else {
|
||||||
control.deactivate();
|
control.deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="init()">
|
<body onload="init()">
|
||||||
<h1 id="title">Drag Feature Example</h1>
|
<h1 id="title">Drag Feature Example</h1>
|
||||||
|
|
||||||
<div id="tags"></div>
|
<div id="tags"></div>
|
||||||
|
|
||||||
<p id="shortdesc">
|
<p id="shortdesc">
|
||||||
Demonstrates point, line and polygon creation and editing.
|
Demonstrates point, line and polygon creation and editing.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
|
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<ul id="controlToggle">
|
<ul id="controlToggle">
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="none" id="noneToggle"
|
<input type="radio" name="type" value="none" id="noneToggle"
|
||||||
onclick="toggleControl(this);" checked="checked" />
|
onclick="toggleControl(this);" checked="checked" />
|
||||||
<label for="noneToggle">navigate</label>
|
<label for="noneToggle">navigate</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="point" id="pointToggle" onclick="toggleControl(this);" />
|
<input type="radio" name="type" value="point" id="pointToggle" onclick="toggleControl(this);" />
|
||||||
<label for="pointToggle">draw point</label>
|
<label for="pointToggle">draw point</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
|
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
|
||||||
<label for="lineToggle">draw line</label>
|
<label for="lineToggle">draw line</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="polygon" id="polygonToggle" onclick="toggleControl(this);" />
|
<input type="radio" name="type" value="polygon" id="polygonToggle" onclick="toggleControl(this);" />
|
||||||
<label for="polygonToggle">draw polygon</label>
|
<label for="polygonToggle">draw polygon</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="drag" id="dragToggle"
|
<input type="radio" name="type" value="drag" id="dragToggle"
|
||||||
onclick="toggleControl(this);" />
|
onclick="toggleControl(this);" />
|
||||||
<label for="dragToggle">drag feature</label>
|
<label for="dragToggle">drag feature</label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="docs"></div>
|
<div id="docs"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,51 +1,51 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>Full Screen Example 2</title>
|
<title>Full Screen Example 2</title>
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#map {
|
#map {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="../lib/OpenLayers.js"></script>
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var map;
|
var map;
|
||||||
function init(){
|
function init(){
|
||||||
map = new OpenLayers.Map('map');
|
map = new OpenLayers.Map('map');
|
||||||
|
|
||||||
var options = {numZoomLevels: 3};
|
var options = {numZoomLevels: 3};
|
||||||
|
|
||||||
var docImage = new OpenLayers.Layer.Image(
|
var docImage = new OpenLayers.Layer.Image(
|
||||||
'Full Screen',
|
'Full Screen',
|
||||||
'fullscreen.jpg',
|
'fullscreen.jpg',
|
||||||
new OpenLayers.Bounds(-156, -90, 156, 90),
|
new OpenLayers.Bounds(-156, -90, 156, 90),
|
||||||
new OpenLayers.Size(1121, 650),
|
new OpenLayers.Size(1121, 650),
|
||||||
options);
|
options);
|
||||||
|
|
||||||
map.addLayers([docImage]);
|
map.addLayers([docImage]);
|
||||||
// map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
// map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="init()">
|
<body onload="init()">
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
|
|
||||||
<div id="text">
|
<div id="text">
|
||||||
<h1 id="title">Full Screen Example</h1>
|
<h1 id="title">Full Screen Example</h1>
|
||||||
|
|
||||||
<div id="tags"></div>
|
<div id="tags"></div>
|
||||||
|
|
||||||
<p id="shortdesc">
|
<p id="shortdesc">
|
||||||
Demonstrate a map that fill the entire browser window.
|
Demonstrate a map that fill the entire browser window.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="docs">
|
<div id="docs">
|
||||||
This example uses CSS to define the dimensions of the map element in order to fill the screen.
|
This example uses CSS to define the dimensions of the map element in order to fill the screen.
|
||||||
When the user resizes the window, the map size changes correspondingly. No scroll bars!
|
When the user resizes the window, the map size changes correspondingly. No scroll bars!
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,173 +1,173 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>Modify Feature</title>
|
<title>Modify Feature</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#map {
|
#map {
|
||||||
width: 512px;
|
width: 512px;
|
||||||
height: 350px;
|
height: 350px;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
}
|
}
|
||||||
#controls {
|
#controls {
|
||||||
width: 512px;
|
width: 512px;
|
||||||
}
|
}
|
||||||
#controlToggle {
|
#controlToggle {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
#controlToggle li {
|
#controlToggle li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="../lib/Firebug/firebug.js"></script>
|
<script src="../lib/Firebug/firebug.js"></script>
|
||||||
<script src="../lib/OpenLayers.js"></script>
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var map, vectors, controls;
|
var map, vectors, controls;
|
||||||
function init(){
|
function init(){
|
||||||
map = new OpenLayers.Map('map');
|
map = new OpenLayers.Map('map');
|
||||||
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
||||||
OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
|
OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
|
||||||
vectors = new OpenLayers.Layer.Vector("Vector Layer");
|
vectors = new OpenLayers.Layer.Vector("Vector Layer");
|
||||||
|
|
||||||
map.addLayers([wms, vectors]);
|
map.addLayers([wms, vectors]);
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
map.addControl(new OpenLayers.Control.MousePosition());
|
map.addControl(new OpenLayers.Control.MousePosition());
|
||||||
|
|
||||||
var modifyOptions = {
|
var modifyOptions = {
|
||||||
onModificationStart: function(feature) {
|
onModificationStart: function(feature) {
|
||||||
OpenLayers.Console.log("start modifying", feature.id);
|
OpenLayers.Console.log("start modifying", feature.id);
|
||||||
},
|
},
|
||||||
onModification: function(feature) {
|
onModification: function(feature) {
|
||||||
OpenLayers.Console.log("modified", feature.id);
|
OpenLayers.Console.log("modified", feature.id);
|
||||||
},
|
},
|
||||||
onModificationEnd: function(feature) {
|
onModificationEnd: function(feature) {
|
||||||
OpenLayers.Console.log("end modifying", feature.id);
|
OpenLayers.Console.log("end modifying", feature.id);
|
||||||
},
|
},
|
||||||
onDelete: function(feature) {
|
onDelete: function(feature) {
|
||||||
OpenLayers.Console.log("delete", feature.id);
|
OpenLayers.Console.log("delete", feature.id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
controls = {
|
controls = {
|
||||||
point: new OpenLayers.Control.DrawFeature(vectors,
|
point: new OpenLayers.Control.DrawFeature(vectors,
|
||||||
OpenLayers.Handler.Point),
|
OpenLayers.Handler.Point),
|
||||||
line: new OpenLayers.Control.DrawFeature(vectors,
|
line: new OpenLayers.Control.DrawFeature(vectors,
|
||||||
OpenLayers.Handler.Path),
|
OpenLayers.Handler.Path),
|
||||||
polygon: new OpenLayers.Control.DrawFeature(vectors,
|
polygon: new OpenLayers.Control.DrawFeature(vectors,
|
||||||
OpenLayers.Handler.Polygon),
|
OpenLayers.Handler.Polygon),
|
||||||
regular: new OpenLayers.Control.DrawFeature(vectors,
|
regular: new OpenLayers.Control.DrawFeature(vectors,
|
||||||
OpenLayers.Handler.RegularPolygon,
|
OpenLayers.Handler.RegularPolygon,
|
||||||
{handlerOptions: {sides: 5}}),
|
{handlerOptions: {sides: 5}}),
|
||||||
modify: new OpenLayers.Control.ModifyFeature(vectors,
|
modify: new OpenLayers.Control.ModifyFeature(vectors,
|
||||||
modifyOptions)
|
modifyOptions)
|
||||||
};
|
};
|
||||||
|
|
||||||
for(var key in controls) {
|
for(var key in controls) {
|
||||||
map.addControl(controls[key]);
|
map.addControl(controls[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
|
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
|
||||||
document.getElementById('noneToggle').checked = true;
|
document.getElementById('noneToggle').checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
// reset modification mode
|
// reset modification mode
|
||||||
controls.modify.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
|
controls.modify.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
|
||||||
var rotate = document.getElementById("rotate").checked;
|
var rotate = document.getElementById("rotate").checked;
|
||||||
if(rotate) {
|
if(rotate) {
|
||||||
controls.modify.mode |= OpenLayers.Control.ModifyFeature.ROTATE;
|
controls.modify.mode |= OpenLayers.Control.ModifyFeature.ROTATE;
|
||||||
}
|
}
|
||||||
var resize = document.getElementById("resize").checked;
|
var resize = document.getElementById("resize").checked;
|
||||||
if(resize) {
|
if(resize) {
|
||||||
controls.modify.mode |= OpenLayers.Control.ModifyFeature.RESIZE;
|
controls.modify.mode |= OpenLayers.Control.ModifyFeature.RESIZE;
|
||||||
}
|
}
|
||||||
var drag = document.getElementById("drag").checked;
|
var drag = document.getElementById("drag").checked;
|
||||||
if(drag) {
|
if(drag) {
|
||||||
controls.modify.mode |= OpenLayers.Control.ModifyFeature.DRAG;
|
controls.modify.mode |= OpenLayers.Control.ModifyFeature.DRAG;
|
||||||
}
|
}
|
||||||
// disable reshape mode if at least one of modes rotate, resize,
|
// disable reshape mode if at least one of modes rotate, resize,
|
||||||
// drag is enabled
|
// drag is enabled
|
||||||
if (rotate || resize || drag) {
|
if (rotate || resize || drag) {
|
||||||
controls.modify.mode &= ~OpenLayers.Control.ModifyFeature.RESHAPE;
|
controls.modify.mode &= ~OpenLayers.Control.ModifyFeature.RESHAPE;
|
||||||
}
|
}
|
||||||
var sides = parseInt(document.getElementById("sides").value);
|
var sides = parseInt(document.getElementById("sides").value);
|
||||||
sides = Math.max(3, isNaN(sides) ? 0 : sides);
|
sides = Math.max(3, isNaN(sides) ? 0 : sides);
|
||||||
controls.regular.handler.sides = sides;
|
controls.regular.handler.sides = sides;
|
||||||
var irregular = document.getElementById("irregular").checked;
|
var irregular = document.getElementById("irregular").checked;
|
||||||
controls.regular.handler.irregular = irregular;
|
controls.regular.handler.irregular = irregular;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleControl(element) {
|
function toggleControl(element) {
|
||||||
for(key in controls) {
|
for(key in controls) {
|
||||||
var control = controls[key];
|
var control = controls[key];
|
||||||
if(element.value == key && element.checked) {
|
if(element.value == key && element.checked) {
|
||||||
control.activate();
|
control.activate();
|
||||||
} else {
|
} else {
|
||||||
control.deactivate();
|
control.deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="init()">
|
<body onload="init()">
|
||||||
<h3 id="title">OpenLayers Modify Feature Example</h3>
|
<h3 id="title">OpenLayers Modify Feature Example</h3>
|
||||||
<div id="shortdesc">A demonstration of the ModifyFeature control for editing vector features.</div>
|
<div id="shortdesc">A demonstration of the ModifyFeature control for editing vector features.</div>
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<ul id="controlToggle">
|
<ul id="controlToggle">
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="none" id="noneToggle"
|
<input type="radio" name="type" value="none" id="noneToggle"
|
||||||
onclick="toggleControl(this);" checked="checked" />
|
onclick="toggleControl(this);" checked="checked" />
|
||||||
<label for="noneToggle">navigate</label>
|
<label for="noneToggle">navigate</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="point" id="pointToggle" onclick="toggleControl(this);" />
|
<input type="radio" name="type" value="point" id="pointToggle" onclick="toggleControl(this);" />
|
||||||
<label for="pointToggle">draw point</label>
|
<label for="pointToggle">draw point</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
|
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
|
||||||
<label for="lineToggle">draw line</label>
|
<label for="lineToggle">draw line</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="polygon" id="polygonToggle" onclick="toggleControl(this);" />
|
<input type="radio" name="type" value="polygon" id="polygonToggle" onclick="toggleControl(this);" />
|
||||||
<label for="polygonToggle">draw polygon</label>
|
<label for="polygonToggle">draw polygon</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="regular" id="regularToggle" onclick="toggleControl(this);" />
|
<input type="radio" name="type" value="regular" id="regularToggle" onclick="toggleControl(this);" />
|
||||||
<label for="regularToggle">draw regular polygon</label>
|
<label for="regularToggle">draw regular polygon</label>
|
||||||
<label for="sides"> - sides</label>
|
<label for="sides"> - sides</label>
|
||||||
<input id="sides" type="text" size="2" maxlength="2"
|
<input id="sides" type="text" size="2" maxlength="2"
|
||||||
name="sides" value="5" onchange="update()" />
|
name="sides" value="5" onchange="update()" />
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<input id="irregular" type="checkbox"
|
<input id="irregular" type="checkbox"
|
||||||
name="irregular" onchange="update()" />
|
name="irregular" onchange="update()" />
|
||||||
<label for="irregular">irregular</label>
|
<label for="irregular">irregular</label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type" value="modify" id="modifyToggle"
|
<input type="radio" name="type" value="modify" id="modifyToggle"
|
||||||
onclick="toggleControl(this);" />
|
onclick="toggleControl(this);" />
|
||||||
<label for="modifyToggle">modify feature</label>
|
<label for="modifyToggle">modify feature</label>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<input id="rotate" type="checkbox"
|
<input id="rotate" type="checkbox"
|
||||||
name="rotate" onchange="update()" />
|
name="rotate" onchange="update()" />
|
||||||
<label for="rotate">allow rotation</label>
|
<label for="rotate">allow rotation</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input id="resize" type="checkbox"
|
<input id="resize" type="checkbox"
|
||||||
name="resize" onchange="update()" />
|
name="resize" onchange="update()" />
|
||||||
<label for="resize">allow resizing</label>
|
<label for="resize">allow resizing</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input id="drag" type="checkbox"
|
<input id="drag" type="checkbox"
|
||||||
name="drag" onchange="update()" />
|
name="drag" onchange="update()" />
|
||||||
<label for="drag">allow dragging</label>
|
<label for="drag">allow dragging</label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,177 +1,177 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>OpenLayers Regular Polygon Example</title>
|
<title>OpenLayers Regular Polygon Example</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
html, body {
|
html, body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
font: 0.9em Verdana, Arial, sans serif;
|
font: 0.9em Verdana, Arial, sans serif;
|
||||||
}
|
}
|
||||||
input, select, textarea {
|
input, select, textarea {
|
||||||
font: 1em Verdana, Arial, sans serif;
|
font: 1em Verdana, Arial, sans serif;
|
||||||
}
|
}
|
||||||
#map {
|
#map {
|
||||||
width: 512px;
|
width: 512px;
|
||||||
height: 350px;
|
height: 350px;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
}
|
}
|
||||||
p {
|
p {
|
||||||
width: 512px;
|
width: 512px;
|
||||||
}
|
}
|
||||||
#config {
|
#config {
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
width: 512px;
|
width: 512px;
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 8em;
|
height: 8em;
|
||||||
}
|
}
|
||||||
#controls {
|
#controls {
|
||||||
padding-left: 2em;
|
padding-left: 2em;
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
width: 12em;
|
width: 12em;
|
||||||
}
|
}
|
||||||
#controls li {
|
#controls li {
|
||||||
padding-top: 0.5em;
|
padding-top: 0.5em;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
#options {
|
#options {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
top: 0;
|
top: 0;
|
||||||
margin-left: 15em;
|
margin-left: 15em;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="../lib/OpenLayers.js"></script>
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var map, polygonControl;
|
var map, polygonControl;
|
||||||
OpenLayers.Util.onImageLoadErrorColor = "transparent";
|
OpenLayers.Util.onImageLoadErrorColor = "transparent";
|
||||||
function init(){
|
function init(){
|
||||||
map = new OpenLayers.Map('map');
|
map = new OpenLayers.Map('map');
|
||||||
|
|
||||||
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||||
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
|
||||||
|
|
||||||
var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
|
var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
|
||||||
|
|
||||||
map.addLayers([wmsLayer, polygonLayer]);
|
map.addLayers([wmsLayer, polygonLayer]);
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
map.addControl(new OpenLayers.Control.MousePosition());
|
map.addControl(new OpenLayers.Control.MousePosition());
|
||||||
|
|
||||||
polyOptions = {sides: 4};
|
polyOptions = {sides: 4};
|
||||||
polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer,
|
polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer,
|
||||||
OpenLayers.Handler.RegularPolygon,
|
OpenLayers.Handler.RegularPolygon,
|
||||||
{handlerOptions: polyOptions});
|
{handlerOptions: polyOptions});
|
||||||
|
|
||||||
map.addControl(polygonControl);
|
map.addControl(polygonControl);
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
|
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
|
||||||
|
|
||||||
document.getElementById('noneToggle').checked = true;
|
document.getElementById('noneToggle').checked = true;
|
||||||
document.getElementById('irregularToggle').checked = false;
|
document.getElementById('irregularToggle').checked = false;
|
||||||
}
|
}
|
||||||
function setOptions(options) {
|
function setOptions(options) {
|
||||||
polygonControl.handler.setOptions(options);
|
polygonControl.handler.setOptions(options);
|
||||||
}
|
}
|
||||||
function setSize(fraction) {
|
function setSize(fraction) {
|
||||||
var radius = fraction * map.getExtent().getHeight();
|
var radius = fraction * map.getExtent().getHeight();
|
||||||
polygonControl.handler.setOptions({radius: radius,
|
polygonControl.handler.setOptions({radius: radius,
|
||||||
angle: 0});
|
angle: 0});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="init()">
|
<body onload="init()">
|
||||||
<h2 id="title">OpenLayers Regular Polygon Example</h2>
|
<h2 id="title">OpenLayers Regular Polygon Example</h2>
|
||||||
<p id="shortdesc">
|
<p id="shortdesc">
|
||||||
Shows how to use the RegularPolygon handler to draw features with
|
Shows how to use the RegularPolygon handler to draw features with
|
||||||
different numbers of sides.
|
different numbers of sides.
|
||||||
</p>
|
</p>
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<div id="config">
|
<div id="config">
|
||||||
|
|
||||||
<ul id="controls"><b>Map Controls</b>
|
<ul id="controls"><b>Map Controls</b>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type"
|
<input type="radio" name="type"
|
||||||
value="none" id="noneToggle"
|
value="none" id="noneToggle"
|
||||||
onclick="polygonControl.deactivate()"
|
onclick="polygonControl.deactivate()"
|
||||||
checked="checked" />
|
checked="checked" />
|
||||||
<label for="noneToggle">navigate</label>
|
<label for="noneToggle">navigate</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="radio" name="type"
|
<input type="radio" name="type"
|
||||||
value="polygon" id="polygonToggle"
|
value="polygon" id="polygonToggle"
|
||||||
onclick="polygonControl.activate()" />
|
onclick="polygonControl.activate()" />
|
||||||
<label for="polygonToggle">draw polygon</label>
|
<label for="polygonToggle">draw polygon</label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<table id="options">
|
<table id="options">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Draw Option</th>
|
<th>Draw Option</th>
|
||||||
<th>Value</th>
|
<th>Value</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
shape
|
shape
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="sides"
|
<select name="sides"
|
||||||
onchange="setOptions({sides: parseInt(this.value)})">
|
onchange="setOptions({sides: parseInt(this.value)})">
|
||||||
<option value="3">triangle</option>
|
<option value="3">triangle</option>
|
||||||
<option value="4" selected="selected">square</option>
|
<option value="4" selected="selected">square</option>
|
||||||
<option value="5">pentagon</option>
|
<option value="5">pentagon</option>
|
||||||
<option value="6">hexagon</option>
|
<option value="6">hexagon</option>
|
||||||
<option value="40">circle</option>
|
<option value="40">circle</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
snap angle
|
snap angle
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="angle"
|
<select name="angle"
|
||||||
onchange="setOptions({snapAngle: parseFloat(this.value)})">
|
onchange="setOptions({snapAngle: parseFloat(this.value)})">
|
||||||
<option value="" selected="selected">no snap</option>
|
<option value="" selected="selected">no snap</option>
|
||||||
<option value="15">15°</option>
|
<option value="15">15°</option>
|
||||||
<option value="45">45°</option>
|
<option value="45">45°</option>
|
||||||
<option value="90">90°</option>
|
<option value="90">90°</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
size
|
size
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="size"
|
<select name="size"
|
||||||
onchange="setSize(parseFloat(this.value))">
|
onchange="setSize(parseFloat(this.value))">
|
||||||
<option value="" selected="selected">variable</option>
|
<option value="" selected="selected">variable</option>
|
||||||
<option value="0.1">small</option>
|
<option value="0.1">small</option>
|
||||||
<option value="0.2">medium</option>
|
<option value="0.2">medium</option>
|
||||||
<option value="0.4">large</option>
|
<option value="0.4">large</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
irregular
|
irregular
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="irregularToggle" name="irregular"
|
<input id="irregularToggle" name="irregular"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
onchange="setOptions({irregular: this.checked})") />
|
onchange="setOptions({irregular: this.checked})") />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
Regular polygons can be drawn by pointing a DrawFeature control to the
|
Regular polygons can be drawn by pointing a DrawFeature control to the
|
||||||
RegularPolygon handler class. The options above demonstrate how the
|
RegularPolygon handler class. The options above demonstrate how the
|
||||||
handler can be configured. Note if you are in angle snapping mode (if
|
handler can be configured. Note if you are in angle snapping mode (if
|
||||||
the snap angle is non-null) and you hold down the <b>Shift</b> key, you
|
the snap angle is non-null) and you hold down the <b>Shift</b> key, you
|
||||||
will toggle to non-snapping mode.
|
will toggle to non-snapping mode.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The <i>irregular</i> option allows drawing of irregular polygons. With this option, the fixed radius option is ignored.
|
The <i>irregular</i> option allows drawing of irregular polygons. With this option, the fixed radius option is ignored.
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,238 +1,238 @@
|
|||||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the clear BSD license.
|
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the clear BSD license.
|
||||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt
|
* See http://svn.openlayers.org/trunk/openlayers/license.txt
|
||||||
* for the full text of the license. */
|
* for the full text of the license. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Handler.js
|
* @requires OpenLayers/Handler.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class: OpenLayers.Handler.Click
|
* Class: OpenLayers.Handler.Click
|
||||||
* A handler for mouse clicks. The intention of this handler is to give
|
* A handler for mouse clicks. The intention of this handler is to give
|
||||||
* controls more flexibility with handling clicks. Browsers trigger
|
* controls more flexibility with handling clicks. Browsers trigger
|
||||||
* click events twice for a double-click. In addition, the mousedown,
|
* click events twice for a double-click. In addition, the mousedown,
|
||||||
* mousemove, mouseup sequence fires a click event. With this handler,
|
* mousemove, mouseup sequence fires a click event. With this handler,
|
||||||
* controls can decide whether to ignore clicks associated with a double
|
* controls can decide whether to ignore clicks associated with a double
|
||||||
* click. By setting a <pixelTolerance>, controls can also ignore clicks
|
* click. By setting a <pixelTolerance>, controls can also ignore clicks
|
||||||
* that include a drag. Create a new instance with the
|
* that include a drag. Create a new instance with the
|
||||||
* <OpenLayers.Handler.Click> constructor.
|
* <OpenLayers.Handler.Click> constructor.
|
||||||
*
|
*
|
||||||
* Inherits from:
|
* Inherits from:
|
||||||
* - <OpenLayers.Handler>
|
* - <OpenLayers.Handler>
|
||||||
*/
|
*/
|
||||||
OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {
|
OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: delay
|
* APIProperty: delay
|
||||||
* {Number} Number of milliseconds between clicks before the event is
|
* {Number} Number of milliseconds between clicks before the event is
|
||||||
* considered a double-click.
|
* considered a double-click.
|
||||||
*/
|
*/
|
||||||
delay: 300,
|
delay: 300,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: single
|
* APIProperty: single
|
||||||
* {Boolean} Handle single clicks. Default is true. If false, clicks
|
* {Boolean} Handle single clicks. Default is true. If false, clicks
|
||||||
* will not be reported. If true, single-clicks will be reported.
|
* will not be reported. If true, single-clicks will be reported.
|
||||||
*/
|
*/
|
||||||
single: true,
|
single: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: double
|
* APIProperty: double
|
||||||
* {Boolean} Handle double-clicks. Default is false.
|
* {Boolean} Handle double-clicks. Default is false.
|
||||||
*/
|
*/
|
||||||
'double': false,
|
'double': false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: pixelTolerance
|
* APIProperty: pixelTolerance
|
||||||
* {Number} Maximum number of pixels between mouseup and mousedown for an
|
* {Number} Maximum number of pixels between mouseup and mousedown for an
|
||||||
* event to be considered a click. Default is 0. If set to an
|
* event to be considered a click. Default is 0. If set to an
|
||||||
* integer value, clicks with a drag greater than the value will be
|
* integer value, clicks with a drag greater than the value will be
|
||||||
* ignored. This property can only be set when the handler is
|
* ignored. This property can only be set when the handler is
|
||||||
* constructed.
|
* constructed.
|
||||||
*/
|
*/
|
||||||
pixelTolerance: 0,
|
pixelTolerance: 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: stopSingle
|
* APIProperty: stopSingle
|
||||||
* {Boolean} Stop other listeners from being notified of clicks. Default
|
* {Boolean} Stop other listeners from being notified of clicks. Default
|
||||||
* is false. If true, any click listeners registered before this one
|
* is false. If true, any click listeners registered before this one
|
||||||
* will not be notified of *any* click event (associated with double
|
* will not be notified of *any* click event (associated with double
|
||||||
* or single clicks).
|
* or single clicks).
|
||||||
*/
|
*/
|
||||||
stopSingle: false,
|
stopSingle: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: stopDouble
|
* APIProperty: stopDouble
|
||||||
* {Boolean} Stop other listeners from being notified of double-clicks.
|
* {Boolean} Stop other listeners from being notified of double-clicks.
|
||||||
* Default is false. If true, any click listeners registered before
|
* Default is false. If true, any click listeners registered before
|
||||||
* this one will not be notified of *any* double-click events.
|
* this one will not be notified of *any* double-click events.
|
||||||
*
|
*
|
||||||
* The one caveat with stopDouble is that given a map with two click
|
* The one caveat with stopDouble is that given a map with two click
|
||||||
* handlers, one with stopDouble true and the other with stopSingle
|
* handlers, one with stopDouble true and the other with stopSingle
|
||||||
* true, the stopSingle handler should be activated last to get
|
* true, the stopSingle handler should be activated last to get
|
||||||
* uniform cross-browser performance. Since IE triggers one click
|
* uniform cross-browser performance. Since IE triggers one click
|
||||||
* with a dblclick and FF triggers two, if a stopSingle handler is
|
* with a dblclick and FF triggers two, if a stopSingle handler is
|
||||||
* activated first, all it gets in IE is a single click when the
|
* activated first, all it gets in IE is a single click when the
|
||||||
* second handler stops propagation on the dblclick.
|
* second handler stops propagation on the dblclick.
|
||||||
*/
|
*/
|
||||||
stopDouble: false,
|
stopDouble: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: timerId
|
* Property: timerId
|
||||||
* {Number} The id of the timeout waiting to clear the <delayedEvent>.
|
* {Number} The id of the timeout waiting to clear the <delayedEvent>.
|
||||||
*/
|
*/
|
||||||
timerId: null,
|
timerId: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: down
|
* Property: down
|
||||||
* {<OpenLayers.Pixel>} The pixel location of the last mousedown.
|
* {<OpenLayers.Pixel>} The pixel location of the last mousedown.
|
||||||
*/
|
*/
|
||||||
down: null,
|
down: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Handler.Click
|
* Constructor: OpenLayers.Handler.Click
|
||||||
* Create a new click handler.
|
* Create a new click handler.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* control - {<OpenLayers.Control>} The control that is making use of
|
* control - {<OpenLayers.Control>} The control that is making use of
|
||||||
* this handler. If a handler is being used without a control, the
|
* this handler. If a handler is being used without a control, the
|
||||||
* handler's setMap method must be overridden to deal properly with
|
* handler's setMap method must be overridden to deal properly with
|
||||||
* the map.
|
* the map.
|
||||||
* callbacks - {Object} An object with keys corresponding to callbacks
|
* callbacks - {Object} An object with keys corresponding to callbacks
|
||||||
* that will be called by the handler. The callbacks should
|
* that will be called by the handler. The callbacks should
|
||||||
* expect to recieve a single argument, the click event.
|
* expect to recieve a single argument, the click event.
|
||||||
* Callbacks for 'click' and 'dblclick' are supported.
|
* Callbacks for 'click' and 'dblclick' are supported.
|
||||||
* options - {Object} Optional object whose properties will be set on the
|
* options - {Object} Optional object whose properties will be set on the
|
||||||
* handler.
|
* handler.
|
||||||
*/
|
*/
|
||||||
initialize: function(control, callbacks, options) {
|
initialize: function(control, callbacks, options) {
|
||||||
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
|
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
|
||||||
// optionally register for mouseup and mousedown
|
// optionally register for mouseup and mousedown
|
||||||
if(this.pixelTolerance != null) {
|
if(this.pixelTolerance != null) {
|
||||||
this.mousedown = function(evt) {
|
this.mousedown = function(evt) {
|
||||||
this.down = evt.xy;
|
this.down = evt.xy;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: mousedown
|
* Method: mousedown
|
||||||
* Handle mousedown. Only registered as a listener if pixelTolerance is
|
* Handle mousedown. Only registered as a listener if pixelTolerance is
|
||||||
* a non-zero value at construction.
|
* a non-zero value at construction.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Boolean} Continue propagating this event.
|
* {Boolean} Continue propagating this event.
|
||||||
*/
|
*/
|
||||||
mousedown: null,
|
mousedown: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: dblclick
|
* Method: dblclick
|
||||||
* Handle dblclick. For a dblclick, we get two clicks in some browsers
|
* Handle dblclick. For a dblclick, we get two clicks in some browsers
|
||||||
* (FF) and one in others (IE). So we need to always register for
|
* (FF) and one in others (IE). So we need to always register for
|
||||||
* dblclick to properly handle single clicks.
|
* dblclick to properly handle single clicks.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Boolean} Continue propagating this event.
|
* {Boolean} Continue propagating this event.
|
||||||
*/
|
*/
|
||||||
dblclick: function(evt) {
|
dblclick: function(evt) {
|
||||||
if(this.passesTolerance(evt)) {
|
if(this.passesTolerance(evt)) {
|
||||||
if(this["double"]) {
|
if(this["double"]) {
|
||||||
this.callback('dblclick', [evt]);
|
this.callback('dblclick', [evt]);
|
||||||
}
|
}
|
||||||
this.clearTimer();
|
this.clearTimer();
|
||||||
}
|
}
|
||||||
return !this.stopDouble;
|
return !this.stopDouble;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: click
|
* Method: click
|
||||||
* Handle click.
|
* Handle click.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Boolean} Continue propagating this event.
|
* {Boolean} Continue propagating this event.
|
||||||
*/
|
*/
|
||||||
click: function(evt) {
|
click: function(evt) {
|
||||||
if(this.passesTolerance(evt)) {
|
if(this.passesTolerance(evt)) {
|
||||||
if(this.timerId != null) {
|
if(this.timerId != null) {
|
||||||
// already received a click
|
// already received a click
|
||||||
this.clearTimer();
|
this.clearTimer();
|
||||||
} else {
|
} else {
|
||||||
// set the timer, send evt only if single is true
|
// set the timer, send evt only if single is true
|
||||||
var clickEvent = this.single ? evt : null;
|
var clickEvent = this.single ? evt : null;
|
||||||
this.timerId = window.setTimeout(
|
this.timerId = window.setTimeout(
|
||||||
OpenLayers.Function.bind(this.delayedCall, this, clickEvent),
|
OpenLayers.Function.bind(this.delayedCall, this, clickEvent),
|
||||||
this.delay
|
this.delay
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !this.stopSingle;
|
return !this.stopSingle;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: passesTolerance
|
* Method: passesTolerance
|
||||||
* Determine whether the event is within the optional pixel tolerance. Note
|
* Determine whether the event is within the optional pixel tolerance. Note
|
||||||
* that the pixel tolerance check only works if mousedown events get to
|
* that the pixel tolerance check only works if mousedown events get to
|
||||||
* the listeners registered here. If they are stopped by other elements,
|
* the listeners registered here. If they are stopped by other elements,
|
||||||
* the <pixelTolerance> will have no effect here (this method will always
|
* the <pixelTolerance> will have no effect here (this method will always
|
||||||
* return true).
|
* return true).
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Boolean} The click is within the pixel tolerance (if specified).
|
* {Boolean} The click is within the pixel tolerance (if specified).
|
||||||
*/
|
*/
|
||||||
passesTolerance: function(evt) {
|
passesTolerance: function(evt) {
|
||||||
var passes = true;
|
var passes = true;
|
||||||
if(this.pixelTolerance != null && this.down) {
|
if(this.pixelTolerance != null && this.down) {
|
||||||
var dpx = Math.sqrt(
|
var dpx = Math.sqrt(
|
||||||
Math.pow(this.down.x - evt.xy.x, 2) +
|
Math.pow(this.down.x - evt.xy.x, 2) +
|
||||||
Math.pow(this.down.y - evt.xy.y, 2)
|
Math.pow(this.down.y - evt.xy.y, 2)
|
||||||
);
|
);
|
||||||
if(dpx > this.pixelTolerance) {
|
if(dpx > this.pixelTolerance) {
|
||||||
passes = false;
|
passes = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return passes;
|
return passes;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: clearTimer
|
* Method: clearTimer
|
||||||
* Clear the timer and set <timerId> to null.
|
* Clear the timer and set <timerId> to null.
|
||||||
*/
|
*/
|
||||||
clearTimer: function() {
|
clearTimer: function() {
|
||||||
if(this.timerId != null) {
|
if(this.timerId != null) {
|
||||||
window.clearTimeout(this.timerId);
|
window.clearTimeout(this.timerId);
|
||||||
this.timerId = null;
|
this.timerId = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: delayedCall
|
* Method: delayedCall
|
||||||
* Sets <timerId> to null. And optionally triggers the click callback if
|
* Sets <timerId> to null. And optionally triggers the click callback if
|
||||||
* evt is set.
|
* evt is set.
|
||||||
*/
|
*/
|
||||||
delayedCall: function(evt) {
|
delayedCall: function(evt) {
|
||||||
this.timerId = null;
|
this.timerId = null;
|
||||||
if(evt) {
|
if(evt) {
|
||||||
this.callback('click', [evt]);
|
this.callback('click', [evt]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: deactivate
|
* APIMethod: deactivate
|
||||||
* Deactivate the handler.
|
* Deactivate the handler.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Boolean} The handler was successfully deactivated.
|
* {Boolean} The handler was successfully deactivated.
|
||||||
*/
|
*/
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
var deactivated = false;
|
var deactivated = false;
|
||||||
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
|
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
|
||||||
this.clearTimer();
|
this.clearTimer();
|
||||||
this.down = null;
|
this.down = null;
|
||||||
deactivated = true;
|
deactivated = true;
|
||||||
}
|
}
|
||||||
return deactivated;
|
return deactivated;
|
||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Handler.Click"
|
CLASS_NAME: "OpenLayers.Handler.Click"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,393 +1,393 @@
|
|||||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||||
* full text of the license. */
|
* full text of the license. */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Handler/Drag.js
|
* @requires OpenLayers/Handler/Drag.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class: OpenLayers.Handler.RegularPolygon
|
* Class: OpenLayers.Handler.RegularPolygon
|
||||||
* Handler to draw a regular polygon on the map. Polygon is displayed on mouse
|
* Handler to draw a regular polygon on the map. Polygon is displayed on mouse
|
||||||
* down, moves or is modified on mouse move, and is finished on mouse up.
|
* down, moves or is modified on mouse move, and is finished on mouse up.
|
||||||
* The handler triggers callbacks for 'done' and 'cancel'. Create a new
|
* The handler triggers callbacks for 'done' and 'cancel'. Create a new
|
||||||
* instance with the <OpenLayers.Handler.RegularPolygon> constructor.
|
* instance with the <OpenLayers.Handler.RegularPolygon> constructor.
|
||||||
*
|
*
|
||||||
* Inherits from:
|
* Inherits from:
|
||||||
* - <OpenLayers.Handler>
|
* - <OpenLayers.Handler>
|
||||||
*/
|
*/
|
||||||
OpenLayers.Handler.RegularPolygon = OpenLayers.Class(OpenLayers.Handler.Drag, {
|
OpenLayers.Handler.RegularPolygon = OpenLayers.Class(OpenLayers.Handler.Drag, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: sides
|
* APIProperty: sides
|
||||||
* {Integer} Number of sides for the regular polygon. Needs to be greater
|
* {Integer} Number of sides for the regular polygon. Needs to be greater
|
||||||
* than 2. Defaults to 4.
|
* than 2. Defaults to 4.
|
||||||
*/
|
*/
|
||||||
sides: 4,
|
sides: 4,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: radius
|
* APIProperty: radius
|
||||||
* {Float} Optional radius in map units of the regular polygon. If this is
|
* {Float} Optional radius in map units of the regular polygon. If this is
|
||||||
* set to some non-zero value, a polygon with a fixed radius will be
|
* set to some non-zero value, a polygon with a fixed radius will be
|
||||||
* drawn and dragged with mose movements. If this property is not
|
* drawn and dragged with mose movements. If this property is not
|
||||||
* set, dragging changes the radius of the polygon. Set to null by
|
* set, dragging changes the radius of the polygon. Set to null by
|
||||||
* default.
|
* default.
|
||||||
*/
|
*/
|
||||||
radius: null,
|
radius: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: snapAngle
|
* APIProperty: snapAngle
|
||||||
* {Float} If set to a non-zero value, the handler will snap the polygon
|
* {Float} If set to a non-zero value, the handler will snap the polygon
|
||||||
* rotation to multiples of the snapAngle. Value is an angle measured
|
* rotation to multiples of the snapAngle. Value is an angle measured
|
||||||
* in degrees counterclockwise from the positive x-axis.
|
* in degrees counterclockwise from the positive x-axis.
|
||||||
*/
|
*/
|
||||||
snapAngle: null,
|
snapAngle: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: snapToggle
|
* APIProperty: snapToggle
|
||||||
* {String} If set, snapToggle is checked on mouse events and will set
|
* {String} If set, snapToggle is checked on mouse events and will set
|
||||||
* the snap mode to the opposite of what it currently is. To disallow
|
* the snap mode to the opposite of what it currently is. To disallow
|
||||||
* toggling between snap and non-snap mode, set freehandToggle to
|
* toggling between snap and non-snap mode, set freehandToggle to
|
||||||
* null. Acceptable toggle values are 'shiftKey', 'ctrlKey', and
|
* null. Acceptable toggle values are 'shiftKey', 'ctrlKey', and
|
||||||
* 'altKey'. Snap mode is only possible if this.snapAngle is set to a
|
* 'altKey'. Snap mode is only possible if this.snapAngle is set to a
|
||||||
* non-zero value.
|
* non-zero value.
|
||||||
*/
|
*/
|
||||||
snapToggle: 'shiftKey',
|
snapToggle: 'shiftKey',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: persist
|
* APIProperty: persist
|
||||||
* {Boolean} Leave the feature rendered until clear is called. Default
|
* {Boolean} Leave the feature rendered until clear is called. Default
|
||||||
* is false. If set to true, the feature remains rendered until
|
* is false. If set to true, the feature remains rendered until
|
||||||
* clear is called, typically by deactivating the handler or starting
|
* clear is called, typically by deactivating the handler or starting
|
||||||
* another drawing.
|
* another drawing.
|
||||||
*/
|
*/
|
||||||
persist: false,
|
persist: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: irregular
|
* APIProperty: irregular
|
||||||
* {Boolean} Draw an irregular polygon instead of a regular polygon.
|
* {Boolean} Draw an irregular polygon instead of a regular polygon.
|
||||||
* Default is false. If true, the initial mouse down will represent
|
* Default is false. If true, the initial mouse down will represent
|
||||||
* one corner of the polygon bounds and with each mouse movement, the
|
* one corner of the polygon bounds and with each mouse movement, the
|
||||||
* polygon will be stretched so the opposite corner of its bounds
|
* polygon will be stretched so the opposite corner of its bounds
|
||||||
* follows the mouse position. This property takes precedence over
|
* follows the mouse position. This property takes precedence over
|
||||||
* the radius property. If set to true, the radius property will
|
* the radius property. If set to true, the radius property will
|
||||||
* be ignored.
|
* be ignored.
|
||||||
*/
|
*/
|
||||||
irregular: false,
|
irregular: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: angle
|
* Property: angle
|
||||||
* {Float} The angle from the origin (mouse down) to the current mouse
|
* {Float} The angle from the origin (mouse down) to the current mouse
|
||||||
* position, in radians. This is measured counterclockwise from the
|
* position, in radians. This is measured counterclockwise from the
|
||||||
* positive x-axis.
|
* positive x-axis.
|
||||||
*/
|
*/
|
||||||
angle: null,
|
angle: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: fixedRadius
|
* Property: fixedRadius
|
||||||
* {Boolean} The polygon has a fixed radius. True if a radius is set before
|
* {Boolean} The polygon has a fixed radius. True if a radius is set before
|
||||||
* drawing begins. False otherwise.
|
* drawing begins. False otherwise.
|
||||||
*/
|
*/
|
||||||
fixedRadius: false,
|
fixedRadius: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: feature
|
* Property: feature
|
||||||
* {<OpenLayers.Feature.Vector>} The currently drawn polygon feature
|
* {<OpenLayers.Feature.Vector>} The currently drawn polygon feature
|
||||||
*/
|
*/
|
||||||
feature: null,
|
feature: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: layer
|
* Property: layer
|
||||||
* {<OpenLayers.Layer.Vector>} The temporary drawing layer
|
* {<OpenLayers.Layer.Vector>} The temporary drawing layer
|
||||||
*/
|
*/
|
||||||
layer: null,
|
layer: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: origin
|
* Property: origin
|
||||||
* {<OpenLayers.Geometry.Point>} Location of the first mouse down
|
* {<OpenLayers.Geometry.Point>} Location of the first mouse down
|
||||||
*/
|
*/
|
||||||
origin: null,
|
origin: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Handler.RegularPolygon
|
* Constructor: OpenLayers.Handler.RegularPolygon
|
||||||
* Create a new regular polygon handler.
|
* Create a new regular polygon handler.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* control - {<OpenLayers.Control>} The control that owns this handler
|
* control - {<OpenLayers.Control>} The control that owns this handler
|
||||||
* callbacks - {Array} An object with a 'done' property whos value is a
|
* callbacks - {Array} An object with a 'done' property whos value is a
|
||||||
* function to be called when the polygon drawing is finished.
|
* function to be called when the polygon drawing is finished.
|
||||||
* The callback should expect to recieve a single argument,
|
* The callback should expect to recieve a single argument,
|
||||||
* the polygon geometry. If the callbacks object contains a
|
* the polygon geometry. If the callbacks object contains a
|
||||||
* 'cancel' property, this function will be called when the
|
* 'cancel' property, this function will be called when the
|
||||||
* handler is deactivated while drawing. The cancel should
|
* handler is deactivated while drawing. The cancel should
|
||||||
* expect to receive a geometry.
|
* expect to receive a geometry.
|
||||||
* options - {Object} An object with properties to be set on the handler.
|
* options - {Object} An object with properties to be set on the handler.
|
||||||
* If the options.sides property is not specified, the number of sides
|
* If the options.sides property is not specified, the number of sides
|
||||||
* will default to 4.
|
* will default to 4.
|
||||||
*/
|
*/
|
||||||
initialize: function(control, callbacks, options) {
|
initialize: function(control, callbacks, options) {
|
||||||
this.style = OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {});
|
this.style = OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {});
|
||||||
|
|
||||||
OpenLayers.Handler.prototype.initialize.apply(this,
|
OpenLayers.Handler.prototype.initialize.apply(this,
|
||||||
[control, callbacks, options]);
|
[control, callbacks, options]);
|
||||||
this.options = (options) ? options : new Object();
|
this.options = (options) ? options : new Object();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: setOptions
|
* APIMethod: setOptions
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* newOptions - {Object}
|
* newOptions - {Object}
|
||||||
*/
|
*/
|
||||||
setOptions: function (newOptions) {
|
setOptions: function (newOptions) {
|
||||||
OpenLayers.Util.extend(this.options, newOptions);
|
OpenLayers.Util.extend(this.options, newOptions);
|
||||||
OpenLayers.Util.extend(this, newOptions);
|
OpenLayers.Util.extend(this, newOptions);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: activate
|
* APIMethod: activate
|
||||||
* Turn on the handler.
|
* Turn on the handler.
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* {Boolean} The handler was successfully activated
|
* {Boolean} The handler was successfully activated
|
||||||
*/
|
*/
|
||||||
activate: function() {
|
activate: function() {
|
||||||
var activated = false;
|
var activated = false;
|
||||||
if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
|
if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
|
||||||
// create temporary vector layer for rendering geometry sketch
|
// create temporary vector layer for rendering geometry sketch
|
||||||
var options = {displayInLayerSwitcher: false};
|
var options = {displayInLayerSwitcher: false};
|
||||||
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);
|
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);
|
||||||
this.map.addLayer(this.layer);
|
this.map.addLayer(this.layer);
|
||||||
activated = true;
|
activated = true;
|
||||||
}
|
}
|
||||||
return activated;
|
return activated;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: deactivate
|
* APIMethod: deactivate
|
||||||
* Turn off the handler.
|
* Turn off the handler.
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* {Boolean} The handler was successfully deactivated
|
* {Boolean} The handler was successfully deactivated
|
||||||
*/
|
*/
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
var deactivated = false;
|
var deactivated = false;
|
||||||
if(OpenLayers.Handler.Drag.prototype.deactivate.apply(this, arguments)) {
|
if(OpenLayers.Handler.Drag.prototype.deactivate.apply(this, arguments)) {
|
||||||
// call the cancel callback if mid-drawing
|
// call the cancel callback if mid-drawing
|
||||||
if(this.dragging) {
|
if(this.dragging) {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
// If a layer's map property is set to null, it means that that
|
// If a layer's map property is set to null, it means that that
|
||||||
// layer isn't added to the map. Since we ourself added the layer
|
// layer isn't added to the map. Since we ourself added the layer
|
||||||
// to the map in activate(), we can assume that if this.layer.map
|
// to the map in activate(), we can assume that if this.layer.map
|
||||||
// is null it means that the layer has been destroyed (as a result
|
// is null it means that the layer has been destroyed (as a result
|
||||||
// of map.destroy() for example.
|
// of map.destroy() for example.
|
||||||
if (this.layer.map != null) {
|
if (this.layer.map != null) {
|
||||||
this.layer.destroy(false);
|
this.layer.destroy(false);
|
||||||
if (this.feature) {
|
if (this.feature) {
|
||||||
this.feature.destroy();
|
this.feature.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.layer = null;
|
this.layer = null;
|
||||||
this.feature = null;
|
this.feature = null;
|
||||||
deactivated = true;
|
deactivated = true;
|
||||||
}
|
}
|
||||||
return deactivated;
|
return deactivated;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: downFeature
|
* Method: downFeature
|
||||||
* Start drawing a new feature
|
* Start drawing a new feature
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* evt - {Event} The drag start event
|
* evt - {Event} The drag start event
|
||||||
*/
|
*/
|
||||||
down: function(evt) {
|
down: function(evt) {
|
||||||
this.fixedRadius = !!(this.radius);
|
this.fixedRadius = !!(this.radius);
|
||||||
var maploc = this.map.getLonLatFromPixel(evt.xy);
|
var maploc = this.map.getLonLatFromPixel(evt.xy);
|
||||||
this.origin = new OpenLayers.Geometry.Point(maploc.lon, maploc.lat);
|
this.origin = new OpenLayers.Geometry.Point(maploc.lon, maploc.lat);
|
||||||
// create the new polygon
|
// create the new polygon
|
||||||
if(!this.fixedRadius || this.irregular) {
|
if(!this.fixedRadius || this.irregular) {
|
||||||
// smallest radius should not be less one pixel in map units
|
// smallest radius should not be less one pixel in map units
|
||||||
// VML doesn't behave well with smaller
|
// VML doesn't behave well with smaller
|
||||||
this.radius = this.map.getResolution();
|
this.radius = this.map.getResolution();
|
||||||
}
|
}
|
||||||
if(this.persist) {
|
if(this.persist) {
|
||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
this.feature = new OpenLayers.Feature.Vector();
|
this.feature = new OpenLayers.Feature.Vector();
|
||||||
this.createGeometry();
|
this.createGeometry();
|
||||||
this.layer.addFeatures([this.feature], {silent: true});
|
this.layer.addFeatures([this.feature], {silent: true});
|
||||||
this.layer.drawFeature(this.feature, this.style);
|
this.layer.drawFeature(this.feature, this.style);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: move
|
* Method: move
|
||||||
* Respond to drag move events
|
* Respond to drag move events
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* evt - {Evt} The move event
|
* evt - {Evt} The move event
|
||||||
*/
|
*/
|
||||||
move: function(evt) {
|
move: function(evt) {
|
||||||
var maploc = this.map.getLonLatFromPixel(evt.xy);
|
var maploc = this.map.getLonLatFromPixel(evt.xy);
|
||||||
var point = new OpenLayers.Geometry.Point(maploc.lon, maploc.lat);
|
var point = new OpenLayers.Geometry.Point(maploc.lon, maploc.lat);
|
||||||
if(this.irregular) {
|
if(this.irregular) {
|
||||||
var ry = Math.sqrt(2) * Math.abs(point.y - this.origin.y) / 2;
|
var ry = Math.sqrt(2) * Math.abs(point.y - this.origin.y) / 2;
|
||||||
this.radius = Math.max(this.map.getResolution() / 2, ry);
|
this.radius = Math.max(this.map.getResolution() / 2, ry);
|
||||||
} else if(this.fixedRadius) {
|
} else if(this.fixedRadius) {
|
||||||
this.origin = point;
|
this.origin = point;
|
||||||
} else {
|
} else {
|
||||||
this.calculateAngle(point, evt);
|
this.calculateAngle(point, evt);
|
||||||
this.radius = Math.max(this.map.getResolution() / 2,
|
this.radius = Math.max(this.map.getResolution() / 2,
|
||||||
point.distanceTo(this.origin));
|
point.distanceTo(this.origin));
|
||||||
}
|
}
|
||||||
this.modifyGeometry();
|
this.modifyGeometry();
|
||||||
if(this.irregular) {
|
if(this.irregular) {
|
||||||
var dx = point.x - this.origin.x;
|
var dx = point.x - this.origin.x;
|
||||||
var dy = point.y - this.origin.y;
|
var dy = point.y - this.origin.y;
|
||||||
var ratio;
|
var ratio;
|
||||||
if(dy == 0) {
|
if(dy == 0) {
|
||||||
ratio = dx / (this.radius * Math.sqrt(2));
|
ratio = dx / (this.radius * Math.sqrt(2));
|
||||||
} else {
|
} else {
|
||||||
ratio = dx / dy;
|
ratio = dx / dy;
|
||||||
}
|
}
|
||||||
this.feature.geometry.resize(1, this.origin, ratio);
|
this.feature.geometry.resize(1, this.origin, ratio);
|
||||||
this.feature.geometry.move(dx / 2, dy / 2);
|
this.feature.geometry.move(dx / 2, dy / 2);
|
||||||
}
|
}
|
||||||
this.layer.drawFeature(this.feature, this.style);
|
this.layer.drawFeature(this.feature, this.style);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: up
|
* Method: up
|
||||||
* Finish drawing the feature
|
* Finish drawing the feature
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* evt - {Event} The mouse up event
|
* evt - {Event} The mouse up event
|
||||||
*/
|
*/
|
||||||
up: function(evt) {
|
up: function(evt) {
|
||||||
this.finalize();
|
this.finalize();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: out
|
* Method: out
|
||||||
* Finish drawing the feature.
|
* Finish drawing the feature.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* evt - {Event} The mouse out event
|
* evt - {Event} The mouse out event
|
||||||
*/
|
*/
|
||||||
out: function(evt) {
|
out: function(evt) {
|
||||||
this.finalize();
|
this.finalize();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: createGeometry
|
* Method: createGeometry
|
||||||
* Create the new polygon geometry. This is called at the start of the
|
* Create the new polygon geometry. This is called at the start of the
|
||||||
* drag and at any point during the drag if the number of sides
|
* drag and at any point during the drag if the number of sides
|
||||||
* changes.
|
* changes.
|
||||||
*/
|
*/
|
||||||
createGeometry: function() {
|
createGeometry: function() {
|
||||||
this.angle = Math.PI * ((1/this.sides) - (1/2));
|
this.angle = Math.PI * ((1/this.sides) - (1/2));
|
||||||
if(this.snapAngle) {
|
if(this.snapAngle) {
|
||||||
this.angle += this.snapAngle * (Math.PI / 180);
|
this.angle += this.snapAngle * (Math.PI / 180);
|
||||||
}
|
}
|
||||||
this.feature.geometry = OpenLayers.Geometry.Polygon.createRegularPolygon(
|
this.feature.geometry = OpenLayers.Geometry.Polygon.createRegularPolygon(
|
||||||
this.origin, this.radius, this.sides, this.snapAngle
|
this.origin, this.radius, this.sides, this.snapAngle
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: modifyGeometry
|
* Method: modifyGeometry
|
||||||
* Modify the polygon geometry in place.
|
* Modify the polygon geometry in place.
|
||||||
*/
|
*/
|
||||||
modifyGeometry: function() {
|
modifyGeometry: function() {
|
||||||
var angle, dx, dy, point;
|
var angle, dx, dy, point;
|
||||||
var ring = this.feature.geometry.components[0];
|
var ring = this.feature.geometry.components[0];
|
||||||
// if the number of sides ever changes, create a new geometry
|
// if the number of sides ever changes, create a new geometry
|
||||||
if(ring.components.length != (this.sides + 1)) {
|
if(ring.components.length != (this.sides + 1)) {
|
||||||
this.createGeometry();
|
this.createGeometry();
|
||||||
ring = this.feature.geometry.components[0];
|
ring = this.feature.geometry.components[0];
|
||||||
}
|
}
|
||||||
for(var i=0; i<this.sides; ++i) {
|
for(var i=0; i<this.sides; ++i) {
|
||||||
point = ring.components[i];
|
point = ring.components[i];
|
||||||
angle = this.angle + (i * 2 * Math.PI / this.sides);
|
angle = this.angle + (i * 2 * Math.PI / this.sides);
|
||||||
point.x = this.origin.x + (this.radius * Math.cos(angle));
|
point.x = this.origin.x + (this.radius * Math.cos(angle));
|
||||||
point.y = this.origin.y + (this.radius * Math.sin(angle));
|
point.y = this.origin.y + (this.radius * Math.sin(angle));
|
||||||
point.clearBounds();
|
point.clearBounds();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: calculateAngle
|
* Method: calculateAngle
|
||||||
* Calculate the angle based on settings.
|
* Calculate the angle based on settings.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* point - {<OpenLayers.Geometry.Point>}
|
* point - {<OpenLayers.Geometry.Point>}
|
||||||
* evt - {Event}
|
* evt - {Event}
|
||||||
*/
|
*/
|
||||||
calculateAngle: function(point, evt) {
|
calculateAngle: function(point, evt) {
|
||||||
var alpha = Math.atan2(point.y - this.origin.y,
|
var alpha = Math.atan2(point.y - this.origin.y,
|
||||||
point.x - this.origin.x);
|
point.x - this.origin.x);
|
||||||
if(this.snapAngle && (this.snapToggle && !evt[this.snapToggle])) {
|
if(this.snapAngle && (this.snapToggle && !evt[this.snapToggle])) {
|
||||||
var snapAngleRad = (Math.PI / 180) * this.snapAngle;
|
var snapAngleRad = (Math.PI / 180) * this.snapAngle;
|
||||||
this.angle = Math.round(alpha / snapAngleRad) * snapAngleRad;
|
this.angle = Math.round(alpha / snapAngleRad) * snapAngleRad;
|
||||||
} else {
|
} else {
|
||||||
this.angle = alpha;
|
this.angle = alpha;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: cancel
|
* APIMethod: cancel
|
||||||
* Finish the geometry and call the "cancel" callback.
|
* Finish the geometry and call the "cancel" callback.
|
||||||
*/
|
*/
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
// the polygon geometry gets cloned in the callback method
|
// the polygon geometry gets cloned in the callback method
|
||||||
this.callback("cancel", null);
|
this.callback("cancel", null);
|
||||||
this.finalize();
|
this.finalize();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: finalize
|
* Method: finalize
|
||||||
* Finish the geometry and call the "done" callback.
|
* Finish the geometry and call the "done" callback.
|
||||||
*/
|
*/
|
||||||
finalize: function() {
|
finalize: function() {
|
||||||
this.origin = null;
|
this.origin = null;
|
||||||
this.radius = this.options.radius;
|
this.radius = this.options.radius;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: clear
|
* APIMethod: clear
|
||||||
* Clear any rendered features on the temporary layer. This is called
|
* Clear any rendered features on the temporary layer. This is called
|
||||||
* when the handler is deactivated, canceled, or done (unless persist
|
* when the handler is deactivated, canceled, or done (unless persist
|
||||||
* is true).
|
* is true).
|
||||||
*/
|
*/
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.layer.renderer.clear();
|
this.layer.renderer.clear();
|
||||||
this.layer.destroyFeatures();
|
this.layer.destroyFeatures();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: callback
|
* Method: callback
|
||||||
* Trigger the control's named callback with the given arguments
|
* Trigger the control's named callback with the given arguments
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* name - {String} The key for the callback that is one of the properties
|
* name - {String} The key for the callback that is one of the properties
|
||||||
* of the handler's callbacks object.
|
* of the handler's callbacks object.
|
||||||
* args - {Array} An array of arguments with which to call the callback
|
* args - {Array} An array of arguments with which to call the callback
|
||||||
* (defined by the control).
|
* (defined by the control).
|
||||||
*/
|
*/
|
||||||
callback: function (name, args) {
|
callback: function (name, args) {
|
||||||
// override the callback method to always send the polygon geometry
|
// override the callback method to always send the polygon geometry
|
||||||
if (this.callbacks[name]) {
|
if (this.callbacks[name]) {
|
||||||
this.callbacks[name].apply(this.control,
|
this.callbacks[name].apply(this.control,
|
||||||
[this.feature.geometry.clone()]);
|
[this.feature.geometry.clone()]);
|
||||||
}
|
}
|
||||||
// since sketch features are added to the temporary layer
|
// since sketch features are added to the temporary layer
|
||||||
// they must be cleared here if done or cancel
|
// they must be cleared here if done or cancel
|
||||||
if(!this.persist && (name == "done" || name == "cancel")) {
|
if(!this.persist && (name == "done" || name == "cancel")) {
|
||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Handler.RegularPolygon"
|
CLASS_NAME: "OpenLayers.Handler.RegularPolygon"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,141 +1,141 @@
|
|||||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||||
* for the full text of the license. */
|
* for the full text of the license. */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Util.js
|
* @requires OpenLayers/Util.js
|
||||||
* @requires OpenLayers/Style.js
|
* @requires OpenLayers/Style.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class: OpenLayers.Rule
|
* Class: OpenLayers.Rule
|
||||||
* This class represents a OGC Rule, as being used for rule-based SLD styling.
|
* This class represents a OGC Rule, as being used for rule-based SLD styling.
|
||||||
*/
|
*/
|
||||||
OpenLayers.Rule = OpenLayers.Class({
|
OpenLayers.Rule = OpenLayers.Class({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: name
|
* APIProperty: name
|
||||||
* {String} name of this rule
|
* {String} name of this rule
|
||||||
*/
|
*/
|
||||||
name: 'default',
|
name: 'default',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: context
|
* Property: context
|
||||||
* {Object} An optional object with properties that the rule and its
|
* {Object} An optional object with properties that the rule and its
|
||||||
* symbolizers' property values should be evaluatad against. If no
|
* symbolizers' property values should be evaluatad against. If no
|
||||||
* context is specified, feature.attributes will be used
|
* context is specified, feature.attributes will be used
|
||||||
*/
|
*/
|
||||||
context: null,
|
context: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: elseFilter
|
* Property: elseFilter
|
||||||
* {Boolean} Determines whether this rule is only to be applied only if
|
* {Boolean} Determines whether this rule is only to be applied only if
|
||||||
* no other rules match (ElseFilter according to the SLD specification).
|
* no other rules match (ElseFilter according to the SLD specification).
|
||||||
* Default is false. For instances of OpenLayers.Rule, if elseFilter is
|
* Default is false. For instances of OpenLayers.Rule, if elseFilter is
|
||||||
* false, the rule will always apply. For subclasses, the else property is
|
* false, the rule will always apply. For subclasses, the else property is
|
||||||
* ignored.
|
* ignored.
|
||||||
*/
|
*/
|
||||||
elseFilter: false,
|
elseFilter: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: symbolizer
|
* Property: symbolizer
|
||||||
* {Object} Hash of styles for this rule. Contains hashes of feature
|
* {Object} Hash of styles for this rule. Contains hashes of feature
|
||||||
* styles. Keys are one or more of ["Point", "Line", "Polygon"]
|
* styles. Keys are one or more of ["Point", "Line", "Polygon"]
|
||||||
*/
|
*/
|
||||||
symbolizer: null,
|
symbolizer: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: minScaleDenominator
|
* APIProperty: minScaleDenominator
|
||||||
* {Number} or {String} minimum scale at which to draw the feature.
|
* {Number} or {String} minimum scale at which to draw the feature.
|
||||||
* In the case of a String, this can be a combination of text and
|
* In the case of a String, this can be a combination of text and
|
||||||
* propertyNames in the form "literal ${propertyName}"
|
* propertyNames in the form "literal ${propertyName}"
|
||||||
*/
|
*/
|
||||||
minScaleDenominator: null,
|
minScaleDenominator: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: maxScaleDenominator
|
* APIProperty: maxScaleDenominator
|
||||||
* {Number} or {String} maximum scale at which to draw the feature.
|
* {Number} or {String} maximum scale at which to draw the feature.
|
||||||
* In the case of a String, this can be a combination of text and
|
* In the case of a String, this can be a combination of text and
|
||||||
* propertyNames in the form "literal ${propertyName}"
|
* propertyNames in the form "literal ${propertyName}"
|
||||||
*/
|
*/
|
||||||
maxScaleDenominator: null,
|
maxScaleDenominator: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Rule
|
* Constructor: OpenLayers.Rule
|
||||||
* Creates a Rule.
|
* Creates a Rule.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* options - {Object} An optional object with properties to set on the
|
* options - {Object} An optional object with properties to set on the
|
||||||
* rule
|
* rule
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {<OpenLayers.Rule>}
|
* {<OpenLayers.Rule>}
|
||||||
*/
|
*/
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.symbolizer = {};
|
this.symbolizer = {};
|
||||||
|
|
||||||
OpenLayers.Util.extend(this, options);
|
OpenLayers.Util.extend(this, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: destroy
|
* APIMethod: destroy
|
||||||
* nullify references to prevent circular references and memory leaks
|
* nullify references to prevent circular references and memory leaks
|
||||||
*/
|
*/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
for (var i in this.symbolizer) {
|
for (var i in this.symbolizer) {
|
||||||
this.symbolizer[i] = null;
|
this.symbolizer[i] = null;
|
||||||
}
|
}
|
||||||
this.symbolizer = null;
|
this.symbolizer = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: evaluate
|
* APIMethod: evaluate
|
||||||
* evaluates this rule for a specific feature
|
* evaluates this rule for a specific feature
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {boolean} true if the rule applies, false if it does not.
|
* {boolean} true if the rule applies, false if it does not.
|
||||||
* This rule is the default rule and always returns true.
|
* This rule is the default rule and always returns true.
|
||||||
*/
|
*/
|
||||||
evaluate: function(feature) {
|
evaluate: function(feature) {
|
||||||
var context = this.getContext(feature);
|
var context = this.getContext(feature);
|
||||||
var applies = true;
|
var applies = true;
|
||||||
|
|
||||||
if (this.minScaleDenominator || this.maxScaleDenominator) {
|
if (this.minScaleDenominator || this.maxScaleDenominator) {
|
||||||
var scale = feature.layer.map.getScale();
|
var scale = feature.layer.map.getScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if within minScale/maxScale bounds
|
// check if within minScale/maxScale bounds
|
||||||
if (this.minScaleDenominator) {
|
if (this.minScaleDenominator) {
|
||||||
applies = scale >= OpenLayers.Style.createLiteral(
|
applies = scale >= OpenLayers.Style.createLiteral(
|
||||||
this.minScaleDenominator, context);
|
this.minScaleDenominator, context);
|
||||||
}
|
}
|
||||||
if (applies && this.maxScaleDenominator) {
|
if (applies && this.maxScaleDenominator) {
|
||||||
applies = scale < OpenLayers.Style.createLiteral(
|
applies = scale < OpenLayers.Style.createLiteral(
|
||||||
this.maxScaleDenominator, context);
|
this.maxScaleDenominator, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return applies;
|
return applies;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: getContext
|
* Method: getContext
|
||||||
* Gets the context for evaluating this rule
|
* Gets the context for evaluating this rule
|
||||||
*
|
*
|
||||||
* Paramters:
|
* Paramters:
|
||||||
* feature - {<OpenLayers.Feature>} feature to take the context from if
|
* feature - {<OpenLayers.Feature>} feature to take the context from if
|
||||||
* none is specified.
|
* none is specified.
|
||||||
*/
|
*/
|
||||||
getContext: function(feature) {
|
getContext: function(feature) {
|
||||||
var context = this.context;
|
var context = this.context;
|
||||||
if (!context) {
|
if (!context) {
|
||||||
context = feature.attributes || feature.data;
|
context = feature.attributes || feature.data;
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Rule"
|
CLASS_NAME: "OpenLayers.Rule"
|
||||||
});
|
});
|
||||||
@@ -1,206 +1,206 @@
|
|||||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||||
* full text of the license. */
|
* full text of the license. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Rule.js
|
* @requires OpenLayers/Rule.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class: OpenLayers.Rule.Comparison
|
* Class: OpenLayers.Rule.Comparison
|
||||||
* This class represents the comparison rules, as being used for rule-based
|
* This class represents the comparison rules, as being used for rule-based
|
||||||
* SLD styling
|
* SLD styling
|
||||||
*
|
*
|
||||||
* Inherits from
|
* Inherits from
|
||||||
* - <OpenLayers.Rule>
|
* - <OpenLayers.Rule>
|
||||||
*/
|
*/
|
||||||
OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
|
OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: type
|
* APIProperty: type
|
||||||
* {String} type: type of the comparison. This is one of
|
* {String} type: type of the comparison. This is one of
|
||||||
* - OpenLayers.Rule.Comparison.EQUAL_TO = "==";
|
* - OpenLayers.Rule.Comparison.EQUAL_TO = "==";
|
||||||
* - OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
|
* - OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
|
||||||
* - OpenLayers.Rule.Comparison.LESS_THAN = "<";
|
* - OpenLayers.Rule.Comparison.LESS_THAN = "<";
|
||||||
* - OpenLayers.Rule.Comparison.GREATER_THAN = ">";
|
* - OpenLayers.Rule.Comparison.GREATER_THAN = ">";
|
||||||
* - OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
* - OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
||||||
* - OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
* - OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
||||||
* - OpenLayers.Rule.Comparison.BETWEEN = "..";
|
* - OpenLayers.Rule.Comparison.BETWEEN = "..";
|
||||||
* - OpenLayers.Rule.Comparison.LIKE = "~";
|
* - OpenLayers.Rule.Comparison.LIKE = "~";
|
||||||
*/
|
*/
|
||||||
type: null,
|
type: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: property
|
* APIProperty: property
|
||||||
* {String}
|
* {String}
|
||||||
* name of the context property to compare
|
* name of the context property to compare
|
||||||
*/
|
*/
|
||||||
property: null,
|
property: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: value
|
* APIProperty: value
|
||||||
* {Number} or {String}
|
* {Number} or {String}
|
||||||
* comparison value for binary comparisons. In the case of a String, this
|
* comparison value for binary comparisons. In the case of a String, this
|
||||||
* can be a combination of text and propertyNames in the form
|
* can be a combination of text and propertyNames in the form
|
||||||
* "literal ${propertyName}"
|
* "literal ${propertyName}"
|
||||||
*/
|
*/
|
||||||
value: null,
|
value: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: lowerBoundary
|
* APIProperty: lowerBoundary
|
||||||
* {Number} or {String}
|
* {Number} or {String}
|
||||||
* lower boundary for between comparisons. In the case of a String, this
|
* lower boundary for between comparisons. In the case of a String, this
|
||||||
* can be a combination of text and propertyNames in the form
|
* can be a combination of text and propertyNames in the form
|
||||||
* "literal ${propertyName}"
|
* "literal ${propertyName}"
|
||||||
*/
|
*/
|
||||||
lowerBoundary: null,
|
lowerBoundary: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: upperBoundary
|
* APIProperty: upperBoundary
|
||||||
* {Number} or {String}
|
* {Number} or {String}
|
||||||
* upper boundary for between comparisons. In the case of a String, this
|
* upper boundary for between comparisons. In the case of a String, this
|
||||||
* can be a combination of text and propertyNames in the form
|
* can be a combination of text and propertyNames in the form
|
||||||
* "literal ${propertyName}"
|
* "literal ${propertyName}"
|
||||||
*/
|
*/
|
||||||
upperBoundary: null,
|
upperBoundary: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Rule.Comparison
|
* Constructor: OpenLayers.Rule.Comparison
|
||||||
* Creates a comparison rule.
|
* Creates a comparison rule.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* params - {Object} Hash of parameters for this rule:
|
* params - {Object} Hash of parameters for this rule:
|
||||||
* -
|
* -
|
||||||
* - value:
|
* - value:
|
||||||
* options - {Object} An optional object with properties to set on the
|
* options - {Object} An optional object with properties to set on the
|
||||||
* rule
|
* rule
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {<OpenLayers.Rule.Comparison>}
|
* {<OpenLayers.Rule.Comparison>}
|
||||||
*/
|
*/
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: evaluate
|
* APIMethod: evaluate
|
||||||
* evaluates this rule for a specific context
|
* evaluates this rule for a specific context
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* context - {Object} context to apply the rule to.
|
* context - {Object} context to apply the rule to.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {boolean} true if the rule applies, false if it does not
|
* {boolean} true if the rule applies, false if it does not
|
||||||
*/
|
*/
|
||||||
evaluate: function(feature) {
|
evaluate: function(feature) {
|
||||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var context = this.getContext(feature);
|
var context = this.getContext(feature);
|
||||||
switch(this.type) {
|
switch(this.type) {
|
||||||
case OpenLayers.Rule.Comparison.EQUAL_TO:
|
case OpenLayers.Rule.Comparison.EQUAL_TO:
|
||||||
case OpenLayers.Rule.Comparison.LESS_THAN:
|
case OpenLayers.Rule.Comparison.LESS_THAN:
|
||||||
case OpenLayers.Rule.Comparison.GREATER_THAN:
|
case OpenLayers.Rule.Comparison.GREATER_THAN:
|
||||||
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
|
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
|
||||||
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
|
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
|
||||||
return this.binaryCompare(context, this.property, this.value);
|
return this.binaryCompare(context, this.property, this.value);
|
||||||
|
|
||||||
case OpenLayers.Rule.Comparison.BETWEEN:
|
case OpenLayers.Rule.Comparison.BETWEEN:
|
||||||
var result =
|
var result =
|
||||||
context[this.property] > this.lowerBoundary;
|
context[this.property] > this.lowerBoundary;
|
||||||
result = result &&
|
result = result &&
|
||||||
context[this.property] < this.upperBoundary;
|
context[this.property] < this.upperBoundary;
|
||||||
return result;
|
return result;
|
||||||
case OpenLayers.Rule.Comparison.LIKE:
|
case OpenLayers.Rule.Comparison.LIKE:
|
||||||
var regexp = new RegExp(this.value,
|
var regexp = new RegExp(this.value,
|
||||||
"gi");
|
"gi");
|
||||||
return regexp.test(context[this.property]);
|
return regexp.test(context[this.property]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: value2regex
|
* APIMethod: value2regex
|
||||||
* Converts the value of this rule into a regular expression string,
|
* Converts the value of this rule into a regular expression string,
|
||||||
* according to the wildcard characters specified. This method has to
|
* according to the wildcard characters specified. This method has to
|
||||||
* be called after instantiation of this class, if the value is not a
|
* be called after instantiation of this class, if the value is not a
|
||||||
* regular expression already.
|
* regular expression already.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* wildCard - {<Char>} wildcard character in the above value, default
|
* wildCard - {<Char>} wildcard character in the above value, default
|
||||||
* is "*"
|
* is "*"
|
||||||
* singleChar - {<Char>) single-character wildcard in the above value
|
* singleChar - {<Char>) single-character wildcard in the above value
|
||||||
* default is "."
|
* default is "."
|
||||||
* escape - {<Char>) escape character in the above value, default is
|
* escape - {<Char>) escape character in the above value, default is
|
||||||
* "!"
|
* "!"
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {String} regular expression string
|
* {String} regular expression string
|
||||||
*/
|
*/
|
||||||
value2regex: function(wildCard, singleChar, escapeChar) {
|
value2regex: function(wildCard, singleChar, escapeChar) {
|
||||||
if (wildCard == ".") {
|
if (wildCard == ".") {
|
||||||
var msg = "'.' is an unsupported wildCard character for "+
|
var msg = "'.' is an unsupported wildCard character for "+
|
||||||
"OpenLayers.Rule.Comparison";
|
"OpenLayers.Rule.Comparison";
|
||||||
OpenLayers.Console.error(msg);
|
OpenLayers.Console.error(msg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set UMN MapServer defaults for unspecified parameters
|
// set UMN MapServer defaults for unspecified parameters
|
||||||
wildCard = wildCard ? wildCard : "*";
|
wildCard = wildCard ? wildCard : "*";
|
||||||
singleChar = singleChar ? singleChar : ".";
|
singleChar = singleChar ? singleChar : ".";
|
||||||
escapeChar = escapeChar ? escapeChar : "!";
|
escapeChar = escapeChar ? escapeChar : "!";
|
||||||
|
|
||||||
this.value = this.value.replace(
|
this.value = this.value.replace(
|
||||||
new RegExp("\\"+escapeChar, "g"), "\\");
|
new RegExp("\\"+escapeChar, "g"), "\\");
|
||||||
this.value = this.value.replace(
|
this.value = this.value.replace(
|
||||||
new RegExp("\\"+singleChar, "g"), ".");
|
new RegExp("\\"+singleChar, "g"), ".");
|
||||||
this.value = this.value.replace(
|
this.value = this.value.replace(
|
||||||
new RegExp("\\"+wildCard, "g"), ".*");
|
new RegExp("\\"+wildCard, "g"), ".*");
|
||||||
this.value = this.value.replace(
|
this.value = this.value.replace(
|
||||||
new RegExp("\\\\.\\*", "g"), "\\"+wildCard);
|
new RegExp("\\\\.\\*", "g"), "\\"+wildCard);
|
||||||
this.value = this.value.replace(
|
this.value = this.value.replace(
|
||||||
new RegExp("\\\\\\.", "g"), "\\"+singleChar);
|
new RegExp("\\\\\\.", "g"), "\\"+singleChar);
|
||||||
|
|
||||||
return this.value;
|
return this.value;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function: binaryCompare
|
* Function: binaryCompare
|
||||||
* Compares a feature property to a rule value
|
* Compares a feature property to a rule value
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* context - {Object}
|
* context - {Object}
|
||||||
* property - {String} or {Number}
|
* property - {String} or {Number}
|
||||||
* value - {String} or {Number}, same as property
|
* value - {String} or {Number}, same as property
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {boolean}
|
* {boolean}
|
||||||
*/
|
*/
|
||||||
binaryCompare: function(context, property, value) {
|
binaryCompare: function(context, property, value) {
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case OpenLayers.Rule.Comparison.EQUAL_TO:
|
case OpenLayers.Rule.Comparison.EQUAL_TO:
|
||||||
return context[property] == value;
|
return context[property] == value;
|
||||||
case OpenLayers.Rule.Comparison.NOT_EQUAL_TO:
|
case OpenLayers.Rule.Comparison.NOT_EQUAL_TO:
|
||||||
return context[property] != value;
|
return context[property] != value;
|
||||||
case OpenLayers.Rule.Comparison.LESS_THAN:
|
case OpenLayers.Rule.Comparison.LESS_THAN:
|
||||||
return context[property] < value;
|
return context[property] < value;
|
||||||
case OpenLayers.Rule.Comparison.GREATER_THAN:
|
case OpenLayers.Rule.Comparison.GREATER_THAN:
|
||||||
return context[property] > value;
|
return context[property] > value;
|
||||||
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
|
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
|
||||||
return context[property] <= value;
|
return context[property] <= value;
|
||||||
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
|
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
|
||||||
return context[property] >= value;
|
return context[property] >= value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Rule.Comparison"
|
CLASS_NAME: "OpenLayers.Rule.Comparison"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
OpenLayers.Rule.Comparison.EQUAL_TO = "==";
|
OpenLayers.Rule.Comparison.EQUAL_TO = "==";
|
||||||
OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
|
OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
|
||||||
OpenLayers.Rule.Comparison.LESS_THAN = "<";
|
OpenLayers.Rule.Comparison.LESS_THAN = "<";
|
||||||
OpenLayers.Rule.Comparison.GREATER_THAN = ">";
|
OpenLayers.Rule.Comparison.GREATER_THAN = ">";
|
||||||
OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
||||||
OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
||||||
OpenLayers.Rule.Comparison.BETWEEN = "..";
|
OpenLayers.Rule.Comparison.BETWEEN = "..";
|
||||||
OpenLayers.Rule.Comparison.LIKE = "~";
|
OpenLayers.Rule.Comparison.LIKE = "~";
|
||||||
|
|||||||
@@ -1,69 +1,69 @@
|
|||||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||||
* full text of the license. */
|
* full text of the license. */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Rule.js
|
* @requires OpenLayers/Rule.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class: OpenLayers.Rule.FeatureId
|
* Class: OpenLayers.Rule.FeatureId
|
||||||
* This class represents a ogc:FeatureId Rule, as being used for rule-based SLD
|
* This class represents a ogc:FeatureId Rule, as being used for rule-based SLD
|
||||||
* styling
|
* styling
|
||||||
*
|
*
|
||||||
* Inherits from
|
* Inherits from
|
||||||
* - <OpenLayers.Rule>
|
* - <OpenLayers.Rule>
|
||||||
*/
|
*/
|
||||||
OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
|
OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: fids
|
* APIProperty: fids
|
||||||
* {Array(<String>)} Feature Ids to evaluate this rule against. To be passed
|
* {Array(<String>)} Feature Ids to evaluate this rule against. To be passed
|
||||||
* To be passed inside the params object.
|
* To be passed inside the params object.
|
||||||
*/
|
*/
|
||||||
fids: null,
|
fids: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Rule.FeatureId
|
* Constructor: OpenLayers.Rule.FeatureId
|
||||||
* Creates an ogc:FeatureId rule.
|
* Creates an ogc:FeatureId rule.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* options - {Object} An optional object with properties to set on the
|
* options - {Object} An optional object with properties to set on the
|
||||||
* rule
|
* rule
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {<OpenLayers.Rule.FeatureId>}
|
* {<OpenLayers.Rule.FeatureId>}
|
||||||
*/
|
*/
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.fids = [];
|
this.fids = [];
|
||||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: evaluate
|
* APIMethod: evaluate
|
||||||
* evaluates this rule for a specific feature
|
* evaluates this rule for a specific feature
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
||||||
* For vector features, the check is run against the fid,
|
* For vector features, the check is run against the fid,
|
||||||
* for plain features against the id.
|
* for plain features against the id.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {boolean} true if the rule applies, false if it does not
|
* {boolean} true if the rule applies, false if it does not
|
||||||
*/
|
*/
|
||||||
evaluate: function(feature) {
|
evaluate: function(feature) {
|
||||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (var i=0; i<this.fids.length; i++) {
|
for (var i=0; i<this.fids.length; i++) {
|
||||||
var fid = feature.fid || feature.id;
|
var fid = feature.fid || feature.id;
|
||||||
if (fid == this.fids[i]) {
|
if (fid == this.fids[i]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Rule.FeatureId"
|
CLASS_NAME: "OpenLayers.Rule.FeatureId"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,104 +1,104 @@
|
|||||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||||
* full text of the license. */
|
* full text of the license. */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Rule.js
|
* @requires OpenLayers/Rule.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class: OpenLayers.Rule.Logical
|
* Class: OpenLayers.Rule.Logical
|
||||||
* This class represents ogc:And, ogc:Or and ogc:Not rules.
|
* This class represents ogc:And, ogc:Or and ogc:Not rules.
|
||||||
*
|
*
|
||||||
* Inherits from
|
* Inherits from
|
||||||
* - <OpenLayers.Rule>
|
* - <OpenLayers.Rule>
|
||||||
*/
|
*/
|
||||||
OpenLayers.Rule.Logical = OpenLayers.Class(OpenLayers.Rule, {
|
OpenLayers.Rule.Logical = OpenLayers.Class(OpenLayers.Rule, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: children
|
* APIProperty: children
|
||||||
* {Array(<OpenLayers.Rule>)} child rules for this rule
|
* {Array(<OpenLayers.Rule>)} child rules for this rule
|
||||||
*/
|
*/
|
||||||
rules: null,
|
rules: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: type
|
* APIProperty: type
|
||||||
* {String} type of logical operator. Available types are:
|
* {String} type of logical operator. Available types are:
|
||||||
* - OpenLayers.Rule.Locical.AND = "&&";
|
* - OpenLayers.Rule.Locical.AND = "&&";
|
||||||
* - OpenLayers.Rule.Logical.OR = "||";
|
* - OpenLayers.Rule.Logical.OR = "||";
|
||||||
* - OpenLayers.Rule.Logical.NOT = "!";
|
* - OpenLayers.Rule.Logical.NOT = "!";
|
||||||
*/
|
*/
|
||||||
type: null,
|
type: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Rule.Logical
|
* Constructor: OpenLayers.Rule.Logical
|
||||||
* Creates a logical rule (And, Or, Not).
|
* Creates a logical rule (And, Or, Not).
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* options - {Object} An optional object with properties to set on the
|
* options - {Object} An optional object with properties to set on the
|
||||||
* rule
|
* rule
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {<OpenLayers.Rule.Logical>}
|
* {<OpenLayers.Rule.Logical>}
|
||||||
*/
|
*/
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.rules = [];
|
this.rules = [];
|
||||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: destroy
|
* APIMethod: destroy
|
||||||
* nullify references to prevent circular references and memory leaks
|
* nullify references to prevent circular references and memory leaks
|
||||||
*/
|
*/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
for (var i=0; i<this.rules.length; i++) {
|
for (var i=0; i<this.rules.length; i++) {
|
||||||
this.rules[i].destroy();
|
this.rules[i].destroy();
|
||||||
}
|
}
|
||||||
this.rules = null;
|
this.rules = null;
|
||||||
OpenLayers.Rule.prototype.destroy.apply(this, arguments);
|
OpenLayers.Rule.prototype.destroy.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: evaluate
|
* APIMethod: evaluate
|
||||||
* evaluates this rule for a specific feature
|
* evaluates this rule for a specific feature
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {boolean} true if the rule applies, false if it does not
|
* {boolean} true if the rule applies, false if it does not
|
||||||
*/
|
*/
|
||||||
evaluate: function(feature) {
|
evaluate: function(feature) {
|
||||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch(this.type) {
|
switch(this.type) {
|
||||||
case OpenLayers.Rule.Logical.AND:
|
case OpenLayers.Rule.Logical.AND:
|
||||||
for (var i=0; i<this.rules.length; i++) {
|
for (var i=0; i<this.rules.length; i++) {
|
||||||
if (this.rules[i].evaluate(feature) == false) {
|
if (this.rules[i].evaluate(feature) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case OpenLayers.Rule.Logical.OR:
|
case OpenLayers.Rule.Logical.OR:
|
||||||
for (var i=0; i<this.rules.length; i++) {
|
for (var i=0; i<this.rules.length; i++) {
|
||||||
if (this.rules[i].evaluate(feature) == true) {
|
if (this.rules[i].evaluate(feature) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case OpenLayers.Rule.Logical.NOT:
|
case OpenLayers.Rule.Logical.NOT:
|
||||||
return (!this.rules[0].evaluate(feature));
|
return (!this.rules[0].evaluate(feature));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Rule.Logical"
|
CLASS_NAME: "OpenLayers.Rule.Logical"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
OpenLayers.Rule.Logical.AND = "&&";
|
OpenLayers.Rule.Logical.AND = "&&";
|
||||||
OpenLayers.Rule.Logical.OR = "||";
|
OpenLayers.Rule.Logical.OR = "||";
|
||||||
OpenLayers.Rule.Logical.NOT = "!";
|
OpenLayers.Rule.Logical.NOT = "!";
|
||||||
|
|||||||
@@ -1,317 +1,317 @@
|
|||||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||||
* full text of the license. */
|
* full text of the license. */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires OpenLayers/Util.js
|
* @requires OpenLayers/Util.js
|
||||||
* @requires OpenLayers/Feature/Vector.js
|
* @requires OpenLayers/Feature/Vector.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class: OpenLayers.Style
|
* Class: OpenLayers.Style
|
||||||
* This class represents a UserStyle obtained
|
* This class represents a UserStyle obtained
|
||||||
* from a SLD, containing styling rules.
|
* from a SLD, containing styling rules.
|
||||||
*/
|
*/
|
||||||
OpenLayers.Style = OpenLayers.Class({
|
OpenLayers.Style = OpenLayers.Class({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: name
|
* APIProperty: name
|
||||||
* {String}
|
* {String}
|
||||||
*/
|
*/
|
||||||
name: null,
|
name: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: layerName
|
* APIProperty: layerName
|
||||||
* {<String>} name of the layer that this style belongs to, usually
|
* {<String>} name of the layer that this style belongs to, usually
|
||||||
* according to the NamedLayer attribute of an SLD document.
|
* according to the NamedLayer attribute of an SLD document.
|
||||||
*/
|
*/
|
||||||
layerName: null,
|
layerName: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: isDefault
|
* APIProperty: isDefault
|
||||||
* {Boolean}
|
* {Boolean}
|
||||||
*/
|
*/
|
||||||
isDefault: false,
|
isDefault: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: rules
|
* Property: rules
|
||||||
* Array({<OpenLayers.Rule>})
|
* Array({<OpenLayers.Rule>})
|
||||||
*/
|
*/
|
||||||
rules: null,
|
rules: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: defaultStyle
|
* Property: defaultStyle
|
||||||
* {Object} hash of style properties to use as default for merging
|
* {Object} hash of style properties to use as default for merging
|
||||||
* rule-based style symbolizers onto. If no rules are defined, createStyle
|
* rule-based style symbolizers onto. If no rules are defined, createStyle
|
||||||
* will return this style.
|
* will return this style.
|
||||||
*/
|
*/
|
||||||
defaultStyle: null,
|
defaultStyle: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: propertyStyles
|
* Property: propertyStyles
|
||||||
* {Hash of Boolean} cache of style properties that need to be parsed for
|
* {Hash of Boolean} cache of style properties that need to be parsed for
|
||||||
* propertyNames. Property names are keys, values won't be used.
|
* propertyNames. Property names are keys, values won't be used.
|
||||||
*/
|
*/
|
||||||
propertyStyles: null,
|
propertyStyles: null,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Style
|
* Constructor: OpenLayers.Style
|
||||||
* Creates a UserStyle.
|
* Creates a UserStyle.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* style - {Object} Optional hash of style properties that will be
|
* style - {Object} Optional hash of style properties that will be
|
||||||
* used as default style for this style object. This style
|
* used as default style for this style object. This style
|
||||||
* applies if no rules are specified. Symbolizers defined in
|
* applies if no rules are specified. Symbolizers defined in
|
||||||
* rules will extend this default style.
|
* rules will extend this default style.
|
||||||
* options - {Object} An optional object with properties to set on the
|
* options - {Object} An optional object with properties to set on the
|
||||||
* userStyle
|
* userStyle
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* {<OpenLayers.Style>}
|
* {<OpenLayers.Style>}
|
||||||
*/
|
*/
|
||||||
initialize: function(style, options) {
|
initialize: function(style, options) {
|
||||||
this.rules = [];
|
this.rules = [];
|
||||||
|
|
||||||
// use the default style from OpenLayers.Feature.Vector if no style
|
// use the default style from OpenLayers.Feature.Vector if no style
|
||||||
// was given in the constructor
|
// was given in the constructor
|
||||||
this.setDefaultStyle(style ||
|
this.setDefaultStyle(style ||
|
||||||
OpenLayers.Feature.Vector.style["default"]);
|
OpenLayers.Feature.Vector.style["default"]);
|
||||||
|
|
||||||
OpenLayers.Util.extend(this, options);
|
OpenLayers.Util.extend(this, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: destroy
|
* APIMethod: destroy
|
||||||
* nullify references to prevent circular references and memory leaks
|
* nullify references to prevent circular references and memory leaks
|
||||||
*/
|
*/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
for (var i=0; i<this.rules.length; i++) {
|
for (var i=0; i<this.rules.length; i++) {
|
||||||
this.rules[i].destroy();
|
this.rules[i].destroy();
|
||||||
this.rules[i] = null;
|
this.rules[i] = null;
|
||||||
}
|
}
|
||||||
this.rules = null;
|
this.rules = null;
|
||||||
this.defaultStyle = null;
|
this.defaultStyle = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: createStyle
|
* APIMethod: createStyle
|
||||||
* creates a style by applying all feature-dependent rules to the base
|
* creates a style by applying all feature-dependent rules to the base
|
||||||
* style.
|
* style.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* feature - {<OpenLayers.Feature>} feature to evaluate rules for
|
* feature - {<OpenLayers.Feature>} feature to evaluate rules for
|
||||||
* baseStyle - {Object} hash of styles feature styles to extend
|
* baseStyle - {Object} hash of styles feature styles to extend
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {<OpenLayers.Feature.Vector.style>} hash of feature styles
|
* {<OpenLayers.Feature.Vector.style>} hash of feature styles
|
||||||
*/
|
*/
|
||||||
createStyle: function(feature) {
|
createStyle: function(feature) {
|
||||||
var style = OpenLayers.Util.extend({}, this.defaultStyle);
|
var style = OpenLayers.Util.extend({}, this.defaultStyle);
|
||||||
|
|
||||||
var rules = this.rules;
|
var rules = this.rules;
|
||||||
|
|
||||||
var rule, context;
|
var rule, context;
|
||||||
var elseRules = [];
|
var elseRules = [];
|
||||||
var appliedRules = false;
|
var appliedRules = false;
|
||||||
for(var i=0; i<rules.length; i++) {
|
for(var i=0; i<rules.length; i++) {
|
||||||
rule = rules[i];
|
rule = rules[i];
|
||||||
context = rule.context;
|
context = rule.context;
|
||||||
if (!context) {
|
if (!context) {
|
||||||
context = feature.attributes || feature.data;
|
context = feature.attributes || feature.data;
|
||||||
}
|
}
|
||||||
// does the rule apply?
|
// does the rule apply?
|
||||||
var applies = rule.evaluate(feature);
|
var applies = rule.evaluate(feature);
|
||||||
|
|
||||||
if(applies) {
|
if(applies) {
|
||||||
if(rule instanceof OpenLayers.Rule && rule.elseFilter) {
|
if(rule instanceof OpenLayers.Rule && rule.elseFilter) {
|
||||||
elseRules.push(rule);
|
elseRules.push(rule);
|
||||||
} else {
|
} else {
|
||||||
appliedRules = true;
|
appliedRules = true;
|
||||||
this.applySymbolizer(rule, style, feature, context);
|
this.applySymbolizer(rule, style, feature, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no other rules apply, apply the rules with else filters
|
// if no other rules apply, apply the rules with else filters
|
||||||
if(appliedRules == false && elseRules.length > 0) {
|
if(appliedRules == false && elseRules.length > 0) {
|
||||||
appliedRules = true;
|
appliedRules = true;
|
||||||
for(var i=0; i<elseRules.length; i++) {
|
for(var i=0; i<elseRules.length; i++) {
|
||||||
this.applySymbolizer(elseRules[i], style, feature, context);
|
this.applySymbolizer(elseRules[i], style, feature, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't display if there were rules but none applied
|
// don't display if there were rules but none applied
|
||||||
if(rules.length > 0 && appliedRules == false) {
|
if(rules.length > 0 && appliedRules == false) {
|
||||||
style.display = "none";
|
style.display = "none";
|
||||||
} else {
|
} else {
|
||||||
style.display = "";
|
style.display = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: applySymbolizer
|
* Method: applySymbolizer
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* rule - {OpenLayers.Rule}
|
* rule - {OpenLayers.Rule}
|
||||||
* style - {Object}
|
* style - {Object}
|
||||||
* feature - {<OpenLayer.Feature.Vector>}
|
* feature - {<OpenLayer.Feature.Vector>}
|
||||||
* context - {Object}
|
* context - {Object}
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Object} A style with new symbolizer applied.
|
* {Object} A style with new symbolizer applied.
|
||||||
*/
|
*/
|
||||||
applySymbolizer: function(rule, style, feature, context) {
|
applySymbolizer: function(rule, style, feature, context) {
|
||||||
var symbolizerPrefix = feature.geometry ?
|
var symbolizerPrefix = feature.geometry ?
|
||||||
this.getSymbolizerPrefix(feature.geometry) :
|
this.getSymbolizerPrefix(feature.geometry) :
|
||||||
OpenLayers.Style.SYMBOLIZER_PREFIXES[0];
|
OpenLayers.Style.SYMBOLIZER_PREFIXES[0];
|
||||||
|
|
||||||
var symbolizer = rule.symbolizer[symbolizerPrefix];
|
var symbolizer = rule.symbolizer[symbolizerPrefix];
|
||||||
|
|
||||||
// merge the style with the current style
|
// merge the style with the current style
|
||||||
return this.createLiterals(
|
return this.createLiterals(
|
||||||
OpenLayers.Util.extend(style, symbolizer), context);
|
OpenLayers.Util.extend(style, symbolizer), context);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: createLiterals
|
* Method: createLiterals
|
||||||
* creates literals for all style properties that have an entry in
|
* creates literals for all style properties that have an entry in
|
||||||
* <this.propertyStyles>.
|
* <this.propertyStyles>.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* style - {Object} style to create literals for. Will be modified
|
* style - {Object} style to create literals for. Will be modified
|
||||||
* inline.
|
* inline.
|
||||||
* context - {Object} context to take property values from. Defaults to
|
* context - {Object} context to take property values from. Defaults to
|
||||||
* feature.attributes (or feature.data, if attributes are not
|
* feature.attributes (or feature.data, if attributes are not
|
||||||
* available)
|
* available)
|
||||||
*
|
*
|
||||||
* Returns;
|
* Returns;
|
||||||
* {Object} the modified style
|
* {Object} the modified style
|
||||||
*/
|
*/
|
||||||
createLiterals: function(style, context) {
|
createLiterals: function(style, context) {
|
||||||
for (var i in this.propertyStyles) {
|
for (var i in this.propertyStyles) {
|
||||||
style[i] = OpenLayers.Style.createLiteral(style[i], context);
|
style[i] = OpenLayers.Style.createLiteral(style[i], context);
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: findPropertyStyles
|
* Method: findPropertyStyles
|
||||||
* Looks into all rules for this style and the defaultStyle to collect
|
* Looks into all rules for this style and the defaultStyle to collect
|
||||||
* all the style hash property names containing ${...} strings that have
|
* all the style hash property names containing ${...} strings that have
|
||||||
* to be replaced using the createLiteral method before returning them.
|
* to be replaced using the createLiteral method before returning them.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {Object} hash of property names that need createLiteral parsing. The
|
* {Object} hash of property names that need createLiteral parsing. The
|
||||||
* name of the property is the key, and the value is true;
|
* name of the property is the key, and the value is true;
|
||||||
*/
|
*/
|
||||||
findPropertyStyles: function() {
|
findPropertyStyles: function() {
|
||||||
var propertyStyles = {};
|
var propertyStyles = {};
|
||||||
|
|
||||||
// check the default style
|
// check the default style
|
||||||
var style = this.defaultStyle;
|
var style = this.defaultStyle;
|
||||||
for (var i in style) {
|
for (var i in style) {
|
||||||
if (typeof style[i] == "string" && style[i].match(/\$\{\w+\}/)) {
|
if (typeof style[i] == "string" && style[i].match(/\$\{\w+\}/)) {
|
||||||
propertyStyles[i] = true;
|
propertyStyles[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// walk through all rules to check for properties in their symbolizer
|
// walk through all rules to check for properties in their symbolizer
|
||||||
var rules = this.rules;
|
var rules = this.rules;
|
||||||
var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;
|
var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;
|
||||||
for (var i in rules) {
|
for (var i in rules) {
|
||||||
for (var s=0; s<prefixes.length; s++) {
|
for (var s=0; s<prefixes.length; s++) {
|
||||||
style = rules[i].symbolizer[prefixes[s]];
|
style = rules[i].symbolizer[prefixes[s]];
|
||||||
for (var j in style) {
|
for (var j in style) {
|
||||||
if (typeof style[j] == "string" &&
|
if (typeof style[j] == "string" &&
|
||||||
style[j].match(/\$\{\w+\}/)) {
|
style[j].match(/\$\{\w+\}/)) {
|
||||||
propertyStyles[j] = true;
|
propertyStyles[j] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return propertyStyles;
|
return propertyStyles;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: addRules
|
* APIMethod: addRules
|
||||||
* Adds rules to this style.
|
* Adds rules to this style.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* rules - {Array(<OpenLayers.Rule>)}
|
* rules - {Array(<OpenLayers.Rule>)}
|
||||||
*/
|
*/
|
||||||
addRules: function(rules) {
|
addRules: function(rules) {
|
||||||
this.rules = this.rules.concat(rules);
|
this.rules = this.rules.concat(rules);
|
||||||
this.propertyStyles = this.findPropertyStyles();
|
this.propertyStyles = this.findPropertyStyles();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: setDefaultStyle
|
* APIMethod: setDefaultStyle
|
||||||
* Sets the default style for this style object.
|
* Sets the default style for this style object.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* style - {Object} Hash of style properties
|
* style - {Object} Hash of style properties
|
||||||
*/
|
*/
|
||||||
setDefaultStyle: function(style) {
|
setDefaultStyle: function(style) {
|
||||||
this.defaultStyle = style;
|
this.defaultStyle = style;
|
||||||
this.propertyStyles = this.findPropertyStyles();
|
this.propertyStyles = this.findPropertyStyles();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: getSymbolizerPrefix
|
* Method: getSymbolizerPrefix
|
||||||
* Returns the correct symbolizer prefix according to the
|
* Returns the correct symbolizer prefix according to the
|
||||||
* geometry type of the passed geometry
|
* geometry type of the passed geometry
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* geometry {<OpenLayers.Geometry>}
|
* geometry {<OpenLayers.Geometry>}
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {String} key of the according symbolizer
|
* {String} key of the according symbolizer
|
||||||
*/
|
*/
|
||||||
getSymbolizerPrefix: function(geometry) {
|
getSymbolizerPrefix: function(geometry) {
|
||||||
var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;
|
var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;
|
||||||
for (var i=0; i<prefixes.length; i++) {
|
for (var i=0; i<prefixes.length; i++) {
|
||||||
if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {
|
if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {
|
||||||
return prefixes[i];
|
return prefixes[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Style"
|
CLASS_NAME: "OpenLayers.Style"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function: createLiteral
|
* Function: createLiteral
|
||||||
* converts a style value holding a combination of PropertyName and Literal
|
* converts a style value holding a combination of PropertyName and Literal
|
||||||
* into a Literal, taking the property values from the passed features.
|
* into a Literal, taking the property values from the passed features.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* value {String} value to parse. If this string contains a construct like
|
* value {String} value to parse. If this string contains a construct like
|
||||||
* "foo ${bar}", then "foo " will be taken as literal, and "${bar}"
|
* "foo ${bar}", then "foo " will be taken as literal, and "${bar}"
|
||||||
* will be replaced by the value of the "bar" attribute of the passed
|
* will be replaced by the value of the "bar" attribute of the passed
|
||||||
* feature.
|
* feature.
|
||||||
* context {Object} context to take attribute values from
|
* context {Object} context to take attribute values from
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {String} the parsed value. In the example of the value parameter above, the
|
* {String} the parsed value. In the example of the value parameter above, the
|
||||||
* result would be "foo valueOfBar", assuming that the passed feature has an
|
* result would be "foo valueOfBar", assuming that the passed feature has an
|
||||||
* attribute named "bar" with the value "valueOfBar".
|
* attribute named "bar" with the value "valueOfBar".
|
||||||
*/
|
*/
|
||||||
OpenLayers.Style.createLiteral = function(value, context) {
|
OpenLayers.Style.createLiteral = function(value, context) {
|
||||||
if (typeof value == "string" && value.indexOf("${") != -1) {
|
if (typeof value == "string" && value.indexOf("${") != -1) {
|
||||||
value = OpenLayers.String.format(value, context)
|
value = OpenLayers.String.format(value, context)
|
||||||
value = isNaN(value) ? value : parseFloat(value);
|
value = isNaN(value) ? value : parseFloat(value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES
|
* Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES
|
||||||
* {Array} prefixes of the sld symbolizers. These are the
|
* {Array} prefixes of the sld symbolizers. These are the
|
||||||
* same as the main geometry types
|
* same as the main geometry types
|
||||||
*/
|
*/
|
||||||
OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon'];
|
OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon'];
|
||||||
|
|||||||
@@ -1,180 +1,180 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<script src="../../lib/OpenLayers.js"></script>
|
<script src="../../lib/OpenLayers.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function test_01_Element_visible(t) {
|
function test_01_Element_visible(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
|
||||||
var elem = {
|
var elem = {
|
||||||
style: {
|
style: {
|
||||||
'display': ""
|
'display': ""
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
elem.style.display = "";
|
elem.style.display = "";
|
||||||
t.ok(OpenLayers.Element.visible(elem), "element with style.display == '' is visible");
|
t.ok(OpenLayers.Element.visible(elem), "element with style.display == '' is visible");
|
||||||
|
|
||||||
elem.style.display = "block";
|
elem.style.display = "block";
|
||||||
t.ok(OpenLayers.Element.visible(elem), "element with style.display == block is visible");
|
t.ok(OpenLayers.Element.visible(elem), "element with style.display == block is visible");
|
||||||
|
|
||||||
elem.style.display = "none";
|
elem.style.display = "none";
|
||||||
t.ok(!OpenLayers.Element.visible(elem), "element with style.display == none is not visible");
|
t.ok(!OpenLayers.Element.visible(elem), "element with style.display == none is not visible");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_02_Element_toggle(t) {
|
function test_02_Element_toggle(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
|
|
||||||
var elem1 = {
|
var elem1 = {
|
||||||
style: {
|
style: {
|
||||||
'display': "none"
|
'display': "none"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var elem2 = {
|
var elem2 = {
|
||||||
style: {
|
style: {
|
||||||
'display': ""
|
'display': ""
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenLayers.Element.toggle(elem1, elem2);
|
OpenLayers.Element.toggle(elem1, elem2);
|
||||||
|
|
||||||
t.eq(elem1.style.display, "", "hidden element toggled to display");
|
t.eq(elem1.style.display, "", "hidden element toggled to display");
|
||||||
t.eq(elem2.style.display, "none", "shown element toggled to hidden");
|
t.eq(elem2.style.display, "none", "shown element toggled to hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_03_Element_hide(t) {
|
function test_03_Element_hide(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
|
|
||||||
var elem1 = {
|
var elem1 = {
|
||||||
style: {
|
style: {
|
||||||
'display': "none"
|
'display': "none"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var elem2 = {
|
var elem2 = {
|
||||||
style: {
|
style: {
|
||||||
'display': ""
|
'display': ""
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenLayers.Element.hide(elem1, elem2);
|
OpenLayers.Element.hide(elem1, elem2);
|
||||||
|
|
||||||
t.eq(elem1.style.display, "none", "hidden element stays hidden");
|
t.eq(elem1.style.display, "none", "hidden element stays hidden");
|
||||||
t.eq(elem2.style.display, "none", "shown element hidden");
|
t.eq(elem2.style.display, "none", "shown element hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_04_Element_show(t) {
|
function test_04_Element_show(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
|
|
||||||
var elem1 = {
|
var elem1 = {
|
||||||
style: {
|
style: {
|
||||||
'display': "none"
|
'display': "none"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var elem2 = {
|
var elem2 = {
|
||||||
style: {
|
style: {
|
||||||
'display': ""
|
'display': ""
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenLayers.Element.show(elem1, elem2);
|
OpenLayers.Element.show(elem1, elem2);
|
||||||
|
|
||||||
t.eq(elem1.style.display, "", "hidden element shown");
|
t.eq(elem1.style.display, "", "hidden element shown");
|
||||||
t.eq(elem2.style.display, "", "shown element stays shown");
|
t.eq(elem2.style.display, "", "shown element stays shown");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_05_Element_remove(t) {
|
function test_05_Element_remove(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|
||||||
var elem = {
|
var elem = {
|
||||||
parentNode: {
|
parentNode: {
|
||||||
'removeChild': function(elem) {
|
'removeChild': function(elem) {
|
||||||
t.ok(true, "removeChild called");
|
t.ok(true, "removeChild called");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
OpenLayers.Element.remove(elem);
|
OpenLayers.Element.remove(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_06_Element_getHeight(t) {
|
function test_06_Element_getHeight(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|
||||||
var elem = {
|
var elem = {
|
||||||
'offsetHeight': {}
|
'offsetHeight': {}
|
||||||
};
|
};
|
||||||
|
|
||||||
t.ok(OpenLayers.Element.getHeight(elem) == elem.offsetHeight, "offsetHeight returned");
|
t.ok(OpenLayers.Element.getHeight(elem) == elem.offsetHeight, "offsetHeight returned");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_07_Element_getDimensions(t) {
|
function test_07_Element_getDimensions(t) {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
|
|
||||||
//shown
|
//shown
|
||||||
t.open_window( "BaseTypes/test_Element.html", function( wnd ) {
|
t.open_window( "BaseTypes/test_Element.html", function( wnd ) {
|
||||||
t.delay_call( 0.5, function() {
|
t.delay_call( 0.5, function() {
|
||||||
var elem = wnd.document.getElementById("elemID");
|
var elem = wnd.document.getElementById("elemID");
|
||||||
|
|
||||||
var dims = OpenLayers.Element.getDimensions(elem);
|
var dims = OpenLayers.Element.getDimensions(elem);
|
||||||
t.eq(dims.width, 50, "width correct when displayed");
|
t.eq(dims.width, 50, "width correct when displayed");
|
||||||
t.eq(dims.height, 100, "height correct when displayed")
|
t.eq(dims.height, 100, "height correct when displayed")
|
||||||
|
|
||||||
elem.style.display = "none";
|
elem.style.display = "none";
|
||||||
dims = OpenLayers.Element.getDimensions(elem);
|
dims = OpenLayers.Element.getDimensions(elem);
|
||||||
t.eq(dims.width, 50, "width correct when hidden");
|
t.eq(dims.width, 50, "width correct when hidden");
|
||||||
t.eq(dims.height, 100, "height correct when hidden")
|
t.eq(dims.height, 100, "height correct when hidden")
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//hidden
|
//hidden
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_08_Element_getStyle(t) {
|
function test_08_Element_getStyle(t) {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
|
|
||||||
//tests for this function are not 100% complete... there is some funky
|
//tests for this function are not 100% complete... there is some funky
|
||||||
// business going on in there with
|
// business going on in there with
|
||||||
// * document.defaultView (moz/ff I believe)
|
// * document.defaultView (moz/ff I believe)
|
||||||
// but I cant seem to find a good way to test them.
|
// but I cant seem to find a good way to test them.
|
||||||
//
|
//
|
||||||
|
|
||||||
var elem = document.getElementById("elemID");
|
var elem = document.getElementById("elemID");
|
||||||
elem.style.chickenHead = {}
|
elem.style.chickenHead = {}
|
||||||
|
|
||||||
var style = "chickenHead";
|
var style = "chickenHead";
|
||||||
t.ok(OpenLayers.Element.getStyle(elem, style) == elem.style.chickenHead, "get style on basic stylename returns correctly");
|
t.ok(OpenLayers.Element.getStyle(elem, style) == elem.style.chickenHead, "get style on basic stylename returns correctly");
|
||||||
|
|
||||||
elem.style.chickenHead = "auto";
|
elem.style.chickenHead = "auto";
|
||||||
style = "chickenHead";
|
style = "chickenHead";
|
||||||
t.ok(OpenLayers.Element.getStyle(elem, style) == null, "get style on 'auto' style returns null");
|
t.ok(OpenLayers.Element.getStyle(elem, style) == null, "get style on 'auto' style returns null");
|
||||||
|
|
||||||
if (OpenLayers.Util.getBrowserName() == "opera") {
|
if (OpenLayers.Util.getBrowserName() == "opera") {
|
||||||
elem.style.top = "15px";
|
elem.style.top = "15px";
|
||||||
style = "top";
|
style = "top";
|
||||||
|
|
||||||
elem.style.position = "static";
|
elem.style.position = "static";
|
||||||
t.ok(OpenLayers.Element.getStyle(elem, style) == null, "in opera: get (top/left/right/bottom) style when position == 'static' returns null");
|
t.ok(OpenLayers.Element.getStyle(elem, style) == null, "in opera: get (top/left/right/bottom) style when position == 'static' returns null");
|
||||||
|
|
||||||
elem.style.position = "";
|
elem.style.position = "";
|
||||||
t.ok(OpenLayers.Element.getStyle(elem, style) == null, "in opera: get (top/left/right/bottom) style when position != 'static', gets computedStyle as static and returns null");
|
t.ok(OpenLayers.Element.getStyle(elem, style) == null, "in opera: get (top/left/right/bottom) style when position != 'static', gets computedStyle as static and returns null");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
t.ok(true, "browser is not opera.");
|
t.ok(true, "browser is not opera.");
|
||||||
t.ok(true, "trust me. browser is not opera.");
|
t.ok(true, "trust me. browser is not opera.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="elemID" style="width:50px; height:100px; background-color:red">test</div>
|
<div id="elemID" style="width:50px; height:100px; background-color:red">test</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -157,173 +157,173 @@
|
|||||||
data = parser.read(test_content[0]);
|
data = parser.read(test_content[0]);
|
||||||
t.eq(data[0].attributes['NAME'], "WY", "Simple Attribute data is read correctly.");
|
t.eq(data[0].attributes['NAME'], "WY", "Simple Attribute data is read correctly.");
|
||||||
t.eq(data[0].attributes['LONGNAME'], "Wyoming", "Attribute data is read from CDATA node correctly.");
|
t.eq(data[0].attributes['LONGNAME'], "Wyoming", "Attribute data is read from CDATA node correctly.");
|
||||||
}
|
}
|
||||||
function test_Format_GML_read_envelope_geom(t) {
|
function test_Format_GML_read_envelope_geom(t) {
|
||||||
t.plan(13);
|
t.plan(13);
|
||||||
|
|
||||||
var envelope = shell_start + geoms['envelope'] + shell_end;
|
var envelope = shell_start + geoms['envelope'] + shell_end;
|
||||||
var parser = new OpenLayers.Format.GML();
|
var parser = new OpenLayers.Format.GML();
|
||||||
data = parser.read(envelope);
|
data = parser.read(envelope);
|
||||||
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Envelope GML returns correct classname");
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Envelope GML returns correct classname");
|
||||||
t.eq(data[0].geometry.components[0].components[0].x, 0, "first x coord correct");
|
t.eq(data[0].geometry.components[0].components[0].x, 0, "first x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[0].y, 1, "first y coord correct");
|
t.eq(data[0].geometry.components[0].components[0].y, 1, "first y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].x, 20, "second x coord correct");
|
t.eq(data[0].geometry.components[0].components[1].x, 20, "second x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].y, 1, "second y coord correct");
|
t.eq(data[0].geometry.components[0].components[1].y, 1, "second y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[2].x, 20, "third x coord correct");
|
t.eq(data[0].geometry.components[0].components[2].x, 20, "third x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[2].y, 21, "third y coord correct");
|
t.eq(data[0].geometry.components[0].components[2].y, 21, "third y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[3].x, 0, "fouth x coord correct");
|
t.eq(data[0].geometry.components[0].components[3].x, 0, "fouth x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[3].y, 21, "fourth y coord correct");
|
t.eq(data[0].geometry.components[0].components[3].y, 21, "fourth y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[4].x, 0, "fifth x coord correct");
|
t.eq(data[0].geometry.components[0].components[4].x, 0, "fifth x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[4].y, 1, "fifth y coord correct");
|
t.eq(data[0].geometry.components[0].components[4].y, 1, "fifth y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components.length, 5, "coords length correct");
|
t.eq(data[0].geometry.components[0].components.length, 5, "coords length correct");
|
||||||
t.eq(data[0].geometry.components.length, 1, "rings length correct");
|
t.eq(data[0].geometry.components.length, 1, "rings length correct");
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// tests the y x order of gml point
|
// tests the y x order of gml point
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
function test_Format_GML_read_point_geom_yx(t) {
|
function test_Format_GML_read_point_geom_yx(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
|
||||||
var point = shell_start + geoms_yx['point'] + shell_end;
|
var point = shell_start + geoms_yx['point'] + shell_end;
|
||||||
var parser = new OpenLayers.Format.GML({'xy':false});
|
var parser = new OpenLayers.Format.GML({'xy':false});
|
||||||
data = parser.read(point);
|
data = parser.read(point);
|
||||||
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Point", "Point GML returns correct classname");
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Point", "Point GML returns correct classname");
|
||||||
t.eq(data[0].geometry.x, 1, "x coord correct");
|
t.eq(data[0].geometry.x, 1, "x coord correct");
|
||||||
t.eq(data[0].geometry.y, 2, "y coord correct");
|
t.eq(data[0].geometry.y, 2, "y coord correct");
|
||||||
}
|
}
|
||||||
function test_Format_GML_read_linestring_geom_yx(t) {
|
function test_Format_GML_read_linestring_geom_yx(t) {
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
|
|
||||||
var line = shell_start + geoms_yx['linestring'] + shell_end;
|
var line = shell_start + geoms_yx['linestring'] + shell_end;
|
||||||
var parser = new OpenLayers.Format.GML({'xy':false});
|
var parser = new OpenLayers.Format.GML({'xy':false});
|
||||||
data = parser.read(line);
|
data = parser.read(line);
|
||||||
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.LineString", "LineString GML returns correct classname");
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.LineString", "LineString GML returns correct classname");
|
||||||
t.eq(data[0].geometry.components[0].x, 1, "first x coord correct");
|
t.eq(data[0].geometry.components[0].x, 1, "first x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].y, 2, "first y coord correct");
|
t.eq(data[0].geometry.components[0].y, 2, "first y coord correct");
|
||||||
t.eq(data[0].geometry.components[1].x, 4, "second x coord correct");
|
t.eq(data[0].geometry.components[1].x, 4, "second x coord correct");
|
||||||
t.eq(data[0].geometry.components[1].y, 5, "second y coord correct");
|
t.eq(data[0].geometry.components[1].y, 5, "second y coord correct");
|
||||||
}
|
}
|
||||||
function test_Format_GML_read_polygon_geom_yx(t) {
|
function test_Format_GML_read_polygon_geom_yx(t) {
|
||||||
t.plan(7);
|
t.plan(7);
|
||||||
|
|
||||||
var polygon = shell_start + geoms_yx['polygon'] + shell_end;
|
var polygon = shell_start + geoms_yx['polygon'] + shell_end;
|
||||||
var parser = new OpenLayers.Format.GML({'xy':false});
|
var parser = new OpenLayers.Format.GML({'xy':false});
|
||||||
data = parser.read(polygon);
|
data = parser.read(polygon);
|
||||||
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Polygon GML returns correct classname");
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Polygon GML returns correct classname");
|
||||||
t.eq(data[0].geometry.components[0].components[0].x, 1, "first x coord correct");
|
t.eq(data[0].geometry.components[0].components[0].x, 1, "first x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[0].y, 2, "first y coord correct");
|
t.eq(data[0].geometry.components[0].components[0].y, 2, "first y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].x, 4, "second x coord correct");
|
t.eq(data[0].geometry.components[0].components[1].x, 4, "second x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].y, 5, "second y coord correct");
|
t.eq(data[0].geometry.components[0].components[1].y, 5, "second y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components.length, 4, "coords length correct");
|
t.eq(data[0].geometry.components[0].components.length, 4, "coords length correct");
|
||||||
t.eq(data[0].geometry.components.length, 1, "rings length correct");
|
t.eq(data[0].geometry.components.length, 1, "rings length correct");
|
||||||
}
|
}
|
||||||
function test_Format_GML_read_multipoint_geom_yx(t) {
|
function test_Format_GML_read_multipoint_geom_yx(t) {
|
||||||
t.plan(6);
|
t.plan(6);
|
||||||
|
|
||||||
var multipoint = shell_start + geoms_yx['multipoint'] + shell_end;
|
var multipoint = shell_start + geoms_yx['multipoint'] + shell_end;
|
||||||
var parser = new OpenLayers.Format.GML({'xy':false});
|
var parser = new OpenLayers.Format.GML({'xy':false});
|
||||||
data = parser.read(multipoint);
|
data = parser.read(multipoint);
|
||||||
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.MultiPoint", "MultiPoint GML returns correct classname");
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.MultiPoint", "MultiPoint GML returns correct classname");
|
||||||
t.eq(data[0].geometry.components[0].x, 1, "x coord correct");
|
t.eq(data[0].geometry.components[0].x, 1, "x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].y, 2, "y coord correct");
|
t.eq(data[0].geometry.components[0].y, 2, "y coord correct");
|
||||||
t.eq(data[0].geometry.components.length, 2, "length correct");
|
t.eq(data[0].geometry.components.length, 2, "length correct");
|
||||||
t.eq(data[0].geometry.components[1].x, 4, "x coord correct");
|
t.eq(data[0].geometry.components[1].x, 4, "x coord correct");
|
||||||
t.eq(data[0].geometry.components[1].y, 5, "y coord correct");
|
t.eq(data[0].geometry.components[1].y, 5, "y coord correct");
|
||||||
}
|
}
|
||||||
function test_Format_GML_read_multilinestring_geom_yx(t) {
|
function test_Format_GML_read_multilinestring_geom_yx(t) {
|
||||||
t.plan(6);
|
t.plan(6);
|
||||||
|
|
||||||
var multilinestring = shell_start + geoms_yx['multilinestring'] + shell_end;
|
var multilinestring = shell_start + geoms_yx['multilinestring'] + shell_end;
|
||||||
var parser = new OpenLayers.Format.GML({'xy':false});
|
var parser = new OpenLayers.Format.GML({'xy':false});
|
||||||
data = parser.read(multilinestring);
|
data = parser.read(multilinestring);
|
||||||
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.MultiLineString", "MultiLineString GML returns correct classname");
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.MultiLineString", "MultiLineString GML returns correct classname");
|
||||||
t.eq(data[0].geometry.components[0].components[0].x, 1, "x coord correct");
|
t.eq(data[0].geometry.components[0].components[0].x, 1, "x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[0].y, 2, "y coord correct");
|
t.eq(data[0].geometry.components[0].components[0].y, 2, "y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components.length, 2, "length correct");
|
t.eq(data[0].geometry.components[0].components.length, 2, "length correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].x, 4, "x coord correct");
|
t.eq(data[0].geometry.components[0].components[1].x, 4, "x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].y, 5, "y coord correct");
|
t.eq(data[0].geometry.components[0].components[1].y, 5, "y coord correct");
|
||||||
|
|
||||||
}
|
}
|
||||||
function test_Format_GML_read_polygon_with_holes_geom_yx(t) {
|
function test_Format_GML_read_polygon_with_holes_geom_yx(t) {
|
||||||
t.plan(12);
|
t.plan(12);
|
||||||
|
|
||||||
var polygon_with_holes = shell_start + geoms_yx['polygon_with_holes'] + shell_end;
|
var polygon_with_holes = shell_start + geoms_yx['polygon_with_holes'] + shell_end;
|
||||||
var parser = new OpenLayers.Format.GML({'xy':false});
|
var parser = new OpenLayers.Format.GML({'xy':false});
|
||||||
data = parser.read(polygon_with_holes);
|
data = parser.read(polygon_with_holes);
|
||||||
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Polygon GML returns correct classname");
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Polygon GML returns correct classname");
|
||||||
t.eq(data[0].geometry.components[0].components[0].x, 1, "first x coord correct");
|
t.eq(data[0].geometry.components[0].components[0].x, 1, "first x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[0].y, 2, "first y coord correct");
|
t.eq(data[0].geometry.components[0].components[0].y, 2, "first y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].x, 4, "second x coord correct");
|
t.eq(data[0].geometry.components[0].components[1].x, 4, "second x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].y, 5, "second y coord correct");
|
t.eq(data[0].geometry.components[0].components[1].y, 5, "second y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components.length, 4, "coords length correct");
|
t.eq(data[0].geometry.components[0].components.length, 4, "coords length correct");
|
||||||
t.eq(data[0].geometry.components[1].components[0].x, 11, "first x coord correct");
|
t.eq(data[0].geometry.components[1].components[0].x, 11, "first x coord correct");
|
||||||
t.eq(data[0].geometry.components[1].components[0].y, 12, "first y coord correct");
|
t.eq(data[0].geometry.components[1].components[0].y, 12, "first y coord correct");
|
||||||
t.eq(data[0].geometry.components[1].components[1].x, 14, "second x coord correct");
|
t.eq(data[0].geometry.components[1].components[1].x, 14, "second x coord correct");
|
||||||
t.eq(data[0].geometry.components[1].components[1].y, 15, "second y coord correct");
|
t.eq(data[0].geometry.components[1].components[1].y, 15, "second y coord correct");
|
||||||
t.eq(data[0].geometry.components[1].components.length, 4, "coords length correct");
|
t.eq(data[0].geometry.components[1].components.length, 4, "coords length correct");
|
||||||
t.eq(data[0].geometry.components.length, 2, "rings length correct");
|
t.eq(data[0].geometry.components.length, 2, "rings length correct");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Format_GML_read_envelope_geom_yx(t) {
|
function test_Format_GML_read_envelope_geom_yx(t) {
|
||||||
t.plan(13);
|
t.plan(13);
|
||||||
|
|
||||||
var envelope = shell_start + geoms_yx['envelope'] + shell_end;
|
var envelope = shell_start + geoms_yx['envelope'] + shell_end;
|
||||||
var parser = new OpenLayers.Format.GML({'xy':false});
|
var parser = new OpenLayers.Format.GML({'xy':false});
|
||||||
data = parser.read(envelope);
|
data = parser.read(envelope);
|
||||||
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Envelope GML returns correct classname");
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Envelope GML returns correct classname");
|
||||||
t.eq(data[0].geometry.components[0].components[0].x, 0, "first x coord correct");
|
t.eq(data[0].geometry.components[0].components[0].x, 0, "first x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[0].y, 1, "first y coord correct");
|
t.eq(data[0].geometry.components[0].components[0].y, 1, "first y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].x, 20, "second x coord correct");
|
t.eq(data[0].geometry.components[0].components[1].x, 20, "second x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[1].y, 1, "second y coord correct");
|
t.eq(data[0].geometry.components[0].components[1].y, 1, "second y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[2].x, 20, "third x coord correct");
|
t.eq(data[0].geometry.components[0].components[2].x, 20, "third x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[2].y, 21, "third y coord correct");
|
t.eq(data[0].geometry.components[0].components[2].y, 21, "third y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[3].x, 0, "fouth x coord correct");
|
t.eq(data[0].geometry.components[0].components[3].x, 0, "fouth x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[3].y, 21, "fourth y coord correct");
|
t.eq(data[0].geometry.components[0].components[3].y, 21, "fourth y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[4].x, 0, "fifth x coord correct");
|
t.eq(data[0].geometry.components[0].components[4].x, 0, "fifth x coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components[4].y, 1, "fifth y coord correct");
|
t.eq(data[0].geometry.components[0].components[4].y, 1, "fifth y coord correct");
|
||||||
t.eq(data[0].geometry.components[0].components.length, 5, "coords length correct");
|
t.eq(data[0].geometry.components[0].components.length, 5, "coords length correct");
|
||||||
t.eq(data[0].geometry.components.length, 1, "rings length correct");
|
t.eq(data[0].geometry.components.length, 1, "rings length correct");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Format_GML_write_geoms_yx(t) {
|
function test_Format_GML_write_geoms_yx(t) {
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
var parser = new OpenLayers.Format.GML({'xy':false});
|
var parser = new OpenLayers.Format.GML({'xy':false});
|
||||||
|
|
||||||
var point_xy = shell_start + serialize_geoms['point'] + shell_end;
|
var point_xy = shell_start + serialize_geoms['point'] + shell_end;
|
||||||
var point = shell_start + serialize_geoms_yx['point'] + shell_end;
|
var point = shell_start + serialize_geoms_yx['point'] + shell_end;
|
||||||
data = parser.read(point);
|
data = parser.read(point);
|
||||||
var output = parser.write(data);
|
var output = parser.write(data);
|
||||||
var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
||||||
t.eq(output, point_xy, "Point geometry round trips correctly.");
|
t.eq(output, point_xy, "Point geometry round trips correctly.");
|
||||||
|
|
||||||
var linestring_xy = shell_start + serialize_geoms['linestring'] + shell_end;
|
var linestring_xy = shell_start + serialize_geoms['linestring'] + shell_end;
|
||||||
var linestring = shell_start + serialize_geoms_yx['linestring'] + shell_end;
|
var linestring = shell_start + serialize_geoms_yx['linestring'] + shell_end;
|
||||||
data = parser.read(linestring);
|
data = parser.read(linestring);
|
||||||
var output = parser.write(data);
|
var output = parser.write(data);
|
||||||
var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
||||||
t.eq(output, linestring_xy, "Line geometry round trips correctly.");
|
t.eq(output, linestring_xy, "Line geometry round trips correctly.");
|
||||||
|
|
||||||
var polygon_xy = shell_start + serialize_geoms['polygon'] + shell_end;
|
var polygon_xy = shell_start + serialize_geoms['polygon'] + shell_end;
|
||||||
var polygon = shell_start + serialize_geoms_yx['polygon'] + shell_end;
|
var polygon = shell_start + serialize_geoms_yx['polygon'] + shell_end;
|
||||||
data = parser.read(polygon);
|
data = parser.read(polygon);
|
||||||
var output = parser.write(data);
|
var output = parser.write(data);
|
||||||
output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
||||||
t.eq(output, polygon_xy, "Poly geometry round trips correctly.");
|
t.eq(output, polygon_xy, "Poly geometry round trips correctly.");
|
||||||
|
|
||||||
var multipoint_xy = shell_start + serialize_geoms['multipoint'] + shell_end;
|
var multipoint_xy = shell_start + serialize_geoms['multipoint'] + shell_end;
|
||||||
var multipoint = shell_start + serialize_geoms_yx['multipoint'] + shell_end;
|
var multipoint = shell_start + serialize_geoms_yx['multipoint'] + shell_end;
|
||||||
data = parser.read(multipoint);
|
data = parser.read(multipoint);
|
||||||
var output = parser.write(data);
|
var output = parser.write(data);
|
||||||
var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
||||||
t.eq(output, multipoint_xy, "MultiPoint geometry round trips correctly.");
|
t.eq(output, multipoint_xy, "MultiPoint geometry round trips correctly.");
|
||||||
|
|
||||||
var multilinestring_xy = shell_start + serialize_geoms['multilinestring'] + shell_end;
|
var multilinestring_xy = shell_start + serialize_geoms['multilinestring'] + shell_end;
|
||||||
var multilinestring = shell_start + serialize_geoms_yx['multilinestring'] + shell_end;
|
var multilinestring = shell_start + serialize_geoms_yx['multilinestring'] + shell_end;
|
||||||
data = parser.read(multilinestring);
|
data = parser.read(multilinestring);
|
||||||
var output = parser.write(data);
|
var output = parser.write(data);
|
||||||
var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
var output = output.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
||||||
t.eq(output, multilinestring_xy, "MultiLine geometry round trips correctly.");
|
t.eq(output, multilinestring_xy, "MultiLine geometry round trips correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var test_content = ['<?xml version="1.0" encoding="utf-8" ?>\n<ogr:FeatureCollection\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://ogr.maptools.org/ testoutput.xsd"\n xmlns:ogr="http://ogr.maptools.org/"\n xmlns:gml="http://www.opengis.net/gml">\n <gml:boundedBy>\n <gml:Box>\n <gml:coord><gml:X>-1254041.389711702</gml:X><gml:Y>250906.9515983529</gml:Y></gml:coord>\n <gml:coord><gml:X>-634517.1199908922</gml:X><gml:Y>762236.2940800377</gml:Y></gml:coord>\n </gml:Box>\n </gml:boundedBy> \n <gml:featureMember>\n <ogr:states fid="F0">\n <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>\n <ogr:NAME>WY</ogr:NAME>\n <ogr:LONGNAME><![CDATA[Wyoming]]></ogr:LONGNAME>\n </ogr:states>\n </gml:featureMember>\n</ogr:FeatureCollection>\n',
|
var test_content = ['<?xml version="1.0" encoding="utf-8" ?>\n<ogr:FeatureCollection\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://ogr.maptools.org/ testoutput.xsd"\n xmlns:ogr="http://ogr.maptools.org/"\n xmlns:gml="http://www.opengis.net/gml">\n <gml:boundedBy>\n <gml:Box>\n <gml:coord><gml:X>-1254041.389711702</gml:X><gml:Y>250906.9515983529</gml:Y></gml:coord>\n <gml:coord><gml:X>-634517.1199908922</gml:X><gml:Y>762236.2940800377</gml:Y></gml:coord>\n </gml:Box>\n </gml:boundedBy> \n <gml:featureMember>\n <ogr:states fid="F0">\n <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>\n <ogr:NAME>WY</ogr:NAME>\n <ogr:LONGNAME><![CDATA[Wyoming]]></ogr:LONGNAME>\n </ogr:states>\n </gml:featureMember>\n</ogr:FeatureCollection>\n',
|
||||||
@@ -373,32 +373,32 @@
|
|||||||
'polygon': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 4,5 3,6 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>',
|
'polygon': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 4,5 3,6 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>',
|
||||||
'polygon_with_holes': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 4,5 3,6 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>11,12 14,15 13,16 11,12</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>',
|
'polygon_with_holes': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 4,5 3,6 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>11,12 14,15 13,16 11,12</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>',
|
||||||
'multipoint': '<gml:MultiPoint><gml:Point><gml:coordinates>1,2,3</gml:coordinates></gml:Point><gml:Point><gml:coordinates>4,5,6</gml:coordinates></gml:Point></gml:MultiPoint>',
|
'multipoint': '<gml:MultiPoint><gml:Point><gml:coordinates>1,2,3</gml:coordinates></gml:Point><gml:Point><gml:coordinates>4,5,6</gml:coordinates></gml:Point></gml:MultiPoint>',
|
||||||
'multilinestring': '<gml:MultiLineString><gml:LineString><gml:coordinates>1,2,3 4,5,6</gml:coordinates></gml:LineString><gml:LineString><gml:coordinates>11,12,13 14,15,16</gml:coordinates></gml:LineString></gml:MultiLineString>',
|
'multilinestring': '<gml:MultiLineString><gml:LineString><gml:coordinates>1,2,3 4,5,6</gml:coordinates></gml:LineString><gml:LineString><gml:coordinates>11,12,13 14,15,16</gml:coordinates></gml:LineString></gml:MultiLineString>',
|
||||||
'envelope': '<gml:Envelope><gml:lowerCorner>0 1</gml:lowerCorner><gml:upperCorner>20 21</gml:upperCorner></gml:Envelope>' // ,
|
'envelope': '<gml:Envelope><gml:lowerCorner>0 1</gml:lowerCorner><gml:upperCorner>20 21</gml:upperCorner></gml:Envelope>' // ,
|
||||||
// 'multipolygon_with_holes': '<gml:MultiPolygon><gml:Polygon><gml:outerBoundaryIs>1,2 4,5 3,6 1,2</gml:outerBoundaryIs><gml:innerBoundaryIs>11,12 14,15 13,16 11,12</gml:innerBoundaryIs></gml:Polygon><gml:Polygon><gml:outerBoundaryIs>101,102 104,105 103,106 101,102</gml:outerBoundaryIs><gml:innerBoundaryIs>111,112 114,115 113,116 111,112</gml:innerBoundaryIs></gml:Polygon></gml:MultiPolygon>'
|
// 'multipolygon_with_holes': '<gml:MultiPolygon><gml:Polygon><gml:outerBoundaryIs>1,2 4,5 3,6 1,2</gml:outerBoundaryIs><gml:innerBoundaryIs>11,12 14,15 13,16 11,12</gml:innerBoundaryIs></gml:Polygon><gml:Polygon><gml:outerBoundaryIs>101,102 104,105 103,106 101,102</gml:outerBoundaryIs><gml:innerBoundaryIs>111,112 114,115 113,116 111,112</gml:innerBoundaryIs></gml:Polygon></gml:MultiPolygon>'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The following data has the (x y) reordered to (y x), in 3 dimensions it goes from (x y z) to (y x z)
|
// The following data has the (x y) reordered to (y x), in 3 dimensions it goes from (x y z) to (y x z)
|
||||||
//
|
//
|
||||||
|
|
||||||
var serialize_geoms_yx = {
|
var serialize_geoms_yx = {
|
||||||
'point': '<gml:Point><gml:coordinates decimal="." cs="," ts=" ">2,1</gml:coordinates></gml:Point>',
|
'point': '<gml:Point><gml:coordinates decimal="." cs="," ts=" ">2,1</gml:coordinates></gml:Point>',
|
||||||
'linestring': '<gml:LineString><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4</gml:coordinates></gml:LineString>',
|
'linestring': '<gml:LineString><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4</gml:coordinates></gml:LineString>',
|
||||||
'polygon': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>',
|
'polygon': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>',
|
||||||
'multipoint': '<gml:MultiPoint><gml:pointMember><gml:Point><gml:coordinates decimal="." cs="," ts=" ">2,1</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates decimal="." cs="," ts=" ">5,4</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint>',
|
'multipoint': '<gml:MultiPoint><gml:pointMember><gml:Point><gml:coordinates decimal="." cs="," ts=" ">2,1</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates decimal="." cs="," ts=" ">5,4</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint>',
|
||||||
'multilinestring': '<gml:MultiLineString><gml:lineStringMember><gml:LineString><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString><gml:coordinates decimal="." cs="," ts=" ">12,11 15,14</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString>'
|
'multilinestring': '<gml:MultiLineString><gml:lineStringMember><gml:LineString><gml:coordinates decimal="." cs="," ts=" ">2,1 5,4</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString><gml:coordinates decimal="." cs="," ts=" ">12,11 15,14</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString>'
|
||||||
};
|
};
|
||||||
var geoms_yx = {
|
var geoms_yx = {
|
||||||
'point': '<gml:Point><gml:coordinates>2,1,3</gml:coordinates></gml:Point>',
|
'point': '<gml:Point><gml:coordinates>2,1,3</gml:coordinates></gml:Point>',
|
||||||
'linestring': '<gml:LineString><gml:coordinates>2,1,3 5,4,6</gml:coordinates></gml:LineString>',
|
'linestring': '<gml:LineString><gml:coordinates>2,1,3 5,4,6</gml:coordinates></gml:LineString>',
|
||||||
'polygon': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>',
|
'polygon': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>',
|
||||||
'polygon_with_holes': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>12,11 15,14 16,13 12,11</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>',
|
'polygon_with_holes': '<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,1 5,4 6,3 2,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>12,11 15,14 16,13 12,11</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>',
|
||||||
'multipoint': '<gml:MultiPoint><gml:Point><gml:coordinates>2,1,3</gml:coordinates></gml:Point><gml:Point><gml:coordinates>5,4,6</gml:coordinates></gml:Point></gml:MultiPoint>',
|
'multipoint': '<gml:MultiPoint><gml:Point><gml:coordinates>2,1,3</gml:coordinates></gml:Point><gml:Point><gml:coordinates>5,4,6</gml:coordinates></gml:Point></gml:MultiPoint>',
|
||||||
'multilinestring': '<gml:MultiLineString><gml:LineString><gml:coordinates>2,1,3 5,4,6</gml:coordinates></gml:LineString><gml:LineString><gml:coordinates>12,11,13 15,14,16</gml:coordinates></gml:LineString></gml:MultiLineString>',
|
'multilinestring': '<gml:MultiLineString><gml:LineString><gml:coordinates>2,1,3 5,4,6</gml:coordinates></gml:LineString><gml:LineString><gml:coordinates>12,11,13 15,14,16</gml:coordinates></gml:LineString></gml:MultiLineString>',
|
||||||
'envelope': '<gml:Envelope><gml:lowerCorner>1 0</gml:lowerCorner><gml:upperCorner>21 20</gml:upperCorner></gml:Envelope>'
|
'envelope': '<gml:Envelope><gml:lowerCorner>1 0</gml:lowerCorner><gml:upperCorner>21 20</gml:upperCorner></gml:Envelope>'
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -56,21 +56,21 @@
|
|||||||
var out = out.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
var out = out.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
||||||
t.eq(out, expected_result, "Output gave expected value");
|
t.eq(out, expected_result, "Output gave expected value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function test_Format_GeoRSS_gml_roundtrip(t) {
|
function test_Format_GeoRSS_gml_roundtrip(t) {
|
||||||
t.plan(input_gml.length);
|
t.plan(input_gml.length);
|
||||||
var parser = new OpenLayers.Format.GeoRSS();
|
var parser = new OpenLayers.Format.GeoRSS();
|
||||||
for(var i=0; i < input_gml.length; i++) {
|
for(var i=0; i < input_gml.length; i++) {
|
||||||
var feed = shell_start_gml+input_gml[i]+shell_end_gml;
|
var feed = shell_start_gml+input_gml[i]+shell_end_gml;
|
||||||
var data = parser.read(feed);
|
var data = parser.read(feed);
|
||||||
var out = parser.write(data);
|
var out = parser.write(data);
|
||||||
var expected_result = output_gml[i];
|
var expected_result = output_gml[i];
|
||||||
if (OpenLayers.Util.getBrowserName() == "opera") {
|
if (OpenLayers.Util.getBrowserName() == "opera") {
|
||||||
expected_result = expected_result.replace(/>/g, ">");
|
expected_result = expected_result.replace(/>/g, ">");
|
||||||
}
|
}
|
||||||
var out = out.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
var out = out.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
|
||||||
t.eq(out, expected_result, "Output gave expected value");
|
t.eq(out, expected_result, "Output gave expected value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var shell_start = '<feed xmlns="http://www.w3.org/2005/Atom" \n xmlns:georss="http://www.georss.org/georss">\n <title>scribble</title>\n <id>http://featureserver.org/featureserver.cgi/scribble?format=atom</id>\n <author><name>FeatureServer</name></author>\n';
|
var shell_start = '<feed xmlns="http://www.w3.org/2005/Atom" \n xmlns:georss="http://www.georss.org/georss">\n <title>scribble</title>\n <id>http://featureserver.org/featureserver.cgi/scribble?format=atom</id>\n <author><name>FeatureServer</name></author>\n';
|
||||||
@@ -81,21 +81,21 @@
|
|||||||
];
|
];
|
||||||
var output= ['<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/562.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">-5.9765625 -131.484375 -58.0078125 -112.5 -50.2734375 -32.34375 52.3828125 -114.609375 -35.5078125 -167.34375 -57.3046875 -146.953125 -34.1015625 -139.921875 -5.9765625 -131.484375</georss:polygon></item></rss>',
|
var output= ['<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/562.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">-5.9765625 -131.484375 -58.0078125 -112.5 -50.2734375 -32.34375 52.3828125 -114.609375 -35.5078125 -167.34375 -57.3046875 -146.953125 -34.1015625 -139.921875 -5.9765625 -131.484375</georss:polygon></item></rss>',
|
||||||
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: 00ccff<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/796.atom</link><georss:point xmlns:georss="http://www.georss.org/georss">75.5859375 15.46875</georss:point></item></rss>',
|
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: 00ccff<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/796.atom</link><georss:point xmlns:georss="http://www.georss.org/georss">75.5859375 15.46875</georss:point></item></rss>',
|
||||||
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 5</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 5<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/794.atom</link><georss:line xmlns:georss="http://www.georss.org/georss">28.828125 32.6953125 49.921875 34.8046875 39.375 58.0078125 39.375 58.0078125 40.078125 58.0078125 41.484375 58.0078125 43.59375 58.0078125 45.703125 58.7109375 47.8125 58.7109375 49.21875 58.7109375 51.328125 59.4140625 52.03125 59.4140625 54.140625 60.8203125 56.25 61.5234375 56.25 62.2265625 57.65625 62.2265625 57.65625 62.9296875 58.359375 63.6328125 58.359375 65.0390625 58.359375 65.7421875 59.0625 66.4453125 59.0625 67.1484375 59.0625 68.5546875 59.765625 69.9609375 59.765625 72.0703125 59.765625 73.4765625 59.765625 76.2890625 59.765625 78.3984375 59.765625 79.8046875 59.765625 81.9140625 59.765625 83.3203125 59.0625 84.7265625 59.0625 86.8359375 58.359375 87.5390625 58.359375 88.2421875 56.953125 89.6484375 56.25 91.0546875 54.84375 93.8671875 52.03125 96.6796875 51.328125 98.7890625 50.625 100.1953125 49.21875 102.3046875 48.515625 103.7109375 47.8125 104.4140625 47.109375 105.8203125 46.40625 106.5234375 46.40625 107.9296875 45.703125 109.3359375 45 110.7421875 43.59375 112.8515625 43.59375 114.2578125 43.59375 114.9609375 42.890625 117.0703125 42.890625 117.7734375 42.1875 118.4765625 42.1875 119.1796875 42.1875 119.8828125</georss:line></item></rss>'
|
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 5</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 5<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/794.atom</link><georss:line xmlns:georss="http://www.georss.org/georss">28.828125 32.6953125 49.921875 34.8046875 39.375 58.0078125 39.375 58.0078125 40.078125 58.0078125 41.484375 58.0078125 43.59375 58.0078125 45.703125 58.7109375 47.8125 58.7109375 49.21875 58.7109375 51.328125 59.4140625 52.03125 59.4140625 54.140625 60.8203125 56.25 61.5234375 56.25 62.2265625 57.65625 62.2265625 57.65625 62.9296875 58.359375 63.6328125 58.359375 65.0390625 58.359375 65.7421875 59.0625 66.4453125 59.0625 67.1484375 59.0625 68.5546875 59.765625 69.9609375 59.765625 72.0703125 59.765625 73.4765625 59.765625 76.2890625 59.765625 78.3984375 59.765625 79.8046875 59.765625 81.9140625 59.765625 83.3203125 59.0625 84.7265625 59.0625 86.8359375 58.359375 87.5390625 58.359375 88.2421875 56.953125 89.6484375 56.25 91.0546875 54.84375 93.8671875 52.03125 96.6796875 51.328125 98.7890625 50.625 100.1953125 49.21875 102.3046875 48.515625 103.7109375 47.8125 104.4140625 47.109375 105.8203125 46.40625 106.5234375 46.40625 107.9296875 45.703125 109.3359375 45 110.7421875 43.59375 112.8515625 43.59375 114.2578125 43.59375 114.9609375 42.890625 117.0703125 42.890625 117.7734375 42.1875 118.4765625 42.1875 119.1796875 42.1875 119.8828125</georss:line></item></rss>'
|
||||||
];
|
];
|
||||||
|
|
||||||
var shell_start_gml = '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss"> <title>scribble</title><id>http://featureserver.org/featureserver.cgi/scribble?format=atom</id><author><name>FeatureServer</name></author>';
|
var shell_start_gml = '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gml="http://www.opengis.net/gml" xmlns:georss="http://www.georss.org/georss"> <title>scribble</title><id>http://featureserver.org/featureserver.cgi/scribble?format=atom</id><author><name>FeatureServer</name></author>';
|
||||||
var shell_end_gml = '</feed>';
|
var shell_end_gml = '</feed>';
|
||||||
var input_gml = ['<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Point><gml:pos>0 10</gml:pos></gml:Point></georss:where></entry>',
|
var input_gml = ['<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Point><gml:pos>0 10</gml:pos></gml:Point></georss:where></entry>',
|
||||||
'<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>110,-50 110,-10 155,-10 155,-50 110,-50</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></georss:where></entry>',
|
'<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>110,-50 110,-10 155,-10 155,-50 110,-50</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></georss:where></entry>',
|
||||||
'<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:LineString><gml:coordinates>0,10 10,20</gml:coordinates></gml:LineString></georss:where></entry>',
|
'<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:LineString><gml:coordinates>0,10 10,20</gml:coordinates></gml:LineString></georss:where></entry>',
|
||||||
'<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Envelope><gml:lowerCorner>0 1</gml:lowerCorner><gml:upperCorner>20 21</gml:upperCorner></gml:Envelope></georss:where></entry>'
|
'<entry><id>http://featureserver.org/featureserver.cgi/scribble/111.atom</id><link href="http://featureserver.org/featureserver.cgi/scribble/111.atom"/><title>Feature 2</title><content type="html"><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</content><georss:where><gml:Envelope><gml:lowerCorner>0 1</gml:lowerCorner><gml:upperCorner>20 21</gml:upperCorner></gml:Envelope></georss:where></entry>'
|
||||||
];
|
];
|
||||||
var output_gml = ['<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:point xmlns:georss="http://www.georss.org/georss">0 10</georss:point></item></rss>',
|
var output_gml = ['<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:point xmlns:georss="http://www.georss.org/georss">0 10</georss:point></item></rss>',
|
||||||
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">110 -50 110 -10 155 -10 155 -50 110 -50</georss:polygon></item></rss>',
|
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">110 -50 110 -10 155 -10 155 -50 110 -50</georss:polygon></item></rss>',
|
||||||
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:line xmlns:georss="http://www.georss.org/georss">0 10 10 20</georss:line></item></rss>',
|
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:line xmlns:georss="http://www.georss.org/georss">0 10 10 20</georss:line></item></rss>',
|
||||||
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">0 1 0 21 20 21 20 1 0 1</georss:polygon></item></rss>'
|
'<rss xmlns="http://backend.userland.com/rss2"><item><title>Feature 2</title><description><b>strokeColor</b>: red<br /><b>title</b>: Feature 2<br /><b>author</b>: Your Name Here</description><link>http://featureserver.org/featureserver.cgi/scribble/111.atom</link><georss:polygon xmlns:georss="http://www.georss.org/georss">0 1 0 21 20 21 20 1 0 1</georss:polygon></item></rss>'
|
||||||
];
|
];
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -1,107 +1,107 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../../lib/OpenLayers.js"></script>
|
<script src="../../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function test_Handler_Path_constructor(t) {
|
function test_Handler_Path_constructor(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
control.id = Math.random();
|
control.id = Math.random();
|
||||||
var callbacks = {foo: "bar"};
|
var callbacks = {foo: "bar"};
|
||||||
var options = {bar: "foo"};
|
var options = {bar: "foo"};
|
||||||
|
|
||||||
var oldInit = OpenLayers.Handler.prototype.initialize;
|
var oldInit = OpenLayers.Handler.prototype.initialize;
|
||||||
|
|
||||||
OpenLayers.Handler.prototype.initialize = function(con, call, opt) {
|
OpenLayers.Handler.prototype.initialize = function(con, call, opt) {
|
||||||
t.eq(con.id, control.id,
|
t.eq(con.id, control.id,
|
||||||
"constructor calls parent with the correct control");
|
"constructor calls parent with the correct control");
|
||||||
t.eq(call, callbacks,
|
t.eq(call, callbacks,
|
||||||
"constructor calls parent with the correct callbacks");
|
"constructor calls parent with the correct callbacks");
|
||||||
t.eq(opt, options,
|
t.eq(opt, options,
|
||||||
"constructor calls parent with the correct options");
|
"constructor calls parent with the correct options");
|
||||||
}
|
}
|
||||||
var handler = new OpenLayers.Handler.Path(control, callbacks, options);
|
var handler = new OpenLayers.Handler.Path(control, callbacks, options);
|
||||||
|
|
||||||
OpenLayers.Handler.prototype.initialize = oldInit;
|
OpenLayers.Handler.prototype.initialize = oldInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_Path_activation(t) {
|
function test_Handler_Path_activation(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.Path(control);
|
var handler = new OpenLayers.Handler.Path(control);
|
||||||
handler.active = true;
|
handler.active = true;
|
||||||
var activated = handler.activate();
|
var activated = handler.activate();
|
||||||
t.ok(!activated,
|
t.ok(!activated,
|
||||||
"activate returns false if the handler was already active");
|
"activate returns false if the handler was already active");
|
||||||
handler.active = false;
|
handler.active = false;
|
||||||
activated = handler.activate();
|
activated = handler.activate();
|
||||||
t.ok(activated,
|
t.ok(activated,
|
||||||
"activate returns true if the handler was not already active");
|
"activate returns true if the handler was not already active");
|
||||||
activated = handler.deactivate();
|
activated = handler.deactivate();
|
||||||
t.ok(activated,
|
t.ok(activated,
|
||||||
"deactivate returns true if the handler was active already");
|
"deactivate returns true if the handler was active already");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_Path_bounds(t) {
|
function test_Handler_Path_bounds(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.Path(control, {});
|
var handler = new OpenLayers.Handler.Path(control, {});
|
||||||
var activated = handler.activate();
|
var activated = handler.activate();
|
||||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||||
handler.mousedown(evt);
|
handler.mousedown(evt);
|
||||||
handler.mouseup(evt);
|
handler.mouseup(evt);
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
|
||||||
handler.mousedown(evt);
|
handler.mousedown(evt);
|
||||||
handler.mouseup(evt);
|
handler.mouseup(evt);
|
||||||
t.ok(handler.line.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)), "Correct bounds");
|
t.ok(handler.line.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)), "Correct bounds");
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
|
||||||
handler.mousedown(evt);
|
handler.mousedown(evt);
|
||||||
var evt = {xy: new OpenLayers.Pixel(125, 100), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(125, 100), which: 1};
|
||||||
handler.mousemove(evt);
|
handler.mousemove(evt);
|
||||||
t.ok(!handler.line.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)), "Correct bounds after dragging without letting go. (Came out as "+handler.line.geometry.getBounds().toBBOX() + ".)");
|
t.ok(!handler.line.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)), "Correct bounds after dragging without letting go. (Came out as "+handler.line.geometry.getBounds().toBBOX() + ".)");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_Path_destroy(t) {
|
function test_Handler_Path_destroy(t) {
|
||||||
t.plan(6);
|
t.plan(6);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.Path(control, {foo: 'bar'});
|
var handler = new OpenLayers.Handler.Path(control, {foo: 'bar'});
|
||||||
|
|
||||||
handler.activate();
|
handler.activate();
|
||||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||||
handler.mousedown(evt);
|
handler.mousedown(evt);
|
||||||
|
|
||||||
t.ok(handler.layer,
|
t.ok(handler.layer,
|
||||||
"handler has a layer prior to destroy");
|
"handler has a layer prior to destroy");
|
||||||
t.ok(handler.point,
|
t.ok(handler.point,
|
||||||
"handler has a point prior to destroy");
|
"handler has a point prior to destroy");
|
||||||
t.ok(handler.line,
|
t.ok(handler.line,
|
||||||
"handler has a line prior to destroy");
|
"handler has a line prior to destroy");
|
||||||
handler.destroy();
|
handler.destroy();
|
||||||
t.eq(handler.layer, null,
|
t.eq(handler.layer, null,
|
||||||
"handler.layer is null after destroy");
|
"handler.layer is null after destroy");
|
||||||
t.eq(handler.point, null,
|
t.eq(handler.point, null,
|
||||||
"handler.point is null after destroy");
|
"handler.point is null after destroy");
|
||||||
t.eq(handler.line, null,
|
t.eq(handler.line, null,
|
||||||
"handler.line is null after destroy");
|
"handler.line is null after destroy");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map" style="width: 300px; height: 150px;"/>
|
<div id="map" style="width: 300px; height: 150px;"/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,113 +1,113 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../../lib/OpenLayers.js"></script>
|
<script src="../../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function test_Handler_Polygon_constructor(t) {
|
function test_Handler_Polygon_constructor(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
control.id = Math.random();
|
control.id = Math.random();
|
||||||
var callbacks = {foo: "bar"};
|
var callbacks = {foo: "bar"};
|
||||||
var options = {bar: "foo"};
|
var options = {bar: "foo"};
|
||||||
|
|
||||||
var oldInit = OpenLayers.Handler.prototype.initialize;
|
var oldInit = OpenLayers.Handler.prototype.initialize;
|
||||||
|
|
||||||
OpenLayers.Handler.prototype.initialize = function(con, call, opt) {
|
OpenLayers.Handler.prototype.initialize = function(con, call, opt) {
|
||||||
t.eq(con.id, control.id,
|
t.eq(con.id, control.id,
|
||||||
"constructor calls parent with the correct control");
|
"constructor calls parent with the correct control");
|
||||||
t.eq(call, callbacks,
|
t.eq(call, callbacks,
|
||||||
"constructor calls parent with the correct callbacks");
|
"constructor calls parent with the correct callbacks");
|
||||||
t.eq(opt, options,
|
t.eq(opt, options,
|
||||||
"constructor calls parent with the correct options");
|
"constructor calls parent with the correct options");
|
||||||
}
|
}
|
||||||
var handler = new OpenLayers.Handler.Polygon(control, callbacks, options);
|
var handler = new OpenLayers.Handler.Polygon(control, callbacks, options);
|
||||||
|
|
||||||
OpenLayers.Handler.prototype.initialize = oldInit;
|
OpenLayers.Handler.prototype.initialize = oldInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_Polygon_activation(t) {
|
function test_Handler_Polygon_activation(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.Polygon(control);
|
var handler = new OpenLayers.Handler.Polygon(control);
|
||||||
handler.active = true;
|
handler.active = true;
|
||||||
var activated = handler.activate();
|
var activated = handler.activate();
|
||||||
t.ok(!activated,
|
t.ok(!activated,
|
||||||
"activate returns false if the handler was already active");
|
"activate returns false if the handler was already active");
|
||||||
handler.active = false;
|
handler.active = false;
|
||||||
activated = handler.activate();
|
activated = handler.activate();
|
||||||
t.ok(activated,
|
t.ok(activated,
|
||||||
"activate returns true if the handler was not already active");
|
"activate returns true if the handler was not already active");
|
||||||
activated = handler.deactivate();
|
activated = handler.deactivate();
|
||||||
t.ok(activated,
|
t.ok(activated,
|
||||||
"deactivate returns true if the handler was active already");
|
"deactivate returns true if the handler was active already");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_Polygon_bounds(t) {
|
function test_Handler_Polygon_bounds(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.Polygon(control, {});
|
var handler = new OpenLayers.Handler.Polygon(control, {});
|
||||||
var activated = handler.activate();
|
var activated = handler.activate();
|
||||||
|
|
||||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||||
handler.mousedown(evt);
|
handler.mousedown(evt);
|
||||||
handler.mouseup(evt);
|
handler.mouseup(evt);
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
|
||||||
handler.mousedown(evt);
|
handler.mousedown(evt);
|
||||||
handler.mouseup(evt);
|
handler.mouseup(evt);
|
||||||
t.ok(handler.line.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)), "Correct bounds");
|
t.ok(handler.line.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)), "Correct bounds");
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 100), which: 1};
|
||||||
handler.mousedown(evt);
|
handler.mousedown(evt);
|
||||||
var evt = {xy: new OpenLayers.Pixel(125, 100), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(125, 100), which: 1};
|
||||||
handler.mousemove(evt);
|
handler.mousemove(evt);
|
||||||
t.ok(!handler.polygon.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)),
|
t.ok(!handler.polygon.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)),
|
||||||
"Correct bounds after dragging without letting go. (Came out as "+handler.line.geometry.getBounds().toBBOX() + ".)");
|
"Correct bounds after dragging without letting go. (Came out as "+handler.line.geometry.getBounds().toBBOX() + ".)");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_Polygon_destroy(t) {
|
function test_Handler_Polygon_destroy(t) {
|
||||||
t.plan(8);
|
t.plan(8);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.Polygon(control, {foo: 'bar'});
|
var handler = new OpenLayers.Handler.Polygon(control, {foo: 'bar'});
|
||||||
|
|
||||||
handler.activate();
|
handler.activate();
|
||||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||||
handler.mousedown(evt);
|
handler.mousedown(evt);
|
||||||
|
|
||||||
t.ok(handler.layer,
|
t.ok(handler.layer,
|
||||||
"handler has a layer prior to destroy");
|
"handler has a layer prior to destroy");
|
||||||
t.ok(handler.point,
|
t.ok(handler.point,
|
||||||
"handler has a point prior to destroy");
|
"handler has a point prior to destroy");
|
||||||
t.ok(handler.line,
|
t.ok(handler.line,
|
||||||
"handler has a line prior to destroy");
|
"handler has a line prior to destroy");
|
||||||
t.ok(handler.polygon,
|
t.ok(handler.polygon,
|
||||||
"handler has a polygon prior to destroy");
|
"handler has a polygon prior to destroy");
|
||||||
handler.destroy();
|
handler.destroy();
|
||||||
t.eq(handler.layer, null,
|
t.eq(handler.layer, null,
|
||||||
"handler.layer is null after destroy");
|
"handler.layer is null after destroy");
|
||||||
t.eq(handler.point, null,
|
t.eq(handler.point, null,
|
||||||
"handler.point is null after destroy");
|
"handler.point is null after destroy");
|
||||||
t.eq(handler.line, null,
|
t.eq(handler.line, null,
|
||||||
"handler.line is null after destroy");
|
"handler.line is null after destroy");
|
||||||
t.eq(handler.polygon, null,
|
t.eq(handler.polygon, null,
|
||||||
"handler.polygon is null after destroy");
|
"handler.polygon is null after destroy");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map" style="width: 300px; height: 150px;"/>
|
<div id="map" style="width: 300px; height: 150px;"/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,49 +1,49 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../../lib/OpenLayers.js"></script>
|
<script src="../../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function test_Handler_RegularPolygon_constructor(t) {
|
function test_Handler_RegularPolygon_constructor(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
control.id = Math.random();
|
control.id = Math.random();
|
||||||
var callbacks = {foo: "bar"};
|
var callbacks = {foo: "bar"};
|
||||||
var options = {bar: "foo"};
|
var options = {bar: "foo"};
|
||||||
|
|
||||||
var oldInit = OpenLayers.Handler.prototype.initialize;
|
var oldInit = OpenLayers.Handler.prototype.initialize;
|
||||||
|
|
||||||
OpenLayers.Handler.prototype.initialize = function(con, call, opt) {
|
OpenLayers.Handler.prototype.initialize = function(con, call, opt) {
|
||||||
t.eq(con.id, control.id,
|
t.eq(con.id, control.id,
|
||||||
"constructor calls parent with the correct control");
|
"constructor calls parent with the correct control");
|
||||||
t.eq(call, callbacks,
|
t.eq(call, callbacks,
|
||||||
"constructor calls parent with the correct callbacks");
|
"constructor calls parent with the correct callbacks");
|
||||||
t.eq(opt, options,
|
t.eq(opt, options,
|
||||||
"regular polygon constructor calls parent with the correct options");
|
"regular polygon constructor calls parent with the correct options");
|
||||||
}
|
}
|
||||||
var handler = new OpenLayers.Handler.RegularPolygon(control, callbacks, options);
|
var handler = new OpenLayers.Handler.RegularPolygon(control, callbacks, options);
|
||||||
|
|
||||||
OpenLayers.Handler.prototype.initialize = oldInit;
|
OpenLayers.Handler.prototype.initialize = oldInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_RegularPolygon_activation(t) {
|
function test_Handler_RegularPolygon_activation(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.RegularPolygon(control);
|
var handler = new OpenLayers.Handler.RegularPolygon(control);
|
||||||
handler.active = true;
|
handler.active = true;
|
||||||
var activated = handler.activate();
|
var activated = handler.activate();
|
||||||
t.ok(!activated,
|
t.ok(!activated,
|
||||||
"activate returns false if the handler was already active");
|
"activate returns false if the handler was already active");
|
||||||
handler.active = false;
|
handler.active = false;
|
||||||
activated = handler.activate();
|
activated = handler.activate();
|
||||||
t.ok(activated,
|
t.ok(activated,
|
||||||
"activate returns true if the handler was not already active");
|
"activate returns true if the handler was not already active");
|
||||||
activated = handler.deactivate();
|
activated = handler.deactivate();
|
||||||
t.ok(activated,
|
t.ok(activated,
|
||||||
"deactivate returns true if the handler was active already");
|
"deactivate returns true if the handler was active already");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_RegularPolygon_deactivation(t) {
|
function test_Handler_RegularPolygon_deactivation(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
@@ -58,91 +58,91 @@
|
|||||||
"deactivate doesn't throw an error if layer was" +
|
"deactivate doesn't throw an error if layer was" +
|
||||||
" previously destroyed");
|
" previously destroyed");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_RegularPolygon_four_corners(t) {
|
function test_Handler_RegularPolygon_four_corners(t) {
|
||||||
t.plan(7);
|
t.plan(7);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.RegularPolygon(control, {});
|
var handler = new OpenLayers.Handler.RegularPolygon(control, {});
|
||||||
var activated = handler.activate();
|
var activated = handler.activate();
|
||||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||||
handler.down(evt);
|
handler.down(evt);
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 75), which: 1};
|
||||||
handler.move(evt);
|
handler.move(evt);
|
||||||
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
||||||
"-35.15625,-35.15625,35.15625,35.15625",
|
"-35.15625,-35.15625,35.15625,35.15625",
|
||||||
"correct bounds after move");
|
"correct bounds after move");
|
||||||
t.eq(handler.feature.geometry.components[0].components.length, 5,
|
t.eq(handler.feature.geometry.components[0].components.length, 5,
|
||||||
"geometry has 5 components");
|
"geometry has 5 components");
|
||||||
t.eq(handler.feature.geometry.CLASS_NAME,
|
t.eq(handler.feature.geometry.CLASS_NAME,
|
||||||
"OpenLayers.Geometry.Polygon",
|
"OpenLayers.Geometry.Polygon",
|
||||||
"geometry is a polygon");
|
"geometry is a polygon");
|
||||||
t.eq(handler.radius, 25*1.40625, "feature radius as set on handler");
|
t.eq(handler.radius, 25*1.40625, "feature radius as set on handler");
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 80), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 80), which: 1};
|
||||||
handler.move(evt);
|
handler.move(evt);
|
||||||
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
||||||
"-35.15625,-35.15625,35.15625,35.15625",
|
"-35.15625,-35.15625,35.15625,35.15625",
|
||||||
"correct bounds after move with a fixed radius");
|
"correct bounds after move with a fixed radius");
|
||||||
handler.cancel();
|
handler.cancel();
|
||||||
handler.setOptions({radius:2 / Math.sqrt(2)});
|
handler.setOptions({radius:2 / Math.sqrt(2)});
|
||||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||||
handler.down(evt);
|
handler.down(evt);
|
||||||
|
|
||||||
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
||||||
"-1,-1,1,1",
|
"-1,-1,1,1",
|
||||||
"bounds with manual radius setting");
|
"bounds with manual radius setting");
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 90), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 90), which: 1};
|
||||||
handler.move(evt);
|
handler.move(evt);
|
||||||
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
||||||
"34.15625,-22.09375,36.15625,-20.09375",
|
"34.15625,-22.09375,36.15625,-20.09375",
|
||||||
"bounds with manual radius setting and mousemove");
|
"bounds with manual radius setting and mousemove");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Handler_RegularPolygon_circle(t) {
|
function test_Handler_RegularPolygon_circle(t) {
|
||||||
t.plan(7);
|
t.plan(7);
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.RegularPolygon(control, {}, {'sides':40});
|
var handler = new OpenLayers.Handler.RegularPolygon(control, {}, {'sides':40});
|
||||||
var activated = handler.activate();
|
var activated = handler.activate();
|
||||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||||
handler.down(evt);
|
handler.down(evt);
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 75), which: 1};
|
||||||
handler.move(evt);
|
handler.move(evt);
|
||||||
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
||||||
"-35.15625,-35.15625,35.15625,35.15625",
|
"-35.15625,-35.15625,35.15625,35.15625",
|
||||||
"correct bounds after move");
|
"correct bounds after move");
|
||||||
t.eq(handler.feature.geometry.components[0].components.length, 41,
|
t.eq(handler.feature.geometry.components[0].components.length, 41,
|
||||||
"geometry has correct numbre of components");
|
"geometry has correct numbre of components");
|
||||||
t.eq(handler.feature.geometry.CLASS_NAME,
|
t.eq(handler.feature.geometry.CLASS_NAME,
|
||||||
"OpenLayers.Geometry.Polygon",
|
"OpenLayers.Geometry.Polygon",
|
||||||
"geometry is a polygon");
|
"geometry is a polygon");
|
||||||
t.eq(handler.radius, 25*1.40625, "feature radius as set on handler");
|
t.eq(handler.radius, 25*1.40625, "feature radius as set on handler");
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 80), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 80), which: 1};
|
||||||
handler.move(evt);
|
handler.move(evt);
|
||||||
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
||||||
"-35.823348,-35.823348,35.823348,35.823348",
|
"-35.823348,-35.823348,35.823348,35.823348",
|
||||||
"correct bounds after move with fixed radius");
|
"correct bounds after move with fixed radius");
|
||||||
handler.cancel();
|
handler.cancel();
|
||||||
handler.setOptions({radius:1});
|
handler.setOptions({radius:1});
|
||||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||||
handler.down(evt);
|
handler.down(evt);
|
||||||
|
|
||||||
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
||||||
"-0.996917,-0.996917,0.996917,0.996917",
|
"-0.996917,-0.996917,0.996917,0.996917",
|
||||||
"bounds with manual radius setting");
|
"bounds with manual radius setting");
|
||||||
var evt = {xy: new OpenLayers.Pixel(175, 80), which: 1};
|
var evt = {xy: new OpenLayers.Pixel(175, 80), which: 1};
|
||||||
handler.move(evt);
|
handler.move(evt);
|
||||||
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
t.eq(handler.feature.geometry.getBounds().toBBOX(),
|
||||||
"34.159333,-8.028167,36.153167,-6.034333",
|
"34.159333,-8.028167,36.153167,-6.034333",
|
||||||
"bounds with manual radius setting and mousemove");
|
"bounds with manual radius setting and mousemove");
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,10 +185,10 @@
|
|||||||
// should result in a 10 x 5 rectangle
|
// should result in a 10 x 5 rectangle
|
||||||
handler.move({xy: {x: 20, y: 15}});
|
handler.move({xy: {x: 20, y: 15}});
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map" style="width: 300px; height: 150px;"/>
|
<div id="map" style="width: 300px; height: 150px;"/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,120 +1,120 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
|
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
|
||||||
<script src="../../lib/OpenLayers.js"></script>
|
<script src="../../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var layer;
|
var layer;
|
||||||
|
|
||||||
function test_01_Layer_Yahoo_constructor (t) {
|
function test_01_Layer_Yahoo_constructor (t) {
|
||||||
t.plan( 4 );
|
t.plan( 4 );
|
||||||
|
|
||||||
var tempEventPane = OpenLayers.Layer.EventPane.prototype.initialize;
|
var tempEventPane = OpenLayers.Layer.EventPane.prototype.initialize;
|
||||||
OpenLayers.Layer.EventPane.prototype.initialize = function(name, options) {
|
OpenLayers.Layer.EventPane.prototype.initialize = function(name, options) {
|
||||||
t.ok(name == g_Name, "EventPane initialize() called with correct name");
|
t.ok(name == g_Name, "EventPane initialize() called with correct name");
|
||||||
t.ok(options == g_Options, "EventPane initialize() called with correct options");
|
t.ok(options == g_Options, "EventPane initialize() called with correct options");
|
||||||
}
|
}
|
||||||
|
|
||||||
var tempFixedZoomLevels = OpenLayers.Layer.FixedZoomLevels.prototype.initialize;
|
var tempFixedZoomLevels = OpenLayers.Layer.FixedZoomLevels.prototype.initialize;
|
||||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize = function(name, options) {
|
OpenLayers.Layer.FixedZoomLevels.prototype.initialize = function(name, options) {
|
||||||
t.ok(name == g_Name, "FixedZoomLevels initialize() called with correct name");
|
t.ok(name == g_Name, "FixedZoomLevels initialize() called with correct name");
|
||||||
t.ok(options == g_Options, "FixedZoomLevels initialize() called with correct options");
|
t.ok(options == g_Options, "FixedZoomLevels initialize() called with correct options");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
g_Name = {};
|
g_Name = {};
|
||||||
g_Options = {};
|
g_Options = {};
|
||||||
var l = new OpenLayers.Layer.Yahoo(g_Name, g_Options);
|
var l = new OpenLayers.Layer.Yahoo(g_Name, g_Options);
|
||||||
|
|
||||||
OpenLayers.Layer.EventPane.prototype.initialize = tempEventPane;
|
OpenLayers.Layer.EventPane.prototype.initialize = tempEventPane;
|
||||||
OpenLayers.Layer.FixedZoomLevels.prototype.initialize = tempFixedZoomLevels;
|
OpenLayers.Layer.FixedZoomLevels.prototype.initialize = tempFixedZoomLevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_02_Layer_Yahoo_loadMapObject(t) {
|
function test_02_Layer_Yahoo_loadMapObject(t) {
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
|
|
||||||
var temp = YMap;
|
var temp = YMap;
|
||||||
YMap = OpenLayers.Class({
|
YMap = OpenLayers.Class({
|
||||||
initialize: function(div, type, size) {
|
initialize: function(div, type, size) {
|
||||||
t.ok(div == g_Div, "correct div passed to YMap constructor");
|
t.ok(div == g_Div, "correct div passed to YMap constructor");
|
||||||
t.ok(type == g_Type, "correct type passed to YMap constructor");
|
t.ok(type == g_Type, "correct type passed to YMap constructor");
|
||||||
t.ok(size == g_YMapSize, "correct size passed to YMap constructor");
|
t.ok(size == g_YMapSize, "correct size passed to YMap constructor");
|
||||||
},
|
},
|
||||||
disableKeyControls: function() {
|
disableKeyControls: function() {
|
||||||
t.ok(true, "disableKeyControls called on map object");
|
t.ok(true, "disableKeyControls called on map object");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
g_Div = {};
|
g_Div = {};
|
||||||
g_Type = {};
|
g_Type = {};
|
||||||
g_MapSize = {};
|
g_MapSize = {};
|
||||||
g_YMapSize = {};
|
g_YMapSize = {};
|
||||||
|
|
||||||
var l = new OpenLayers.Layer.Yahoo();
|
var l = new OpenLayers.Layer.Yahoo();
|
||||||
l.div = g_Div;
|
l.div = g_Div;
|
||||||
l.type = g_Type;
|
l.type = g_Type;
|
||||||
l.map = {
|
l.map = {
|
||||||
'getSize': function() {
|
'getSize': function() {
|
||||||
return g_MapSize;
|
return g_MapSize;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
l.getMapObjectSizeFromOLSize = function(mapSize) {
|
l.getMapObjectSizeFromOLSize = function(mapSize) {
|
||||||
t.ok(mapSize == g_MapSize, "correctly translating map size from ol to YSize");
|
t.ok(mapSize == g_MapSize, "correctly translating map size from ol to YSize");
|
||||||
return g_YMapSize;
|
return g_YMapSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
l.loadMapObject();
|
l.loadMapObject();
|
||||||
|
|
||||||
YMap = temp;
|
YMap = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_03_Layer_Yahoo_onMapResize(t) {
|
function test_03_Layer_Yahoo_onMapResize(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
|
|
||||||
g_MapSize = {};
|
g_MapSize = {};
|
||||||
g_YMapSize = {};
|
g_YMapSize = {};
|
||||||
|
|
||||||
var l = new OpenLayers.Layer.Yahoo();
|
var l = new OpenLayers.Layer.Yahoo();
|
||||||
l.mapObject = {
|
l.mapObject = {
|
||||||
'resizeTo': function(size) {
|
'resizeTo': function(size) {
|
||||||
t.ok(size == g_YMapSize, "correct YSize passed to reiszeTo on map object");
|
t.ok(size == g_YMapSize, "correct YSize passed to reiszeTo on map object");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
l.map = {
|
l.map = {
|
||||||
'getSize': function() {
|
'getSize': function() {
|
||||||
return g_MapSize;
|
return g_MapSize;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
l.getMapObjectSizeFromOLSize = function(mapSize) {
|
l.getMapObjectSizeFromOLSize = function(mapSize) {
|
||||||
t.ok(mapSize == g_MapSize, "correctly translating map size from ol to YSize");
|
t.ok(mapSize == g_MapSize, "correctly translating map size from ol to YSize");
|
||||||
return g_YMapSize;
|
return g_YMapSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
l.onMapResize();
|
l.onMapResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_04_Layer_Yahoo_getMapObjectSizeFromOLSize(t) {
|
function test_04_Layer_Yahoo_getMapObjectSizeFromOLSize(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
|
|
||||||
var temp = YSize;
|
var temp = YSize;
|
||||||
YSize = function(w, h) {
|
YSize = function(w, h) {
|
||||||
t.ok(w == g_Size.w, "correct width passed to YSize constructor");
|
t.ok(w == g_Size.w, "correct width passed to YSize constructor");
|
||||||
t.ok(h == g_Size.h, "correct height passed to YSize constructor");
|
t.ok(h == g_Size.h, "correct height passed to YSize constructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Size = {
|
g_Size = {
|
||||||
'w': {},
|
'w': {},
|
||||||
'h': {}
|
'h': {}
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenLayers.Layer.Yahoo.prototype.getMapObjectSizeFromOLSize(g_Size);
|
OpenLayers.Layer.Yahoo.prototype.getMapObjectSizeFromOLSize(g_Size);
|
||||||
|
|
||||||
YSize = temp;
|
YSize = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,59 +1,59 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../../lib/OpenLayers.js"></script>
|
<script src="../../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function test_Popup_Anchored_setOpacity(t) {
|
function test_Popup_Anchored_setOpacity(t) {
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
var opacity = 0.5;
|
var opacity = 0.5;
|
||||||
var id = "chicken";
|
var id = "chicken";
|
||||||
var w = 500;
|
var w = 500;
|
||||||
var h = 400;
|
var h = 400;
|
||||||
var sz = new OpenLayers.Size(w,h);
|
var sz = new OpenLayers.Size(w,h);
|
||||||
var lon = 5;
|
var lon = 5;
|
||||||
var lat = 40;
|
var lat = 40;
|
||||||
var ll = new OpenLayers.LonLat(lon, lat);
|
var ll = new OpenLayers.LonLat(lon, lat);
|
||||||
var content = "foo";
|
var content = "foo";
|
||||||
var x = 50;
|
var x = 50;
|
||||||
var y = 100;
|
var y = 100;
|
||||||
|
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
map.addLayer(new OpenLayers.Layer('name', {'isBaseLayer':true}));
|
map.addLayer(new OpenLayers.Layer('name', {'isBaseLayer':true}));
|
||||||
map.zoomToMaxExtent();
|
map.zoomToMaxExtent();
|
||||||
|
|
||||||
var popup = new OpenLayers.Popup.AnchoredBubble(id,
|
var popup = new OpenLayers.Popup.AnchoredBubble(id,
|
||||||
ll,
|
ll,
|
||||||
sz,
|
sz,
|
||||||
content,
|
content,
|
||||||
null,
|
null,
|
||||||
false);
|
false);
|
||||||
map.addPopup(popup);
|
map.addPopup(popup);
|
||||||
|
|
||||||
popup.setOpacity(opacity);
|
popup.setOpacity(opacity);
|
||||||
popup.draw(new OpenLayers.Pixel(x, y));
|
popup.draw(new OpenLayers.Pixel(x, y));
|
||||||
|
|
||||||
if (navigator.appName.indexOf("Microsoft") == -1) {
|
if (navigator.appName.indexOf("Microsoft") == -1) {
|
||||||
t.eq(parseFloat(popup.div.style.opacity), opacity, "good default popup.opacity");
|
t.eq(parseFloat(popup.div.style.opacity), opacity, "good default popup.opacity");
|
||||||
} else {
|
} else {
|
||||||
t.eq(popup.div.style.filter, "alpha(opacity=" + opacity*100 + ")", "good default popup.opacity");
|
t.eq(popup.div.style.filter, "alpha(opacity=" + opacity*100 + ")", "good default popup.opacity");
|
||||||
}
|
}
|
||||||
|
|
||||||
t.ok(popup.groupDiv!=null, "popup.groupDiv exists");
|
t.ok(popup.groupDiv!=null, "popup.groupDiv exists");
|
||||||
t.ok(popup.groupDiv.parentNode!=null, "popup.groupDiv.parentNode exists");
|
t.ok(popup.groupDiv.parentNode!=null, "popup.groupDiv.parentNode exists");
|
||||||
t.ok(popup.groupDiv.parentNode.getElementsByTagName("span").length > 0, "popup.groupDiv.parentNode has SPAN children");
|
t.ok(popup.groupDiv.parentNode.getElementsByTagName("span").length > 0, "popup.groupDiv.parentNode has SPAN children");
|
||||||
|
|
||||||
var ricoCornerDiv = popup.groupDiv.parentNode.getElementsByTagName("span")[0];
|
var ricoCornerDiv = popup.groupDiv.parentNode.getElementsByTagName("span")[0];
|
||||||
if (navigator.appName.indexOf("Microsoft") == -1) {
|
if (navigator.appName.indexOf("Microsoft") == -1) {
|
||||||
t.eq(parseFloat(ricoCornerDiv.style.opacity), opacity, "good default ricoCornerDiv.opacity");
|
t.eq(parseFloat(ricoCornerDiv.style.opacity), opacity, "good default ricoCornerDiv.opacity");
|
||||||
} else {
|
} else {
|
||||||
t.eq(ricoCornerDiv.style.filter, "alpha(opacity=" + opacity*100 + ")", "good default ricoCornerDiv.opacity");
|
t.eq(ricoCornerDiv.style.filter, "alpha(opacity=" + opacity*100 + ")", "good default ricoCornerDiv.opacity");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map" style="width:512px; height:256px"> </div>
|
<div id="map" style="width:512px; height:256px"> </div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,41 +1,41 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../../lib/OpenLayers.js"></script>
|
<script src="../../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function test_Logical_constructor(t) {
|
function test_Logical_constructor(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
|
||||||
var options = {'foo': 'bar'};
|
var options = {'foo': 'bar'};
|
||||||
var rule = new OpenLayers.Rule.Logical(options);
|
var rule = new OpenLayers.Rule.Logical(options);
|
||||||
t.ok(rule instanceof OpenLayers.Rule.Logical,
|
t.ok(rule instanceof OpenLayers.Rule.Logical,
|
||||||
"new OpenLayers.Rule.Logical returns object" );
|
"new OpenLayers.Rule.Logical returns object" );
|
||||||
t.eq(rule.foo, "bar", "constructor sets options correctly");
|
t.eq(rule.foo, "bar", "constructor sets options correctly");
|
||||||
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
|
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Logical_destroy(t) {
|
function test_Logical_destroy(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|
||||||
var rule = new OpenLayers.Rule.Logical();
|
var rule = new OpenLayers.Rule.Logical();
|
||||||
rule.destroy();
|
rule.destroy();
|
||||||
t.eq(rule.rules, null, "rules array nulled properly");
|
t.eq(rule.rules, null, "rules array nulled properly");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Logical_evaluate(t) {
|
function test_Logical_evaluate(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|
||||||
var rule = new OpenLayers.Rule.Logical({
|
var rule = new OpenLayers.Rule.Logical({
|
||||||
type: OpenLayers.Rule.Logical.NOT});
|
type: OpenLayers.Rule.Logical.NOT});
|
||||||
rule.rules.push(new OpenLayers.Rule());
|
rule.rules.push(new OpenLayers.Rule());
|
||||||
|
|
||||||
var feature = new OpenLayers.Feature.Vector();
|
var feature = new OpenLayers.Feature.Vector();
|
||||||
|
|
||||||
t.eq(rule.evaluate(feature), false,
|
t.eq(rule.evaluate(feature), false,
|
||||||
"feature evaluates to false correctly.");
|
"feature evaluates to false correctly.");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,146 +1,146 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../lib/OpenLayers.js"></script>
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function test_Style_constructor(t) {
|
function test_Style_constructor(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
|
||||||
var options = {'foo': 'bar'};
|
var options = {'foo': 'bar'};
|
||||||
var style = new OpenLayers.Style(null, options);
|
var style = new OpenLayers.Style(null, options);
|
||||||
t.ok(style instanceof OpenLayers.Style,
|
t.ok(style instanceof OpenLayers.Style,
|
||||||
"new OpenLayers.Style returns object" );
|
"new OpenLayers.Style returns object" );
|
||||||
t.eq(style.foo, "bar", "constructor sets options correctly");
|
t.eq(style.foo, "bar", "constructor sets options correctly");
|
||||||
t.eq(typeof style.createStyle, "function", "style has a createStyle function");
|
t.eq(typeof style.createStyle, "function", "style has a createStyle function");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Style_create(t) {
|
function test_Style_create(t) {
|
||||||
t.plan(10);
|
t.plan(10);
|
||||||
|
|
||||||
var map = new OpenLayers.Map("map");
|
var map = new OpenLayers.Map("map");
|
||||||
|
|
||||||
var layer = new OpenLayers.Layer.Vector("layer");
|
var layer = new OpenLayers.Layer.Vector("layer");
|
||||||
|
|
||||||
var baseStyle = OpenLayers.Util.extend(
|
var baseStyle = OpenLayers.Util.extend(
|
||||||
OpenLayers.Feature.Vector.style["default"],
|
OpenLayers.Feature.Vector.style["default"],
|
||||||
{externalGraphic: "bar${foo}.png"});
|
{externalGraphic: "bar${foo}.png"});
|
||||||
|
|
||||||
var style = new OpenLayers.Style(baseStyle);
|
var style = new OpenLayers.Style(baseStyle);
|
||||||
|
|
||||||
var rule1 = new OpenLayers.Rule.FeatureId({
|
var rule1 = new OpenLayers.Rule.FeatureId({
|
||||||
fids: ["1"],
|
fids: ["1"],
|
||||||
symbolizer: {"Point": {fillColor: "green"}},
|
symbolizer: {"Point": {fillColor: "green"}},
|
||||||
maxScaleDenominator: 500000});
|
maxScaleDenominator: 500000});
|
||||||
var rule2 = new OpenLayers.Rule.FeatureId({
|
var rule2 = new OpenLayers.Rule.FeatureId({
|
||||||
fids: ["1"],
|
fids: ["1"],
|
||||||
symbolizer: {"Point": {fillColor: "yellow"}},
|
symbolizer: {"Point": {fillColor: "yellow"}},
|
||||||
minScaleDenominator: 500000,
|
minScaleDenominator: 500000,
|
||||||
maxScaleDenominator: 1000000});
|
maxScaleDenominator: 1000000});
|
||||||
var rule3 = new OpenLayers.Rule.FeatureId({
|
var rule3 = new OpenLayers.Rule.FeatureId({
|
||||||
fids: ["1"],
|
fids: ["1"],
|
||||||
symbolizer: {"Point": {fillColor: "red"}},
|
symbolizer: {"Point": {fillColor: "red"}},
|
||||||
minScaleDenominator: 1000000,
|
minScaleDenominator: 1000000,
|
||||||
maxScaleDenominator: 2500000});
|
maxScaleDenominator: 2500000});
|
||||||
style.addRules([rule1, rule2, rule3]);
|
style.addRules([rule1, rule2, rule3]);
|
||||||
|
|
||||||
var feature = new OpenLayers.Feature.Vector(
|
var feature = new OpenLayers.Feature.Vector(
|
||||||
new OpenLayers.Geometry.Point(3,5),
|
new OpenLayers.Geometry.Point(3,5),
|
||||||
{"foo": "bar"},
|
{"foo": "bar"},
|
||||||
style);
|
style);
|
||||||
|
|
||||||
feature.fid = "1";
|
feature.fid = "1";
|
||||||
// for this fid, the above rule should apply
|
// for this fid, the above rule should apply
|
||||||
|
|
||||||
layer.addFeatures([feature]);
|
layer.addFeatures([feature]);
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
map.setBaseLayer(layer);
|
map.setBaseLayer(layer);
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(3,5), 10);
|
map.setCenter(new OpenLayers.LonLat(3,5), 10);
|
||||||
|
|
||||||
// at this scale, the feature should be green
|
// at this scale, the feature should be green
|
||||||
var createdStyle = style.createStyle(feature);
|
var createdStyle = style.createStyle(feature);
|
||||||
t.eq(createdStyle.externalGraphic, "barbar.png", "Calculated property style correctly.");
|
t.eq(createdStyle.externalGraphic, "barbar.png", "Calculated property style correctly.");
|
||||||
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
|
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
|
||||||
t.eq(createdStyle.fillColor, "green", "Point symbolizer from rule applied correctly.");
|
t.eq(createdStyle.fillColor, "green", "Point symbolizer from rule applied correctly.");
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(3,5), 9);
|
map.setCenter(new OpenLayers.LonLat(3,5), 9);
|
||||||
// at this scale, the feature should be red
|
// at this scale, the feature should be red
|
||||||
createdStyle = style.createStyle(feature);
|
createdStyle = style.createStyle(feature);
|
||||||
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
|
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
|
||||||
t.eq(createdStyle.fillColor, "yellow", "Point symbolizer from rule applied correctly.");
|
t.eq(createdStyle.fillColor, "yellow", "Point symbolizer from rule applied correctly.");
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(3,5), 8);
|
map.setCenter(new OpenLayers.LonLat(3,5), 8);
|
||||||
// at this scale, the feature should be yellow
|
// at this scale, the feature should be yellow
|
||||||
createdStyle = style.createStyle(feature);
|
createdStyle = style.createStyle(feature);
|
||||||
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
|
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
|
||||||
t.eq(createdStyle.fillColor, "red", "Point symbolizer from rule applied correctly.");
|
t.eq(createdStyle.fillColor, "red", "Point symbolizer from rule applied correctly.");
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(3,5), 7);
|
map.setCenter(new OpenLayers.LonLat(3,5), 7);
|
||||||
// at this scale, the feature should be invisible
|
// at this scale, the feature should be invisible
|
||||||
createdStyle = style.createStyle(feature);
|
createdStyle = style.createStyle(feature);
|
||||||
t.eq(createdStyle.display, "none", "Feature is invisible at scale "+map.getScale());
|
t.eq(createdStyle.display, "none", "Feature is invisible at scale "+map.getScale());
|
||||||
t.eq(createdStyle.fillColor, baseStyle.fillColor, "Point symbolizer from base style applied correctly.");
|
t.eq(createdStyle.fillColor, baseStyle.fillColor, "Point symbolizer from base style applied correctly.");
|
||||||
|
|
||||||
feature.fid = "2";
|
feature.fid = "2";
|
||||||
// now the rule should not apply
|
// now the rule should not apply
|
||||||
|
|
||||||
createdStyle = style.createStyle(feature);
|
createdStyle = style.createStyle(feature);
|
||||||
t.eq(createdStyle.fillColor, baseStyle.fillColor, "Correct style for rule that does not apply to fid=\"2\".");
|
t.eq(createdStyle.fillColor, baseStyle.fillColor, "Correct style for rule that does not apply to fid=\"2\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Style_createStyle(t) {
|
function test_Style_createStyle(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
var style = new OpenLayers.Style();
|
var style = new OpenLayers.Style();
|
||||||
var rule = new OpenLayers.Rule({
|
var rule = new OpenLayers.Rule({
|
||||||
id: Math.random()
|
id: Math.random()
|
||||||
});
|
});
|
||||||
var elseRule = new OpenLayers.Rule({
|
var elseRule = new OpenLayers.Rule({
|
||||||
id: Math.random(),
|
id: Math.random(),
|
||||||
elseFilter: true
|
elseFilter: true
|
||||||
});
|
});
|
||||||
style.addRules([rule, elseRule]);
|
style.addRules([rule, elseRule]);
|
||||||
|
|
||||||
// test that applySymbolizer is only called with rule
|
// test that applySymbolizer is only called with rule
|
||||||
style.applySymbolizer = function(r) {
|
style.applySymbolizer = function(r) {
|
||||||
t.eq(r.id, rule.id, "(plain) applySymbolizer called with correct rule");
|
t.eq(r.id, rule.id, "(plain) applySymbolizer called with correct rule");
|
||||||
}
|
}
|
||||||
style.createStyle(new OpenLayers.Feature.Vector());
|
style.createStyle(new OpenLayers.Feature.Vector());
|
||||||
|
|
||||||
rule.evaluate = function() {return false;};
|
rule.evaluate = function() {return false;};
|
||||||
style.applySymbolizer = function(r) {
|
style.applySymbolizer = function(r) {
|
||||||
t.eq(r.id, elseRule.id, "(else) applySymbolizer called with correct rule");
|
t.eq(r.id, elseRule.id, "(else) applySymbolizer called with correct rule");
|
||||||
}
|
}
|
||||||
style.createStyle(new OpenLayers.Feature.Vector());
|
style.createStyle(new OpenLayers.Feature.Vector());
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Style_context(t) {
|
function test_Style_context(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
var context = {
|
var context = {
|
||||||
foo: "bar",
|
foo: "bar",
|
||||||
size: 10};
|
size: 10};
|
||||||
var rule = new OpenLayers.Rule.Comparison({
|
var rule = new OpenLayers.Rule.Comparison({
|
||||||
type: OpenLayers.Rule.Comparison.LESS_THAN,
|
type: OpenLayers.Rule.Comparison.LESS_THAN,
|
||||||
context: context,
|
context: context,
|
||||||
property: "size",
|
property: "size",
|
||||||
value: 11,
|
value: 11,
|
||||||
symbolizer: {"Point": {externalGraphic: "${foo}.png"}}});
|
symbolizer: {"Point": {externalGraphic: "${foo}.png"}}});
|
||||||
var style = new OpenLayers.Style();
|
var style = new OpenLayers.Style();
|
||||||
style.addRules([rule]);
|
style.addRules([rule]);
|
||||||
var styleHash = style.createStyle(new OpenLayers.Feature.Vector());
|
var styleHash = style.createStyle(new OpenLayers.Feature.Vector());
|
||||||
t.eq(styleHash.externalGraphic, "bar.png", "correctly evaluated rule against a custom context");
|
t.eq(styleHash.externalGraphic, "bar.png", "correctly evaluated rule against a custom context");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Style_destroy(t) {
|
function test_Style_destroy(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|
||||||
var style = new OpenLayers.Style();
|
var style = new OpenLayers.Style();
|
||||||
style.destroy();
|
style.destroy();
|
||||||
t.eq(style.rules, null, "rules array nulled properly");
|
t.eq(style.rules, null, "rules array nulled properly");
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map" style="width:500px;height:500px"></div>
|
<div id="map" style="width:500px;height:500px"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user