Merge branch 'master' of github.com:bartvde/openlayers into csw
This commit is contained in:
@@ -288,6 +288,40 @@
|
||||
// panel.deactivate();
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_iconOn_iconOff(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
|
||||
var panel = new OpenLayers.Control.Panel();
|
||||
var ctrl = new OpenLayers.Control({displayClass: 'ctrl'});
|
||||
panel.addControls([ctrl]);
|
||||
|
||||
map.addControl(panel);
|
||||
|
||||
// add arbitrary classes to the panel div - we want to test
|
||||
// than iconOn and iconOff do their jobs even when the panel
|
||||
// div has application-specific classes.
|
||||
|
||||
ctrl.panel_div.className =
|
||||
'ctrlItemInactive fooItemActive fooItemInactive';
|
||||
|
||||
panel.iconOn.call(ctrl);
|
||||
t.eq(ctrl.panel_div.className,
|
||||
'ctrlItemActive fooItemActive fooItemInactive',
|
||||
'iconOn behaves as expected');
|
||||
|
||||
ctrl.panel_div.className =
|
||||
'ctrlItemActive fooItemActive fooItemInactive';
|
||||
|
||||
panel.iconOff.call(ctrl);
|
||||
t.eq(ctrl.panel_div.className,
|
||||
'ctrlItemInactive fooItemActive fooItemInactive',
|
||||
'iconOff behaves as expected');
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -82,6 +82,44 @@
|
||||
control.box.move(center);
|
||||
t.geom_eq(control.handles[0].geometry, control.box.geometry.components[0], "handle moved with box");
|
||||
}
|
||||
|
||||
function test_handleMove(t) {
|
||||
t.plan(16);
|
||||
var map = new OpenLayers.Map("map", {allOverlays: true});
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
var feature = new OpenLayers.Feature.Vector(
|
||||
OpenLayers.Geometry.fromWKT("POLYGON((-1 -1, 1 -1, 1 1, -1 1))"));
|
||||
layer.addFeatures([feature]);
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0, 0), 18);
|
||||
var control = new OpenLayers.Control.TransformFeature(layer);
|
||||
map.addControl(control);
|
||||
control.setFeature(feature);
|
||||
|
||||
var bottomLeft = new OpenLayers.LonLat(-2, -2);
|
||||
control.handles[0].move(bottomLeft);
|
||||
t.geom_eq(control.handles[0].geometry, new OpenLayers.Geometry.Point(-2, -2), "bottom left handle at -2,-2");
|
||||
t.geom_eq(control.handles[1].geometry, new OpenLayers.Geometry.Point(0, -2), "bottom handle at 0,-2");
|
||||
t.geom_eq(control.handles[2].geometry, new OpenLayers.Geometry.Point(2, -2), "bottom right handle at 2,-2");
|
||||
t.geom_eq(control.handles[3].geometry, new OpenLayers.Geometry.Point(2, 0), "right handle at 2,0");
|
||||
t.geom_eq(control.handles[4].geometry, new OpenLayers.Geometry.Point(2, 2), "top right handle at 2,2");
|
||||
t.geom_eq(control.handles[5].geometry, new OpenLayers.Geometry.Point(0, 2), "top handle at 0,2");
|
||||
t.geom_eq(control.handles[6].geometry, new OpenLayers.Geometry.Point(-2, 2), "top left handle at -2,2");
|
||||
t.geom_eq(control.handles[7].geometry, new OpenLayers.Geometry.Point(-2, 0), "left handle at -2,0");
|
||||
|
||||
control.irregular = true;
|
||||
|
||||
var bottomLeft = new OpenLayers.LonLat(-3, -3);
|
||||
control.handles[0].move(bottomLeft);
|
||||
t.geom_eq(control.handles[0].geometry, new OpenLayers.Geometry.Point(-3, -3), "bottom left handle at -3,-3");
|
||||
t.geom_eq(control.handles[1].geometry, new OpenLayers.Geometry.Point(-0.5, -3), "bottom handle at 0,-3");
|
||||
t.geom_eq(control.handles[2].geometry, new OpenLayers.Geometry.Point(2, -3), "bottom right handle at 2,-3");
|
||||
t.geom_eq(control.handles[3].geometry, new OpenLayers.Geometry.Point(2, -0.5), "right handle at 2,0");
|
||||
t.geom_eq(control.handles[4].geometry, new OpenLayers.Geometry.Point(2, 2), "top right handle at 2,2");
|
||||
t.geom_eq(control.handles[5].geometry, new OpenLayers.Geometry.Point(-0.5, 2), "top handle at 0,2");
|
||||
t.geom_eq(control.handles[6].geometry, new OpenLayers.Geometry.Point(-3, 2), "top left handle at -3,2");
|
||||
t.geom_eq(control.handles[7].geometry, new OpenLayers.Geometry.Point(-3, -0.5), "left handle at -3,0");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -413,6 +413,13 @@
|
||||
' <wps:ComplexData><![CDATA[<html><head></head><body></body></head>]]></wps:ComplexData>' +
|
||||
' </wps:Data>' +
|
||||
' </wps:Input>' +
|
||||
' <wps:Input>' +
|
||||
' <ows:Identifier>GMLPoint</ows:Identifier>' +
|
||||
' <ows:Title>Point as GML</ows:Title>' +
|
||||
' <wps:Data>' +
|
||||
' <wps:ComplexData><feature:geometry xmlns:feature="http://www.opengis.net/gml"><feature:Point><feature:pos>10 10</feature:pos></feature:Point></feature:geometry></wps:ComplexData>' +
|
||||
' </wps:Data>' +
|
||||
' </wps:Input>' +
|
||||
' </wps:DataInputs>' +
|
||||
' <wps:ResponseForm>' +
|
||||
' <wps:ResponseDocument storeExecuteResponse="true">' +
|
||||
@@ -442,6 +449,14 @@
|
||||
value: "<html><head></head><body></body></head>"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
identifier: "GMLPoint",
|
||||
title: "Point as GML",
|
||||
data: {
|
||||
complexData: {
|
||||
value: OpenLayers.Format.GML.v3.prototype.writers.feature["_geometry"].apply(new OpenLayers.Format.GML.v3({curve: true, surface: true}), [new OpenLayers.Geometry.Point(10, 10)])
|
||||
}
|
||||
}
|
||||
}],
|
||||
responseForm: {
|
||||
responseDocument: {
|
||||
|
||||
@@ -334,6 +334,19 @@
|
||||
t.geom_eq(wkt(cases[i].wkt), cases[i].geom, "case " + i);
|
||||
}
|
||||
}
|
||||
|
||||
function test_fromWKT_undefined(t) {
|
||||
t.plan(1);
|
||||
|
||||
var WKT = OpenLayers.Format.WKT;
|
||||
OpenLayers.Format.WKT = null;
|
||||
delete OpenLayers.Geometry.fromWKT.format;
|
||||
|
||||
var geom = OpenLayers.Geometry.fromWKT("POINT(1 1)");
|
||||
t.eq(geom, undefined, "undefined when OpenLayers.Format.WKT is not available");
|
||||
|
||||
OpenLayers.Format.WKT = WKT;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -101,6 +101,21 @@
|
||||
"toString() returns WKT" );
|
||||
|
||||
}
|
||||
|
||||
function test_Point_toString_no_wkt(t) {
|
||||
t.plan(1);
|
||||
|
||||
var WKT = OpenLayers.Format.WKT;
|
||||
OpenLayers.Format.WKT = null;
|
||||
|
||||
var x = 10;
|
||||
var y = 20;
|
||||
point = new OpenLayers.Geometry.Point(x, y);
|
||||
t.eq(point.toString(), "[object Object]", "default string representation");
|
||||
|
||||
OpenLayers.Format.WKT = WKT;
|
||||
|
||||
}
|
||||
|
||||
function test_Point_move(t) {
|
||||
t.plan(3);
|
||||
|
||||
+21
-1
@@ -21,13 +21,14 @@
|
||||
|
||||
|
||||
function test_Layer_Grid_constructor (t) {
|
||||
t.plan( 5 );
|
||||
t.plan( 6 );
|
||||
|
||||
layer = new OpenLayers.Layer.Grid(name, url, params, null);
|
||||
t.ok( layer instanceof OpenLayers.Layer.Grid, "returns OpenLayers.Layer.Grid object" );
|
||||
t.eq( layer.buffer, 0, "buffer default is 0");
|
||||
t.eq( layer.ratio, 1.5, "ratio default is 1.5");
|
||||
t.eq( layer.numLoadingTiles, 0, "numLoadingTiles starts at 0");
|
||||
t.eq( layer.tileClass, OpenLayers.Tile.Image, "tileClass default is OpenLayers.Tile.Image");
|
||||
|
||||
var obj = {};
|
||||
var func = function() {};
|
||||
@@ -48,6 +49,25 @@
|
||||
|
||||
}
|
||||
|
||||
function test_Layer_Grid_tileClass(t) {
|
||||
t.plan(2);
|
||||
|
||||
var myTileClass = OpenLayers.Class(OpenLayers.Tile, {});
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params, {
|
||||
tileClass: myTileClass
|
||||
});
|
||||
map.addLayer(layer);
|
||||
|
||||
t.eq(layer.tileClass, myTileClass, "tileClass is set");
|
||||
var instance = layer.addTile(new OpenLayers.Bounds(-10, 10, 50, 100),
|
||||
new OpenLayers.Pixel(10, 12));
|
||||
|
||||
t.ok(instance instanceof myTileClass, "addTile returns type is correct");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Layer_Grid_clearTiles (t) {
|
||||
t.plan(4);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript">var oldAlert = window.alert, gMess; window.alert = function(message) {gMess = message; return true;};</script>
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
|
||||
<script type="text/javascript">window.alert = oldAlert;</script>
|
||||
|
||||
|
||||
@@ -216,44 +215,6 @@
|
||||
|
||||
}
|
||||
|
||||
function test_Layer_MapServer_Reproject (t) {
|
||||
var validkey = (window.location.protocol == "file:") ||
|
||||
(window.location.host == "localhost") ||
|
||||
(window.location.host == "openlayers.org");
|
||||
|
||||
if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") {
|
||||
t.plan(1);
|
||||
t.debug_print("Can't test google reprojection in Opera or Safari.");
|
||||
} else if(validkey) {
|
||||
t.plan(5);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.Google("Google");
|
||||
map.addLayer(layer);
|
||||
layer = new OpenLayers.Layer.MapServer(name, url, params, {isBaseLayer: false, buffer: 2});
|
||||
layer.isBaseLayer=false;
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
t.eq( tile.bounds.left, -22.5, "left side matches" );
|
||||
t.eq( tile.bounds.right, -11.25, "top side matches" );
|
||||
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );
|
||||
t.eq( tile.bounds.top.toFixed(6), '21.943046', "top side matches" );
|
||||
map.destroy();
|
||||
} else {
|
||||
t.plan(1);
|
||||
t.debug_print("can't test google layer from " +
|
||||
window.location.host);
|
||||
}
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.MapServer(name, url, params, {buffer:2});
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
t.ok( tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)), "okay");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Layer_MapServer_singleTile (t) {
|
||||
t.plan( 5 );
|
||||
var map = new OpenLayers.Map('map');
|
||||
|
||||
+12
-4
@@ -380,11 +380,13 @@
|
||||
*/
|
||||
|
||||
function test_Map_isValidZoomLevel(t) {
|
||||
t.plan(4);
|
||||
t.plan(5);
|
||||
var map = new OpenLayers.Map("map");
|
||||
map.addLayer(new OpenLayers.Layer(null, {
|
||||
isBaseLayer: true, numZoomLevels: 19
|
||||
}))
|
||||
isBaseLayer: true, wrapDateLine: true, numZoomLevels: 19
|
||||
}));
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
var valid;
|
||||
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [-1]);
|
||||
@@ -398,6 +400,9 @@
|
||||
|
||||
valid = OpenLayers.Map.prototype.isValidZoomLevel.apply(map, [19]);
|
||||
t.eq(valid, false, "19 is not a valid zoomLevel");
|
||||
|
||||
map.moveTo([16, 48], 0);
|
||||
t.eq(map.getCenter().toShortString(), "0, 0", "no panning when moveTo is called with invalid zoom");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
@@ -1966,7 +1971,7 @@
|
||||
}
|
||||
|
||||
function test_adjustZoom(t) {
|
||||
t.plan(3);
|
||||
t.plan(4);
|
||||
var map = new OpenLayers.Map({
|
||||
div: 'map',
|
||||
layers: [
|
||||
@@ -1981,6 +1986,9 @@
|
||||
|
||||
t.eq(map.adjustZoom(9), 9, "valid zoom maintained");
|
||||
t.eq(map.adjustZoom(1), 2, "zoom adjusted to not exceed world width");
|
||||
|
||||
map.moveTo([16, 48], 0);
|
||||
t.eq(map.getCenter().toShortString(), "0, 0", "no panning when moveTo is called with invalid zoom");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -614,6 +614,9 @@
|
||||
getMaxExtent: function() {
|
||||
return new OpenLayers.Bounds(-180,-90,180,90);
|
||||
},
|
||||
getExtent: function() {
|
||||
return r.extent;
|
||||
},
|
||||
getResolution: function() {
|
||||
return resolution;
|
||||
},
|
||||
|
||||
@@ -34,6 +34,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function assertFloatEqual
|
||||
* Test two objects for floating point equivalence. Throw an exception
|
||||
* if not equivalent.
|
||||
*
|
||||
* Parameters:
|
||||
* got - {Object}
|
||||
* expected - {Object}
|
||||
* msg - {String} The message to be thrown. This message will be appended
|
||||
* with ": got {got} but expected {expected}" where got and expected are
|
||||
* replaced with string representations of the above arguments.
|
||||
*/
|
||||
function assertFloatEqual(got, expected, msg) {
|
||||
var OpenLayers = Test.AnotherWay._g_test_iframe.OpenLayers;
|
||||
if(got === undefined) {
|
||||
got = "undefined";
|
||||
} else if (got === null) {
|
||||
got = "null";
|
||||
}
|
||||
if(expected === undefined) {
|
||||
expected = "undefined";
|
||||
} else if (expected === null) {
|
||||
expected = "null";
|
||||
}
|
||||
if(Math.abs(got - expected) > Math.pow(10, -OpenLayers.Util.DEFAULT_PRECISION)) {
|
||||
throw msg + ": got '" + got + "' but expected '" + expected + "'";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function assertGeometryEqual
|
||||
* Test two geometries for equivalence. Geometries are considered
|
||||
@@ -58,9 +87,9 @@
|
||||
|
||||
if(got instanceof OpenLayers.Geometry.Point) {
|
||||
// compare points
|
||||
assertEqual(got.x, expected.x, "x mismatch");
|
||||
assertEqual(got.y, expected.y, "y mismatch");
|
||||
assertEqual(got.z, expected.z, "z mismatch");
|
||||
assertFloatEqual(got.x, expected.x, "x mismatch");
|
||||
assertFloatEqual(got.y, expected.y, "y mismatch");
|
||||
assertFloatEqual(got.z, expected.z, "z mismatch");
|
||||
} else {
|
||||
// compare components
|
||||
assertEqual(
|
||||
@@ -107,4 +136,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
})();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script src="../../OLLoader.js"></script>
|
||||
<script src="../../../lib/deprecated.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_Rectangle_constructor (t) {
|
||||
@@ -0,0 +1,59 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
|
||||
|
||||
<script src="../../OLLoader.js"></script>
|
||||
<script src="../../../lib/deprecated.js"></script>
|
||||
<script type="text/javascript">
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
|
||||
var name = 'Test Layer';
|
||||
var url = "http://labs.metacarta.com/cgi-bin/mapserv";
|
||||
var params = { map: '/mapdata/vmap_wms.map',
|
||||
layers: 'basic'};
|
||||
|
||||
function test_Layer_MapServer_Reproject (t) {
|
||||
var validkey = (window.location.protocol == "file:") ||
|
||||
(window.location.host == "localhost") ||
|
||||
(window.location.host == "openlayers.org");
|
||||
|
||||
if (OpenLayers.BROWSER_NAME == "opera" || OpenLayers.BROWSER_NAME == "safari") {
|
||||
t.plan(1);
|
||||
t.debug_print("Can't test google reprojection in Opera or Safari.");
|
||||
} else if(validkey) {
|
||||
t.plan(5);
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.Google("Google");
|
||||
map.addLayer(layer);
|
||||
layer = new OpenLayers.Layer.MapServer(name, url, params, {reproject: true, isBaseLayer: false, buffer: 2});
|
||||
layer.isBaseLayer=false;
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
t.eq( tile.bounds.left, -22.5, "left side matches" );
|
||||
t.eq( tile.bounds.right, -11.25, "top side matches" );
|
||||
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );
|
||||
t.eq( tile.bounds.top.toFixed(6), '21.943046', "top side matches" );
|
||||
map.destroy();
|
||||
} else {
|
||||
t.plan(1);
|
||||
t.debug_print("can't test google layer from " +
|
||||
window.location.host);
|
||||
}
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.MapServer(name, url, params, {buffer:2});
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
t.ok( tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)), "okay");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -123,7 +123,6 @@
|
||||
<li>Geometry/MultiPolygon.html</li>
|
||||
<li>Geometry/Point.html</li>
|
||||
<li>Geometry/Polygon.html</li>
|
||||
<li>Geometry/Rectangle.html</li>
|
||||
<li>Handler.html</li>
|
||||
<li>Handler/Box.html</li>
|
||||
<li>Handler/Click.html</li>
|
||||
@@ -223,7 +222,9 @@
|
||||
<li>deprecated/BaseTypes/Class.html</li>
|
||||
<li>deprecated/BaseTypes/Element.html</li>
|
||||
<li>deprecated/Control/MouseToolbar.html</li>
|
||||
<li>deprecated/Geometry/Rectangle.html</li>
|
||||
<li>deprecated/Layer/GML.html</li>
|
||||
<li>deprecated/Layer/MapServer.html</li>
|
||||
<li>deprecated/Layer/MapServer/Untiled.html</li>
|
||||
<li>deprecated/Layer/MultiMap.html</li>
|
||||
<li>deprecated/Layer/WFS.html</li>
|
||||
|
||||
Reference in New Issue
Block a user