Add support for the extremely awesomely super-comprehensive rule based styling

that Andreas has been working so hard on. I think this is the single most
awesome commit I've ever had the pleasure of committing. The results of this
commit are described on http://trac.openlayers.org/wiki/Styles: essentially,
this makes it possible to style features in all kinds of fun ways based on
rules, and will also form the underlying basis for #533. Things this patch
adds:

 * OL.Rule classes. These classes allow you to do tests against the propertie
   of a feature, and set a style based on these properties -- so you can
   compare the 'speedlimit' property of a line, and test if it is > 60, and if
   it is greater than 60, render it in a different color. You can also test
   combinations of rules using the OL.Rule.Logical class, and test featureids
   with the FeatureID class. 
 * OL.Style class: The OL.Style class lets you wrap up Rules into styles that 
   can be used with drawFeature to draw the feature in the selected style.
 * OL.Layer.Vector.drawFeature will check if the given style is an OL.Style
   object, and if so, it will draw the feature accordingly.

examples/georss-flickr.html shows usage of these classes.

Many, many thanks go to Andreas for all his hard work on this: this code really
is very pretty, and includes unit tests for all the classes (and we know that I
am a big fan of tests.)

Three cheers for Andreas: Hip hip, hooray! hip hip, hooray! hip hip, hooray!


git-svn-id: http://svn.openlayers.org/trunk/openlayers@5429 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-12-15 16:17:50 +00:00
parent 43a4f9320b
commit fb3c02354f
15 changed files with 1851 additions and 0 deletions

105
examples/georss-flickr.html Normal file
View File

