Merge branch 'master' into osm

Conflicts:
	apidoc_config/Menu.txt
This commit is contained in:
Éric Lemoine
2012-01-12 21:27:39 +01:00
81 changed files with 562 additions and 225 deletions

View File

@@ -141,7 +141,7 @@
function test_isEligible(t) {
t.plan(9);
t.plan(10);
var control = new OpenLayers.Control.Split();
var geometry = OpenLayers.Geometry.fromWKT("LINESTRING(0 1, 1 2)");
@@ -176,6 +176,9 @@
control.targetFilter.value = "baz";
t.eq(control.isEligible(feature), true, "feature is eligible if it matches filter");
delete feature.geometry;
t.eq(control.isEligible(feature), false, "feature with no geometry is not eligible");
control.destroy();
}

View File

@@ -534,6 +534,43 @@
map.destroy();
}
function test_freehand_maxVertices(t) {
t.plan(1);
var map = new OpenLayers.Map("map", {
resolutions: [1]
});
var layer = new OpenLayers.Layer.Vector("foo", {
maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
isBaseLayer: true
});
map.addLayer(layer);
var control = new OpenLayers.Control({});
var log = {};
var MAX_VERTICES = 2;
var doneCallback = function(geo) {
t.eq(geo.components.length, MAX_VERTICES,
'When maxVertices is reached, the geometry is finalized automatically');
};
var handler = new OpenLayers.Handler.Path(control,
{'done': doneCallback},
{freehand: true,
maxVertices: MAX_VERTICES});
control.handler = handler;
map.addControl(control);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
// mock up feature freehand drawing
handler.activate();
var evt = {xy: new OpenLayers.Pixel(0, 0)};
handler.mousemove(evt);
handler.mousedown(evt);
evt = {xy: new OpenLayers.Pixel(20, 20)};
handler.mousemove(evt);
evt = {xy: new OpenLayers.Pixel(40, 40)};
handler.mousemove(evt);
map.destroy();
}
/**
* Helper functions for editing method tests
*/

90
tests/Protocol/CSW.html Normal file
View File

@@ -0,0 +1,90 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_initialize(t) {
t.plan(3);
var protocol = new OpenLayers.Protocol.CSW({formatOptions: {foo: "bar"},});
t.ok(protocol instanceof OpenLayers.Protocol.CSW.v2_0_2,
"initialize returns instance of default versioned protocol");
var format = protocol.format;
t.ok(format instanceof OpenLayers.Format.CSWGetRecords.v2_0_2, "Default format created");
t.ok(format.foo, "bar", "formatOptions set correctly");
protocol.destroy();
}
function test_read(t) {
t.plan(6);
var protocol = new OpenLayers.Protocol.CSW({
url: "http://some.url.org",
parseData: function(request) {
t.eq(request.responseText, "foo", "parseData called properly");
return "foo";
}
});
var _POST = OpenLayers.Request.POST;
var expected, status;
OpenLayers.Request.POST = function(obj) {
t.xml_eq(new OpenLayers.Format.XML().read(obj.data).documentElement, expected, "GetRecords request is correct");
obj.status = status;
obj.responseText = "foo";
obj.options = {};
t.delay_call(0.1, function() {obj.callback.call(this)});
return obj;
};
expected = readXML("GetRecords");
status = 200;
var data = {
"resultType": "results",
"maxRecords": 100,
"Query": {
"typeNames": "gmd:MD_Metadata",
"ElementSetName": {
"value": "full"
}
}
};
var response = protocol.read({
params: data,
callback: function(response) {
t.eq(response.data, "foo", "user callback properly called with data");
t.eq(response.code, OpenLayers.Protocol.Response.SUCCESS, "success reported properly to user callback");
}
});
var options = {
params: data,
callback: function(response) {
t.eq(response.code, OpenLayers.Protocol.Response.FAILURE, "failure reported properly to user callback");
}
};
status = 400;
var response = protocol.read(options);
OpenLayers.Request.POST = _POST;
}
function readXML(id) {
var xml = document.getElementById(id).firstChild.nodeValue;
return new OpenLayers.Format.XML().read(xml).documentElement;
}
</script>
</head>
<body>
<div id="map" style="width:512px; height:256px"> </div>
<div id="GetRecords"><!--
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="2.0.2" resultType="results" maxRecords="100">
<csw:Query typeNames="gmd:MD_Metadata">
<csw:ElementSetName>full</csw:ElementSetName>
</csw:Query>
</csw:GetRecords>
--></div>
</body>
</html>

View File

@@ -185,6 +185,7 @@
<li>Protocol/HTTP.html</li>
<li>Protocol/Script.html</li>
<li>Protocol/WFS.html</li>
<li>Protocol/CSW.html</li>
<li>Protocol/SOS.html</li>
<li>Renderer.html</li>
<li>Renderer/Canvas.html</li>