[OpenLayers-Commits] r12174 - in sandbox/august/trunk: . examples
examples/tasmania lib/OpenLayers lib/OpenLayers/Format
lib/OpenLayers/Format/GML lib/OpenLayers/Format/WFST
lib/OpenLayers/Layer lib/OpenLayers/Protocol/WFS
lib/OpenLayers/Renderer tests tests/Format tests/Format/WFST
tests/Renderer tests/manual
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Jul 20 13:26:53 EDT 2011
Author: augusttown
Date: 2011-07-20 10:26:52 -0700 (Wed, 20 Jul 2011)
New Revision: 12174
Added:
sandbox/august/trunk/examples/label-scale.html
sandbox/august/trunk/examples/label-scale.js
sandbox/august/trunk/examples/sld.js
sandbox/august/trunk/tests/manual/svg2-coordinaterange.html
Modified:
sandbox/august/trunk/
sandbox/august/trunk/examples/mobile-jq.js
sandbox/august/trunk/examples/sld.html
sandbox/august/trunk/examples/tasmania/sld-tasmania.xml
sandbox/august/trunk/lib/OpenLayers/Control.js
sandbox/august/trunk/lib/OpenLayers/Format/GML/Base.js
sandbox/august/trunk/lib/OpenLayers/Format/GML/v3.js
sandbox/august/trunk/lib/OpenLayers/Format/WFST/v1.js
sandbox/august/trunk/lib/OpenLayers/Format/WKT.js
sandbox/august/trunk/lib/OpenLayers/Layer/Vector.js
sandbox/august/trunk/lib/OpenLayers/Protocol/WFS/v1.js
sandbox/august/trunk/lib/OpenLayers/Renderer/NG.js
sandbox/august/trunk/lib/OpenLayers/Renderer/SVG2.js
sandbox/august/trunk/lib/OpenLayers/Util.js
sandbox/august/trunk/tests/Format/WFST/v1.html
sandbox/august/trunk/tests/Format/WKT.html
sandbox/august/trunk/tests/Renderer/SVG2.html
sandbox/august/trunk/tests/Util.html
Log:
Merge with trunk @ revision 12173
Property changes on: sandbox/august/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/openlayers:10329-10354,10357-10502,10504-12158
+ /trunk/openlayers:10329-10354,10357-10502,10504-12173
Copied: sandbox/august/trunk/examples/label-scale.html (from rev 12173, trunk/openlayers/examples/label-scale.html)
===================================================================
--- sandbox/august/trunk/examples/label-scale.html (rev 0)
+++ sandbox/august/trunk/examples/label-scale.html 2011-07-20 17:26:52 UTC (rev 12174)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <title>OpenLayers Scale Dependent Labels</title>
+ <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
+ <link rel="stylesheet" href="style.css" type="text/css">
+ <script src="../lib/OpenLayers.js"></script>
+ </head>
+ <body>
+ <h1 id="title">Scale Dependent Labels Example</h1>
+ <div id="tags">
+ label, scale, stylemap
+ </div>
+ <p id="shortdesc">
+ Demonstrates how to use a StyleMap for displaying scale dependent labels.
+ </p>
+ <div id="map" class="smallmap"></div>
+ <div id="docs">
+ <p>
+ This example uses rule based styling to change the how features are
+ labeled at different scales. An <code>OpenLayers.Rule</code> object
+ can have <code>minScaleDenominator</code> and
+ <code>maxScaleDenominator</code> properties to control when the
+ provided symbolizer should be used.
+ </p><p>
+ View the <a href="label-scale.js">source</a> to see how this is done.
+ </p>
+ </div>
+ <script src="label-scale.js"></script>
+ </body>
+</html>
Copied: sandbox/august/trunk/examples/label-scale.js (from rev 12173, trunk/openlayers/examples/label-scale.js)
===================================================================
--- sandbox/august/trunk/examples/label-scale.js (rev 0)
+++ sandbox/august/trunk/examples/label-scale.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -0,0 +1,72 @@
+// Create 50 random features, and give them a "type" attribute that
+// will be used for the label text.
+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, (180 * Math.random()) - 90
+ ), {
+ type: 5 + parseInt(5 * Math.random())
+ }
+ );
+}
+
+/**
+ * Create a style instance that is a collection of rules with symbolizers.
+ * Use a default symbolizer to extend symoblizers for all rules.
+ */
+var style = new OpenLayers.Style({
+ fillColor: "#ffcc66",
+ strokeColor: "#ff9933",
+ strokeWidth: 2,
+ label: "${type}",
+ fontColor: "#333333",
+ fontFamily: "sans-serif",
+ fontWeight: "bold"
+}, {
+ rules: [
+ new OpenLayers.Rule({
+ minScaleDenominator: 200000000,
+ symbolizer: {
+ pointRadius: 7,
+ fontSize: "9px"
+ }
+ }),
+ new OpenLayers.Rule({
+ maxScaleDenominator: 200000000,
+ minScaleDenominator: 100000000,
+ symbolizer: {
+ pointRadius: 10,
+ fontSize: "12px"
+ }
+ }),
+ new OpenLayers.Rule({
+ maxScaleDenominator: 100000000,
+ symbolizer: {
+ pointRadius: 13,
+ fontSize: "15px"
+ }
+ })
+ ]
+});
+
+// Create a vector layer and give it your style map.
+var points = new OpenLayers.Layer.Vector("Points", {
+ styleMap: new OpenLayers.StyleMap(style)
+});
+points.addFeatures(features);
+
+var map = new OpenLayers.Map({
+ div: "map",
+ layers: [
+ new OpenLayers.Layer.WMS(
+ "OpenLayers WMS",
+ "http://vmap0.tiles.osgeo.org/wms/vmap0",
+ {layers: "basic"}
+ ),
+ points
+ ],
+ center: new OpenLayers.LonLat(0, 0),
+ zoom: 1
+});
+
Modified: sandbox/august/trunk/examples/mobile-jq.js
===================================================================
--- sandbox/august/trunk/examples/mobile-jq.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/examples/mobile-jq.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -1,3 +1,6 @@
+// Start with the map page
+window.location.replace(window.location.href.split("#")[0] + "#mappage");
+
var selectedFeature = null;
$(document).ready(function() {
@@ -2,18 +5,14 @@
- // Start with the map page
- if (window.location.hash && window.location.hash!='#mappage') {
- $.mobile.changePage('mappage');
- }
-
// fix height of content
function fixContentHeight() {
var footer = $("div[data-role='footer']:visible"),
- content = $("div[data-role='content']:visible:visible"),
- viewHeight = $(window).height(),
- contentHeight = viewHeight - footer.outerHeight();
+ content = $("div[data-role='content']:visible:visible"),
+ viewHeight = $(window).height(),
+ contentHeight = viewHeight - footer.outerHeight();
if ((content.outerHeight() + footer.outerHeight()) !== viewHeight) {
- contentHeight -= (content.outerHeight() - content.height());
+ contentHeight -= (content.outerHeight() - content.height() + 1);
content.height(contentHeight);
}
+
if (window.map) {
@@ -24,13 +23,13 @@
// initialize map
init(function(feature) {
selectedFeature = feature;
- $.mobile.changePage($("#popup"), "pop");
+ $.mobile.changePage("#popup", "pop");
});
+ initLayerList();
}
}
$(window).bind("orientationchange resize pageshow", fixContentHeight);
- fixContentHeight();
- //init();
+ document.body.onload = fixContentHeight;
// Map zoom
$("#plus").click(function(){
@@ -48,7 +47,7 @@
}
});
- $('div#popup').live('pageshow',function(event, ui){
+ $('#popup').live('pageshow',function(event, ui){
var li = "";
for(var attr in selectedFeature.attributes){
li += "<li><div style='width:25%;float:left'>" + attr + "</div><div style='width:75%;float:right'>"
@@ -83,7 +82,7 @@
}))
.appendTo('#search_results')
.click(function() {
- $.mobile.changePage('mappage');
+ $.mobile.changePage('#mappage');
var lonlat = new OpenLayers.LonLat(place.lng, place.lat);
map.setCenter(lonlat.transform(gg, sm), 10);
})
@@ -97,7 +96,10 @@
$('#searchpage').die('pageshow', arguments.callee);
});
- $('#layerslist').listview();
+});
+
+function initLayerList() {
+ $('#layerspage').page();
$('<li>', {
"data-role": "list-divider",
text: "Base Layers"
@@ -122,7 +124,7 @@
map.events.register("addlayer", this, function(e) {
addLayerToList(e.layer);
});
-});
+}
function addLayerToList(layer) {
var item = $('<li>', {
@@ -133,7 +135,7 @@
text: layer.name
})
.click(function() {
- $.mobile.changePage('mappage');
+ $.mobile.changePage('#mappage');
if (layer.isBaseLayer) {
layer.map.setBaseLayer(layer);
} else {
Modified: sandbox/august/trunk/examples/sld.html
===================================================================
--- sandbox/august/trunk/examples/sld.html 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/examples/sld.html 2011-07-20 17:26:52 UTC (rev 12174)
@@ -6,92 +6,9 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
- <script src="../lib/Firebug/firebug.js"></script>
+ <!--script src="../lib/Firebug/firebug.js"></script-->
<script src="../lib/OpenLayers.js"></script>
- <script type="text/javascript">
-
- var map, sld, gmlLayers;
- var format = new OpenLayers.Format.SLD();
- function init() {
-
- map = new OpenLayers.Map('map');
- map.addControl(new OpenLayers.Control.LayerSwitcher());
-
- OpenLayers.loadURL("tasmania/sld-tasmania.xml", null, null, complete);
-
- }
-
- function getDefaultStyle(sld, layerName) {
- var styles = sld.namedLayers[layerName].userStyles;
- var style;
- for(var i=0; i<styles.length; ++i) {
- style = styles[i];
- if(style.isDefault) {
- break;
- }
- }
- return style;
- }
-
- function complete(req) {
-
- sld = format.read(req.responseXML || req.responseText);
- var hoverStyle = sld.namedLayers["WaterBodies"].userStyles[1];
- hoverStyle.defaultStyle = OpenLayers.Util.extend(
- {}, OpenLayers.Feature.Vector.style["select"]
- );
-
- gmlLayers = [
- // use the sld UserStyle named "Default Styler"
- new OpenLayers.Layer.GML(
- "StateBoundaries",
- "tasmania/TasmaniaStateBoundaries.xml",
- {
- styleMap: new OpenLayers.StyleMap(
- getDefaultStyle(sld, "Land")
- ),
- isBaseLayer: true
- }
- ),
- new OpenLayers.Layer.GML(
- "Roads",
- "tasmania/TasmaniaRoads.xml",
- {styleMap: new OpenLayers.StyleMap(getDefaultStyle(sld, "Roads"))}
- ),
- new OpenLayers.Layer.GML(
- "WaterBodies",
- "tasmania/TasmaniaWaterBodies.xml",
- {
- styleMap: new OpenLayers.StyleMap({
- "default": getDefaultStyle(sld, "WaterBodies"),
- "select": hoverStyle
- })
- }
- ),
- new OpenLayers.Layer.GML(
- "Cities",
- "tasmania/TasmaniaCities.xml",
- {styleMap: new OpenLayers.StyleMap(getDefaultStyle(sld, "Cities"))}
- )
- ];
-
- map.addLayers(gmlLayers);
- map.zoomToExtent(new OpenLayers.Bounds(143,-39,150,-45));
-
- var hover = new OpenLayers.Control.SelectFeature(
- gmlLayers[2], {hover: true}
- );
- map.addControl(hover);
- hover.activate();
- }
-
- // set a new style when the radio button changes
- function setStyle(index) {
- gmlLayers[2].styleMap.styles["default"] = sld.namedLayers["WaterBodies"].userStyles[index];
- // change the style of the features of the WaterBodies layer
- gmlLayers[2].redraw();
- }
- </script>
+ <script src="sld.js"></script>
</head>
<body onload="init()">
<h1 id="title">Styled Layer Descriptor (SLD) Example</h1>
@@ -105,19 +22,10 @@
<p id="docs">This example uses a <a target="_blank" href="tasmania/sld-tasmania.xml">SLD
file</a> to style the vector features. To construct layers that use styles
from SLD, create a StyleMap for the layer that uses one of the userStyles in the
- namedLayers object of the return from format.read().</p>
+ namedLayers object of the return from format.read(). Look at the <a href="sld.js">sld.js source</a>
+ to see how this is done.</p>
<p>Select a new style for the WaterBodies layer below:</p>
- <form>
- <input type="radio" name="style" onclick="setStyle(this.value)" checked="checked" value="0">Default Styler (zoom in to see more features)</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="3">Styler Test PropertyIsEqualTo</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="4">Styler Test WATER_TYPE</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="5">Styler Test PropertyIsGreaterThanOrEqualTo</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="6">Styler Test PropertyIsLessThanOrEqualTo</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="7">Styler Test PropertyIsGreaterThan</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="8">Styler Test PropertyIsLessThan</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="9">Styler Test PropertyIsLike</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="10">Styler Test PropertyIsBetween</input><br>
- <input type="radio" name="style" onclick="setStyle(this.value)" value="11">Styler Test FeatureId</input><br>
- </form>
+ <ul id="style_chooser">
+ </ul>
</body>
</html>
Copied: sandbox/august/trunk/examples/sld.js (from rev 12173, trunk/openlayers/examples/sld.js)
===================================================================
--- sandbox/august/trunk/examples/sld.js (rev 0)
+++ sandbox/august/trunk/examples/sld.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -0,0 +1,99 @@
+var map, sld, waterBodies;
+var format = new OpenLayers.Format.SLD();
+function init() {
+
+ map = new OpenLayers.Map('map', {allOverlays: true});
+ var layers = createLayers();
+ map.addLayers(layers);
+
+ waterBodies = layers[2];
+ map.addControl(new OpenLayers.Control.SelectFeature(
+ waterBodies, {hover: true, autoActivate: true}
+ ));
+ map.addControl(new OpenLayers.Control.LayerSwitcher());
+
+ OpenLayers.loadURL("tasmania/sld-tasmania.xml", null, null, complete);
+}
+
+// handler for the loadURL function in the init method
+function complete(req) {
+ sld = format.read(req.responseXML || req.responseText);
+ buildStyleChooser();
+ setLayerStyles();
+
+ map.zoomToExtent(new OpenLayers.Bounds(143,-39,150,-45));
+}
+
+function createLayers() {
+ // the name of each layer matches a NamedLayer name in the SLD document
+ var layerData = [{
+ name: "Land",
+ url: "tasmania/TasmaniaStateBoundaries.xml"
+ }, {
+ name: "Roads",
+ url: "tasmania/TasmaniaRoads.xml"
+ }, {
+ name: "WaterBodies",
+ url: "tasmania/TasmaniaWaterBodies.xml"
+ }, {
+ name: "Cities",
+ url: "tasmania/TasmaniaCities.xml"
+ }];
+
+ var layers = [];
+ for (var i=0,ii=layerData.length; i<ii; ++i) {
+ layers.push(new OpenLayers.Layer.Vector(
+ layerData[i].name, {
+ protocol: new OpenLayers.Protocol.HTTP({
+ url: layerData[i].url,
+ format: new OpenLayers.Format.GML.v2()
+ }),
+ strategies: [new OpenLayers.Strategy.Fixed()],
+ // empty style map, will be populated in setLayerStyles
+ styleMap: new OpenLayers.StyleMap()
+ }
+ ));
+ }
+ return layers;
+}
+
+function setLayerStyles() {
+ // set the default style for each layer from sld
+ for (var l in sld.namedLayers) {
+ var styles = sld.namedLayers[l].userStyles, style;
+ for (var i=0,ii=styles.length; i<ii; ++i) {
+ style = styles[i];
+ if (style.isDefault) {
+ map.getLayersByName(l)[0].styleMap.styles["default"] = style;
+ break;
+ }
+ }
+ }
+ // select style for mouseover on WaterBodies objects
+ waterBodies.styleMap.styles.select = sld.namedLayers["WaterBodies"].userStyles[1];
+}
+
+// add a radio button for each userStyle
+function buildStyleChooser() {
+ var styles = sld.namedLayers["WaterBodies"].userStyles;
+ var chooser = document.getElementById("style_chooser"), input, li;
+ for (var i=0,ii=styles.length; i<ii; ++i) {
+ input = document.createElement("input");
+ input.type = "radio";
+ input.name = "style";
+ input.value = i;
+ input.checked = i == 0;
+ input.onclick = function() { setStyle(this.value); };
+ li = document.createElement("li");
+ li.appendChild(input);
+ li.appendChild(document.createTextNode(styles[i].title));
+ chooser.appendChild(li);
+ }
+}
+
+// set a new style when the radio button changes
+function setStyle(index) {
+ waterBodies.styleMap.styles["default"] = sld.namedLayers["WaterBodies"].userStyles[index];
+ // apply the new style of the features of the Water Bodies layer
+ waterBodies.redraw();
+}
Modified: sandbox/august/trunk/examples/tasmania/sld-tasmania.xml
===================================================================
--- sandbox/august/trunk/examples/tasmania/sld-tasmania.xml 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/examples/tasmania/sld-tasmania.xml 2011-07-20 17:26:52 UTC (rev 12174)
@@ -10,7 +10,7 @@
<sld:Name>WaterBodies</sld:Name>
<sld:UserStyle>
<sld:Name>Default Styler</sld:Name>
- <sld:Title>Default Styler</sld:Title>
+ <sld:Title>Default Styler (zoom in to see more objects)</sld:Title>
<sld:Abstract></sld:Abstract>
<sld:IsDefault>1</sld:IsDefault>
<sld:FeatureTypeStyle>
Modified: sandbox/august/trunk/lib/OpenLayers/Control.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Control.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Control.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -116,8 +116,9 @@
autoActivate: false,
/**
- * Property: active
- * {Boolean} The control is active.
+ * APIProperty: active
+ * {Boolean} The control is active (read-only). Use <activate> and
+ * <deactivate> to change control state.
*/
active: null,
Modified: sandbox/august/trunk/lib/OpenLayers/Format/GML/Base.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Format/GML/Base.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Format/GML/Base.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -504,8 +504,9 @@
},
"MultiPoint": function(geometry) {
var node = this.createElementNSPlus("gml:MultiPoint");
- for(var i=0; i<geometry.components.length; ++i) {
- this.writeNode("pointMember", geometry.components[i], node);
+ var components = geometry.components || [geometry];
+ for(var i=0, ii=components.length; i<ii; ++i) {
+ this.writeNode("pointMember", components[i], node);
}
return node;
},
@@ -516,8 +517,9 @@
},
"MultiLineString": function(geometry) {
var node = this.createElementNSPlus("gml:MultiLineString");
- for(var i=0; i<geometry.components.length; ++i) {
- this.writeNode("lineStringMember", geometry.components[i], node);
+ var components = geometry.components || [geometry];
+ for(var i=0, ii=components.length; i<ii; ++i) {
+ this.writeNode("lineStringMember", components[i], node);
}
return node;
},
@@ -528,9 +530,10 @@
},
"MultiPolygon": function(geometry) {
var node = this.createElementNSPlus("gml:MultiPolygon");
- for(var i=0; i<geometry.components.length; ++i) {
+ var components = geometry.components || [geometry];
+ for(var i=0, ii=components.length; i<ii; ++i) {
this.writeNode(
- "polygonMember", geometry.components[i], node
+ "polygonMember", components[i], node
);
}
return node;
Modified: sandbox/august/trunk/lib/OpenLayers/Format/GML/v3.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Format/GML/v3.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Format/GML/v3.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -378,8 +378,9 @@
},
"MultiCurve": function(geometry) {
var node = this.createElementNSPlus("gml:MultiCurve");
- for(var i=0, len=geometry.components.length; i<len; ++i) {
- this.writeNode("curveMember", geometry.components[i], node);
+ var components = geometry.components || [geometry];
+ for(var i=0, len=components.length; i<len; ++i) {
+ this.writeNode("curveMember", components[i], node);
}
return node;
},
@@ -394,8 +395,9 @@
},
"MultiSurface": function(geometry) {
var node = this.createElementNSPlus("gml:MultiSurface");
- for(var i=0, len=geometry.components.length; i<len; ++i) {
- this.writeNode("surfaceMember", geometry.components[i], node);
+ var components = geometry.components || [geometry];
+ for(var i=0, len=components.length; i<len; ++i) {
+ this.writeNode("surfaceMember", components[i], node);
}
return node;
},
Modified: sandbox/august/trunk/lib/OpenLayers/Format/WFST/v1.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Format/WFST/v1.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Format/WFST/v1.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -71,7 +71,7 @@
* {Object} Maps feature states to node names.
*/
stateName: null,
-
+
/**
* Constructor: OpenLayers.Format.WFST.v1
* Instances of this class are not created directly. Use the
@@ -190,6 +190,10 @@
* in *modified.attributes* will be included. If *modified.geometry*
* is not set, the geometry will not be included.
*
+ * Valid options include:
+ * - *multi* {Boolean} If set to true, geometries will be casted to
+ * Multi geometries before writing.
+ *
* Returns:
* {String} A serialized WFS transaction.
*/
@@ -220,6 +224,7 @@
attributes: {
service: "WFS",
version: this.version,
+ handle: options && options.handle,
outputFormat: options && options.outputFormat,
maxFeatures: options && options.maxFeatures,
"xsi:schemaLocation": this.schemaLocationAttr(options)
@@ -236,26 +241,43 @@
return node;
},
"Transaction": function(obj) {
+ obj = obj || {};
+ var options = obj.options || {};
var node = this.createElementNSPlus("wfs:Transaction", {
attributes: {
service: "WFS",
- version: this.version
+ version: this.version,
+ handle: options.handle
}
});
var i, len;
- var features = obj && obj.features;
- var options = obj && obj.options;
+ var features = obj.features;
if(features) {
+ // temporarily re-assigning geometry types
+ if (options.multi === true) {
+ OpenLayers.Util.extend(this.geometryTypes, {
+ "OpenLayers.Geometry.Point": "MultiPoint",
+ "OpenLayers.Geometry.LineString": (this.multiCurve === true) ? "MultiCurve": "MultiLineString",
+ "OpenLayers.Geometry.Polygon": (this.multiSurface === true) ? "MultiSurface" : "MultiPolygon"
+ });
+ }
var name, feature;
for(i=0, len=features.length; i<len; ++i) {
feature = features[i];
name = this.stateName[feature.state];
if(name) {
- this.writeNode(name, feature, node);
+ this.writeNode(name, {
+ feature: feature,
+ options: options
+ }, node);
}
}
+ // switch back to original geometry types assignment
+ if (options.multi === true) {
+ this.setGeometryTypes();
+ }
}
- if (options && options.nativeElements) {
+ if (options.nativeElements) {
for (i=0, len=options.nativeElements.length; i<len; ++i) {
this.writeNode("wfs:Native",
options.nativeElements[i], node);
@@ -273,15 +295,24 @@
});
return node;
},
- "Insert": function(feature) {
- var node = this.createElementNSPlus("wfs:Insert");
+ "Insert": function(obj) {
+ var feature = obj.feature;
+ var options = obj.options;
+ var node = this.createElementNSPlus("wfs:Insert", {
+ attributes: {
+ handle: options && options.handle
+ }
+ });
this.srsName = this.getSrsName(feature);
this.writeNode("feature:_typeName", feature, node);
return node;
},
- "Update": function(feature) {
+ "Update": function(obj) {
+ var feature = obj.feature;
+ var options = obj.options;
var node = this.createElementNSPlus("wfs:Update", {
attributes: {
+ handle: options && options.handle,
typeName: (this.featureNS ? this.featurePrefix + ":" : "") +
this.featureType
}
@@ -339,9 +370,12 @@
}
return node;
},
- "Delete": function(feature) {
+ "Delete": function(obj) {
+ var feature = obj.feature;
+ var options = obj.options;
var node = this.createElementNSPlus("wfs:Delete", {
attributes: {
+ handle: options && options.handle,
typeName: (this.featureNS ? this.featurePrefix + ":" : "") +
this.featureType
}
Modified: sandbox/august/trunk/lib/OpenLayers/Format/WKT.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Format/WKT.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Format/WKT.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -276,7 +276,7 @@
*/
'multipoint': function(str) {
var point;
- var points = OpenLayers.String.trim(str).split(this.regExes.parenComma);
+ var points = OpenLayers.String.trim(str).split(',');
var components = [];
for(var i=0, len=points.length; i<len; ++i) {
point = points[i].replace(this.regExes.trimParens, '$1');
Modified: sandbox/august/trunk/lib/OpenLayers/Layer/Vector.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Layer/Vector.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Layer/Vector.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -474,7 +474,7 @@
var ng = (OpenLayers.Renderer.NG && this.renderer instanceof OpenLayers.Renderer.NG);
if (ng) {
- zoomChanged && this.renderer.updateDimensions();
+ dragging || this.renderer.updateDimensions(zoomChanged);
} else {
var coordSysUnchanged = true;
Modified: sandbox/august/trunk/lib/OpenLayers/Protocol/WFS/v1.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Protocol/WFS/v1.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Protocol/WFS/v1.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -105,6 +105,9 @@
* geometryName - {String} Name of geometry attribute. If featureNS is not
* configured, the default is null to avoid failing on BBOX filters,
* and it will be set on <read>. Otherwise, the default is 'the_geom'.
+ * multi - {Boolean} If set to true, geometries will be casted to Multi
+ * geometries before they are written in a transaction. No casting will
+ * be done when reading features.
*/
initialize: function(options) {
OpenLayers.Protocol.prototype.initialize.apply(this, [options]);
Modified: sandbox/august/trunk/lib/OpenLayers/Renderer/NG.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Renderer/NG.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Renderer/NG.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -38,10 +38,14 @@
* To be extended by subclasses - here we set positioning related styles
* on HTML elements, subclasses have to do the same for renderer specific
* elements (e.g. viewBox, width and height of the rendererRoot)
+ *
+ * Parameters:
+ * zoomChanged - {Boolean} Has the zoom changed? If so, subclasses may have
+ * to update feature styles/dimensions.
*/
- updateDimensions: function() {
+ updateDimensions: function(zoomChanged) {
var mapExtent = this.map.getExtent();
- var renderExtent = this.map.getMaxExtent();
+ var renderExtent = mapExtent.scale(3);
this.setExtent(renderExtent, true);
var res = this.getResolution();
var div = this.rendererRoot.parentNode;
Modified: sandbox/august/trunk/lib/OpenLayers/Renderer/SVG2.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Renderer/SVG2.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Renderer/SVG2.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -73,8 +73,11 @@
/**
* Method: updateDimensions
+ *
+ * Parameters:
+ * zoomChanged - {Boolean}
*/
- updateDimensions: function() {
+ updateDimensions: function(zoomChanged) {
OpenLayers.Renderer.NG.prototype.updateDimensions.apply(this, arguments);
var res = this.getResolution();
@@ -92,20 +95,22 @@
this.rendererRoot.setAttributeNS(null, "width", width / res);
this.rendererRoot.setAttributeNS(null, "height", height / res);
- // update styles for the new resolution
- var i, len;
- var nodes = this.vectorRoot.childNodes;
- for (i=0, len=nodes.length; i<len; ++i) {
- this.setStyle(nodes[i]);
+ if (zoomChanged === true) {
+ // update styles for the new resolution
+ var i, len;
+ var nodes = this.vectorRoot.childNodes;
+ for (i=0, len=nodes.length; i<len; ++i) {
+ this.setStyle(nodes[i]);
+ }
+ var textNodes = this.textRoot.childNodes;
+ var label;
+ for (i=0, len=textNodes.length; i<len; ++i) {
+ label = textNodes[i];
+ this.drawText(label, label._style,
+ new OpenLayers.Geometry.Point(label._x, label._y)
+ );
+ }
}
- var textNodes = this.textRoot.childNodes;
- var label;
- for (i=0, len=textNodes.length; i<len; ++i) {
- label = textNodes[i];
- this.drawText(label, label._style,
- new OpenLayers.Geometry.Point(label._x, label._y)
- );
- }
},
/**
Modified: sandbox/august/trunk/lib/OpenLayers/Util.js
===================================================================
--- sandbox/august/trunk/lib/OpenLayers/Util.js 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/lib/OpenLayers/Util.js 2011-07-20 17:26:52 UTC (rev 12174)
@@ -1865,6 +1865,9 @@
if (!dmsOption) {
dmsOption = 'dms'; //default to show degree, minutes, seconds
}
+
+ coordinate = (coordinate+540)%360 - 180; // normalize for sphere being round
+
var abscoordinate = Math.abs(coordinate);
var coordinatedegrees = Math.floor(abscoordinate);
Modified: sandbox/august/trunk/tests/Format/WFST/v1.html
===================================================================
--- sandbox/august/trunk/tests/Format/WFST/v1.html 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/tests/Format/WFST/v1.html 2011-07-20 17:26:52 UTC (rev 12174)
@@ -47,11 +47,11 @@
t.plan(7);
var snippets = {
- "GetFeature": {maxFeatures: 1, outputFormat: 'json'},
- "Transaction": null,
- "Insert": insertFeature,
- "Update": updateFeature,
- "Delete": deleteFeature
+ "GetFeature": {handle: "handle_g", maxFeatures: 1, outputFormat: 'json'},
+ "Transaction": {handle: "handle_t"},
+ "Insert": {feature: insertFeature, options: {handle: "handle_i"}},
+ "Update": {feature: updateFeature, options: {handle: "handle_u"}},
+ "Delete": {feature: deleteFeature, options: {handle: "handle_d"}}
}
var arg;
@@ -65,14 +65,14 @@
updateFeature.modified = {geometry: updateFeature.geometry.clone()};
updateFeature.geometry = new OpenLayers.Geometry.Point(2,3);
var expected = readXML("UpdateModified");
- var got = format.writers["wfs"]["Update"].apply(format, [updateFeature]);
+ var got = format.writers["wfs"]["Update"].apply(format, [{feature: updateFeature}]);
t.xml_eq(got, expected, "Update request for feature with modified geometry created correctly");
updateFeature.modified.attributes = {foo: "bar"};
updateFeature.attributes.foo = "baz";
delete updateFeature.modified.geometry;
var expected = readXML("UpdateModifiedNoGeometry");
- var got = format.writers["wfs"]["Update"].apply(format, [updateFeature]);
+ var got = format.writers["wfs"]["Update"].apply(format, [{feature: updateFeature}]);
t.xml_eq(got, expected, "Update request for feature with no modified geometry but modified attributes created correctly");
}
@@ -114,7 +114,7 @@
t.plan(1);
var snippets = {
- "UpdateNoGeometry": feature
+ "UpdateNoGeometry": {feature: feature}
}
var arg;
@@ -140,7 +140,7 @@
t.plan(1);
var snippets = {
- "UpdateNullGeometry": feature
+ "UpdateNullGeometry": {feature: feature}
};
var arg;
@@ -174,7 +174,44 @@
t.xml_eq(got, expected, snippet + " request created correctly with multiple typenames");
}
}
+
+ function test_write_multi(t) {
+ t.plan(2);
+ var format = new OpenLayers.Format.WFST({
+ featureNS: "http://www.openplans.org/topp",
+ featureType: "states",
+ featurePrefix: "topp",
+ geometryName: "the_geom"
+ });
+ var feature = new OpenLayers.Feature.Vector(
+ new OpenLayers.Geometry.Point(1,2),
+ {foo: "bar"}
+ );
+
+ var insertFeature = feature.clone();
+ // null value does not show up in insert
+ insertFeature.attributes.nul = null;
+ insertFeature.state = OpenLayers.State.INSERT;
+ var updateFeature = feature.clone();
+ // undefined value means don't create a Property element
+ updateFeature.attributes.unwritten = undefined;
+ // null value gets Property element with no Value
+ updateFeature.attributes.nul = null;
+ updateFeature.fid = "fid.42";
+ updateFeature.state = OpenLayers.State.UPDATE;
+ var features = [insertFeature, updateFeature];
+
+ var expected = readXML("TransactionMulti");
+ var geomTypes = OpenLayers.Util.extend({}, format.geometryTypes);
+ var got = format.writers["wfs"]["Transaction"].apply(format, [{
+ features: features,
+ options: {multi: true}}
+ ]);
+ t.xml_eq(got, expected, "Transaction request with multi option created correctly");
+ t.eq(format.geometryTypes, geomTypes, "geometry types unchanged after write with multi option");
+ }
+
function readXML(id) {
var xml = document.getElementById(id).firstChild.nodeValue;
return new OpenLayers.Format.XML().read(xml).documentElement;
@@ -230,7 +267,7 @@
--></div>
<div id="GetFeature"><!--
-<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" outputFormat="json" maxFeatures="1" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" handle="handle_g" outputFormat="json" maxFeatures="1" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="topp:states" xmlns:topp="http://www.openplans.org/topp"/>
</wfs:GetFeature>
--></div>
@@ -243,8 +280,50 @@
<div id="Transaction"><!--
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0"/>
--></div>
+<div id="TransactionMulti"><!--
+<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0">
+ <wfs:Insert>
+ <feature:states xmlns:feature="http://www.openplans.org/topp">
+ <feature:the_geom>
+ <gml:MultiPoint xmlns:gml="http://www.opengis.net/gml">
+ <gml:pointMember>
+ <gml:Point>
+ <gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
+ </gml:Point>
+ </gml:pointMember>
+ </gml:MultiPoint>
+ </feature:the_geom>
+ <feature:foo>bar</feature:foo>
+ </feature:states>
+ </wfs:Insert>
+ <wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
+ <wfs:Property>
+ <wfs:Name>the_geom</wfs:Name>
+ <wfs:Value>
+ <gml:MultiPoint xmlns:gml="http://www.opengis.net/gml">
+ <gml:pointMember>
+ <gml:Point>
+ <gml:coordinates decimal="." cs="," ts=" ">1,2</gml:coordinates>
+ </gml:Point>
+ </gml:pointMember>
+ </gml:MultiPoint>
+ </wfs:Value>
+ </wfs:Property>
+ <wfs:Property>
+ <wfs:Name>foo</wfs:Name>
+ <wfs:Value>bar</wfs:Value>
+ </wfs:Property>
+ <wfs:Property>
+ <wfs:Name>nul</wfs:Name>
+ </wfs:Property>
+ <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
+ <ogc:FeatureId fid="fid.42"/>
+ </ogc:Filter>
+ </wfs:Update>
+</wfs:Transaction>
+--></div>
<div id="Insert"><!--
-<wfs:Insert xmlns:wfs="http://www.opengis.net/wfs">
+<wfs:Insert xmlns:wfs="http://www.opengis.net/wfs" handle="handle_i">
<feature:states xmlns:feature="http://www.openplans.org/topp">
<feature:the_geom>
<gml:Point xmlns:gml="http://www.opengis.net/gml">
@@ -256,7 +335,7 @@
</wfs:Insert>
--></div>
<div id="Update"><!--
-<wfs:Update xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
+<wfs:Update xmlns:wfs="http://www.opengis.net/wfs" handle="handle_u" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
<wfs:Property>
<wfs:Name>the_geom</wfs:Name>
<wfs:Value>
@@ -311,7 +390,7 @@
</wfs:Update>
--></div>
<div id="Delete"><!--
-<wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
+<wfs:Delete xmlns:wfs="http://www.opengis.net/wfs" handle="handle_d" typeName="topp:states" xmlns:topp="http://www.openplans.org/topp">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:FeatureId fid="fid.37"/>
</ogc:Filter>
Modified: sandbox/august/trunk/tests/Format/WKT.html
===================================================================
--- sandbox/august/trunk/tests/Format/WKT.html 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/tests/Format/WKT.html 2011-07-20 17:26:52 UTC (rev 12174)
@@ -188,7 +188,7 @@
}
function test_Format_WKT_read(t) {
- t.plan(12);
+ t.plan(13);
var format = new OpenLayers.Format.WKT();
@@ -204,7 +204,14 @@
// test a multipoint
t.ok(multipoint.geometry.equals(format.read(format.write(multipoint)).geometry),
"format correctly reads MultiPoint WKT");
-
+
+ // test a multipoint without separating parens
+ t.ok(multipoint.geometry.equals(format.read(
+ "MULTIPOINT(" + points[0].geometry.x + " " + points[0].geometry.y + "," +
+ points[1].geometry.x + " " + points[1].geometry.y + "," +
+ points[2].geometry.x + " " + points[2].geometry.y + ")").geometry),
+ "format correctly reads MultiPoint WKT without parens");
+
// test a linestring
t.ok(linestrings[0].geometry.equals(format.read(format.write(linestrings[0])).geometry),
"format correctly reads LineString WKT");
Modified: sandbox/august/trunk/tests/Renderer/SVG2.html
===================================================================
--- sandbox/august/trunk/tests/Renderer/SVG2.html 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/tests/Renderer/SVG2.html 2011-07-20 17:26:52 UTC (rev 12174)
@@ -48,7 +48,7 @@
return;
}
- t.plan(5);
+ t.plan(7);
OpenLayers.Renderer.SVG2.prototype._setExtent =
OpenLayers.Renderer.SVG2.prototype.setExtent;
@@ -76,14 +76,16 @@
t.eq(g_SetExtent, true, "Elements.setExtent() called");
- t.eq(r.rendererRoot.getAttributeNS(null, "width"), "4", "width is correct");
- t.eq(r.rendererRoot.getAttributeNS(null, "height"), "4", "height is correct");
- t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "1 -4 2 2", "rendererRoot viewBox is correct");
+ t.eq(r.extent.toString(), extent.scale(3).toString(), "renderer's extent is correct");
+ t.eq(r.rendererRoot.getAttributeNS(null, "width"), "12", "width is correct");
+ t.eq(r.rendererRoot.getAttributeNS(null, "height"), "12", "height is correct");
+ t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "-1 -6 6 6", "rendererRoot viewBox is correct");
// test extent changes
extent = new OpenLayers.Bounds(2,3,5,6);
r.updateDimensions();
- t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "2 -6 3 3", "rendererRoot viewBox is correct after a new setExtent");
+ t.eq(r.extent.toString(), extent.scale(3).toString(), "renderer's extent changed after updateDimensions");
+ t.eq(r.rendererRoot.getAttributeNS(null, "viewBox"), "-1 -9 9 9", "rendererRoot viewBox is correct after a new setExtent");
OpenLayers.Renderer.SVG2.prototype.setExtent =
OpenLayers.Renderer.SVG2.prototype._setExtent;
Modified: sandbox/august/trunk/tests/Util.html
===================================================================
--- sandbox/august/trunk/tests/Util.html 2011-07-19 10:09:58 UTC (rev 12173)
+++ sandbox/august/trunk/tests/Util.html 2011-07-20 17:26:52 UTC (rev 12174)
@@ -1146,10 +1146,12 @@
"toFloat rounds large floats correctly #2");
}
function test_getFormattedLonLat(t) {
- t.plan(1);
+ t.plan(3);
var z = 2 + (4/60) - 0.000002 ;
t.eq(OpenLayers.Util.getFormattedLonLat(z,"lon"), "02°04'00\"E",
"LonLat does not show 60 seconds.");
+ t.eq(OpenLayers.Util.getFormattedLonLat(-181, "lon"), "179°00'00\"E", "crossing dateline from the west results in correct east coordinate");
+ t.eq(OpenLayers.Util.getFormattedLonLat(181, "lon"), "179°00'00\"W", "crossing dateline from the east results in correct west coordinate");
}
</script>
</head>
Copied: sandbox/august/trunk/tests/manual/svg2-coordinaterange.html (from rev 12173, trunk/openlayers/tests/manual/svg2-coordinaterange.html)
===================================================================
--- sandbox/august/trunk/tests/manual/svg2-coordinaterange.html (rev 0)
+++ sandbox/august/trunk/tests/manual/svg2-coordinaterange.html 2011-07-20 17:26:52 UTC (rev 12174)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
+<link rel="stylesheet" href="../../theme/default/style.css" type="text/css" />
+<style type="text/css">
+ #map {
+ width: 512px;
+ height: 512px;
+ border: 1px solid gray;
+ }
+</style>
+<title>SVG2 coordinate range check</title>
+<script type="text/javascript" src="../../lib/OpenLayers.js"></script>
+<script>
+
+var WGS84 = new OpenLayers.Projection("EPSG:4326");
+var Mercator = new OpenLayers.Projection("EPSG:900913");
+var wkt = new OpenLayers.Format.WKT({ internalProjection: Mercator, externalProjection: WGS84 });
+
+function init() {
+ var externalGraphic, baseURL, baseLayer, layerOptions, hidemessenger;
+
+ var map = new OpenLayers.Map('map', {
+ controls: [
+ new OpenLayers.Control.Navigation(),
+ new OpenLayers.Control.PanZoom(),
+ new OpenLayers.Control.Attribution()
+ ],
+ theme: null
+ });
+
+ baseLayer = new OpenLayers.Layer.OSM("OSM");
+
+ var viewLayer = new OpenLayers.Layer.Vector("View Layer", {renderers: ["SVG2"]});
+ map.addLayers([baseLayer, viewLayer]);
+
+ viewLayer.addFeatures([wkt.read("LINESTRING(2.4356174739332 48.816618174539, 2.4313688548536 48.826083884311)")]);
+ var lonLat = new OpenLayers.LonLat( 2.43686, 48.81742) .transform( WGS84, Mercator);
+ map.setCenter (lonLat, 16);
+}
+</script>
+
+<body onload="init()">
+<div id="map"></div>
+<p>The map should show a line on top of the OSM layer. If it does not, then
+ either the CSS or the SVG coordinate range is exceeded.</p>
+<p>This test only works on browsers that support SVG.</p>
+</body>
+</html>
More information about the Commits
mailing list