@@ -0,0 +1,105 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 400px;
border: 1px solid black;
}
.olPopupContent {
font-size: smaller;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map, layer, markerLayer, style, popup;
function init(){
map = new OpenLayers.Map('map', {maxResolution:'auto'});
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
map.addControl(new OpenLayers.Control.LayerSwitcher());
// create a property style that reads the externalGraphic url from
// the thumbail attribute of the rss item
style = new OpenLayers.Style({
externalGraphic: "${thumbnail}",
pointRadius: 20});
// create a rule with a point symbolizer that will make the thumbnail
// larger if the title of the rss item conatins "powder"
var rule = new OpenLayers.Rule.Comparison({
type: OpenLayers.Rule.Comparison.LIKE,
property: "title",
value: "*powder*",
symbolizer: {"Point": {pointRadius: 30}}});
rule.value2regex("*");
style.addRules([rule]);
markerLayer = new OpenLayers.Layer.Vector("", {style: style});
map.addLayer(markerLayer);
// control that will show a popup when clicking on a thumbnail
var popupControl = new OpenLayers.Control.SelectFeature(markerLayer, {
selectStyle: style,
onSelect: function(feature) {
var pos = feature.geometry;
if (popup) {
map.removePopup(popup);
}
popup = new OpenLayers.Popup("popup",
new OpenLayers.LonLat(pos.x, pos.y),
new OpenLayers.Size(254,320),
"<h3>" + feature.attributes.title + "</h3>" +
feature.attributes.description,
true);
map.addPopup(popup);
}
});
map.addControl(popupControl);
popupControl.activate();
OpenLayers.loadURL("xml/georss-flickr.xml", "", null, afterload);
}
function afterload(req) {
// extended version of OpenLayers.Format.GeoRSS.createFeatureFromItem;
// adds the thumbnail attribute to the feature
function createFeatureFromItem(item) {
var feature = OpenLayers.Format.GeoRSS.prototype
.createFeatureFromItem.apply(this, arguments);
feature.attributes.thumbnail =
this.getElementsByTagNameNS(
item, "*", "thumbnail")[0].getAttribute("url");
return feature;
}
var store = new OpenLayers.Format.GeoRSS({
createFeatureFromItem: createFeatureFromItem});
rss = store.read(req.responseXML);
// get the title of the RSS feed
var title = req.responseXML.getElementsByTagName("title")[0]
.firstChild.nodeValue;
markerLayer.setName(title);
markerLayer.addFeatures(rss);
}
</script>
</head>
<body onload="init()">
<h1>GeoRSS from Flickr in OpenLayers</h1>
<p>The displayed GeoRSS feed has a <tt>&lt;media:thumbnail/&gt;</tt> property for each item. An extended <tt>createFeatureFromItem()</tt> function is used to add this attribute to the attributes hash of each feature read in by <tt>OpenLayers.Format.GeoRSS</tt>. The example is configured with a style to render each item with its thumbnail image. Also, to show how rules work, we defined a rule that if the title of an rss item contains "powder", it will be rendered larger than the others.</p>
<div id="map"></div>
</body>
</html>

View File

@@ -0,0 +1,730 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:georss="http://www.georss.org/georss">
<channel>
<title>Photos from everyone tagged snowboard and powder, with geodata</title>
<link>http://www.flickr.com/photos/</link>
<description><![CDATA[]]></description>
<pubDate>Sat, 24 Nov 2007 16:25:03 -0800</pubDate>
<lastBuildDate>Sat, 24 Nov 2007 16:25:03 -0800</lastBuildDate>
<generator>http://www.flickr.com/</generator>
<image>
<url>http://www.flickr.com/images/buddyicon.jpg</url>
<title>Photos from everyone tagged snowboard and powder, with geodata</title>
<link>http://www.flickr.com/photos/</link>
</image>
<item>
<title>hofü07_5259</title>
<link>http://www.flickr.com/photos/-mo-/2061136492/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/-mo-/">I - mo - I</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/-mo-/2061136492/" title="hofü07_5259"><img src="http://farm3.static.flickr.com/2303/2061136492_b529e65785_m.jpg" width="240" height="184"
alt="hofü07_5259" /></a></p>
]]></description>
<pubDate>Sat, 24 Nov 2007 16:25:03 -0800</pubDate>
<dc:date.Taken>2007-11-17T12:01:18-08:00</dc:date.Taken>
<author>nobody@flickr.com (I - mo - I)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/2061136492</guid>
<georss:point>47.25162 11.754426</georss:point>
<geo:Point>
<geo:lat>47.25162</geo:lat>
<geo:long>11.754426</geo:long>
</geo:Point>
<media:content url="http://farm3.static.flickr.com/2303/2061136492_7da2c08df7_o.jpg" type="image/jpeg" height="613" width="800" />
<media:title>hofü07_5259</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/-mo-/">I - mo - I</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/-mo-/2061136492/" title="hofü07_5259"><img src="http://farm3.static.flickr.com/2303/2061136492_b529e65785_m.jpg" width="240" height="184"
alt="hofü07_5259" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm3.static.flickr.com/2303/2061136492_b529e65785_s.jpg" height="75" width="75" />
<media:credit role="photographer">I - mo - I</media:credit>
<media:category scheme="urn:flickr:tags">sun snow fall fun austria yeah powder snowboard tyrol 2007 hochfügen powderahyeahturn</media:category>
</item>
<item>
<title>First tracks</title>
<link>http://www.flickr.com/photos/ruthanddave/2046899659/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/ruthanddave/">Ruth and Dave</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/ruthanddave/2046899659/" title="First tracks"><img src="http://farm3.static.flickr.com/2207/2046899659_95fa37ae23_m.jpg" width="180"
height="240" alt="First tracks" /></a></p>
<p>Not mine, alas.</p>
]]></description>
<pubDate>Mon, 19 Nov 2007 08:20:11 -0800</pubDate>
<dc:date.Taken>2007-11-18T11:19:50-08:00</dc:date.Taken>
<author>nobody@flickr.com (Ruth and Dave)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/2046899659</guid>
<georss:point>50.107423 -122.899847</georss:point>
<geo:Point>
<geo:lat>50.107423</geo:lat>
<geo:long>-122.899847</geo:long>
</geo:Point>
<media:content url="http://farm3.static.flickr.com/2207/2046899659_b4f5485d50_o.jpg" type="image/jpeg" height="3648" width="2736" />
<media:title>First tracks</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/ruthanddave/">Ruth and Dave</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/ruthanddave/2046899659/" title="First tracks"><img src="http://farm3.static.flickr.com/2207/2046899659_95fa37ae23_m.jpg" width="180"
height="240" alt="First tracks" /></a></p>
<p>Not mine, alas.</p>
]]></media:text>
<media:thumbnail url="http://farm3.static.flickr.com/2207/2046899659_95fa37ae23_s.jpg" height="75" width="75" />
<media:credit role="photographer">Ruth and Dave</media:credit>
<media:category scheme="urn:flickr:tags">november lines whistler snowboarding tracks peak powder snowboard turns freshies</media:category>
</item>
<item>
<title>Powder turns</title>
<link>http://www.flickr.com/photos/ruthanddave/2047707124/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/ruthanddave/">Ruth and Dave</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/ruthanddave/2047707124/" title="Powder turns"><img src="http://farm3.static.flickr.com/2126/2047707124_2c0e32e014_m.jpg" width="180"
height="240" alt="Powder turns" /></a></p>
]]></description>
<pubDate>Mon, 19 Nov 2007 08:26:04 -0800</pubDate>
<dc:date.Taken>2007-11-18T11:19:57-08:00</dc:date.Taken>
<author>nobody@flickr.com (Ruth and Dave)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/2047707124</guid>
<georss:point>50.107423 -122.899847</georss:point>
<geo:Point>
<geo:lat>50.107423</geo:lat>
<geo:long>-122.899847</geo:long>
</geo:Point>
<media:content url="http://farm3.static.flickr.com/2126/2047707124_0d458f4c19_o.jpg" type="image/jpeg" height="3648" width="2736" />
<media:title>Powder turns</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/ruthanddave/">Ruth and Dave</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/ruthanddave/2047707124/" title="Powder turns"><img src="http://farm3.static.flickr.com/2126/2047707124_2c0e32e014_m.jpg" width="180"
height="240" alt="Powder turns" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm3.static.flickr.com/2126/2047707124_2c0e32e014_s.jpg" height="75" width="75" />
<media:credit role="photographer">Ruth and Dave</media:credit>
<media:category scheme="urn:flickr:tags">november face lines whistler snowboarding tracks first peak powder fresh snowboard turns</media:category>
</item>
<item>
<title>Splitboard</title>
<link>http://www.flickr.com/photos/hamsgod/1330385819/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/hamsgod/">@nt!x</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/hamsgod/1330385819/" title="Splitboard"><img src="http://farm2.static.flickr.com/1111/1330385819_8bf66f33be_m.jpg" width="162" height="240"
alt="Splitboard" /></a></p>
]]></description>
<pubDate>Wed, 5 Sep 2007 09:00:56 -0800</pubDate>
<dc:date.Taken>2007-03-04T04:40:12-08:00</dc:date.Taken>
<author>nobody@flickr.com (@nt!x)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/1330385819</guid>
<georss:point>41.931831 -111.646049</georss:point>
<geo:Point>
<geo:lat>41.931831</geo:lat>
<geo:long>-111.646049</geo:long>
</geo:Point>
<media:content url="http://farm2.static.flickr.com/1111/1330385819_8bf66f33be_m.jpg" type="image/jpeg" height="240" width="162" />
<media:title>Splitboard</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/hamsgod/">@nt!x</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/hamsgod/1330385819/" title="Splitboard"><img src="http://farm2.static.flickr.com/1111/1330385819_8bf66f33be_m.jpg" width="162" height="240"
alt="Splitboard" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm2.static.flickr.com/1111/1330385819_8bf66f33be_s.jpg" height="75" width="75" />
<media:credit role="photographer">@nt!x</media:credit>
<media:category scheme="urn:flickr:tags">snow mountains snowboarding utah powder yurt snowboard splitboard supershot</media:category>
</item>
<item>
<title>Fresh powder</title>
<link>http://www.flickr.com/photos/oliver80/1266854486/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/oliver80/">Oliver Astrologo</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/oliver80/1266854486/" title="Fresh powder"><img src="http://farm2.static.flickr.com/1310/1266854486_990ef8d68a_m.jpg" width="240" height="160"
alt="Fresh powder" /></a></p>
]]></description>
<pubDate>Wed, 29 Aug 2007 05:19:36 -0800</pubDate>
<dc:date.Taken>2007-08-24T10:05:48-08:00</dc:date.Taken>
<author>nobody@flickr.com (Oliver Astrologo)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/1266854486</guid>
<georss:point>46.528236 10.449789</georss:point>
<geo:Point>
<geo:lat>46.528236</geo:lat>
<geo:long>10.449789</geo:long>
</geo:Point>
<media:content url="http://farm2.static.flickr.com/1310/1266854486_990ef8d68a_m.jpg" type="image/jpeg" height="160" width="240" />
<media:title>Fresh powder</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/oliver80/">Oliver Astrologo</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/oliver80/1266854486/" title="Fresh powder"><img src="http://farm2.static.flickr.com/1310/1266854486_990ef8d68a_m.jpg" width="240" height="160"
alt="Fresh powder" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm2.static.flickr.com/1310/1266854486_990ef8d68a_s.jpg" height="75" width="75" />
<media:credit role="photographer">Oliver Astrologo</media:credit>
<media:category scheme="urn:flickr:tags">sky people italy panorama mountain snow alps landscape powder snowboard rider snowboarder passo ghiacciaio stelvio</media:category>
</item>
<item>
<title>Sawatch Range From Vail Pano</title>
<link>http://www.flickr.com/photos/dman861/498747983/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/dman861/">dman861</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/dman861/498747983/" title="Sawatch Range From Vail Pano"><img src="http://farm1.static.flickr.com/202/498747983_0831eb06b6_m.jpg" width="240"
height="64" alt="Sawatch Range From Vail Pano" /></a></p>
<p>View near the Eagle's Nest at the top of Eagle Bahn Gondola. Mount of the Holy Cross mountain is visible in this picture but you can't make out the cross shape. I have no idea who the lady is. Handheld panorama, stitch of 5
photos.</p>
]]></description>
<pubDate>Mon, 14 May 2007 17:05:11 -0800</pubDate>
<dc:date.Taken>2007-05-14T15:00:27-08:00</dc:date.Taken>
<author>nobody@flickr.com (dman861)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/498747983</guid>
<georss:point>39.617598 -106.386773</georss:point>
<geo:Point>
<geo:lat>39.617598</geo:lat>
<geo:long>-106.386773</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/202/498747983_2e2ad022e0_o.jpg" type="image/jpeg" height="768" width="2889" />
<media:title>Sawatch Range From Vail Pano</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/dman861/">dman861</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/dman861/498747983/" title="Sawatch Range From Vail Pano"><img src="http://farm1.static.flickr.com/202/498747983_0831eb06b6_m.jpg" width="240"
height="64" alt="Sawatch Range From Vail Pano" /></a></p>
<p>View near the Eagle's Nest at the top of Eagle Bahn Gondola. Mount of the Holy Cross mountain is visible in this picture but you can't make out the cross shape. I have no idea who the lady is. Handheld panorama, stitch of 5
photos.</p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/202/498747983_0831eb06b6_s.jpg" height="75" width="75" />
<media:credit role="photographer">dman861</media:credit>
<media:category scheme="urn:flickr:tags">
trees sky panorama mountain snow ski mountains sport pinetree person photo colorado peak wideangle panoramic powder resort panasonic trail vail snowboard gondola beavercreek range avon mountainrange mountoftheholycross sawatch dmctz3 tz3
</media:category>
</item>
<item>
<title>Flash Powder</title>
<link>http://www.flickr.com/photos/eckan/488776800/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/eckan/">Erik Eckerström</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/eckan/488776800/" title="Flash Powder"><img src="http://farm1.static.flickr.com/228/488776800_a2b7484210_m.jpg" width="240" height="160"
alt="Flash Powder" /></a></p>
<p>Some late night powder in Åre</p>
]]></description>
<pubDate>Mon, 7 May 2007 13:17:48 -0800</pubDate>
<dc:date.Taken>2007-01-18T15:37:17-08:00</dc:date.Taken>
<author>nobody@flickr.com (Erik Eckerström)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/488776800</guid>
<georss:point>63.409238 13.079953</georss:point>
<geo:Point>
<geo:lat>63.409238</geo:lat>
<geo:long>13.079953</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/228/488776800_38966d0741_o.jpg" type="image/jpeg" height="2336" width="3504" />
<media:title>Flash Powder</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/eckan/">Erik Eckerström</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/eckan/488776800/" title="Flash Powder"><img src="http://farm1.static.flickr.com/228/488776800_a2b7484210_m.jpg" width="240" height="160"
alt="Flash Powder" /></a></p>
<p>Some late night powder in Åre</p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/228/488776800_a2b7484210_s.jpg" height="75" width="75" />
<media:credit role="photographer">Erik Eckerström</media:credit>
<media:category scheme="urn:flickr:tags">snow forest canon eos board flash powder snowboard portfolio Åre 30d canon30d canoneos30d are</media:category>
</item>
<item>
<title>Hannes and Reini</title>
<link>http://www.flickr.com/photos/moschitz/483974969/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483974969/" title="Hannes and Reini"><img src="http://farm1.static.flickr.com/230/483974969_6645a1267c_m.jpg" width="240"
height="180" alt="Hannes and Reini" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:56:02 -0800</pubDate>
<dc:date.Taken>2007-03-26T12:17:53-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483974969</guid>
<georss:point>47.252086 14.365139</georss:point>
<geo:Point>
<geo:lat>47.252086</geo:lat>
<geo:long>14.365139</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/230/483974969_ceb3fbf711_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>Hannes and Reini</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483974969/" title="Hannes and Reini"><img src="http://farm1.static.flickr.com/230/483974969_6645a1267c_m.jpg" width="240"
height="180" alt="Hannes and Reini" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/230/483974969_6645a1267c_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>Zehnerkar, Obertauern</title>
<link>http://www.flickr.com/photos/moschitz/483975805/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483975805/" title="Zehnerkar, Obertauern"><img src="http://farm1.static.flickr.com/202/483975805_aae74c0e2d_m.jpg" width="240"
height="180" alt="Zehnerkar, Obertauern" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:56:46 -0800</pubDate>
<dc:date.Taken>2007-03-21T15:56:56-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483975805</guid>
<georss:point>47.249698 13.557643</georss:point>
<geo:Point>
<geo:lat>47.249698</geo:lat>
<geo:long>13.557643</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/202/483975805_b8749393b9_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>Zehnerkar, Obertauern</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483975805/" title="Zehnerkar, Obertauern"><img src="http://farm1.static.flickr.com/202/483975805_aae74c0e2d_m.jpg" width="240"
height="180" alt="Zehnerkar, Obertauern" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/202/483975805_aae74c0e2d_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>Uhh, thats high</title>
<link>http://www.flickr.com/photos/moschitz/483941044/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483941044/" title="Uhh, thats high"><img src="http://farm1.static.flickr.com/179/483941044_11806b381b_m.jpg" width="240" height="180"
alt="Uhh, thats high" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:55:25 -0800</pubDate>
<dc:date.Taken>2007-03-23T11:38:54-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483941044</guid>
<georss:point>47.258669 14.359989</georss:point>
<geo:Point>
<geo:lat>47.258669</geo:lat>
<geo:long>14.359989</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/179/483941044_7b13748500_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>Uhh, thats high</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483941044/" title="Uhh, thats high"><img src="http://farm1.static.flickr.com/179/483941044_11806b381b_m.jpg" width="240" height="180"
alt="Uhh, thats high" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/179/483941044_11806b381b_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>Powder days</title>
<link>http://www.flickr.com/photos/moschitz/483973863/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483973863/" title="Powder days"><img src="http://farm1.static.flickr.com/185/483973863_fdef927258_m.jpg" width="240" height="180"
alt="Powder days" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:55:02 -0800</pubDate>
<dc:date.Taken>2007-03-26T11:25:01-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483973863</guid>
<georss:point>47.258669 14.359989</georss:point>
<geo:Point>
<geo:lat>47.258669</geo:lat>
<geo:long>14.359989</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/185/483973863_3d460e16ac_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>Powder days</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483973863/" title="Powder days"><img src="http://farm1.static.flickr.com/185/483973863_fdef927258_m.jpg" width="240" height="180"
alt="Powder days" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/185/483973863_fdef927258_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>Getting ready</title>
<link>http://www.flickr.com/photos/moschitz/483940792/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483940792/" title="Getting ready"><img src="http://farm1.static.flickr.com/186/483940792_03aa2476e5_m.jpg" width="240" height="180"
alt="Getting ready" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:55:14 -0800</pubDate>
<dc:date.Taken>2007-03-23T11:38:53-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483940792</guid>
<georss:point>47.258669 14.359989</georss:point>
<geo:Point>
<geo:lat>47.258669</geo:lat>
<geo:long>14.359989</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/186/483940792_c6d43a3f38_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>Getting ready</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483940792/" title="Getting ready"><img src="http://farm1.static.flickr.com/186/483940792_03aa2476e5_m.jpg" width="240" height="180"
alt="Getting ready" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/186/483940792_03aa2476e5_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>Going up and getting ready for the descent</title>
<link>http://www.flickr.com/photos/moschitz/483941528/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483941528/" title="Going up and getting ready for the descent"><img src="http://farm1.static.flickr.com/224/483941528_9fba721265_m.jpg"
width="240" height="180" alt="Going up and getting ready for the descent" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:55:50 -0800</pubDate>
<dc:date.Taken>2007-03-26T12:17:17-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483941528</guid>
<georss:point>47.258669 14.359989</georss:point>
<geo:Point>
<geo:lat>47.258669</geo:lat>
<geo:long>14.359989</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/224/483941528_c92ea73dea_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>Going up and getting ready for the descent</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483941528/" title="Going up and getting ready for the descent"><img src="http://farm1.static.flickr.com/224/483941528_9fba721265_m.jpg"
width="240" height="180" alt="Going up and getting ready for the descent" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/224/483941528_9fba721265_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>I made it!</title>
<link>http://www.flickr.com/photos/moschitz/483941314/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483941314/" title="I made it!"><img src="http://farm1.static.flickr.com/196/483941314_84884b47de_m.jpg" width="240" height="180"
alt="I made it!" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:55:39 -0800</pubDate>
<dc:date.Taken>2007-03-23T11:38:54-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483941314</guid>
<georss:point>47.258669 14.359989</georss:point>
<geo:Point>
<geo:lat>47.258669</geo:lat>
<geo:long>14.359989</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/196/483941314_6d08f6e97b_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>I made it!</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483941314/" title="I made it!"><img src="http://farm1.static.flickr.com/196/483941314_84884b47de_m.jpg" width="240" height="180"
alt="I made it!" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/196/483941314_84884b47de_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>Reini and me</title>
<link>http://www.flickr.com/photos/moschitz/483942166/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483942166/" title="Reini and me"><img src="http://farm1.static.flickr.com/167/483942166_ab3470e411_m.jpg" width="240" height="180"
alt="Reini and me" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:56:24 -0800</pubDate>
<dc:date.Taken>2007-03-21T15:45:38-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483942166</guid>
<georss:point>47.249698 13.557643</georss:point>
<geo:Point>
<geo:lat>47.249698</geo:lat>
<geo:long>13.557643</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/167/483942166_ea09729354_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>Reini and me</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483942166/" title="Reini and me"><img src="http://farm1.static.flickr.com/167/483942166_ab3470e411_m.jpg" width="240" height="180"
alt="Reini and me" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/167/483942166_ab3470e411_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>Obertauern</title>
<link>http://www.flickr.com/photos/moschitz/483976145/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483976145/" title="Obertauern"><img src="http://farm1.static.flickr.com/174/483976145_3817dac9dc_m.jpg" width="240" height="180"
alt="Obertauern" /></a></p>
]]></description>
<pubDate>Fri, 4 May 2007 08:57:04 -0800</pubDate>
<dc:date.Taken>2007-03-21T15:48:01-08:00</dc:date.Taken>
<author>nobody@flickr.com (martinom)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/483976145</guid>
<georss:point>47.249698 13.557643</georss:point>
<geo:Point>
<geo:lat>47.249698</geo:lat>
<geo:long>13.557643</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/174/483976145_a40e67f8e4_o.jpg" type="image/jpeg" height="1200" width="1600" />
<media:title>Obertauern</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/moschitz/">martinom</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/moschitz/483976145/" title="Obertauern"><img src="http://farm1.static.flickr.com/174/483976145_3817dac9dc_m.jpg" width="240" height="180"
alt="Obertauern" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/174/483976145_3817dac9dc_s.jpg" height="75" width="75" />
<media:credit role="photographer">martinom</media:credit>
<media:category scheme="urn:flickr:tags">powder snowboard autoupload obertauern lachtal</media:category>
</item>
<item>
<title>Ross Fall Line 2</title>
<link>http://www.flickr.com/photos/pwadsworth/480290173/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/pwadsworth/">phwadsworth</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/pwadsworth/480290173/" title="Ross Fall Line 2"><img src="http://farm1.static.flickr.com/230/480290173_92696d207c_m.jpg" width="182"
height="240" alt="Ross Fall Line 2" /></a></p>
]]></description>
<pubDate>Tue, 1 May 2007 12:02:23 -0800</pubDate>
<dc:date.Taken>2007-05-01T15:02:23-08:00</dc:date.Taken>
<author>nobody@flickr.com (phwadsworth)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/480290173</guid>
<georss:point>44.196728 -72.926688</georss:point>
<geo:Point>
<geo:lat>44.196728</geo:lat>
<geo:long>-72.926688</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/230/480290173_5b8ebaf718_o.jpg" type="image/jpeg" height="793" width="600" />
<media:title>Ross Fall Line 2</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/pwadsworth/">phwadsworth</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/pwadsworth/480290173/" title="Ross Fall Line 2"><img src="http://farm1.static.flickr.com/230/480290173_92696d207c_m.jpg" width="182"
height="240" alt="Ross Fall Line 2" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/230/480290173_92696d207c_s.jpg" height="75" width="75" />
<media:credit role="photographer">phwadsworth</media:credit>
<media:category scheme="urn:flickr:tags">ski river geotagged powder glen snowboard mad vt mrg vemont</media:category>
</item>
<item>
<title>Ross Fall Line 1</title>
<link>http://www.flickr.com/photos/pwadsworth/480290169/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/pwadsworth/">phwadsworth</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/pwadsworth/480290169/" title="Ross Fall Line 1"><img src="http://farm1.static.flickr.com/218/480290169_35b0301cb4_m.jpg" width="150"
height="240" alt="Ross Fall Line 1" /></a></p>
]]></description>
<pubDate>Tue, 1 May 2007 12:02:23 -0800</pubDate>
<dc:date.Taken>2007-05-01T15:02:23-08:00</dc:date.Taken>
<author>nobody@flickr.com (phwadsworth)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/480290169</guid>
<georss:point>44.196728 -72.926688</georss:point>
<geo:Point>
<geo:lat>44.196728</geo:lat>
<geo:long>-72.926688</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/218/480290169_bd54859899_o.jpg" type="image/jpeg" height="959" width="600" />
<media:title>Ross Fall Line 1</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/pwadsworth/">phwadsworth</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/pwadsworth/480290169/" title="Ross Fall Line 1"><img src="http://farm1.static.flickr.com/218/480290169_35b0301cb4_m.jpg" width="150"
height="240" alt="Ross Fall Line 1" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/218/480290169_35b0301cb4_s.jpg" height="75" width="75" />
<media:credit role="photographer">phwadsworth</media:credit>
<media:category scheme="urn:flickr:tags">ski river geotagged powder glen snowboard mad vt mrg vemont</media:category>
</item>
<item>
<title>IMGP0575</title>
<link>http://www.flickr.com/photos/beppoegeppa/471446918/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/beppoegeppa/">beppovox</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/beppoegeppa/471446918/" title="IMGP0575"><img src="http://farm1.static.flickr.com/169/471446918_fa54874333_m.jpg" width="240" height="180"
alt="IMGP0575" /></a></p>
]]></description>
<pubDate>Tue, 24 Apr 2007 10:32:41 -0800</pubDate>
<dc:date.Taken>2003-12-29T11:07:29-08:00</dc:date.Taken>
<author>nobody@flickr.com (beppovox)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/471446918</guid>
<georss:point>45.082308 6.761913</georss:point>
<geo:Point>
<geo:lat>45.082308</geo:lat>
<geo:long>6.761913</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/169/471446918_f199685d82_o.jpg" type="image/jpeg" height="1944" width="2592" />
<media:title>IMGP0575</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/beppoegeppa/">beppovox</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/beppoegeppa/471446918/" title="IMGP0575"><img src="http://farm1.static.flickr.com/169/471446918_fa54874333_m.jpg" width="240" height="180"
alt="IMGP0575" /></a></p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/169/471446918_fa54874333_s.jpg" height="75" width="75" />
<media:credit role="photographer">beppovox</media:credit>
<media:category scheme="urn:flickr:tags">geotagged free powder snowboard freeride jafferau</media:category>
</item>
<item>
<title>Slopes</title>
<link>http://www.flickr.com/photos/blupic/469735045/</link>
<description><![CDATA[
<p><a href="http://www.flickr.com/people/blupic/">blupic.com</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/blupic/469735045/" title="Slopes"><img src="http://farm1.static.flickr.com/203/469735045_e035c04ab2_m.jpg" width="240" height="160"
alt="Slopes" /></a></p>
<p>One day...</p>
]]></description>
<pubDate>Mon, 23 Apr 2007 02:48:17 -0800</pubDate>
<dc:date.Taken>2007-03-31T17:31:13-08:00</dc:date.Taken>
<author>nobody@flickr.com (blupic.com)</author>
<guid isPermaLink="false">tag:flickr.com,2004:/photo/469735045</guid>
<georss:point>50.111882 -122.939436</georss:point>
<geo:Point>
<geo:lat>50.111882</geo:lat>
<geo:long>-122.939436</geo:long>
</geo:Point>
<media:content url="http://farm1.static.flickr.com/203/469735045_e035c04ab2_m.jpg" type="image/jpeg" height="160" width="240" />
<media:title>Slopes</media:title>
<media:text type="html"><![CDATA[
<p><a href="http://www.flickr.com/people/blupic/">blupic.com</a> posted a photo:</p>
<p><a href="http://www.flickr.com/photos/blupic/469735045/" title="Slopes"><img src="http://farm1.static.flickr.com/203/469735045_e035c04ab2_m.jpg" width="240" height="160"
alt="Slopes" /></a></p>
<p>One day...</p>
]]></media:text>
<media:thumbnail url="http://farm1.static.flickr.com/203/469735045_e035c04ab2_s.jpg" height="75" width="75" />
<media:credit role="photographer">blupic.com</media:credit>
<media:category scheme="urn:flickr:tags">blue winter sky mountain snow canada ski nature vancouver whistler nikon skiing d70 peak columbia powder 1870mmf3545g snowboard british blackcomb mogul</media:category>
</item>
</channel>
</rss>

