Compare commits

...

5 Commits

Author SHA1 Message Date
crschmidt
22c1d22caf Tag RC2.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.6-rc2@6836 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2008-04-09 18:02:23 +00:00
crschmidt
53b20137cb Finish pullups for RC2.
#1498 Easily turning off/overriding default select and temporary intent
        styles
  #1501 GeoRSS format tests fail in Safari
  #1502 Events register method fails if listeners member is not an array
  #1503 panning off for odd-sized viewport
  #1504 doc review


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.6@6835 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2008-04-09 17:58:44 +00:00
crschmidt
4085a2c220 Pullup commits from trunk to 2.6 branch:
* virtualStyle typo (Closes #1495)
 * JSON fix for Safari 3.1 (Closes #1493)
 * panzoombar off-by-one (Closes #1486)
 * Handler Hover exception (Closes #1480)
 * Popup.framedcloud exception (Closes #1479)
 * VML Renderer when including namespace in page (Closes #1477)
 * SLD/Rule/Filter changes -- most of this commit (Closes #1492)


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.6@6819 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2008-04-08 01:51:04 +00:00
crschmidt
b9348dd5d5 avlee, elemoine, and ahocevar point out that we should change the
initialization of the imageSrc property to be *before* we call the 
superclass. This pullup (Closes #1475), and is the last thing I'm going 
to touch before the 2.6 release. svn merge -r6749:6751 trunk branch.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.6@6752 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2008-04-01 11:00:45 +00:00
Schuyler Erle
1c055d4f84 Branch the 2.6 release. Hooray!
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.6@6749 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2008-04-01 01:30:22 +00:00
64 changed files with 1036 additions and 826 deletions

View File

@@ -69,7 +69,7 @@ Group: OpenLayers {
File: Control (no auto-title, OpenLayers/Control.js) File: Control (no auto-title, OpenLayers/Control.js)
File: ArgParser (no auto-title, OpenLayers/Control/ArgParser.js) File: ArgParser (no auto-title, OpenLayers/Control/ArgParser.js)
File: Attribution (no auto-title, OpenLayers/Control/Attribution.js) File: Attribution (no auto-title, OpenLayers/Control/Attribution.js)
File: Control.Button (no auto-title, OpenLayers/Control/Button.js) File: Button (no auto-title, OpenLayers/Control/Button.js)
File: DragFeature (no auto-title, OpenLayers/Control/DragFeature.js) File: DragFeature (no auto-title, OpenLayers/Control/DragFeature.js)
File: DragPan (no auto-title, OpenLayers/Control/DragPan.js) File: DragPan (no auto-title, OpenLayers/Control/DragPan.js)
File: DrawFeature (no auto-title, OpenLayers/Control/DrawFeature.js) File: DrawFeature (no auto-title, OpenLayers/Control/DrawFeature.js)
@@ -104,6 +104,14 @@ Group: OpenLayers {
File: WFS (no auto-title, OpenLayers/Feature/WFS.js) File: WFS (no auto-title, OpenLayers/Feature/WFS.js)
} # Group: Feature } # Group: Feature
Group: Filter {
File: Filter (no auto-title, OpenLayers/Filter.js)
File: Comparison (no auto-title, OpenLayers/Filter/Comparison.js)
File: FeatureId (no auto-title, OpenLayers/Filter/FeatureId.js)
File: Logical (no auto-title, OpenLayers/Filter/Logical.js)
} # Group: Filter
Group: Format { Group: Format {
File: Format (no auto-title, OpenLayers/Format.js) File: Format (no auto-title, OpenLayers/Format.js)
@@ -113,10 +121,18 @@ Group: OpenLayers {
File: JSON (no auto-title, OpenLayers/Format/JSON.js) File: JSON (no auto-title, OpenLayers/Format/JSON.js)
File: KML (no auto-title, OpenLayers/Format/KML.js) File: KML (no auto-title, OpenLayers/Format/KML.js)
File: OSM (no auto-title, OpenLayers/Format/OSM.js) File: OSM (no auto-title, OpenLayers/Format/OSM.js)
File: SLD (no auto-title, OpenLayers/Format/SLD.js)
Group: SLD {
File: SLD (no auto-title, OpenLayers/Format/SLD.js)
File: v1 (no auto-title, OpenLayers/Format/SLD/v1.js)
File: v1_0_0 (no auto-title, OpenLayers/Format/SLD/v1_0_0.js)
} # Group: SLD
File: Text (no auto-title, OpenLayers/Format/Text.js) File: Text (no auto-title, OpenLayers/Format/Text.js)
File: WFS (no auto-title, OpenLayers/Format/WFS.js) File: WFS (no auto-title, OpenLayers/Format/WFS.js)
File: WKT (no auto-title, OpenLayers/Format/WKT.js) File: WKT (no auto-title, OpenLayers/Format/WKT.js)
File: XML (no auto-title, OpenLayers/Format/XML.js)
Group: WMC { Group: WMC {
@@ -126,7 +142,6 @@ Group: OpenLayers {
File: v1_1_0 (no auto-title, OpenLayers/Format/WMC/v1_1_0.js) File: v1_1_0 (no auto-title, OpenLayers/Format/WMC/v1_1_0.js)
} # Group: WMC } # Group: WMC
File: XML (no auto-title, OpenLayers/Format/XML.js)
} # Group: Format } # Group: Format
Group: Geometry { Group: Geometry {
@@ -142,7 +157,6 @@ Group: OpenLayers {
File: Point (no auto-title, OpenLayers/Geometry/Point.js) File: Point (no auto-title, OpenLayers/Geometry/Point.js)
File: Polygon (no auto-title, OpenLayers/Geometry/Polygon.js) File: Polygon (no auto-title, OpenLayers/Geometry/Polygon.js)
File: Rectangle (no auto-title, OpenLayers/Geometry/Rectangle.js) File: Rectangle (no auto-title, OpenLayers/Geometry/Rectangle.js)
File: Surface (no auto-title, OpenLayers/Geometry/Surface.js)
} # Group: Geometry } # Group: Geometry
Group: Handler { Group: Handler {
@@ -166,6 +180,7 @@ Group: OpenLayers {
Group: Lang { Group: Lang {
File: Lang (no auto-title, OpenLayers/Lang.js) File: Lang (no auto-title, OpenLayers/Lang.js)
File: Lang["cs-CZ"] (OpenLayers/Lang/cs-CZ.js)
File: Lang["de"] (no auto-title, OpenLayers/Lang/de.js) File: Lang["de"] (no auto-title, OpenLayers/Lang/de.js)
File: Lang["en"] (no auto-title, OpenLayers/Lang/en.js) File: Lang["en"] (no auto-title, OpenLayers/Lang/en.js)
File: Lang["en-CA"] (no auto-title, OpenLayers/Lang/en-CA.js) File: Lang["en-CA"] (no auto-title, OpenLayers/Lang/en-CA.js)
@@ -217,6 +232,8 @@ Group: OpenLayers {
File: Popup (no auto-title, OpenLayers/Popup.js) File: Popup (no auto-title, OpenLayers/Popup.js)
File: Anchored (no auto-title, OpenLayers/Popup/Anchored.js) File: Anchored (no auto-title, OpenLayers/Popup/Anchored.js)
File: AnchoredBubble (no auto-title, OpenLayers/Popup/AnchoredBubble.js) File: AnchoredBubble (no auto-title, OpenLayers/Popup/AnchoredBubble.js)
File: Framed (OpenLayers/Popup/Framed.js)
File: FramedCloud (OpenLayers/Popup/FramedCloud.js)
} # Group: Popup } # Group: Popup
File: Projection (no auto-title, OpenLayers/Projection.js) File: Projection (no auto-title, OpenLayers/Projection.js)
@@ -229,14 +246,7 @@ Group: OpenLayers {
File: VML (no auto-title, OpenLayers/Renderer/VML.js) File: VML (no auto-title, OpenLayers/Renderer/VML.js)
} # Group: Renderer } # Group: Renderer
Group: Rule { File: Rule (no auto-title, OpenLayers/Rule.js)
File: Rule (no auto-title, OpenLayers/Rule.js)
File: Comparison (no auto-title, OpenLayers/Rule/Comparison.js)
File: FeatureId (no auto-title, OpenLayers/Rule/FeatureId.js)
File: Logical (no auto-title, OpenLayers/Rule/Logical.js)
} # Group: Rule
File: Style (no auto-title, OpenLayers/Style.js) File: Style (no auto-title, OpenLayers/Style.js)
File: StyleMap (no auto-title, OpenLayers/StyleMap.js) File: StyleMap (no auto-title, OpenLayers/StyleMap.js)

View File

@@ -69,7 +69,7 @@ Group: OpenLayers {
File: Control (no auto-title, OpenLayers/Control.js) File: Control (no auto-title, OpenLayers/Control.js)
File: ArgParser (no auto-title, OpenLayers/Control/ArgParser.js) File: ArgParser (no auto-title, OpenLayers/Control/ArgParser.js)
File: Attribution (no auto-title, OpenLayers/Control/Attribution.js) File: Attribution (no auto-title, OpenLayers/Control/Attribution.js)
File: Control.Button (no auto-title, OpenLayers/Control/Button.js) File: Button (no auto-title, OpenLayers/Control/Button.js)
File: DragFeature (no auto-title, OpenLayers/Control/DragFeature.js) File: DragFeature (no auto-title, OpenLayers/Control/DragFeature.js)
File: DragPan (no auto-title, OpenLayers/Control/DragPan.js) File: DragPan (no auto-title, OpenLayers/Control/DragPan.js)
File: DrawFeature (no auto-title, OpenLayers/Control/DrawFeature.js) File: DrawFeature (no auto-title, OpenLayers/Control/DrawFeature.js)
@@ -104,6 +104,14 @@ Group: OpenLayers {
File: WFS (no auto-title, OpenLayers/Feature/WFS.js) File: WFS (no auto-title, OpenLayers/Feature/WFS.js)
} # Group: Feature } # Group: Feature
Group: Filter {
File: Filter (no auto-title, OpenLayers/Filter.js)
File: Comparison (no auto-title, OpenLayers/Filter/Comparison.js)
File: FeatureId (no auto-title, OpenLayers/Filter/FeatureId.js)
File: Logical (no auto-title, OpenLayers/Filter/Logical.js)
} # Group: Filter
Group: Format { Group: Format {
File: Format (no auto-title, OpenLayers/Format.js) File: Format (no auto-title, OpenLayers/Format.js)
@@ -113,10 +121,18 @@ Group: OpenLayers {
File: JSON (no auto-title, OpenLayers/Format/JSON.js) File: JSON (no auto-title, OpenLayers/Format/JSON.js)
File: KML (no auto-title, OpenLayers/Format/KML.js) File: KML (no auto-title, OpenLayers/Format/KML.js)
File: OSM (no auto-title, OpenLayers/Format/OSM.js) File: OSM (no auto-title, OpenLayers/Format/OSM.js)
File: SLD (no auto-title, OpenLayers/Format/SLD.js)
Group: SLD {
File: SLD (no auto-title, OpenLayers/Format/SLD.js)
File: v1 (no auto-title, OpenLayers/Format/SLD/v1.js)
File: v1_0_0 (no auto-title, OpenLayers/Format/SLD/v1_0_0.js)
} # Group: SLD
File: Text (no auto-title, OpenLayers/Format/Text.js) File: Text (no auto-title, OpenLayers/Format/Text.js)
File: WFS (no auto-title, OpenLayers/Format/WFS.js) File: WFS (no auto-title, OpenLayers/Format/WFS.js)
File: WKT (no auto-title, OpenLayers/Format/WKT.js) File: WKT (no auto-title, OpenLayers/Format/WKT.js)
File: XML (no auto-title, OpenLayers/Format/XML.js)
Group: WMC { Group: WMC {
@@ -126,7 +142,6 @@ Group: OpenLayers {
File: v1_1_0 (no auto-title, OpenLayers/Format/WMC/v1_1_0.js) File: v1_1_0 (no auto-title, OpenLayers/Format/WMC/v1_1_0.js)
} # Group: WMC } # Group: WMC
File: XML (no auto-title, OpenLayers/Format/XML.js)
} # Group: Format } # Group: Format
Group: Geometry { Group: Geometry {
@@ -142,7 +157,6 @@ Group: OpenLayers {
File: Point (no auto-title, OpenLayers/Geometry/Point.js) File: Point (no auto-title, OpenLayers/Geometry/Point.js)
File: Polygon (no auto-title, OpenLayers/Geometry/Polygon.js) File: Polygon (no auto-title, OpenLayers/Geometry/Polygon.js)
File: Rectangle (no auto-title, OpenLayers/Geometry/Rectangle.js) File: Rectangle (no auto-title, OpenLayers/Geometry/Rectangle.js)
File: Surface (no auto-title, OpenLayers/Geometry/Surface.js)
} # Group: Geometry } # Group: Geometry
Group: Handler { Group: Handler {
@@ -166,6 +180,7 @@ Group: OpenLayers {
Group: Lang { Group: Lang {
File: Lang (no auto-title, OpenLayers/Lang.js) File: Lang (no auto-title, OpenLayers/Lang.js)
File: Lang["cs-CZ"] (OpenLayers/Lang/cs-CZ.js)
File: Lang["de"] (no auto-title, OpenLayers/Lang/de.js) File: Lang["de"] (no auto-title, OpenLayers/Lang/de.js)
File: Lang["en"] (no auto-title, OpenLayers/Lang/en.js) File: Lang["en"] (no auto-title, OpenLayers/Lang/en.js)
File: Lang["en-CA"] (no auto-title, OpenLayers/Lang/en-CA.js) File: Lang["en-CA"] (no auto-title, OpenLayers/Lang/en-CA.js)
@@ -217,6 +232,8 @@ Group: OpenLayers {
File: Popup (no auto-title, OpenLayers/Popup.js) File: Popup (no auto-title, OpenLayers/Popup.js)
File: Anchored (no auto-title, OpenLayers/Popup/Anchored.js) File: Anchored (no auto-title, OpenLayers/Popup/Anchored.js)
File: AnchoredBubble (no auto-title, OpenLayers/Popup/AnchoredBubble.js) File: AnchoredBubble (no auto-title, OpenLayers/Popup/AnchoredBubble.js)
File: Framed (OpenLayers/Popup/Framed.js)
File: FramedCloud (OpenLayers/Popup/FramedCloud.js)
} # Group: Popup } # Group: Popup
File: Projection (no auto-title, OpenLayers/Projection.js) File: Projection (no auto-title, OpenLayers/Projection.js)
@@ -229,14 +246,7 @@ Group: OpenLayers {
File: VML (no auto-title, OpenLayers/Renderer/VML.js) File: VML (no auto-title, OpenLayers/Renderer/VML.js)
} # Group: Renderer } # Group: Renderer
Group: Rule { File: Rule (no auto-title, OpenLayers/Rule.js)
File: Rule (no auto-title, OpenLayers/Rule.js)
File: Comparison (no auto-title, OpenLayers/Rule/Comparison.js)
File: FeatureId (no auto-title, OpenLayers/Rule/FeatureId.js)
File: Logical (no auto-title, OpenLayers/Rule/Logical.js)
} # Group: Rule
File: Style (no auto-title, OpenLayers/Style.js) File: Style (no auto-title, OpenLayers/Style.js)
File: StyleMap (no auto-title, OpenLayers/StyleMap.js) File: StyleMap (no auto-title, OpenLayers/StyleMap.js)

View File

@@ -31,28 +31,34 @@
// the thumbail attribute of the rss item // the thumbail attribute of the rss item
style = new OpenLayers.Style({externalGraphic: "${thumbnail}"}); style = new OpenLayers.Style({externalGraphic: "${thumbnail}"});
// make the thumbnails larger when we select them
selectStyle = new OpenLayers.Style({pointRadius: 35});
// create a rule with a point symbolizer that will make the thumbnail // create a rule with a point symbolizer that will make the thumbnail
// larger if the title of the rss item conatins "powder" // larger if the title of the rss item conatins "powder"
var rule = new OpenLayers.Rule.Comparison({ var rule = new OpenLayers.Rule({
type: OpenLayers.Rule.Comparison.LIKE, symbolizer: {pointRadius: 30},
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.LIKE,
property: "title", property: "title",
value: "*powder*", value: "*powder*"
symbolizer: {"Point": {pointRadius: 30}}}); })
rule.value2regex("*"); });
rule.filter.value2regex("*");
// If the above rule does not apply, use a smaller pointRadius. // If the above rule does not apply, use a smaller pointRadius.
var elseRule = new OpenLayers.Rule({ var elseRule = new OpenLayers.Rule({
elseFilter: true, elseFilter: true,
symbolizer: {"Point": {pointRadius: 20}}}); symbolizer: {pointRadius: 20}
});
style.addRules([rule, elseRule]); style.addRules([rule, elseRule]);
markerLayer = new OpenLayers.Layer.Vector("", {styleMap: new OpenLayers.StyleMap({ // Create a layer with a style map. Giving the style map keys
"default": style, // for "default" and "select" rendering intent.
"select": selectStyle})}); markerLayer = new OpenLayers.Layer.Vector("", {
styleMap: new OpenLayers.StyleMap({
"default": style,
"select": new OpenLayers.Style({pointRadius: 35})
})
});
map.addLayer(markerLayer); map.addLayer(markerLayer);
// control that will show a popup when clicking on a thumbnail // control that will show a popup when clicking on a thumbnail

View File

@@ -49,23 +49,20 @@
} }
function init(){ function init(){
var options = { var options = {
projection: "EPSG:26912", maxExtent: new OpenLayers.Bounds(-110.994, 45.885, -110.950, 45.929),
units: 'm', maxResolution: "auto"
maxExtent: new OpenLayers.Bounds(455402, 4967657, 473295, 4984095),
maxResolution: 'auto',
maxZoomLevel: 8
}; };
map = new OpenLayers.Map('map', options); map = new OpenLayers.Map('map', options);
var drg = new OpenLayers.Layer.WMS("Topo Maps", var drg = new OpenLayers.Layer.WMS("Topo Maps",
"http://terraservice.net/ogcmap.ashx", "http://terraservice.net/ogcmap.ashx",
{layers: "DRG"}); {layers: "DRG"});
shade = new OpenLayers.Layer.WMS("Shaded Relief", shade = new OpenLayers.Layer.WMS("Shaded Relief",
"http://ims.cr.usgs.gov/servlet19/com.esri.wms.Esrimap/USGS_EDC_Elev_NED_3", "http://gisdata.usgs.gov/wmsconnector/com.esri.wms.Esrimap?ServiceName=USGS_EDC_Elev_NED_3",
{layers: "HR-NED.IMAGE", reaspect: "false", transparent: 'true'}, {layers: "HR-NED.IMAGE", reaspect: "false", transparent: 'true'},
{isBaseLayer: false, opacity: 0.3}); {isBaseLayer: false, opacity: 0.3});
map.addLayers([drg, shade]); map.addLayers([drg, shade]);
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(464348.5,4975876), 1); map.zoomToMaxExtent();
} }
</script> </script>
</head> </head>

View File

@@ -121,7 +121,7 @@
map.addControl(new OpenLayers.Control.EditingToolbar(vector)); map.addControl(new OpenLayers.Control.EditingToolbar(vector));
map.addControl(new OpenLayers.Control.Permalink()); map.addControl(new OpenLayers.Control.Permalink());
map.addControl(new OpenLayers.Control.MousePosition()); map.addControl(new OpenLayers.Control.MousePosition());
map.zoomToMaxExtent() if (!map.getCenter()) {map.zoomToMaxExtent()}
} }
function osm_getTileURL(bounds) { function osm_getTileURL(bounds) {

View File

@@ -106,111 +106,3 @@
</div> </div>
</body> </body>
</html> </html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OpenLayers Vector Styles</title>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
<style type="text/css">
#map {
width: 800px;
height: 400px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map;
function init(){
map = new OpenLayers.Map('map', {maxResolution:'auto'});
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
// Strategy 1: Style features based on some attribute.
// create 50 random features in the northern hemisphere
// give them a "type" attribute that will be used to style
// them by size
var features = new Array(50);
for (var i=0; i<features.length; i++) {
features[i] = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(
(360 * Math.random()) - 180, 90 * Math.random()
), {
type: 5 + parseInt(5 * Math.random())
}
);
}
// create the layer styleMap with a simple symbolizer template
var layer1 = new OpenLayers.Layer.Vector('Points', {
styleMap: new OpenLayers.StyleMap({
pointRadius: "${type}", // based on feature.attributes.type
fillColor: "#666666"
})
});
layer1.addFeatures(features);
// Strategy 2: Style features based on something besides attributes.
// create 50 random features in the southern hemisphere
var features = new Array(50);
for (var i=0; i<features.length; i++) {
features[i] = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(
(360 * Math.random()) - 180, -90 * Math.random()
), {
type: 5 + parseInt(5 * Math.random())
}
);
}
// create the layer styleMap by giving the default style a context
var colors = ["red", "green", "blue"];
var context = {
getColor: function(feature) {
var region = parseInt((feature.geometry.x + 180) / 120);
return colors[region];
},
getType: function(feature) {
return feature.attributes["type"];
}
};
var template = {
pointRadius: "${getType}", // using context.getType(feature)
fillColor: "${getColor}" // using context.getColor(feature)
};
var style = new OpenLayers.Style(template, {context: context});
var layer2 = new OpenLayers.Layer.Vector('Points', {
styleMap: new OpenLayers.StyleMap(style)
});
layer2.addFeatures(features);
map.addLayers([layer1, layer2]);
}
</script>
</head>
<body onload="init()">
<h1 id="title">Feature Styles Example</h1>
<div id="tags"></div>
<p id="shortdesc">
Shows how to create a feature styles.
</p>
<div id="map"></div>
<div id="docs">
<p>Features in the northern hemisphere are styled according to their
"type" attribute. This is accomplished with a simple template that
is evaluated with the feature attributes as context.</p>
<p>Features in the sourthern hemisphere are styled according to a
combination of their attributes and non-attribute properties. This
is accomplished using an advanced template that calls functions
on the context object passed to the Style constructor.</p>
</div>
</body>
</html>

View File

@@ -183,9 +183,10 @@
"OpenLayers/Style.js", "OpenLayers/Style.js",
"OpenLayers/StyleMap.js", "OpenLayers/StyleMap.js",
"OpenLayers/Rule.js", "OpenLayers/Rule.js",
"OpenLayers/Rule/FeatureId.js", "OpenLayers/Filter.js",
"OpenLayers/Rule/Logical.js", "OpenLayers/Filter/FeatureId.js",
"OpenLayers/Rule/Comparison.js", "OpenLayers/Filter/Logical.js",
"OpenLayers/Filter/Comparison.js",
"OpenLayers/Format.js", "OpenLayers/Format.js",
"OpenLayers/Format/XML.js", "OpenLayers/Format/XML.js",
"OpenLayers/Format/GML.js", "OpenLayers/Format/GML.js",

View File

@@ -17,16 +17,14 @@
* OpenLayers custom string, number and function functions are described here. * OpenLayers custom string, number and function functions are described here.
*/ */
/********************* /**
* * * Namespace: OpenLayers.String
* STRING * * Contains convenience functions for string manipulation.
* * */
*********************/
OpenLayers.String = { OpenLayers.String = {
/** /**
* APIFunction: OpenLayers.String.startsWith * APIFunction: startsWith
* Test whether a string starts with another string. * Test whether a string starts with another string.
* *
* Parameters: * Parameters:
@@ -41,7 +39,7 @@ OpenLayers.String = {
}, },
/** /**
* APIFunction: OpenLayers.String.contains * APIFunction: contains
* Test whether a string contains another string. * Test whether a string contains another string.
* *
* Parameters: * Parameters:
@@ -56,7 +54,7 @@ OpenLayers.String = {
}, },
/** /**
* APIFunction: OpenLayers.String.trim * APIFunction: trim
* Removes leading and trailing whitespace characters from a string. * Removes leading and trailing whitespace characters from a string.
* *
* Parameters: * Parameters:
@@ -72,7 +70,7 @@ OpenLayers.String = {
}, },
/** /**
* APIFunction: OpenLayers.String.camelize * APIFunction: camelize
* Camel-case a hyphenated string. * Camel-case a hyphenated string.
* Ex. "chicken-head" becomes "chickenHead", and * Ex. "chicken-head" becomes "chickenHead", and
* "-chicken-head" becomes "ChickenHead". * "-chicken-head" becomes "ChickenHead".
@@ -94,7 +92,7 @@ OpenLayers.String = {
}, },
/** /**
* APIFunction: OpenLayers.String.format * APIFunction: format
* Given a string with tokens in the form ${token}, return a string * Given a string with tokens in the form ${token}, return a string
* with tokens replaced with properties from the given context * with tokens replaced with properties from the given context
* object. Represent a literal "${" by doubling it, e.g. "${${". * object. Represent a literal "${" by doubling it, e.g. "${${".
@@ -209,28 +207,26 @@ if (!String.prototype.camelize) {
}; };
} }
/********************* /**
* * * Namespace: OpenLayers.Number
* NUMBER * * Contains convenience functions for manipulating numbers.
* * */
*********************/
OpenLayers.Number = { OpenLayers.Number = {
/** /**
* Property: OpenLayers.Number.decimalSeparator * Property: decimalSeparator
* Decimal separator to use when formatting numbers. * Decimal separator to use when formatting numbers.
*/ */
decimalSeparator: ".", decimalSeparator: ".",
/** /**
* Property: OpenLayers.Number.thousandsSeparator * Property: thousandsSeparator
* Thousands separator to use when formatting numbers. * Thousands separator to use when formatting numbers.
*/ */
thousandsSeparator: ",", thousandsSeparator: ",",
/** /**
* APIFunction: OpenLayers.Number.limitSigDigs * APIFunction: limitSigDigs
* Limit the number of significant digits on a float. * Limit the number of significant digits on a float.
* *
* Parameters: * Parameters:
@@ -250,7 +246,7 @@ OpenLayers.Number = {
}, },
/** /**
* APIFunction: OpenLayers.Number.format * APIFunction: format
* Formats a number for output. * Formats a number for output.
* *
* Parameters: * Parameters:
@@ -324,15 +320,13 @@ if (!Number.prototype.limitSigDigs) {
}; };
} }
/********************* /**
* * * Namespace: OpenLayers.Function
* FUNCTION * * Contains convenience functions for function manipulation.
* * */
*********************/
OpenLayers.Function = { OpenLayers.Function = {
/** /**
* APIFunction: OpenLayers.Function.bind * APIFunction: bind
* Bind a function to an object. Method to easily create closures with * Bind a function to an object. Method to easily create closures with
* 'this' altered. * 'this' altered.
* *
@@ -357,7 +351,7 @@ OpenLayers.Function = {
}, },
/** /**
* APIFunction: OpenLayers.Function.bindAsEventListener * APIFunction: bindAsEventListener
* Bind a function to an object, and configure it to receive the event * Bind a function to an object, and configure it to receive the event
* object as first parameter when called. * object as first parameter when called.
* *
@@ -416,16 +410,14 @@ if (!Function.prototype.bindAsEventListener) {
}; };
} }
/********************* /**
* * * Namespace: OpenLayers.Array
* ARRAY * * Contains convenience functions for array manipulation.
* * */
*********************/
OpenLayers.Array = { OpenLayers.Array = {
/** /**
* APIMethod: OpenLayers.Array.filter * APIMethod: filter
* Filter an array. Provides the functionality of the * Filter an array. Provides the functionality of the
* Array.prototype.filter extension to the ECMA-262 standard. Where * Array.prototype.filter extension to the ECMA-262 standard. Where
* available, Array.prototype.filter will be used. * available, Array.prototype.filter will be used.

View File

@@ -18,25 +18,25 @@ OpenLayers.Bounds = OpenLayers.Class({
/** /**
* Property: left * Property: left
* {Number} * {Number} Minimum horizontal coordinate.
*/ */
left: null, left: null,
/** /**
* Property: bottom * Property: bottom
* {Number} * {Number} Minimum vertical coordinate.
*/ */
bottom: null, bottom: null,
/** /**
* Property: right * Property: right
* {Number} * {Number} Maximum horizontal coordinate.
*/ */
right: null, right: null,
/** /**
* Property: top * Property: top
* {Number} * {Number} Maximum vertical coordinate.
*/ */
top: null, top: null,
@@ -349,7 +349,7 @@ OpenLayers.Bounds = OpenLayers.Class({
* *
* Parameters: * Parameters:
* bounds - {<OpenLayers.Bounds>} * bounds - {<OpenLayers.Bounds>}
* inclusive - {<Boolean>} Whether or not to include the border. Default * inclusive - {Boolean} Whether or not to include the border. Default
* is true. * is true.
* *
* Returns: * Returns:
@@ -384,10 +384,10 @@ OpenLayers.Bounds = OpenLayers.Class({
* APIMethod: containsBounds * APIMethod: containsBounds
* *
* bounds - {<OpenLayers.Bounds>} * bounds - {<OpenLayers.Bounds>}
* partial - {<Boolean>} If true, only part of passed-in bounds needs be * partial - {Boolean} If true, only part of passed-in bounds needs be
* within this bounds. If false, the entire passed-in bounds must be * within this bounds. If false, the entire passed-in bounds must be
* within. Default is false * within. Default is false
* inclusive - {<Boolean>} Whether or not to include the border. Default is * inclusive - {Boolean} Whether or not to include the border. Default is
* true. * true.
* *
* Returns: * Returns:

View File

@@ -103,7 +103,7 @@ OpenLayers.Control = OpenLayers.Class({
/** /**
* Property: active * Property: active
* {boolean} null * {Boolean} The control is active.
*/ */
active: null, active: null,

View File

@@ -30,8 +30,8 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
/** /**
* Method: draw * Method: draw
* Creates a Drag handler, using <OpenLayers.Control.PanMap.panMap> and * Creates a Drag handler, using <panMap> and
* <OpenLayers.Control.PanMap.panMapDone> as callbacks. * <panMapDone> as callbacks.
*/ */
draw: function() { draw: function() {
this.handler = new OpenLayers.Handler.Drag(this, this.handler = new OpenLayers.Handler.Drag(this,

View File

@@ -72,7 +72,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
/** /**
* Property: selectControl * Property: selectControl
* {<OpenLayers.Control.Select>} * {<OpenLayers.Control.SelectFeature>}
*/ */
selectControl: null, selectControl: null,
@@ -99,7 +99,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
/** /**
* APIProperty: virtualStyle * APIProperty: virtualStyle
* {<OpenLayers.Feature.Vector.Style>} * {Object} A symbolizer to be used for virtual vertices.
*/ */
virtualStyle: null, virtualStyle: null,
@@ -179,10 +179,10 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
this.layer = layer; this.layer = layer;
this.vertices = []; this.vertices = [];
this.virtualVertices = []; this.virtualVertices = [];
this.styleVirtual = OpenLayers.Util.extend({}, this.virtualStyle = OpenLayers.Util.extend({},
this.layer.style || this.layer.styleMap.createSymbolizer()); this.layer.style || this.layer.styleMap.createSymbolizer());
this.styleVirtual.fillOpacity = 0.3; this.virtualStyle.fillOpacity = 0.3;
this.styleVirtual.strokeOpacity = 0.3; this.virtualStyle.strokeOpacity = 0.3;
this.deleteCodes = [46, 100]; this.deleteCodes = [46, 100];
this.mode = OpenLayers.Control.ModifyFeature.RESHAPE; this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
OpenLayers.Control.prototype.initialize.apply(this, [options]); OpenLayers.Control.prototype.initialize.apply(this, [options]);
@@ -564,7 +564,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
var y = (prevVertex.y + nextVertex.y) / 2; var y = (prevVertex.y + nextVertex.y) / 2;
var point = new OpenLayers.Feature.Vector( var point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(x, y), new OpenLayers.Geometry.Point(x, y),
null, control.styleVirtual null, control.virtualStyle
); );
// set the virtual parent and intended index // set the virtual parent and intended index
point.geometry.parent = geometry; point.geometry.parent = geometry;

View File

@@ -10,6 +10,9 @@
/** /**
* Class: OpenLayers.Control.NavToolbar * Class: OpenLayers.Control.NavToolbar
*
* Inherits from:
* - <OpenLayers.Control.Panel>
*/ */
OpenLayers.Control.NavToolbar = OpenLayers.Class(OpenLayers.Control.Panel, { OpenLayers.Control.NavToolbar = OpenLayers.Class(OpenLayers.Control.Panel, {

View File

@@ -16,7 +16,7 @@
* when there are no states to restore. * when there are no states to restore.
* *
* Inherits from: * Inherits from:
* - <OpenLayers.Control.Control> * - <OpenLayers.Control>
*/ */
OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
@@ -32,7 +32,7 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
/** /**
* APIProperty: previous * APIProperty: previous
* {OpenLayers.Control} A button type control whose trigger method restores * {<OpenLayers.Control>} A button type control whose trigger method restores
* the previous state managed by this control. * the previous state managed by this control.
*/ */
previous: null, previous: null,
@@ -46,7 +46,7 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {
/** /**
* APIProperty: next * APIProperty: next
* {OpenLayers.Control} A button type control whose trigger method restores * {<OpenLayers.Control>} A button type control whose trigger method restores
* the next state managed by this control. * the next state managed by this control.
*/ */
next: null, next: null,

View File

@@ -27,7 +27,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
/** /**
* APIProperty: ovmap * APIProperty: ovmap
* {<OpenLayers.Map>} A reference to the overvew map itself. * {<OpenLayers.Map>} A reference to the overview map itself.
*/ */
ovmap: null, ovmap: null,

View File

@@ -8,7 +8,7 @@
*/ */
/** /**
* Class: OpenLayers.PanZoom * Class: OpenLayers.Control.PanZoom
* *
* Inherits from: * Inherits from:
* - <OpenLayers.Control> * - <OpenLayers.Control>

View File

@@ -12,7 +12,6 @@
* *
* Inherits from: * Inherits from:
* - <OpenLayers.Control.PanZoom> * - <OpenLayers.Control.PanZoom>
* - <OpenLayers.Control>
*/ */
OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, { OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
@@ -56,7 +55,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
zoomWorldIcon: false, zoomWorldIcon: false,
/** /**
* Constructor: <OpenLayers.Control.PanZoomBar> * Constructor: OpenLayers.Control.PanZoomBar
*/ */
initialize: function() { initialize: function() {
OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments); OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments);
@@ -242,12 +241,11 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
var y = evt.xy.y; var y = evt.xy.y;
var top = OpenLayers.Util.pagePosition(evt.object)[1]; var top = OpenLayers.Util.pagePosition(evt.object)[1];
var levels = (y - top)/this.zoomStopHeight; var levels = (y - top)/this.zoomStopHeight;
var zoom = (this.map.getNumZoomLevels() - 1) - levels; if(!this.map.fractionalZoom) {
if(this.map.fractionalZoom) { levels = Math.floor(levels);
zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);
} else {
zoom = Math.floor(zoom);
} }
var zoom = (this.map.getNumZoomLevels() - 1) - levels;
zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);
this.map.zoomTo(zoom); this.map.zoomTo(zoom);
OpenLayers.Event.stop(evt); OpenLayers.Event.stop(evt);
}, },

View File

@@ -15,7 +15,7 @@
OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, { OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
/** /**
* Property: controls * Property: controls
* Array({<OpenLayers.Control>}) * {Array(<OpenLayers.Control>)}
*/ */
controls: null, controls: null,

View File

@@ -532,7 +532,9 @@ OpenLayers.Events = OpenLayers.Class({
*/ */
register: function (type, obj, func) { register: function (type, obj, func) {
if (func != null) { if (func != null &&
((this.eventTypes && OpenLayers.Util.indexOf(this.eventTypes, type) != -1) ||
OpenLayers.Util.indexOf(this.BROWSER_EVENTS, type) != -1)) {
if (obj == null) { if (obj == null) {
obj = this.object; obj = this.object;
} }

View File

@@ -162,6 +162,10 @@ OpenLayers.Feature = OpenLayers.Class({
* If no 'lonlat' is set, returns null. * If no 'lonlat' is set, returns null.
* If no this.marker has been created, no anchor is sent. * If no this.marker has been created, no anchor is sent.
* *
* Note - the returned popup object is 'owned' by the feature, so you
* cannot use the popup's destroy method to discard the popup.
* Instead, you must use the feature's destroyPopup
*
* Note - this.popup is set to return value * Note - this.popup is set to return value
* *
* Parameters: * Parameters:

55
lib/OpenLayers/Filter.js Normal file
View File

@@ -0,0 +1,55 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
* for the full text of the license. */
/**
* @requires OpenLayers/Util.js
* @requires OpenLayers/Style.js
*/
/**
* Class: OpenLayers.Filter
* This class represents an OGC Filter.
*/
OpenLayers.Filter = OpenLayers.Class({
/**
* Constructor: OpenLayers.Filter
* This is an abstract class. Create an instance of a filter subclass.
*
* Parameters:
* options - {Object} Optional object whose properties will be set on the
* instance.
*
* Returns:
* {<OpenLayers.Filter>}
*/
initialize: function(options) {
OpenLayers.Util.extend(this, options);
},
/**
* APIMethod: destroy
* Remove reference to anything added.
*/
destroy: function() {
},
/**
* APIMethod: evaluate
* Evaluates this filter in a specific context. Should be implemented by
* subclasses.
*
* Parameters:
* context - {Object} Context to use in evaluating the filter.
*
* Returns:
* {Boolean} The filter applies.
*/
evaluate: function(context) {
return true;
},
CLASS_NAME: "OpenLayers.Filter"
});

View File

@@ -3,30 +3,29 @@
* full text of the license. */ * full text of the license. */
/** /**
* @requires OpenLayers/Rule.js * @requires OpenLayers/Filter.js
*/ */
/** /**
* Class: OpenLayers.Rule.Comparison * Class: OpenLayers.Filter.Comparison
* This class represents the comparison rules, as being used for rule-based * This class represents a comparison filter.
* SLD styling
* *
* Inherits from * Inherits from
* - <OpenLayers.Rule> * - <OpenLayers.Filter>
*/ */
OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, { OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
/** /**
* 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.Filter.Comparison.EQUAL_TO = "==";
* - OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!="; * - OpenLayers.Filter.Comparison.NOT_EQUAL_TO = "!=";
* - OpenLayers.Rule.Comparison.LESS_THAN = "<"; * - OpenLayers.Filter.Comparison.LESS_THAN = "<";
* - OpenLayers.Rule.Comparison.GREATER_THAN = ">"; * - OpenLayers.Filter.Comparison.GREATER_THAN = ">";
* - OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<="; * - OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
* - OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">="; * - OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
* - OpenLayers.Rule.Comparison.BETWEEN = ".."; * - OpenLayers.Filter.Comparison.BETWEEN = "..";
* - OpenLayers.Rule.Comparison.LIKE = "~"; * - OpenLayers.Filter.Comparison.LIKE = "~";
*/ */
type: null, type: null,
@@ -65,53 +64,47 @@ OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
upperBoundary: null, upperBoundary: null,
/** /**
* Constructor: OpenLayers.Rule.Comparison * Constructor: OpenLayers.Filter.Comparison
* Creates a comparison rule. * Creates a comparison rule.
* *
* Parameters: * Parameters:
* params - {Object} Hash of parameters for this rule:
* -
* - 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.Filter.Comparison>}
*/ */
initialize: function(options) { initialize: function(options) {
OpenLayers.Rule.prototype.initialize.apply(this, [options]); OpenLayers.Filter.prototype.initialize.apply(this, [options]);
}, },
/** /**
* APIMethod: evaluate * APIMethod: evaluate
* evaluates this rule for a specific context * Evaluates this filter in a specific context. Should be implemented by
* subclasses.
* *
* Parameters: * Parameters:
* context - {Object} context to apply the rule to. * context - {Object} Context to use in evaluating the filter.
* *
* Returns: * Returns:
* {boolean} true if the rule applies, false if it does not * {Boolean} The filter applies.
*/ */
evaluate: function(feature) { evaluate: function(context) {
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
return false;
}
var context = this.getContext(feature);
switch(this.type) { switch(this.type) {
case OpenLayers.Rule.Comparison.EQUAL_TO: case OpenLayers.Filter.Comparison.EQUAL_TO:
case OpenLayers.Rule.Comparison.LESS_THAN: case OpenLayers.Filter.Comparison.LESS_THAN:
case OpenLayers.Rule.Comparison.GREATER_THAN: case OpenLayers.Filter.Comparison.GREATER_THAN:
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO: case OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO:
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO: case OpenLayers.Filter.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.Filter.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.Filter.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]);
@@ -139,7 +132,7 @@ OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
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.Filter.Comparison";
OpenLayers.Console.error(msg); OpenLayers.Console.error(msg);
return null; return null;
} }
@@ -208,34 +201,34 @@ OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
* 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.Filter.Comparison.EQUAL_TO:
return context[property] == value; return context[property] == value;
case OpenLayers.Rule.Comparison.NOT_EQUAL_TO: case OpenLayers.Filter.Comparison.NOT_EQUAL_TO:
return context[property] != value; return context[property] != value;
case OpenLayers.Rule.Comparison.LESS_THAN: case OpenLayers.Filter.Comparison.LESS_THAN:
return context[property] < value; return context[property] < value;
case OpenLayers.Rule.Comparison.GREATER_THAN: case OpenLayers.Filter.Comparison.GREATER_THAN:
return context[property] > value; return context[property] > value;
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO: case OpenLayers.Filter.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.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO:
return context[property] >= value; return context[property] >= value;
} }
}, },
CLASS_NAME: "OpenLayers.Rule.Comparison" CLASS_NAME: "OpenLayers.Filter.Comparison"
}); });
OpenLayers.Rule.Comparison.EQUAL_TO = "=="; OpenLayers.Filter.Comparison.EQUAL_TO = "==";
OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!="; OpenLayers.Filter.Comparison.NOT_EQUAL_TO = "!=";
OpenLayers.Rule.Comparison.LESS_THAN = "<"; OpenLayers.Filter.Comparison.LESS_THAN = "<";
OpenLayers.Rule.Comparison.GREATER_THAN = ">"; OpenLayers.Filter.Comparison.GREATER_THAN = ">";
OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<="; OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">="; OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
OpenLayers.Rule.Comparison.BETWEEN = ".."; OpenLayers.Filter.Comparison.BETWEEN = "..";
OpenLayers.Rule.Comparison.LIKE = "~"; OpenLayers.Filter.Comparison.LIKE = "~";

View File

@@ -4,28 +4,28 @@
/** /**
* @requires OpenLayers/Rule.js * @requires OpenLayers/Filter.js
*/ */
/** /**
* Class: OpenLayers.Rule.FeatureId * Class: OpenLayers.Filter.FeatureId
* This class represents a ogc:FeatureId Rule, as being used for rule-based SLD * This class represents a ogc:FeatureId Filter, as being used for rule-based SLD
* styling * styling
* *
* Inherits from * Inherits from
* - <OpenLayers.Rule> * - <OpenLayers.Filter>
*/ */
OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, { OpenLayers.Filter.FeatureId = OpenLayers.Class(OpenLayers.Filter, {
/** /**
* 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.Filter.FeatureId
* Creates an ogc:FeatureId rule. * Creates an ogc:FeatureId rule.
* *
* Parameters: * Parameters:
@@ -33,11 +33,11 @@ OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
* rule * rule
* *
* Returns: * Returns:
* {<OpenLayers.Rule.FeatureId>} * {<OpenLayers.Filter.FeatureId>}
*/ */
initialize: function(options) { initialize: function(options) {
this.fids = []; this.fids = [];
OpenLayers.Rule.prototype.initialize.apply(this, [options]); OpenLayers.Filter.prototype.initialize.apply(this, [options]);
}, },
/** /**
@@ -50,12 +50,9 @@ OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
* 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)) {
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]) {
@@ -65,5 +62,5 @@ OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
return false; return false;
}, },
CLASS_NAME: "OpenLayers.Rule.FeatureId" CLASS_NAME: "OpenLayers.Filter.FeatureId"
}); });

View File

@@ -0,0 +1,99 @@
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Filter.js
*/
/**
* Class: OpenLayers.Filter.Logical
* This class represents ogc:And, ogc:Or and ogc:Not rules.
*
* Inherits from
* - <OpenLayers.Filter>
*/
OpenLayers.Filter.Logical = OpenLayers.Class(OpenLayers.Filter, {
/**
* APIProperty: filters
* {Array(<OpenLayers.Filter>)} Child filters for this filter.
*/
filters: null,
/**
* APIProperty: type
* {String} type of logical operator. Available types are:
* - OpenLayers.Filter.Locical.AND = "&&";
* - OpenLayers.Filter.Logical.OR = "||";
* - OpenLayers.Filter.Logical.NOT = "!";
*/
type: null,
/**
* Constructor: OpenLayers.Filter.Logical
* Creates a logical filter (And, Or, Not).
*
* Parameters:
* options - {Object} An optional object with properties to set on the
* filter.
*
* Returns:
* {<OpenLayers.Filter.Logical>}
*/
initialize: function(options) {
this.filters = [];
OpenLayers.Filter.prototype.initialize.apply(this, [options]);
},
/**
* APIMethod: destroy
* Remove reference to child filters.
*/
destroy: function() {
this.filters = null;
OpenLayers.Filter.prototype.destroy.apply(this);
},
/**
* APIMethod: evaluate
* Evaluates this filter in a specific context. Should be implemented by
* subclasses.
*
* Parameters:
* context - {Object} Context to use in evaluating the filter.
*
* Returns:
* {Boolean} The filter applies.
*/
evaluate: function(context) {
switch(this.type) {
case OpenLayers.Filter.Logical.AND:
for (var i=0; i<this.filters.length; i++) {
if (this.filters[i].evaluate(context) == false) {
return false;
}
}
return true;
case OpenLayers.Filter.Logical.OR:
for (var i=0; i<this.filters.length; i++) {
if (this.filters[i].evaluate(context) == true) {
return true;
}
}
return false;
case OpenLayers.Filter.Logical.NOT:
return (!this.filters[0].evaluate(context));
}
},
CLASS_NAME: "OpenLayers.Filter.Logical"
});
OpenLayers.Filter.Logical.AND = "&&";
OpenLayers.Filter.Logical.OR = "||";
OpenLayers.Filter.Logical.NOT = "!";

View File

@@ -267,7 +267,7 @@ OpenLayers.Format.GeoRSS = OpenLayers.Class(OpenLayers.Format.XML, {
* Accept Feature Collection, and return a string. * Accept Feature Collection, and return a string.
* *
* Parameters: * Parameters:
* features - Array({<OpenLayers.Feature.Vector>}) List of features to serialize into a string. * features - {Array(<OpenLayers.Feature.Vector>)} List of features to serialize into a string.
*/ */
write: function(features) { write: function(features) {
var georss; var georss;

View File

@@ -95,8 +95,9 @@ OpenLayers.Format.JSON = OpenLayers.Class(OpenLayers.Format, {
* characters. * characters.
*/ */
try { try {
if(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/. if (/^[\],:{}\s]*$/.test(json.replace(/\\["\\\/bfnrtu]/g, '@').
test(json)) { replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
/** /**
* In the second stage we use the eval function to compile the * In the second stage we use the eval function to compile the

View File

@@ -283,7 +283,7 @@ OpenLayers.Format.OSM = OpenLayers.Class(OpenLayers.Format.XML, {
* in tools like JOSM. * in tools like JOSM.
* *
* Parameters: * Parameters:
* features - Array({<OpenLayers.Feature.Vector>}) * features - {Array(<OpenLayers.Feature.Vector>)}
*/ */
write: function(features) { write: function(features) {
if (!(features instanceof Array)) { if (!(features instanceof Array)) {

View File

@@ -5,9 +5,9 @@
/** /**
* @requires OpenLayers/Format/XML.js * @requires OpenLayers/Format/XML.js
* @requires OpenLayers/Style.js * @requires OpenLayers/Style.js
* @requires OpenLayers/Rule/FeatureId.js * @requires OpenLayers/Filter/FeatureId.js
* @requires OpenLayers/Rule/Logical.js * @requires OpenLayers/Filter/Logical.js
* @requires OpenLayers/Rule/Comparison.js * @requires OpenLayers/Filter/Comparison.js
*/ */
/** /**

View File

@@ -142,24 +142,8 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
style.rules = obj.rules; style.rules = obj.rules;
}, },
"Rule": function(node, obj) { "Rule": function(node, obj) {
// Rule elements are represented as OpenLayers.Rule instances. var rule = new OpenLayers.Rule();
// Filter elements are represented as instances of this.readChildNodes(node, rule);
// OpenLayers.Rule subclasses.
var config = {
rules: [],
symbolizer: {}
};
this.readChildNodes(node, config);
// Now we've either got zero or one rules (from filters)
var rule;
if(config.rules.length == 0) {
delete config.rules;
rule = new OpenLayers.Rule(config);
} else {
rule = config.rules[0];
delete config.rules;
OpenLayers.Util.extend(rule, config);
}
obj.rules.push(rule); obj.rules.push(rule);
}, },
"ElseFilter": function(node, rule) { "ElseFilter": function(node, rule) {
@@ -283,146 +267,121 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
}, },
"ogc": { "ogc": {
"Filter": function(node, rule) { "Filter": function(node, rule) {
// Filters correspond to subclasses of OpenLayers.Rule. // Filters correspond to subclasses of OpenLayers.Filter.
// Since they contain information we don't persist, we // Since they contain information we don't persist, we
// create a temporary object and then pass on the rules // create a temporary object and then pass on the filter
// (ogc:Filter) to the parent rule (sld:Rule). // (ogc:Filter) to the parent rule (sld:Rule).
var filter = { var obj = {
fids: [], fids: [],
rules: [] filters: []
}; };
this.readChildNodes(node, filter); this.readChildNodes(node, obj);
if(filter.fids.length > 0) { if(obj.fids.length > 0) {
rule.rules.push(new OpenLayers.Rule.FeatureId({ rule.filter = new OpenLayers.Filter.FeatureId({
fids: filter.fids fids: obj.fids
})); });
} } else if(obj.filters.length > 0) {
if(filter.rules.length > 0) { rule.filter = obj.filters[0];
rule.rules = rule.rules.concat(filter.rules);
} }
}, },
"FeatureId": function(node, filter) { "FeatureId": function(node, obj) {
var fid = node.getAttribute("fid"); var fid = node.getAttribute("fid");
if(fid) { if(fid) {
filter.fids.push(fid); obj.fids.push(fid);
} }
}, },
"And": function(node, filter) { "And": function(node, obj) {
var rule = new OpenLayers.Rule.Logical({ var filter = new OpenLayers.Filter.Logical({
type: OpenLayers.Rule.Logical.AND type: OpenLayers.Filter.Logical.AND
}); });
// since FeatureId rules may be nested here, make room for them this.readChildNodes(node, filter);
rule.fids = []; obj.filters.push(filter);
this.readChildNodes(node, rule);
if(rule.fids.length > 0) {
rule.rules.push(new OpenLayers.Rule.FeatureId({
fids: rule.fids
}));
}
delete rule.fids;
filter.rules.push(rule);
}, },
"Or": function(node, filter) { "Or": function(node, obj) {
var rule = new OpenLayers.Rule.Logical({ var filter = new OpenLayers.Filter.Logical({
type: OpenLayers.Rule.Logical.OR type: OpenLayers.Filter.Logical.OR
}); });
// since FeatureId rules may be nested here, make room for them this.readChildNodes(node, filter);
rule.fids = []; obj.filters.push(filter);
this.readChildNodes(node, rule);
if(rule.fids.length > 0) {
rule.rules.push(new OpenLayers.Rule.FeatureId({
fids: rule.fids
}));
}
delete rule.fids;
filter.rules.push(rule);
}, },
"Not": function(node, filter) { "Not": function(node, obj) {
var rule = new OpenLayers.Rule.Logical({ var filter = new OpenLayers.Filter.Logical({
type: OpenLayers.Rule.Logical.NOT type: OpenLayers.Filter.Logical.NOT
}); });
// since FeatureId rules may be nested here, make room for them this.readChildNodes(node, filter);
rule.fids = []; obj.filters.push(filter);
this.readChildNodes(node, rule);
if(rule.fids.length > 0) {
rule.rules.push(new OpenLayers.Rule.FeatureId({
fids: rule.fids
}));
}
delete rule.fids;
filter.rules.push(rule);
}, },
"PropertyIsEqualTo": function(node, filter) { "PropertyIsEqualTo": function(node, obj) {
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Rule.Comparison.EQUAL_TO type: OpenLayers.Filter.Comparison.EQUAL_TO
}); });
this.readChildNodes(node, rule); this.readChildNodes(node, filter);
filter.rules.push(rule); obj.filters.push(filter);
}, },
"PropertyIsNotEqualTo": function(node, filter) { "PropertyIsNotEqualTo": function(node, obj) {
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Rule.Comparison.NOT_EQUAL_TO type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO
}); });
this.readChildNodes(node, rule); this.readChildNodes(node, filter);
filter.rules.push(rule); obj.filters.push(filter);
}, },
"PropertyIsLessThan": function(node, filter) { "PropertyIsLessThan": function(node, obj) {
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Rule.Comparison.LESS_THAN type: OpenLayers.Filter.Comparison.LESS_THAN
}); });
this.readChildNodes(node, rule); this.readChildNodes(node, filter);
filter.rules.push(rule); obj.filters.push(filter);
}, },
"PropertyIsGreaterThan": function(node, filter) { "PropertyIsGreaterThan": function(node, obj) {
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Rule.Comparison.GREATER_THAN type: OpenLayers.Filter.Comparison.GREATER_THAN
}); });
this.readChildNodes(node, rule); this.readChildNodes(node, filter);
filter.rules.push(rule); obj.filters.push(filter);
}, },
"PropertyIsLessThanOrEqualTo": function(node, filter) { "PropertyIsLessThanOrEqualTo": function(node, obj) {
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO
}); });
this.readChildNodes(node, rule); this.readChildNodes(node, filter);
filter.rules.push(rule); obj.filters.push(filter);
}, },
"PropertyIsGreaterThanOrEqualTo": function(node, filter) { "PropertyIsGreaterThanOrEqualTo": function(node, obj) {
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO
}); });
this.readChildNodes(node, rule); this.readChildNodes(node, filter);
filter.rules.push(rule); obj.filters.push(filter);
}, },
"PropertyIsBetween": function(node, filter) { "PropertyIsBetween": function(node, obj) {
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Rule.Comparison.BETWEEN type: OpenLayers.Filter.Comparison.BETWEEN
}); });
this.readChildNodes(node, rule); this.readChildNodes(node, filter);
filter.rules.push(rule); obj.filters.push(filter);
}, },
"PropertyIsLike": function(node, filter) { "PropertyIsLike": function(node, obj) {
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Rule.Comparison.LIKE type: OpenLayers.Filter.Comparison.LIKE
}); });
this.readChildNodes(node, rule); this.readChildNodes(node, filter);
var wildCard = node.getAttribute("wildCard"); var wildCard = node.getAttribute("wildCard");
var singleChar = node.getAttribute("singleChar"); var singleChar = node.getAttribute("singleChar");
var esc = node.getAttribute("escape"); var esc = node.getAttribute("escape");
rule.value2regex(wildCard, singleChar, esc); filter.value2regex(wildCard, singleChar, esc);
filter.rules.push(rule); obj.filters.push(filter);
}, },
"Literal": function(node, obj) { "Literal": function(node, obj) {
obj.value = this.getChildValue(node); obj.value = this.getChildValue(node);
}, },
"PropertyName": function(node, rule) { "PropertyName": function(node, filter) {
rule.property = this.getChildValue(node); filter.property = this.getChildValue(node);
}, },
"LowerBoundary": function(node, rule) { "LowerBoundary": function(node, filter) {
rule.lowerBoundary = this.readOgcExpression(node); filter.lowerBoundary = this.readOgcExpression(node);
}, },
"UpperBoundary": function(node, rule) { "UpperBoundary": function(node, filter) {
rule.upperBoundary = this.readOgcExpression(node); filter.upperBoundary = this.readOgcExpression(node);
} }
} }
}, },
@@ -682,8 +641,8 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
// add in optional filters // add in optional filters
if(rule.elseFilter) { if(rule.elseFilter) {
this.writeNode(node, "ElseFilter"); this.writeNode(node, "ElseFilter");
} else if(rule.CLASS_NAME != "OpenLayers.Rule") { } else if(rule.filter) {
this.writeNode(node, "ogc:Filter", rule); this.writeNode(node, "ogc:Filter", rule.filter);
} }
// add in scale limits // add in scale limits
@@ -867,15 +826,15 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
} }
}, },
"ogc": { "ogc": {
"Filter": function(rule) { "Filter": function(filter) {
var node = this.createElementNSPlus("ogc:Filter"); var node = this.createElementNSPlus("ogc:Filter");
var sub = rule.CLASS_NAME.split(".").pop(); var sub = filter.CLASS_NAME.split(".").pop();
if(sub == "FeatureId") { if(sub == "FeatureId") {
for(var i=0; i<rule.fids.length; ++i) { for(var i=0; i<filter.fids.length; ++i) {
this.writeNode(node, "FeatureId", rule.fids[i]); this.writeNode(node, "FeatureId", filter.fids[i]);
} }
} else { } else {
this.writeNode(node, this.getFilterType(rule), rule); this.writeNode(node, this.getFilterType(filter), filter);
} }
return node; return node;
}, },
@@ -884,120 +843,120 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
attributes: {fid: fid} attributes: {fid: fid}
}); });
}, },
"And": function(rule) { "And": function(filter) {
var node = this.createElementNSPlus("ogc:And"); var node = this.createElementNSPlus("ogc:And");
var childRule; var childFilter;
for(var i=0; i<rule.rules.length; ++i) { for(var i=0; i<filter.filters.length; ++i) {
childRule = rule.rules[i]; childFilter = filter.filters[i];
this.writeNode( this.writeNode(
node, this.getFilterType(childRule), childRule node, this.getFilterType(childFilter), childFilter
); );
} }
return node; return node;
}, },
"Or": function(rule) { "Or": function(filter) {
var node = this.createElementNSPlus("ogc:Or"); var node = this.createElementNSPlus("ogc:Or");
var childRule; var childFilter;
for(var i=0; i<rule.rules.length; ++i) { for(var i=0; i<filter.filters.length; ++i) {
childRule = rule.rules[i]; childFilter = filter.filters[i];
this.writeNode( this.writeNode(
node, this.getFilterType(childRule), childRule node, this.getFilterType(childFilter), childFilter
); );
} }
return node; return node;
}, },
"Not": function(rule) { "Not": function(filter) {
var node = this.createElementNSPlus("ogc:Not"); var node = this.createElementNSPlus("ogc:Not");
var childRule = rule.rules[0]; var childFilter = filter.filters[0];
this.writeNode( this.writeNode(
node, this.getFilterType(childRule), childRule node, this.getFilterType(childFilter), childFilter
); );
return node; return node;
}, },
"PropertyIsEqualTo": function(rule) { "PropertyIsEqualTo": function(filter) {
var node = this.createElementNSPlus("ogc:PropertyIsEqualTo"); var node = this.createElementNSPlus("ogc:PropertyIsEqualTo");
// no ogc:expression handling for now // no ogc:expression handling for now
this.writeNode(node, "PropertyName", rule); this.writeNode(node, "PropertyName", filter);
this.writeNode(node, "Literal", rule); this.writeNode(node, "Literal", filter.value);
return node; return node;
}, },
"PropertyIsNotEqualTo": function(rule) { "PropertyIsNotEqualTo": function(filter) {
var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo"); var node = this.createElementNSPlus("ogc:PropertyIsNotEqualTo");
// no ogc:expression handling for now // no ogc:expression handling for now
this.writeNode(node, "PropertyName", rule); this.writeNode(node, "PropertyName", filter);
this.writeNode(node, "Literal", rule); this.writeNode(node, "Literal", filter.value);
return node; return node;
}, },
"PropertyIsLessThan": function(rule) { "PropertyIsLessThan": function(filter) {
var node = this.createElementNSPlus("ogc:PropertyIsLessThan"); var node = this.createElementNSPlus("ogc:PropertyIsLessThan");
// no ogc:expression handling for now // no ogc:expression handling for now
this.writeNode(node, "PropertyName", rule); this.writeNode(node, "PropertyName", filter);
this.writeNode(node, "Literal", rule); this.writeNode(node, "Literal", filter.value);
return node; return node;
}, },
"PropertyIsGreaterThan": function(rule) { "PropertyIsGreaterThan": function(filter) {
var node = this.createElementNSPlus("ogc:PropertyIsGreaterThan"); var node = this.createElementNSPlus("ogc:PropertyIsGreaterThan");
// no ogc:expression handling for now // no ogc:expression handling for now
this.writeNode(node, "PropertyName", rule); this.writeNode(node, "PropertyName", filter);
this.writeNode(node, "Literal", rule); this.writeNode(node, "Literal", filter.value);
return node; return node;
}, },
"PropertyIsLessThanOrEqualTo": function(rule) { "PropertyIsLessThanOrEqualTo": function(filter) {
var node = this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo"); var node = this.createElementNSPlus("ogc:PropertyIsLessThanOrEqualTo");
// no ogc:expression handling for now // no ogc:expression handling for now
this.writeNode(node, "PropertyName", rule); this.writeNode(node, "PropertyName", filter);
this.writeNode(node, "Literal", rule); this.writeNode(node, "Literal", filter.value);
return node; return node;
}, },
"PropertyIsGreaterThanOrEqualTo": function(rule) { "PropertyIsGreaterThanOrEqualTo": function(filter) {
var node = this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo"); var node = this.createElementNSPlus("ogc:PropertyIsGreaterThanOrEqualTo");
// no ogc:expression handling for now // no ogc:expression handling for now
this.writeNode(node, "PropertyName", rule); this.writeNode(node, "PropertyName", filter);
this.writeNode(node, "Literal", rule); this.writeNode(node, "Literal", filter.value);
return node; return node;
}, },
"PropertyIsBetween": function(rule) { "PropertyIsBetween": function(filter) {
var node = this.createElementNSPlus("ogc:PropertyIsBetween"); var node = this.createElementNSPlus("ogc:PropertyIsBetween");
// no ogc:expression handling for now // no ogc:expression handling for now
this.writeNode(node, "PropertyName", rule); this.writeNode(node, "PropertyName", filter);
this.writeNode(node, "LowerBoundary", rule); this.writeNode(node, "LowerBoundary", filter);
this.writeNode(node, "UpperBoundary", rule); this.writeNode(node, "UpperBoundary", filter);
return node; return node;
}, },
"PropertyIsLike": function(rule) { "PropertyIsLike": function(filter) {
var node = this.createElementNSPlus("ogc:PropertyIsLike", { var node = this.createElementNSPlus("ogc:PropertyIsLike", {
attributes: { attributes: {
wildCard: "*", singleChar: ".", escape: "!" wildCard: "*", singleChar: ".", escape: "!"
} }
}); });
// no ogc:expression handling for now // no ogc:expression handling for now
this.writeNode(node, "PropertyName", rule); this.writeNode(node, "PropertyName", filter);
// convert regex string to ogc string // convert regex string to ogc string
this.writeNode(node, "Literal", {value: rule.regex2value()}); this.writeNode(node, "Literal", filter.regex2value());
return node; return node;
}, },
"PropertyName": function(rule) { "PropertyName": function(filter) {
// no ogc:expression handling for now // no ogc:expression handling for now
return this.createElementNSPlus("ogc:PropertyName", { return this.createElementNSPlus("ogc:PropertyName", {
value: rule.property value: filter.property
}); });
}, },
"Literal": function(rule) { "Literal": function(value) {
// no ogc:expression handling for now // no ogc:expression handling for now
return this.createElementNSPlus("ogc:Literal", { return this.createElementNSPlus("ogc:Literal", {
value: rule.value value: value
}); });
}, },
"LowerBoundary": function(rule) { "LowerBoundary": function(filter) {
// no ogc:expression handling for now // no ogc:expression handling for now
var node = this.createElementNSPlus("ogc:LowerBoundary"); var node = this.createElementNSPlus("ogc:LowerBoundary");
this.writeNode(node, "Literal", rule.lowerBoundary); this.writeNode(node, "Literal", filter.lowerBoundary);
return node; return node;
}, },
"UpperBoundary": function(rule) { "UpperBoundary": function(filter) {
// no ogc:expression handling for now // no ogc:expression handling for now
var node = this.createElementNSPlus("ogc:UpperBoundary"); var node = this.createElementNSPlus("ogc:UpperBoundary");
this.writeNode(node, "Literal", rule.upperBoundary); this.writeNode(node, "Literal", filter.upperBoundary);
return node; return node;
} }
} }
@@ -1006,17 +965,17 @@ OpenLayers.Format.SLD.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
/** /**
* Method: getFilterType * Method: getFilterType
*/ */
getFilterType: function(rule) { getFilterType: function(filter) {
var filterType = this.filterMap[rule.type]; var filterType = this.filterMap[filter.type];
if(!filterType) { if(!filterType) {
throw "SLD writing not supported for rule type: " + rule.type; throw "SLD writing not supported for rule type: " + filter.type;
} }
return filterType; return filterType;
}, },
/** /**
* Property: filterMap * Property: filterMap
* {Object} Contains a member for each rule type. Values are node names * {Object} Contains a member for each filter type. Values are node names
* for corresponding OGC Filter child elements. * for corresponding OGC Filter child elements.
*/ */
filterMap: { filterMap: {

View File

@@ -31,7 +31,7 @@ OpenLayers.Geometry.MultiPoint = OpenLayers.Class(
* Create a new MultiPoint Geometry * Create a new MultiPoint Geometry
* *
* Parameters: * Parameters:
* components - Array({<OpenLayers.Geometry.Point>}) * components - {Array(<OpenLayers.Geometry.Point>)}
* *
* Returns: * Returns:
* {<OpenLayers.Geometry.MultiPoint>} * {<OpenLayers.Geometry.MultiPoint>}

View File

@@ -33,7 +33,7 @@ OpenLayers.Geometry.Polygon = OpenLayers.Class(
* *
* *
* Parameters: * Parameters:
* components - Array({<OpenLayers.Geometry.LinearRing>}) * components - {Array(<OpenLayers.Geometry.LinearRing>)}
*/ */
initialize: function(components) { initialize: function(components) {
OpenLayers.Geometry.Collection.prototype.initialize.apply(this, OpenLayers.Geometry.Collection.prototype.initialize.apply(this,

View File

@@ -6,15 +6,8 @@
* @requires OpenLayers/Geometry.js * @requires OpenLayers/Geometry.js
*/ */
/**
* Class: OpenLayers.Geometry.Surface
*/
OpenLayers.Geometry.Surface = OpenLayers.Class(OpenLayers.Geometry, { OpenLayers.Geometry.Surface = OpenLayers.Class(OpenLayers.Geometry, {
/**
* Constructor: OpenLayers.Geometry.Surface
*
*/
initialize: function() { initialize: function() {
OpenLayers.Geometry.prototype.initialize.apply(this, arguments); OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
}, },

View File

@@ -79,7 +79,7 @@ OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {
/** /**
* 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 <delayedCall>.
*/ */
timerId: null, timerId: null,

View File

@@ -997,6 +997,8 @@ OpenLayers.Layer = OpenLayers.Class({
/** /**
* APIMethod: getViewPortPxFromLonLat * APIMethod: getViewPortPxFromLonLat
* Returns a pixel location given a map location. This method will return
* fractional pixel values.
* *
* Parameters: * Parameters:
* lonlat - {<OpenLayers.LonLat>} * lonlat - {<OpenLayers.LonLat>}
@@ -1011,8 +1013,8 @@ OpenLayers.Layer = OpenLayers.Class({
var resolution = this.map.getResolution(); var resolution = this.map.getResolution();
var extent = this.map.getExtent(); var extent = this.map.getExtent();
px = new OpenLayers.Pixel( px = new OpenLayers.Pixel(
Math.round(1/resolution * (lonlat.lon - extent.left)), (1/resolution * (lonlat.lon - extent.left)),
Math.round(1/resolution * (extent.top - lonlat.lat)) (1/resolution * (extent.top - lonlat.lat))
); );
} }
return px; return px;

View File

@@ -26,7 +26,7 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, {
/** /**
* Property: features * Property: features
* Array({<OpenLayers.Feature>}) * {Array(<OpenLayers.Feature>)}
*/ */
features: null, features: null,

View File

@@ -9,8 +9,8 @@
/** /**
* Class: OpenLayers.Layer.MapServer.Untiled * Class: OpenLayers.Layer.MapServer.Untiled
* Deprecated, to be removed in 3.0 - instead use OpenLayers.Layer.MapServer and * *Deprecated*. To be removed in 3.0. Instead use OpenLayers.Layer.MapServer
* pass the option 'singleTile' as true. * and pass the option 'singleTile' as true.
* *
* Inherits from: * Inherits from:
* - <OpenLayers.Layer.MapServer> * - <OpenLayers.Layer.MapServer>

View File

@@ -23,7 +23,7 @@ OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer, {
/** /**
* Property: markers * Property: markers
* Array({<OpenLayers.Marker>}) internal marker list * {Array(<OpenLayers.Marker>)} internal marker list
*/ */
markers: null, markers: null,

View File

@@ -13,8 +13,8 @@
* option. See Ticket #953 for more details. * option. See Ticket #953 for more details.
* *
* Inherits from: * Inherits from:
* - <OpenLayers.Layers.EventPane> * - <OpenLayers.Layer.EventPane>
* - <OpenLayers.Layers.FixedZoomLevels> * - <OpenLayers.Layer.FixedZoomLevels>
*/ */
OpenLayers.Layer.MultiMap = OpenLayers.Class( OpenLayers.Layer.MultiMap = OpenLayers.Class(
OpenLayers.Layer.EventPane, OpenLayers.Layer.FixedZoomLevels, { OpenLayers.Layer.EventPane, OpenLayers.Layer.FixedZoomLevels, {

View File

@@ -50,7 +50,7 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, {
/** /**
* Property: features * Property: features
* Array({<OpenLayers.Feature>}) * {Array(<OpenLayers.Feature>)}
*/ */
features: null, features: null,

View File

@@ -87,13 +87,13 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
/** /**
* APIProperty: features * APIProperty: features
* Array({<OpenLayers.Feature.Vector>}) * {Array(<OpenLayers.Feature.Vector>)}
*/ */
features: null, features: null,
/** /**
* Property: selectedFeatures * Property: selectedFeatures
* Array({<OpenLayers.Feature.Vector>}) * {Array(<OpenLayers.Feature.Vector>)}
*/ */
selectedFeatures: null, selectedFeatures: null,
@@ -118,7 +118,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
/** /**
* Property: renderers * Property: renderers
* Array({String}) List of supported Renderer classes. Add to this list to * {Array(String)} List of supported Renderer classes. Add to this list to
* add support for additional renderers. This list is ordered: * add support for additional renderers. This list is ordered:
* the first renderer which returns true for the 'supported()' * the first renderer which returns true for the 'supported()'
* method will be used, if not defined in the 'renderer' option. * method will be used, if not defined in the 'renderer' option.

View File

@@ -9,7 +9,7 @@
/** /**
* Class: OpenLayers.Layer.WMS.Untiled * Class: OpenLayers.Layer.WMS.Untiled
* Deprecated, to be removed in 3.0 - instead use OpenLayers.Layer.WMS and * *Deprecated*. To be removed in 3.0. Instead use OpenLayers.Layer.WMS and
* pass the option 'singleTile' as true. * pass the option 'singleTile' as true.
* *
* Inherits from: * Inherits from:

View File

@@ -820,7 +820,7 @@ OpenLayers.Map = OpenLayers.Class({
* APIMethod: addLayers * APIMethod: addLayers
* *
* Parameters: * Parameters:
* layers - Array({<OpenLayers.Layer>}) * layers - {Array(<OpenLayers.Layer>)}
*/ */
addLayers: function (layers) { addLayers: function (layers) {
for (var i = 0; i < layers.length; i++) { for (var i = 0; i < layers.length; i++) {
@@ -1593,8 +1593,8 @@ OpenLayers.Map = OpenLayers.Class({
var newPx = this.getViewPortPxFromLonLat(lonlat); var newPx = this.getViewPortPxFromLonLat(lonlat);
if ((originPx != null) && (newPx != null)) { if ((originPx != null) && (newPx != null)) {
this.layerContainerDiv.style.left = (originPx.x - newPx.x) + "px"; this.layerContainerDiv.style.left = Math.round(originPx.x - newPx.x) + "px";
this.layerContainerDiv.style.top = (originPx.y - newPx.y) + "px"; this.layerContainerDiv.style.top = Math.round(originPx.y - newPx.y) + "px";
} }
}, },
@@ -1963,7 +1963,7 @@ OpenLayers.Map = OpenLayers.Class({
// //
/** /**
* APIMethod: getLonLatFromViewPortPx * Method: getLonLatFromViewPortPx
* *
* Parameters: * Parameters:
* viewPortPx - {<OpenLayers.Pixel>} * viewPortPx - {<OpenLayers.Pixel>}
@@ -2022,17 +2022,23 @@ OpenLayers.Map = OpenLayers.Class({
/** /**
* APIMethod: getPixelFromLonLat * APIMethod: getPixelFromLonLat
* Returns a pixel location given a map location. The map location is
* translated to an integer pixel location (in viewport pixel
* coordinates) by the current base layer.
* *
* Parameters: * Parameters:
* lonlat - {<OpenLayers.LonLat>} * lonlat - {<OpenLayers.LonLat>} A map location.
* *
* Returns: * Returns:
* {<OpenLayers.Pixel>} An OpenLayers.Pixel corresponding to the * {<OpenLayers.Pixel>} An OpenLayers.Pixel corresponding to the
* <OpenLayers.LonLat> translated into view port * <OpenLayers.LonLat> translated into view port pixels by the current
* pixels by the current base layer. * base layer.
*/ */
getPixelFromLonLat: function (lonlat) { getPixelFromLonLat: function (lonlat) {
return this.getViewPortPxFromLonLat(lonlat); var px = this.getViewPortPxFromLonLat(lonlat);
px.x = Math.round(px.x);
px.y = Math.round(px.y);
return px;
}, },
@@ -2089,7 +2095,7 @@ OpenLayers.Map = OpenLayers.Class({
// //
/** /**
* APIMethod: getLonLatFromLayerPx * Method: getLonLatFromLayerPx
* *
* Parameters: * Parameters:
* px - {<OpenLayers.Pixel>} * px - {<OpenLayers.Pixel>}
@@ -2116,7 +2122,7 @@ OpenLayers.Map = OpenLayers.Class({
*/ */
getLayerPxFromLonLat: function (lonlat) { getLayerPxFromLonLat: function (lonlat) {
//adjust for displacement of layerContainerDiv //adjust for displacement of layerContainerDiv
var px = this.getViewPortPxFromLonLat(lonlat); var px = this.getPixelFromLonLat(lonlat);
return this.getLayerPxFromViewPortPx(px); return this.getLayerPxFromViewPortPx(px);
}, },

View File

@@ -250,7 +250,16 @@ OpenLayers.Popup.Framed =
createBlocks: function() { createBlocks: function() {
this.blocks = []; this.blocks = [];
var position = this.positionBlocks[this.relativePosition]; //since all positions contain the same number of blocks, we can
// just pick the first position and use its blocks array to create
// our blocks array
var firstPosition = null;
for(var key in this.positionBlocks) {
firstPosition = key;
break;
}
var position = this.positionBlocks[firstPosition];
for (var i = 0; i < position.blocks.length; i++) { for (var i = 0; i < position.blocks.length; i++) {
var block = {}; var block = {};
@@ -283,48 +292,49 @@ OpenLayers.Popup.Framed =
* the popup's blocks in their appropropriate places. * the popup's blocks in their appropropriate places.
*/ */
updateBlocks: function() { updateBlocks: function() {
if (!this.blocks) { if (!this.blocks) {
this.createBlocks(); this.createBlocks();
} }
var position = this.positionBlocks[this.relativePosition]; if (this.relativePosition) {
for (var i = 0; i < position.blocks.length; i++) { var position = this.positionBlocks[this.relativePosition];
for (var i = 0; i < position.blocks.length; i++) {
var positionBlock = position.blocks[i]; var positionBlock = position.blocks[i];
var block = this.blocks[i]; var block = this.blocks[i];
// adjust sizes // adjust sizes
var l = positionBlock.anchor.left; var l = positionBlock.anchor.left;
var b = positionBlock.anchor.bottom; var b = positionBlock.anchor.bottom;
var r = positionBlock.anchor.right; var r = positionBlock.anchor.right;
var t = positionBlock.anchor.top; var t = positionBlock.anchor.top;
//note that we use the isNaN() test here because if the //note that we use the isNaN() test here because if the
// size object is initialized with a "auto" parameter, the // size object is initialized with a "auto" parameter, the
// size constructor calls parseFloat() on the string, // size constructor calls parseFloat() on the string,
// which will turn it into NaN // which will turn it into NaN
// //
var w = (isNaN(positionBlock.size.w)) ? this.size.w - (r + l) var w = (isNaN(positionBlock.size.w)) ? this.size.w - (r + l)
: positionBlock.size.w; : positionBlock.size.w;
var h = (isNaN(positionBlock.size.h)) ? this.size.h - (b + t) var h = (isNaN(positionBlock.size.h)) ? this.size.h - (b + t)
: positionBlock.size.h; : positionBlock.size.h;
block.div.style.width = w + 'px'; block.div.style.width = w + 'px';
block.div.style.height = h + 'px'; block.div.style.height = h + 'px';
block.div.style.left = (l != null) ? l + 'px' : ''; block.div.style.left = (l != null) ? l + 'px' : '';
block.div.style.bottom = (b != null) ? b + 'px' : ''; block.div.style.bottom = (b != null) ? b + 'px' : '';
block.div.style.right = (r != null) ? r + 'px' : ''; block.div.style.right = (r != null) ? r + 'px' : '';
block.div.style.top = (t != null) ? t + 'px' : ''; block.div.style.top = (t != null) ? t + 'px' : '';
block.image.style.left = positionBlock.position.x + 'px'; block.image.style.left = positionBlock.position.x + 'px';
block.image.style.top = positionBlock.position.y + 'px'; block.image.style.top = positionBlock.position.y + 'px';
}
this.contentDiv.style.left = this.padding.left + "px";
this.contentDiv.style.top = this.padding.top + "px";
} }
this.contentDiv.style.left = this.padding.left + "px";
this.contentDiv.style.top = this.padding.top + "px";
}, },
CLASS_NAME: "OpenLayers.Popup.Framed" CLASS_NAME: "OpenLayers.Popup.Framed"

View File

@@ -28,12 +28,6 @@ OpenLayers.Popup.FramedCloud =
*/ */
panMapIfOutOfView: true, panMapIfOutOfView: true,
/**
* Property: imageSrc
* {String}
*/
imageSrc: null,
/** /**
* APIProperty: imageSize * APIProperty: imageSize
* {<OpenLayers.Size>} * {<OpenLayers.Size>}
@@ -214,9 +208,9 @@ OpenLayers.Popup.FramedCloud =
initialize:function(id, lonlat, size, contentHTML, anchor, closeBox, initialize:function(id, lonlat, size, contentHTML, anchor, closeBox,
closeBoxCallback) { closeBoxCallback) {
this.imageSrc = OpenLayers.Util.getImagesLocation() + 'cloud-popup-relative.png';
OpenLayers.Popup.Framed.prototype.initialize.apply(this, arguments); OpenLayers.Popup.Framed.prototype.initialize.apply(this, arguments);
this.contentDiv.className = "olFramedCloudPopupContent"; this.contentDiv.className = "olFramedCloudPopupContent";
this.imageSrc = OpenLayers.Util.getImagesLocation() + 'cloud-popup-relative.png';
}, },
/** /**

View File

@@ -37,10 +37,10 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
if (!this.supported()) { if (!this.supported()) {
return; return;
} }
if (!document.namespaces.v) { if (!document.namespaces.olv) {
document.namespaces.add("v", this.xmlns); document.namespaces.add("olv", this.xmlns);
var style = document.createStyleSheet(); var style = document.createStyleSheet();
style.addRule('v\\:*', "behavior: url(#default#VML); " + style.addRule('olv\\:*', "behavior: url(#default#VML); " +
"position: absolute; display: inline-block;"); "position: absolute; display: inline-block;");
} }
OpenLayers.Renderer.Elements.prototype.initialize.apply(this, OpenLayers.Renderer.Elements.prototype.initialize.apply(this,
@@ -120,17 +120,17 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
var nodeType = null; var nodeType = null;
switch (geometry.CLASS_NAME) { switch (geometry.CLASS_NAME) {
case "OpenLayers.Geometry.Point": case "OpenLayers.Geometry.Point":
nodeType = style.externalGraphic ? "v:rect" : "v:oval"; nodeType = style.externalGraphic ? "olv:rect" : "olv:oval";
break; break;
case "OpenLayers.Geometry.Rectangle": case "OpenLayers.Geometry.Rectangle":
nodeType = "v:rect"; nodeType = "olv:rect";
break; break;
case "OpenLayers.Geometry.LineString": case "OpenLayers.Geometry.LineString":
case "OpenLayers.Geometry.LinearRing": case "OpenLayers.Geometry.LinearRing":
case "OpenLayers.Geometry.Polygon": case "OpenLayers.Geometry.Polygon":
case "OpenLayers.Geometry.Curve": case "OpenLayers.Geometry.Curve":
case "OpenLayers.Geometry.Surface": case "OpenLayers.Geometry.Surface":
nodeType = "v:shape"; nodeType = "olv:shape";
break; break;
default: default:
break; break;
@@ -195,7 +195,7 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
} }
} else { } else {
if (!fill) { if (!fill) {
fill = this.createNode('v:fill', node.id + "_fill"); fill = this.createNode('olv:fill', node.id + "_fill");
} }
fill.setAttribute("opacity", style.fillOpacity); fill.setAttribute("opacity", style.fillOpacity);
@@ -236,7 +236,7 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
} }
} else { } else {
if (!stroke) { if (!stroke) {
stroke = this.createNode('v:stroke', node.id + "_stroke"); stroke = this.createNode('olv:stroke', node.id + "_stroke");
node.appendChild(stroke); node.appendChild(stroke);
} }
stroke.setAttribute("opacity", style.strokeOpacity); stroke.setAttribute("opacity", style.strokeOpacity);
@@ -379,7 +379,7 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
* {DOMElement} The main root element to which we'll add vectors * {DOMElement} The main root element to which we'll add vectors
*/ */
createRoot: function() { createRoot: function() {
return this.nodeFactory(this.container.id + "_root", "v:group"); return this.nodeFactory(this.container.id + "_root", "olv:group");
}, },
/************************************** /**************************************

View File

@@ -10,7 +10,7 @@
/** /**
* Class: OpenLayers.Rule * Class: OpenLayers.Rule
* This class represents a OGC Rule, as being used for rule-based SLD styling. * This class represents an SLD Rule, as being used for rule-based SLD styling.
*/ */
OpenLayers.Rule = OpenLayers.Class({ OpenLayers.Rule = OpenLayers.Class({
@@ -46,6 +46,12 @@ OpenLayers.Rule = OpenLayers.Class({
*/ */
context: null, context: null,
/**
* Property: filter
* {<OpenLayers.Filter>} Optional filter for the rule.
*/
filter: 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
@@ -116,7 +122,7 @@ OpenLayers.Rule = OpenLayers.Class({
* 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) {
@@ -137,6 +143,16 @@ OpenLayers.Rule = OpenLayers.Class({
this.maxScaleDenominator, context); this.maxScaleDenominator, context);
} }
// check if optional filter applies
if(applies && this.filter) {
// feature id filters get the feature, others get the context
if(this.filter.CLASS_NAME == "OpenLayers.Filter.FeatureId") {
applies = this.filter.evaluate(feature);
} else {
applies = this.filter.evaluate(context);
}
}
return applies; return applies;
}, },

View File

@@ -1,104 +0,0 @@
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Rule.js
*/
/**
* Class: OpenLayers.Rule.Logical
* This class represents ogc:And, ogc:Or and ogc:Not rules.
*
* Inherits from
* - <OpenLayers.Rule>
*/
OpenLayers.Rule.Logical = OpenLayers.Class(OpenLayers.Rule, {
/**
* APIProperty: children
* {Array(<OpenLayers.Rule>)} child rules for this rule
*/
rules: null,
/**
* APIProperty: type
* {String} type of logical operator. Available types are:
* - OpenLayers.Rule.Locical.AND = "&&";
* - OpenLayers.Rule.Logical.OR = "||";
* - OpenLayers.Rule.Logical.NOT = "!";
*/
type: null,
/**
* Constructor: OpenLayers.Rule.Logical
* Creates a logical rule (And, Or, Not).
*
* Parameters:
* options - {Object} An optional object with properties to set on the
* rule
*
* Returns:
* {<OpenLayers.Rule.Logical>}
*/
initialize: function(options) {
this.rules = [];
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
},
/**
* APIMethod: destroy
* nullify references to prevent circular references and memory leaks
*/
destroy: function() {
for (var i=0; i<this.rules.length; i++) {
this.rules[i].destroy();
}
this.rules = null;
OpenLayers.Rule.prototype.destroy.apply(this, arguments);
},
/**
* APIMethod: evaluate
* evaluates this rule for a specific feature
*
* Parameters:
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
*
* Returns:
* {boolean} true if the rule applies, false if it does not
*/
evaluate: function(feature) {
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
return false;
}
switch(this.type) {
case OpenLayers.Rule.Logical.AND:
for (var i=0; i<this.rules.length; i++) {
if (this.rules[i].evaluate(feature) == false) {
return false;
}
}
return true;
case OpenLayers.Rule.Logical.OR:
for (var i=0; i<this.rules.length; i++) {
if (this.rules[i].evaluate(feature) == true) {
return true;
}
}
return false;
case OpenLayers.Rule.Logical.NOT:
return (!this.rules[0].evaluate(feature));
}
},
CLASS_NAME: "OpenLayers.Rule.Logical"
});
OpenLayers.Rule.Logical.AND = "&&";
OpenLayers.Rule.Logical.OR = "||";
OpenLayers.Rule.Logical.NOT = "!";

View File

@@ -48,7 +48,7 @@ OpenLayers.Style = OpenLayers.Class({
/** /**
* Property: rules * Property: rules
* Array({<OpenLayers.Rule>}) * {Array(<OpenLayers.Rule>)}
*/ */
rules: null, rules: null,

View File

@@ -22,8 +22,8 @@ OpenLayers.StyleMap = OpenLayers.Class({
/** /**
* Property: extendDefault * Property: extendDefault
* {Boolean} if true, every render intent will extend the symbolizers * {Boolean} if true, every render intent will extend the symbolizers
* specified for the "default" intent. Otherwise, every rendering intent * specified for the "default" intent at rendering time. Otherwise, every
* is treated as a completely independent symbolizer. * rendering intent will be treated as a completely independent style.
*/ */
extendDefault: true, extendDefault: true,
@@ -33,7 +33,9 @@ OpenLayers.StyleMap = OpenLayers.Class({
* Parameters: * Parameters:
* style - {Object} Optional. Either a style hash, or a style object, or * style - {Object} Optional. Either a style hash, or a style object, or
* a hash of style objects (style hashes) keyed by rendering * a hash of style objects (style hashes) keyed by rendering
* intent * intent. If just one style hash or style object is passed,
* this will be used for all known render intents (default,
* select, temporary)
* options - {Object} optional hash of additional options for this * options - {Object} optional hash of additional options for this
* instance * instance
*/ */
@@ -52,6 +54,8 @@ OpenLayers.StyleMap = OpenLayers.Class({
if(style instanceof OpenLayers.Style) { if(style instanceof OpenLayers.Style) {
// user passed a style object // user passed a style object
this.styles["default"] = style; this.styles["default"] = style;
this.styles["select"] = style;
this.styles["temporary"] = style;
} else if(typeof style == "object") { } else if(typeof style == "object") {
for(var key in style) { for(var key in style) {
if(style[key] instanceof OpenLayers.Style) { if(style[key] instanceof OpenLayers.Style) {
@@ -63,6 +67,8 @@ OpenLayers.StyleMap = OpenLayers.Class({
} else { } else {
// user passed a style hash (i.e. symbolizer) // user passed a style hash (i.e. symbolizer)
this.styles["default"] = new OpenLayers.Style(style); this.styles["default"] = new OpenLayers.Style(style);
this.styles["select"] = new OpenLayers.Style(style);
this.styles["temporary"] = new OpenLayers.Style(style);
break; break;
} }
} }
@@ -128,11 +134,14 @@ OpenLayers.StyleMap = OpenLayers.Class({
addUniqueValueRules: function(renderIntent, property, symbolizers) { addUniqueValueRules: function(renderIntent, property, symbolizers) {
var rules = []; var rules = [];
for (var value in symbolizers) { for (var value in symbolizers) {
rules.push(new OpenLayers.Rule.Comparison({ rules.push(new OpenLayers.Rule({
type: OpenLayers.Rule.Comparison.EQUAL_TO, symbolizer: symbolizers[value],
property: property, filter: new OpenLayers.Filter.Comparison({
value: value, type: OpenLayers.Filter.Comparison.EQUAL_TO,
symbolizer: symbolizers[value]})); property: property,
value: value
})
}));
} }
this.styles[renderIntent].addRules(rules); this.styles[renderIntent].addRules(rules);
}, },

View File

@@ -56,12 +56,24 @@ OpenLayers.Util.extend = function(destination, source) {
destination[property] = value; destination[property] = value;
} }
} }
/** /**
* IE doesn't include the toString property when iterating over an object's * IE doesn't include the toString property when iterating over an object's
* properties with the for(property in object) syntax. Explicitly check if * properties with the for(property in object) syntax. Explicitly check if
* the source has its own toString property. * the source has its own toString property.
*/ */
if(source.hasOwnProperty && source.hasOwnProperty('toString')) {
/*
* FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative
* prototype object" when calling hawOwnProperty if the source object
* is an instance of window.Event.
*/
var sourceIsEvt = typeof window.Event == "function"
&& source instanceof window.Event;
if(!sourceIsEvt
&& source.hasOwnProperty && source.hasOwnProperty('toString')) {
destination.toString = source.toString; destination.toString = source.toString;
} }
} }
@@ -510,9 +522,18 @@ OpenLayers.Util.upperCaseObject = function (object) {
* in place and returned by this function. * in place and returned by this function.
*/ */
OpenLayers.Util.applyDefaults = function (to, from) { OpenLayers.Util.applyDefaults = function (to, from) {
/*
* FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative
* prototype object" when calling hawOwnProperty if the source object is an
* instance of window.Event.
*/
var fromIsEvt = typeof window.Event == "function"
&& from instanceof window.Event;
for (var key in from) { for (var key in from) {
if (to[key] === undefined || if (to[key] === undefined ||
(from.hasOwnProperty (!fromIsEvt && from.hasOwnProperty
&& from.hasOwnProperty(key) && !to.hasOwnProperty(key))) { && from.hasOwnProperty(key) && !to.hasOwnProperty(key))) {
to[key] = from[key]; to[key] = from[key];
} }
@@ -522,7 +543,7 @@ OpenLayers.Util.applyDefaults = function (to, from) {
* properties with the for(property in object) syntax. Explicitly check if * properties with the for(property in object) syntax. Explicitly check if
* the source has its own toString property. * the source has its own toString property.
*/ */
if(from.hasOwnProperty if(!fromIsEvt && from.hasOwnProperty
&& from.hasOwnProperty('toString') && !to.hasOwnProperty('toString')) { && from.hasOwnProperty('toString') && !to.hasOwnProperty('toString')) {
to.toString = from.toString; to.toString = from.toString;
} }

View File

@@ -33,6 +33,23 @@
map.addControl(control2, new OpenLayers.Pixel(100,100)); map.addControl(control2, new OpenLayers.Pixel(100,100));
t.eq( control2.div.style.top, "100px", "2nd control div is located correctly"); t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
} }
function test_Control_PanZoomBar_divClick (t) {
t.plan(2);
map = new OpenLayers.Map('map', {controls:[]});
var layer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(layer);
control = new OpenLayers.Control.PanZoomBar();
map.addControl(control);
control.divClick({'xy': {'x': 0, 'y': 50}, which: 1});
t.eq(map.zoom, 11, "zoom is correct on standard map");
map.fractionalZoom = true;
control.divClick({'xy': {'x': 0, 'y': 49}, which: 1});
t.eq(map.zoom.toFixed(3), '10.545', "zoom is correct on fractional zoom map");
}
</script> </script>
</head> </head>

21
tests/Extras.html Normal file
View File

@@ -0,0 +1,21 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map;
// Ensure that we continue to work if silly Javascript frameworks
// extend object.
Object.prototype.foo = function() { }
function test_Events_Object_Extension(t) {
t.plan(1)
map = new OpenLayers.Map("map");
t.ok("Map created if object prototype is extended.");
}
</script>
</head>
<body>
<div id="map" style="width: 600px; height: 300px;"/>
</body>
</html>

21
tests/Filter.html Normal file
View File

@@ -0,0 +1,21 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_initialize(t) {
t.plan(3);
var options = {'foo': 'bar'};
var filter = new OpenLayers.Filter(options);
t.ok(filter instanceof OpenLayers.Filter,
"new OpenLayers.Filter returns object" );
t.eq(filter.foo, "bar", "constructor sets options correctly");
t.eq(typeof filter.evaluate, "function", "filter has an evaluate function");
}
</script>
</head>
<body>
</body>
</html>

View File

@@ -7,41 +7,41 @@
t.plan(3); t.plan(3);
var options = {'foo': 'bar'}; var options = {'foo': 'bar'};
var rule = new OpenLayers.Rule.Comparison(options); var filter = new OpenLayers.Filter.Comparison(options);
t.ok(rule instanceof OpenLayers.Rule.Comparison, t.ok(filter instanceof OpenLayers.Filter.Comparison,
"new OpenLayers.Rule.Comparison returns object" ); "new OpenLayers.Filter.Comparison returns object" );
t.eq(rule.foo, "bar", "constructor sets options correctly"); t.eq(filter.foo, "bar", "constructor sets options correctly");
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function"); t.eq(typeof filter.evaluate, "function", "filter has an evaluate function");
} }
function test_Comparison_destroy(t) { function test_Comparison_destroy(t) {
t.plan(1); t.plan(1);
var rule = new OpenLayers.Rule.Comparison(); var filter = new OpenLayers.Filter.Comparison();
rule.destroy(); filter.destroy();
t.eq(rule.symbolizer, null, "symbolizer hash nulled properly"); t.eq(filter.symbolizer, null, "symbolizer hash nulled properly");
} }
function test_Comparison_value2regex(t) { function test_Comparison_value2regex(t) {
t.plan(2); t.plan(2);
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
property: "foo", property: "foo",
value: "*b?r\\*\\?*", value: "*b?r\\*\\?*",
type: OpenLayers.Rule.Comparison.LIKE}); type: OpenLayers.Filter.Comparison.LIKE});
rule.value2regex("*", "?", "\\"); filter.value2regex("*", "?", "\\");
t.eq(rule.value, ".*b.r\\*\\?.*", "Regular expression generated correctly."); t.eq(filter.value, ".*b.r\\*\\?.*", "Regular expression generated correctly.");
rule.value = "%b.r!%!.%"; filter.value = "%b.r!%!.%";
rule.value2regex("%", ".", "!"); filter.value2regex("%", ".", "!");
t.eq(rule.value, ".*b.r\\%\\..*", "Regular expression with different wildcard and escape chars generated correctly."); t.eq(filter.value, ".*b.r\\%\\..*", "Regular expression with different wildcard and escape chars generated correctly.");
} }
function test_regex2value(t) { function test_regex2value(t) {
t.plan(8); t.plan(8);
function r2v(regex) { function r2v(regex) {
return OpenLayers.Rule.Comparison.prototype.regex2value.call( return OpenLayers.Filter.Comparison.prototype.regex2value.call(
{value: regex} {value: regex}
); );
} }
@@ -60,11 +60,11 @@
function test_Comparison_evaluate(t) { function test_Comparison_evaluate(t) {
t.plan(5); t.plan(5);
var rule = new OpenLayers.Rule.Comparison({ var filter = new OpenLayers.Filter.Comparison({
property: "area", property: "area",
lowerBoundary: 1000, lowerBoundary: 1000,
upperBoundary: 4999, upperBoundary: 4999,
type: OpenLayers.Rule.Comparison.BETWEEN}); type: OpenLayers.Filter.Comparison.BETWEEN});
var features = [ var features = [
new OpenLayers.Feature.Vector(null, { new OpenLayers.Feature.Vector(null, {
@@ -76,21 +76,21 @@
new OpenLayers.Feature.Vector(null, { new OpenLayers.Feature.Vector(null, {
area: 5000})]; area: 5000})];
// PropertyIsBetween filter: lower and upper boundary are inclusive // PropertyIsBetween filter: lower and upper boundary are inclusive
var ruleResults = { var filterResults = {
0: false, 0: false,
1: true, 1: true,
2: true, 2: true,
3: false}; 3: false};
for (var i in ruleResults) { for (var i in filterResults) {
var result = rule.evaluate(features[i]); var result = filter.evaluate(features[i].attributes);
t.eq(result, ruleResults[i], "feature "+i+ t.eq(result, filterResults[i], "feature "+i+
" evaluates to "+result.toString()+" correctly."); " evaluates to "+result.toString()+" correctly.");
} }
rule.context = { var context = {
area: 4998 area: 4998
} };
var result = rule.evaluate(); var result = filter.evaluate(context);
t.eq(result, true, "evaluation against custom rule context works."); t.eq(result, true, "evaluation against custom filter context works.");
} }
</script> </script>
</head> </head>

View File

@@ -0,0 +1,47 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_FeatureId_constructor(t) {
t.plan(3);
var options = {'foo': 'bar'};
var filter = new OpenLayers.Filter.FeatureId(options);
t.ok(filter instanceof OpenLayers.Filter.FeatureId,
"new OpenLayers.Filter.FeatureId returns object" );
t.eq(filter.foo, "bar", "constructor sets options correctly");
t.eq(typeof filter.evaluate, "function", "filter has an evaluate function");
}
function test_FeatureId_destroy(t) {
t.plan(1);
var filter = new OpenLayers.Filter.FeatureId();
filter.destroy();
t.eq(filter.symbolizer, null, "symbolizer hash nulled properly");
}
function test_FeatureId_evaluate(t) {
t.plan(3);
var filter = new OpenLayers.Filter.FeatureId(
{fids: ["fid_1", "fid_3"]});
var filterResults = {
"fid_1" : true,
"fid_2" : false,
"fid_3" : true};
for (var i in filterResults) {
var feature = new OpenLayers.Feature.Vector();
feature.fid = i;
var result = filter.evaluate(feature);
t.eq(result, filterResults[i], "feature "+i+" evaluates to "+result.toString()+" correctly.");
feature.destroy();
}
}
</script>
</head>
<body>
</body>
</html>

41
tests/Filter/Logical.html Normal file
View File

@@ -0,0 +1,41 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Logical_constructor(t) {
t.plan(3);
var options = {'foo': 'bar'};
var filter = new OpenLayers.Filter.Logical(options);
t.ok(filter instanceof OpenLayers.Filter.Logical,
"new OpenLayers.Filter.Logical returns object" );
t.eq(filter.foo, "bar", "constructor sets options correctly");
t.eq(typeof filter.evaluate, "function", "filter has an evaluate function");
}
function test_Logical_destroy(t) {
t.plan(1);
var filter = new OpenLayers.Filter.Logical();
filter.destroy();
t.eq(filter.filters, null, "filters array nulled properly");
}
function test_Logical_evaluate(t) {
t.plan(1);
var filter = new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.NOT});
filter.filters.push(new OpenLayers.Filter());
var feature = new OpenLayers.Feature.Vector();
t.eq(filter.evaluate(feature.attributes), false,
"feature evaluates to false correctly.");
}
</script>
</head>
<body>
</body>
</html>

View File

@@ -24,8 +24,7 @@
var l = new OpenLayers.Geometry.LineString([point, point2]); var l = new OpenLayers.Geometry.LineString([point, point2]);
var f = new OpenLayers.Feature.Vector(l); var f = new OpenLayers.Feature.Vector(l);
var data = parser.write([f]); var data = parser.write([f]);
var data = data.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog t.xml_eq(data, '<rss xmlns="http://backend.userland.com/rss2"><item><title></title><description></description><georss:line xmlns:georss="http://www.georss.org/georss">45.68 -111.04 45.68 -112.04</georss:line></item></rss>', 'GeoRSS serializes a line correctly');
t.eq(data, '<rss xmlns="http://backend.userland.com/rss2"><item><title></title><description></description><georss:line xmlns:georss="http://www.georss.org/georss">45.68 -111.04 45.68 -112.04</georss:line></item></rss>', 'GeoRSS serializes a line correctly');
} }
function test_Format_GeoRSS_w3cgeo(t) { function test_Format_GeoRSS_w3cgeo(t) {
t.plan(2); t.plan(2);
@@ -50,11 +49,7 @@
var data = parser.read(feed); var data = parser.read(feed);
var out = parser.write(data); var out = parser.write(data);
var expected_result = output[i]; var expected_result = output[i];
if (OpenLayers.Util.getBrowserName() == "opera") { t.xml_eq(out, expected_result, "Output gave expected value");
expected_result = expected_result.replace(/&gt;/g, ">");
}
var out = out.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
t.eq(out, expected_result, "Output gave expected value");
} }
} }
function test_Format_GeoRSS_gml_roundtrip(t) { function test_Format_GeoRSS_gml_roundtrip(t) {
@@ -65,11 +60,7 @@
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") { t.xml_eq(out, expected_result, "Output gave expected value");
expected_result = expected_result.replace(/&gt;/g, ">");
}
var out = out.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
t.eq(out, expected_result, "Output gave expected value");
} }
} }

View File

@@ -0,0 +1,158 @@
<html>
<head>
<script src="../../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var sld =
'<StyledLayerDescriptor version="1.0.0" ' +
'xmlns="http://www.opengis.net/sld" ' +
'xmlns:gml="http://www.opengis.net/gml" ' +
'xmlns:ogc="http://www.opengis.net/ogc" ' +
'xmlns:xlink="http://www.w3.org/1999/xlink" ' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">' +
'<NamedLayer>' +
'<Name>AAA161</Name>' +
'<UserStyle>' +
'<FeatureTypeStyle>' +
'<Rule>' +
'<Name>stortsteen</Name>' +
'<ogc:Filter>' +
'<ogc:PropertyIsEqualTo>' +
'<ogc:PropertyName>CTE</ogc:PropertyName>' +
'<ogc:Literal>V0305</ogc:Literal>' +
'</ogc:PropertyIsEqualTo>' +
'</ogc:Filter>' +
'<MaxScaleDenominator>50000</MaxScaleDenominator>' +
'<PolygonSymbolizer>' +
'<Fill>' +
'<CssParameter name="fill">#ffffff</CssParameter>' +
'</Fill>' +
'<Stroke>' +
'<CssParameter name="stroke">#000000</CssParameter>' +
'</Stroke>' +
'</PolygonSymbolizer>' +
'</Rule>' +
'<Rule>' +
'<Name>betonbekleding</Name>' +
'<ogc:Filter>' +
'<ogc:PropertyIsLessThan>' +
'<ogc:PropertyName>CTE</ogc:PropertyName>' +
'<ogc:Literal>1000</ogc:Literal>' +
'</ogc:PropertyIsLessThan>' +
'</ogc:Filter>' +
'<MaxScaleDenominator>50000</MaxScaleDenominator>' +
'<PolygonSymbolizer>' +
'<Fill>' +
'<CssParameter name="fill">#ffff00</CssParameter>' +
'</Fill>' +
'<Stroke>' +
'<CssParameter name="stroke">#0000ff</CssParameter>' +
'</Stroke>' +
'</PolygonSymbolizer>' +
'</Rule>' +
'</FeatureTypeStyle>' +
'</UserStyle>' +
'</NamedLayer>' +
'<NamedLayer>' +
'<Name>Second Layer</Name>' +
'<UserStyle>' +
'<FeatureTypeStyle>' +
'<Rule>' +
'<Name>first rule second layer</Name>' +
'<ogc:Filter>' +
'<ogc:Or>' +
'<ogc:PropertyIsBetween>' +
'<ogc:PropertyName>number</ogc:PropertyName>' +
'<ogc:LowerBoundary>' +
'<ogc:Literal>1064866676</ogc:Literal>' +
'</ogc:LowerBoundary>' +
'<ogc:UpperBoundary>' +
'<ogc:Literal>1065512599</ogc:Literal>' +
'</ogc:UpperBoundary>' +
'</ogc:PropertyIsBetween>' +
'<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">' +
'<ogc:PropertyName>cat</ogc:PropertyName>' +
'<ogc:Literal>*dog.food!*good</ogc:Literal>' +
'</ogc:PropertyIsLike>' +
'<ogc:Not>' +
'<ogc:PropertyIsLessThanOrEqualTo>' +
'<ogc:PropertyName>FOO</ogc:PropertyName>' +
'<ogc:Literal>5000</ogc:Literal>' +
'</ogc:PropertyIsLessThanOrEqualTo>' +
'</ogc:Not>' +
'</ogc:Or>' +
'</ogc:Filter>' +
'<MaxScaleDenominator>10000</MaxScaleDenominator>' +
'<PointSymbolizer>' +
'<Graphic>' +
'<Mark>' +
'<WellKnownName>star</WellKnownName>' +
'<Fill>' +
'<CssParameter name="fill">lime</CssParameter>' +
'</Fill>' +
'<Stroke>' +
'<CssParameter name="stroke">olive</CssParameter>' +
'<CssParameter name="stroke-width">2</CssParameter>' +
'</Stroke>' +
'</Mark>' +
'</Graphic>' +
'</PointSymbolizer>' +
'</Rule>' +
'</FeatureTypeStyle>' +
'</UserStyle>' +
'</NamedLayer>' +
'</StyledLayerDescriptor>';
function test_read(t) {
t.plan(6);
var parser = new OpenLayers.Format.SLD.v1_0_0();
var xml = new OpenLayers.Format.XML();
var obj = parser.read(xml.read(sld));
// test the named layer count
var count = 0;
for(var key in obj.namedLayers) {
++count;
}
t.eq(count, 2, "correct number of named layers");
var layer, style, rule;
// check the first named layer
layer = obj.namedLayers["AAA161"];
t.ok(layer, "first named layer exists");
t.ok(layer.userStyles instanceof Array, "(AAA161) layer has array of user styles");
t.eq(layer.userStyles.length, 1, "(AAA161) first layer has a single user style");
// check the first user style
style = layer.userStyles[0];
t.ok(style instanceof OpenLayers.Style, "(AAA161,0) user style is instance of OpenLayers.Style");
t.eq(style.rules.length, 2, "(AAA161,0) user style has 2 rules");
// check the first rule
// etc. I'm convinced read works, really wanted to test write (since examples don't test that)
// I'll add more tests here later.
}
function test_write(t) {
t.plan(1);
// read first - testing that write produces the SLD aboce
var parser = new OpenLayers.Format.SLD.v1_0_0();
var xml = new OpenLayers.Format.XML();
var obj = parser.read(xml.read(sld));
var node = parser.write(obj);
t.xml_eq(node, sld, "SLD correctly written");
}
</script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,18 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Popup_FramedCloud_setHTML(t) {
t.plan(1);
popup = new OpenLayers.Popup.FramedCloud();
popup.setContentHTML("<p></p>");
t.ok("setHTML on popup not yet added to map doesn't fail");
}
</script>
</head>
<body>
<div id="map" style="width:512px; height:256px"> </div>
</body>
</html>

View File

@@ -1,47 +0,0 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_FeatureId_constructor(t) {
t.plan(3);
var options = {'foo': 'bar'};
var rule = new OpenLayers.Rule.FeatureId(options);
t.ok(rule instanceof OpenLayers.Rule.FeatureId,
"new OpenLayers.Rule.FeatureId returns object" );
t.eq(rule.foo, "bar", "constructor sets options correctly");
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
}
function test_FeatureId_destroy(t) {
t.plan(1);
var rule = new OpenLayers.Rule.FeatureId();
rule.destroy();
t.eq(rule.symbolizer, null, "symbolizer hash nulled properly");
}
function test_FeatureId_evaluate(t) {
t.plan(3);
var rule = new OpenLayers.Rule.FeatureId(
{fids: ["fid_1", "fid_3"]});
var ruleResults = {
"fid_1" : true,
"fid_2" : false,
"fid_3" : true};
for (var i in ruleResults) {
var feature = new OpenLayers.Feature.Vector();
feature.fid = i;
var result = rule.evaluate(feature);
t.eq(result, ruleResults[i], "feature "+i+" evaluates to "+result.toString()+" correctly.");
feature.destroy();
}
}
</script>
</head>
<body>
</body>
</html>

View File

@@ -1,41 +0,0 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Logical_constructor(t) {
t.plan(3);
var options = {'foo': 'bar'};
var rule = new OpenLayers.Rule.Logical(options);
t.ok(rule instanceof OpenLayers.Rule.Logical,
"new OpenLayers.Rule.Logical returns object" );
t.eq(rule.foo, "bar", "constructor sets options correctly");
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
}
function test_Logical_destroy(t) {
t.plan(1);
var rule = new OpenLayers.Rule.Logical();
rule.destroy();
t.eq(rule.rules, null, "rules array nulled properly");
}
function test_Logical_evaluate(t) {
t.plan(1);
var rule = new OpenLayers.Rule.Logical({
type: OpenLayers.Rule.Logical.NOT});
rule.rules.push(new OpenLayers.Rule());
var feature = new OpenLayers.Feature.Vector();
t.eq(rule.evaluate(feature), false,
"feature evaluates to false correctly.");
}
</script>
</head>
<body>
</body>
</html>

View File

@@ -27,20 +27,29 @@
var style = new OpenLayers.Style(baseStyle); var style = new OpenLayers.Style(baseStyle);
var rule1 = new OpenLayers.Rule.FeatureId({ var rule1 = new OpenLayers.Rule({
fids: ["1"], symbolizer: {"Point": {fillColor: "green"}},
symbolizer: {"Point": {fillColor: "green"}}, maxScaleDenominator: 500000,
maxScaleDenominator: 500000}); filter: new OpenLayers.Filter.FeatureId({
var rule2 = new OpenLayers.Rule.FeatureId({ fids: ["1"]
fids: ["1"], })
symbolizer: {"Point": {fillColor: "yellow"}}, });
minScaleDenominator: 500000, var rule2 = new OpenLayers.Rule({
maxScaleDenominator: 1000000}); symbolizer: {"Point": {fillColor: "yellow"}},
var rule3 = new OpenLayers.Rule.FeatureId({ minScaleDenominator: 500000,
fids: ["1"], maxScaleDenominator: 1000000,
symbolizer: {"Point": {fillColor: "red"}}, filter: new OpenLayers.Filter.FeatureId({
minScaleDenominator: 1000000, fids: ["1"]
maxScaleDenominator: 2500000}); })
});
var rule3 = new OpenLayers.Rule({
symbolizer: {"Point": {fillColor: "red"}},
minScaleDenominator: 1000000,
maxScaleDenominator: 2500000,
filter: new OpenLayers.Filter.FeatureId({
fids: ["1"]
})
});
var feature = new OpenLayers.Feature.Vector( var feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(3,5), new OpenLayers.Geometry.Point(3,5),
@@ -119,11 +128,14 @@
function test_Style_context(t) { function test_Style_context(t) {
t.plan(1); t.plan(1);
var rule = new OpenLayers.Rule.Comparison({ var rule = new OpenLayers.Rule({
type: OpenLayers.Rule.Comparison.LESS_THAN, symbolizer: {"Point": {externalGraphic: "${img1}"}},
property: "size", filter: new OpenLayers.Filter.Comparison({
value: 11, type: OpenLayers.Filter.Comparison.LESS_THAN,
symbolizer: {"Point": {externalGraphic: "${img1}"}}}); property: "size",
value: 11
})
});
var style = new OpenLayers.Style(); var style = new OpenLayers.Style();
style.context = { style.context = {
"img1": "myImage.png" "img1": "myImage.png"

View File

@@ -2332,7 +2332,9 @@ onload=function()
} }
} }
// --> // -->
</script></head><body> </script>
<script type="text/javascript" src="xml_eq.js"></script>
</head><body>
<div id="col1"> <div id="col1">
<div id="col1_header">Test pages:</div> <div id="col1_header">Test pages:</div>

View File

@@ -1,5 +1,6 @@
<ul id="testlist"> <ul id="testlist">
<li>OpenLayers.html</li> <li>OpenLayers.html</li>
<li>Extras.html</li>
<li>Ajax.html</li> <li>Ajax.html</li>
<li>BaseTypes.html</li> <li>BaseTypes.html</li>
<li>BaseTypes/Bounds.html</li> <li>BaseTypes/Bounds.html</li>
@@ -29,6 +30,7 @@
<li>Format/OSM.html</li> <li>Format/OSM.html</li>
<li>Format/KML.html</li> <li>Format/KML.html</li>
<li>Format/SLD.html</li> <li>Format/SLD.html</li>
<li>Format/SLD/v1_0_0.html</li>
<li>Format/WKT.html</li> <li>Format/WKT.html</li>
<li>Format/WMC.html</li> <li>Format/WMC.html</li>
<li>Format/WMC/v1_1_0.html</li> <li>Format/WMC/v1_1_0.html</li>
@@ -40,14 +42,16 @@
<li>Popup.html</li> <li>Popup.html</li>
<li>Popup/Anchored.html</li> <li>Popup/Anchored.html</li>
<li>Popup/AnchoredBubble.html</li> <li>Popup/AnchoredBubble.html</li>
<li>Popup/FramedCloud.html</li>
<li>Feature.html</li> <li>Feature.html</li>
<li>Feature/Vector.html</li> <li>Feature/Vector.html</li>
<li>Style.html</li> <li>Style.html</li>
<li>StyleMap.html</li> <li>StyleMap.html</li>
<li>Rule.html</li> <li>Rule.html</li>
<li>Rule/Comparison.html</li> <li>Filter.html</li>
<li>Rule/FeatureId.html</li> <li>Filter/Comparison.html</li>
<li>Rule/Logical.html</li> <li>Filter/FeatureId.html</li>
<li>Filter/Logical.html</li>
<li>Events.html</li> <li>Events.html</li>
<li>Util.html</li> <li>Util.html</li>
<li>Lang.html</li> <li>Lang.html</li>