View File

@@ -164,6 +164,11 @@
"OpenLayers/Renderer/VML.js",
"OpenLayers/Layer/Vector.js",
"OpenLayers/Layer/GML.js",
"OpenLayers/Style.js",
"OpenLayers/Rule.js",
"OpenLayers/Rule/FeatureId.js",
"OpenLayers/Rule/Logical.js",
"OpenLayers/Rule/Comparison.js",
"OpenLayers/Format.js",
"OpenLayers/Format/XML.js",
"OpenLayers/Format/GML.js",

View File

@@ -350,6 +350,12 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
style = this.style;
}
}
if (style && style.CLASS_NAME &&
style.CLASS_NAME == "OpenLayers.Style") {
style = style.createStyle(feature);
}
this.renderer.drawFeature(feature, style);
},

90
lib/OpenLayers/Rule.js Normal file
View File

@@ -0,0 +1,90 @@
/* 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.Rule
*
* This class represents a OGC Rule, as being used for rule-based SLD styling
*/
OpenLayers.Rule = OpenLayers.Class({
/**
* APIProperty: name
* {String} name of this rule
*/
name: 'default',
/**
* Property: symbolizer
* {Object} Hash of styles for this rule. Contains hashes of feature
* styles. Keys are one or more of ["Point", "Line", "Polygon"]
*/
symbolizer: null,
/**
* APIProperty: minScale
* {Number} or {String} minimum scale at which to draw the feature.
* In the case of a String, this can be a combination of text and
* propertyNames in the form "literal ${propertyName}"
*/
minScale: null,
/**
* APIProperty: maxScale
* {Number} or {String} maximum scale at which to draw the feature.
* In the case of a String, this can be a combination of text and
* propertyNames in the form "literal ${propertyName}"
*/
maxScale: null,
/**
* Constructor: OpenLayers.Rule
* Creates a Rule.
*
* Parameters:
* options - {Object} An optional object with properties to set on the
* rule
*
* Returns:
* {<OpenLayers.Rule>}
*/
initialize: function(options) {
this.symbolizer = {};
OpenLayers.Util.extend(this, options);
},
/**
* APIMethod: destroy
* nullify references to prevent circular references and memory leaks
*/
destroy: function() {
for (var i in this.symbolizer) {
this.symbolizer[i] = null;
}
this.symbolizer = null;
},
/**
* 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.
* This rule is the default rule and always returns true.
*/
evaluate: function(feature) {
// Default rule always applies. Subclasses will want to override this.
return true;
},
CLASS_NAME: "OpenLayers.Rule"
});

View File

@@ -0,0 +1,204 @@
/* Copyright (c) 2006-2007 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.Comparison
*
* This class represents the comparison rules, as being used for rule-based
* SLD styling
*
* Inherits from
* - <OpenLayers.Rule>
*/
OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
/**
* APIProperty: type
* {String} type: type of the comparison. This is one of
* - OpenLayers.Rule.Comparison.EQUAL_TO = "==";
* - OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
* - OpenLayers.Rule.Comparison.LESS_THAN = "<";
* - OpenLayers.Rule.Comparison.GREATER_THAN = ">";
* - OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
* - OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
* - OpenLayers.Rule.Comparison.BETWEEN = "..";
* - OpenLayers.Rule.Comparison.LIKE = "~";
*/
type: null,
/**
* APIProperty: property
* {String}
* name of the feature attribute to compare
*/
property: null,
/**
* APIProperty: value
* {Number} or {String}
* comparison value for binary comparisons. In the case of a String, this
* can be a combination of text and propertyNames in the form
* "literal ${propertyName}"
*/
value: null,
/**
* APIProperty: lowerBoundary
* {Number} or {String}
* lower boundary for between comparisons. In the case of a String, this
* can be a combination of text and propertyNames in the form
* "literal ${propertyName}"
*/
lowerBoundary: null,
/**
* APIProperty: upperBoundary
* {Number} or {String}
* upper boundary for between comparisons. In the case of a String, this
* can be a combination of text and propertyNames in the form
* "literal ${propertyName}"
*/
upperBoundary: null,
/**
* Constructor: OpenLayers.Rule.Logical
* Creates a logical rule (And, Or, Not).
*
* Parameters:
* params - {Object} Hash of parameters for this rule:
* -
* - value:
* options - {Object} An optional object with properties to set on the
* rule
*
* Returns:
* {<OpenLayers.Rule>}
*/
initialize: function(options) {
OpenLayers.Rule.prototype.initialize.apply(
this, [options]);
},
/**
* 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) {
var attributes = feature.attributes || feature.data;
switch(this.type) {
case OpenLayers.Rule.Comparison.EQUAL_TO:
case OpenLayers.Rule.Comparison.LESS_THAN:
case OpenLayers.Rule.Comparison.GREATER_THAN:
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
return this.binaryCompare(feature, this.property, this.value);
case OpenLayers.Rule.Comparison.BETWEEN:
var result =
attributes[this.property] > this.lowerBoundary;
result = result &&
attributes[this.property] < this.upperBoundary;
return result;
case OpenLayers.Rule.Comparison.LIKE:
var regexp = new RegExp(this.value,
"gi");
return regexp.test(attributes[this.property]);
}
},
/**
* APIMethod: value2regex
* Converts the value of this rule into a regular expression string,
* according to the wildcard characters specified. This method has to
* be called after instantiation of this class, if the value is not a
* regular expression already.
*
* Parameters:
* wildCard - {<Char>} wildcard character in the above value, default
* is "*"
* singleChar - {<Char>) single-character wildcard in the above value
* default is "."
* escape - {<Char>) escape character in the above value, default is
* "!"
*
* Returns:
* {String} regular expression string
*/
value2regex: function(wildCard, singleChar, escapeChar) {
if (wildCard == ".") {
var msg = "'.' is an unsupported wildCard character for "+
"OpenLayers.Rule.Comparison";
OpenLayers.Console.error(msg);
return null;
}
// set UMN MapServer defaults for unspecified parameters
wildCard = wildCard ? wildCard : "*";
singleChar = singleChar ? singleChar : ".";
escapeChar = escapeChar ? escapeChar : "!";
this.value = this.value.replace(
new RegExp("\\"+escapeChar, "g"), "\\");
this.value = this.value.replace(
new RegExp("\\"+singleChar, "g"), ".");
this.value = this.value.replace(
new RegExp("\\"+wildCard, "g"), ".*");
this.value = this.value.replace(
new RegExp("\\\\.\\*", "g"), "\\"+wildCard);
this.value = this.value.replace(
new RegExp("\\\\\\.", "g"), "\\"+singleChar);
return this.value;
},
/**
* Function: binaryCompare
* Compares a feature property to a rule value
*
* Parameters:
* feature - {<OpenLayers.Feature>}
* property - {String} or {Number}
* value - {String} or {Number}, same as property
*
* Returns:
* {boolean}
*/
binaryCompare: function(feature, property, value) {
var attributes = feature.attributes || feature.data;
switch (this.type) {
case OpenLayers.Rule.Comparison.EQUAL_TO:
return attributes[property] == value;
case OpenLayers.Rule.Comparison.NOT_EQUAL_TO:
return attributes[property] != value;
case OpenLayers.Rule.Comparison.LESS_THAN:
return attributes[property] < value;
case OpenLayers.Rule.Comparison.GREATER_THAN:
return attributes[property] > value;
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
return attributes[property] <= value;
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
return attributes[property] >= value;
}
},
CLASS_NAME: "OpenLayers.Rule.Comparison"
});
OpenLayers.Rule.Comparison.EQUAL_TO = "==";
OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
OpenLayers.Rule.Comparison.LESS_THAN = "<";
OpenLayers.Rule.Comparison.GREATER_THAN = ">";
OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
OpenLayers.Rule.Comparison.BETWEEN = "..";
OpenLayers.Rule.Comparison.LIKE = "~";

View File

@@ -0,0 +1,69 @@
/* Copyright (c) 2006-2007 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
*
* This class represents a ogc:FeatureId Rule, as being used for rule-based SLD
* styling
*
* Inherits from
* - <OpenLayers.Rule>
*/
OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
/**
* APIProperty: fid
* {Array(<String>)} Feature Ids to evaluate this rule against. To be passed
* To be passed inside the params object.
*/
fids: null,
/**
* Constructor: OpenLayers.Rule.FeatureId
* Creates an ogc:FeatureId rule.
*
* Parameters:
* options - {Object} An optional object with properties to set on the
* rule
*
* Returns:
* {<OpenLayers.Rule>}
*
* Inherits from:
* - <OpenLayers.Rule>
*/
initialize: function(options) {
this.fids = [];
OpenLayers.Rule.prototype.initialize.apply(
this, [options]);
},
/**
* APIMethod: evaluate
* evaluates this rule for a specific feature
*
* Parameters:
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
* For vector features, the check is run against the fid,
* for plain features against the id.
*
* Returns:
* {boolean} true if the rule applies, false if it does not
*/
evaluate: function(feature) {
for (var i=0; i<this.fids.length; i++) {
var fid = feature.fid || feature.id;
if (fid == this.fids[i]) {
return true;
}
}
return false;
},
CLASS_NAME: "OpenLayers.Rule.FeatureId"
});

View File

@@ -0,0 +1,101 @@
/* Copyright (c) 2006-2007 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
*/
children: 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>}
*/
initialize: function(options) {
this.children = [];
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.children.length; i++) {
this.children[i].destroy();
}
this.children = 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) {
switch(this.type) {
case OpenLayers.Rule.Logical.AND:
for (var i=0; i<this.children.length; i++) {
if (this.children[i].evaluate(feature) == false) {
return false;
}
}
return true;
case OpenLayers.Rule.Logical.OR:
for (var i=0; i<this.children.length; i++) {
if (this.children[i].evaluate(feature) == true) {
return true;
}
}
return false;
case OpenLayers.Rule.Logical.NOT:
return (!this.children[0].evaluate(feature));
}
},
CLASS_NAME: "OpenLayers.Rule.Logical"
});
OpenLayers.Rule.Logical.AND = "&&";
OpenLayers.Rule.Logical.OR = "||";
OpenLayers.Rule.Logical.NOT = "!";

270
lib/OpenLayers/Style.js Normal file
View File

@@ -0,0 +1,270 @@
/* Copyright (c) 2006-2007 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/Util.js
* @requires OpenLayers/Feature/Vector.js
*
* Class: OpenLayers.Style
*
* This class represents a UserStyle obtained
* from a SLD, containing styling rules.
*/
OpenLayers.Style = OpenLayers.Class({
/**
* APIProperty: name
* {String}
*/
name: null,
/**
* APIProperty: layerName
* {<String>} name of the layer that this style belongs to, usually
* according to the NamedLayer attribute of an SLD document.
*/
layerName: null,
/**
* APIProperty: isDefault
* {Boolean}
*/
isDefault: false,
/**
* Property: rules
* Array({<OpenLayers.Rule>})
*/
rules: null,
/**
* Property: defaultStyle
* {Object} hash of style properties to use as default for merging
* rule-based style symbolizers onto. If no rules are defined, createStyle
* will return this style.
*/
defaultStyle: null,
/**
* Property: propertyStyles
* {Hash of Boolean} cache of style properties that need to be parsed for
* propertyNames. Property names are keys, values won't be used.
*/
propertyStyles: null,
/**
* Constructor: OpenLayers.Style
* Creates a UserStyle.
*
* Parameters:
* style - {Object} Optional hash of style properties that will be
* used as default style for this style object. This style
* applies if no rules are specified. Symbolizers defined in
* rules will extend this default style.
* options - {Object} An optional object with properties to set on the
* userStyle
*
* Return:
* {<OpenLayers.Style>}
*/
initialize: function(style, options) {
this.rules = [];
// use the default style from OpenLayers.Feature.Vector if no style
// was given in the constructor
this.setDefaultStyle(style ||
OpenLayers.Feature.Vector.style["default"]);
OpenLayers.Util.extend(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[i] = null;
}
this.rules = null;
this.defaultStyle = null;
},
/**
* APIMethod: createStyle
* creates a style by applying all feature-dependent rules to the base
* style.
*
* Parameters:
* feature - {<OpenLayers.Feature>} feature to evaluate rules for
* baseStyle - {Object} hash of styles feature styles to extend
*
* Returns:
* {<OpenLayers.Feature.Vector.style>} hash of feature styles
*/
createStyle: function(feature, baseStyle) {
if (!baseStyle) {
baseStyle = this.defaultStyle;
}
var style = OpenLayers.Util.extend({}, baseStyle);
var draw = true;
for (var i=0; i<this.rules.length; i++) {
// does the rule apply?
var applies = this.rules[i].evaluate(feature);
if (applies) {
// check if within minScale/maxScale bounds
var scale = feature.layer.map.getScale();
if (this.rules[i].minScale) {
draw = scale > OpenLayers.Style.createLiteral(
this.rules[i].minScale, feature);
}
if (draw && this.rules[i].maxScale) {
draw = scale < OpenLayers.Style.createLiteral(
this.rules[i].maxScale, feature);
}
// determine which symbolizer (Point, Line, Polygon) to use
var symbolizerPrefix = feature.geometry ?
this.getSymbolizerPrefix(feature.geometry) :
OpenLayers.Style.SYMBOLIZER_PREFIXES[0];
// now merge the style with the current style
var symbolizer = this.rules[i].symbolizer[symbolizerPrefix];
OpenLayers.Util.extend(style, symbolizer);
}
}
style.display = draw ? "" : "none";
// calculate literals for all styles in the propertyStyles cache
for (var i in this.propertyStyles) {
style[i] = OpenLayers.Style.createLiteral(style[i], feature);
}
return style;
},
/**
* Method: findPropertyStyles
* Looks into all rules for this style and the defaultStyle to collect
* all the style hash property names containing ${...} strings that have
* to be replaced using the createLiteral method before returning them.
*
* Returns:
* {Object} hash of property names that need createLiteral parsing. The
* name of the property is the key, and the value is true;
*/
findPropertyStyles: function() {
var propertyStyles = {};
// check the default style
var style = this.defaultStyle;
for (var i in style) {
if (typeof style[i] == "string" && style[i].match(/\$\{\w+\}/)) {
propertyStyles[i] = true;
}
}
// walk through all rules to check for properties in their symbolizer
var rules = this.rules;
var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;
for (var i in rules) {
for (var s=0; s<prefixes.length; s++) {
style = rules[i].symbolizer[prefixes[s]];
for (var j in style) {
if (typeof style[j] == "string" &&
style[j].match(/\$\{\w+\}/)) {
propertyStyles[j] = true;
}
}
}
}
return propertyStyles;
},
/**
* APIMethod: addRules
* Adds rules to this style.
*
* Parameters:
* rules - {Array(<OpenLayers.Rule>)}
*/
addRules: function(rules) {
this.rules = this.rules.concat(rules);
this.propertyStyles = this.findPropertyStyles();
},
/**
* APIMethod: setDefaultStyle
* Sets the default style for this style object.
*
* Parameters:
* style - {Object} Hash of style properties
*/
setDefaultStyle: function(style) {
this.defaultStyle = style;
this.propertyStyles = this.findPropertyStyles();
},
/**
* Method: getSymbolizerPrefix
* Returns the correct symbolizer prefix according to the
* geometry type of the passed geometry
*
* Parameters:
* geometry {<OpenLayers.Geometry>}
*
* Returns:
* {String} key of the according symbolizer
*/
getSymbolizerPrefix: function(geometry) {
var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;
for (var i=0; i<prefixes.length; i++) {
if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {
return prefixes[i];
}
}
},
CLASS_NAME: "OpenLayers.Style"
});
/**
* Function: createLiteral
* converts a style value holding a combination of PropertyName and Literal
* into a Literal, taking the property values from the passed features.
*
* Parameters:
* value {String} value to parse. If this string contains a construct like
* "foo ${bar}", then "foo " will be taken as literal, and "${bar}"
* will be replaced by the value of the "bar" attribute of the passed
* feature.
* feature {<OpenLayers.Feature>} feature to take attribute values from
*
* Returns:
* {String} the parsed value. In the example of the value parameter above, the
* result would be "foo valueOfBar", assuming that the passed feature has an
* attribute named "bar" with the value "valueOfBar".
*/
OpenLayers.Style.createLiteral = function(value, feature) {
if (typeof value == "string" && value.indexOf("${") != -1) {
var attributes = feature.attributes || feature.data;
value = OpenLayers.String.format(value, attributes)
value = isNaN(value) ? value : parseFloat(value);
}
return value;
}
/**
* Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES
* {Array} prefixes of the sld symbolizers. These are the
* same as the main geometry types
*/
OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon'];

View File

@@ -0,0 +1,70 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Comparison_constructor(t) {
t.plan(3);
var options = {'foo': 'bar'};
var rule = new OpenLayers.Rule.Comparison(options);
t.ok(rule instanceof OpenLayers.Rule.Comparison,
"new OpenLayers.Rule.Comparison returns object" );
t.eq(rule.foo, "bar", "constructor sets options correctly");
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
}
function test_Comparison_destroy(t) {
t.plan(1);
var rule = new OpenLayers.Rule.Comparison();
rule.destroy();
t.eq(rule.symbolizer, null, "symbolizer hash nulled properly");
}
function test_Comparison_value2regex(t) {
t.plan(2);
var rule = new OpenLayers.Rule.Comparison({
property: "foo",
value: "*b?r\\*\\?*",
type: OpenLayers.Rule.Comparison.LIKE});
rule.value2regex("*", "?", "\\");
t.eq(rule.value, ".*b.r\\*\\?.*", "Regular expression generated correctly.");
rule.value = "%b.r!%!.%";
rule.value2regex("%", ".", "!");
t.eq(rule.value, ".*b.r\\%\\..*", "Regular expression with different wildcard and escape chars generated correctly.");
}
function test_Comparison_evaluate(t) {
t.plan(3);
var rule = new OpenLayers.Rule.Comparison({
property: "area",
lowerBoundary: 1000,
upperBoundary: 5000,
type: OpenLayers.Rule.Comparison.BETWEEN});
var features = [
new OpenLayers.Feature.Vector(null, {
area: 2000}),
new OpenLayers.Feature.Vector(null, {
area: 6000}),
new OpenLayers.Feature.Vector(null, {
area: 4999})];
var ruleResults = {
0: true,
1: false,
2: true};
for (var i in ruleResults) {
var result = rule.evaluate(features[i]);
t.eq(result, ruleResults[i], "feature "+i+
" evaluates to "+result.toString()+" correctly.");
}
}
</script>
</head>
<body>
</body>
</html>

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 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

@@ -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 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.children, null, "children array nulled properly");
}
function test_Logical_evaluate(t) {
t.plan(1);
var rule = new OpenLayers.Rule.Logical({
type: OpenLayers.Rule.Logical.NOT});
rule.children.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

@@ -35,6 +35,11 @@
<li>Popup/test_AnchoredBubble.html</li>
<li>test_Feature.html</li>
<li>Feature/test_Vector.html</li>
<li>test_Style.html</li>
<li>test_Rule.html</li>
<li>Rule/test_FeatureId.html</li>
<li>Rule/test_Logical.html</li>
<li>Rule/test_Comparison.html</li>
<li>test_Events.html</li>
<li>test_Util.html</li>
<li>test_Layer.html</li>

29
tests/test_Rule.html Normal file
View File

@@ -0,0 +1,29 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Rule_constructor(t) {
t.plan(3);
var options = {'foo': 'bar'};
var rule = new OpenLayers.Rule(options);
t.ok(rule instanceof OpenLayers.Rule,
"new OpenLayers.Rule returns object" );
t.eq(rule.foo, "bar", "constructor sets options correctly");
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
}
function test_Rule_destroy(t) {
t.plan(1);
var rule = new OpenLayers.Rule();
rule.destroy();
t.eq(rule.symbolizer, null, "symbolizer hash nulled properly");
}
</script>
</head>
<body>
</body>
</html>

79
tests/test_Style.html Normal file
View File

@@ -0,0 +1,79 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Style_constructor(t) {
t.plan(3);
var options = {'foo': 'bar'};
var style = new OpenLayers.Style(null, options);
t.ok(style instanceof OpenLayers.Style,
"new OpenLayers.Style returns object" );
t.eq(style.foo, "bar", "constructor sets options correctly");
t.eq(typeof style.createStyle, "function", "style has a createStyle function");
}
function test_Style_create(t) {
t.plan(5);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector("layer");
var baseStyle = {externalGraphic: "bar${foo}.png"};
var style = new OpenLayers.Style(baseStyle);
var rule = new OpenLayers.Rule.FeatureId({
fids: ["1"],
symbolizer: {"Point": {fillColor: "green"}},
maxScale: 2000000});
style.addRules([rule]);
var feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(3,5),
{"foo": "bar"},
style);
feature.fid = "1";
// for this fid, the above rule should apply
layer.addFeatures([feature]);
map.addLayer(layer);
map.setBaseLayer(layer);
map.setCenter(new OpenLayers.LonLat(3,5), 8);
// at this scale, the feature should be visible
var createdStyle = style.createStyle(feature);
t.eq(createdStyle.externalGraphic, "barbar.png", "Calculated property style correctly.");
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
map.setCenter(new OpenLayers.LonLat(3,5), 7);
// at this scale, the feature should be invisible
createdStyle = style.createStyle(feature);
t.eq(createdStyle.display, "none", "Feature is invisible at scale "+map.getScale());
t.eq(createdStyle.fillColor, "green", "Point symbolizer from rule for fid=\"1\" applied correctly.");
feature.fid = "2";
// now the rule should not apply
createdStyle = style.createStyle(feature);
t.eq(createdStyle.fillColor, undefined, "Correct style for rule that does not apply to fid=\"2\".");
}
function test_Style_destroy(t) {
t.plan(1);
var style = new OpenLayers.Style();
style.destroy();
t.eq(style.rules, null, "rules array nulled properly");
}
</script>
</head>
<body>
<div id="map" style="width:500px;height:500px"></div>
</body>
</html>