Merge changes from trunk to 2.4:

svn merge trunk/openlayers/@3088 trunk/openlayers/@HEAD branches/openlayers/2.4/

Changes include:
 * Improved GML parsing to catch fid better
 * Letting panels pass mouseup through
 * Fixing small bug in panel example
 * Display of markers/layers when out of range on startup.
 * Fix to aspect ratio of Overview Map.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.4@3112 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-05-02 14:06:41 +00:00
parent b5103eb8ce
commit 3c6cd6f559
13 changed files with 159 additions and 195 deletions

View File

@@ -0,0 +1,57 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var test_content = '<wfs:FeatureCollection' +
' xmlns:fs="http://example.com/featureserver"' +
' xmlns:wfs="http://www.opengis.net/wfs"' +
' xmlns:gml="http://www.opengis.net/gml"' +
' xmlns:ogc="http://www.opengis.net/ogc"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengeospatial.net//wfs/1.0.0/WFS-basic.xsd">' +
' ' +
'' +
' <gml:featureMember>' +
' \n<fs:scribble fid="221">' +
' <fs:geometry>' +
' <gml:Polygon>' +
' ' +
' <gml:outerBoundaryIs><gml:LinearRing>' +
' <gml:coordinates>149.105072021,-35.1816558838 149.100608826,-35.1844024658 149.098892212,-35.1898956299 149.105072021,-35.1816558838</gml:coordinates>' +
' </gml:LinearRing></gml:outerBoundaryIs>' +
' ' +
' </gml:Polygon>' +
' </fs:geometry>' +
' <fs:title>random test features</fs:title>' +
' </fs:scribble>' +
'</gml:featureMember> ' +
' <gml:featureMember><fs:scribble fid="8"> <fs:geometry> <gml:Point><gml:coordinates>-81.38671875,27.0703125</gml:coordinates></gml:Point> </fs:geometry> ' +
' <fs:down>south</fs:down><fs:title>Florida</fs:title> </fs:scribble></gml:featureMember>' +
'</wfs:FeatureCollection>';
function test_Format_GML_constructor(t) {
t.plan(4);
var options = {'foo': 'bar'};
var format = new OpenLayers.Format.GML(options);
t.ok(format instanceof OpenLayers.Format.GML,
"new OpenLayers.Format.GML returns object" );
t.eq(format.foo, "bar", "constructor sets options correctly");
t.eq(typeof format.read, "function", "format has a read function");
t.eq(typeof format.write, "function", "format has a write function");
}
function test_Format_GML_getFid(t) {
t.plan(2);
var parser = new OpenLayers.Format.GML();
data = parser.read(test_content);
t.eq(data[0].fid, '221', 'fid on polygons set correctly (with whitespace)');
t.eq(data[1].fid, '8', 'fid on linestrings set correctly with whitespace');
}
// -->
</script>
</head>
<body>
</body>
</html>

View File

@@ -29,7 +29,7 @@
}
function test_03_Layer_Vector_removeFeatures(t) {
t.plan(2);
t.plan(3);
var layer = new OpenLayers.Layer.Vector(name);
@@ -43,6 +43,9 @@
t.ok(layer.features.length == 1, "OpenLayers.Layer.Vector.removeFeatures removes a feature from the features array");
layer.addFeatures([pointFeature1.clone(), pointFeature2.clone()]);
layer.selectedFeatures.push(layer.features[0]);
layer.removeFeatures(layer.features[0]);
t.eq(layer.selectedFeatures, [], "Remove features removes selected features");
var features = layer.removeFeatures(layer.features);
t.ok(layer.features.length == 0,
@@ -69,12 +72,16 @@
var feature = new OpenLayers.Feature.Vector(geometry);
var f, s;
// Layer renderer needs a destroy, and draw, for functional tests.
layer.renderer = {
drawFeature: function(feature, style) {
f = feature;
s = style;
}
},
destroy: function() { }
};
layer.drawFeature(feature);
t.ok(geometry.equals(f.geometry),
@@ -112,7 +119,8 @@
layer.renderer = {
eraseFeatures: function(features) {
f = features[0];
}
},
destroy: function() { }
};
layer.eraseFeatures([feature]);

View File

@@ -178,185 +178,4 @@
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var box;
function test_01_Box_constructor (t) {
t.plan( 7 );
OpenLayers.Marker.Box.prototype._setBorder =
OpenLayers.Marker.Box.prototype.setBorder;
OpenLayers.Marker.Box.prototype.setBorder = function (x,y) {
g_Color = x;
g_Width = y;
};
var bounds = new OpenLayers.Bounds(1,2,3,4);
var borderColor = "blue";
var borderWidth = 55;
g_Color = g_Width = null;
box = new OpenLayers.Marker.Box(bounds, borderColor, borderWidth);
t.ok( box instanceof OpenLayers.Marker.Box, "new OpenLayers.Marker.Box returns Box object" );
t.ok( box.bounds.equals(bounds), "bounds object correctly set");
t.ok( box.div != null, "div created");
t.eq( box.div.style.overflow, "hidden", "div style overflow hidden");
t.ok( box.events != null, "events object created");
t.eq( g_Color, borderColor, "setBorder called with correct border color");
t.eq( g_Width, borderWidth, "setBorder called with correct border width");
OpenLayers.Marker.Box.prototype.setBorder =
OpenLayers.Marker.Box.prototype._setBorder;
}
function test_02_Box_setBorder(t) {
t.plan( 2 );
var box = {
div: {
style: {}
}
};
//defaults
var args = [];
OpenLayers.Marker.Box.prototype.setBorder.apply(box, args);
t.eq(box.div.style.border, "2px solid red", "style correctly set with no good values (defaults work)");
//good vals
var borderColor = "blue";
var borderWidth = 55;
args = [borderColor, borderWidth];
OpenLayers.Marker.Box.prototype.setBorder.apply(box, args);
t.eq(box.div.style.border, borderWidth + "px solid " + borderColor, "style correctly set with both good values");
}
function test_03_Box_draw(t) {
t.plan( 5 );
OpenLayers.Util._modifyDOMElement =
OpenLayers.Util.modifyDOMElement;
OpenLayers.Util.modifyDOMElement =
function (element, id, px, sz) {
g_Element = element;
g_Id = id;
g_Px = px;
g_Sz = sz;
};
var box = {
div: {}
};
var px = {};
var sz = {};
var args = [px, sz];
g_Element = g_Id = g_Px = g_Sz = null;
var retVal = OpenLayers.Marker.Box.prototype.draw.apply(box, args);
t.eq(g_Element, box.div, "modifyDOMElement passes box's div for element");
t.eq(g_Id, null, "modifyDOMElement passes null for id");
t.eq(g_Px, px, "modifyDOMElement passes new px value for px");
t.eq(g_Sz, sz, "modifyDOMElement passes new sz value for sz");
t.ok(retVal == box.div, "draw returns box's div");
OpenLayers.Util.modifyDOMElement =
OpenLayers.Util._modifyDOMElement;
}
function test_04_Box_onScreen(t) {
t.plan( 2 );
var map = new OpenLayers.Map("map");
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
layer = new OpenLayers.Layer.WMS(name, url);
map.addLayer(layer);
mlayer = new OpenLayers.Layer.Boxes('Test Layer');
map.addLayer(mlayer);
map.zoomToExtent(new OpenLayers.Bounds(-50,-50,50,50));
//onscreen box
var bounds = new OpenLayers.Bounds(-1,-1,1,1);
var box = new OpenLayers.Marker.Box(bounds);
mlayer.addMarker(box);
t.ok( box.onScreen(), "box knows it's onscreen" );
//offscreen box
var bounds = new OpenLayers.Bounds(100,100,150,150);
var box2 = new OpenLayers.Marker.Box(bounds);
mlayer.addMarker(box2);
t.ok( !box2.onScreen(), "box knows it's offscreen" );
map.destroy();
}
function test_05_Box_display(t) {
t.plan( 2 );
var box = {
div: {
style: {}
}
};
//display(true)
var args = [true];
OpenLayers.Marker.Box.prototype.display.apply(box, args);
t.eq(box.div.style.display, "", "style.display correctly set to '' when display(true)");
//display(false)
var args = [false];
OpenLayers.Marker.Box.prototype.display.apply(box, args);
t.eq(box.div.style.display, "none", "style.display correctly set to 'none' when display(false)");
}
function test_99_Box_destroy(t) {
t.plan(3);
OpenLayers.Marker.prototype._destroy =
OpenLayers.Marker.prototype.destroy;
OpenLayers.Marker.prototype.destroy = function() {
g_Destroy = true;
}
var bounds = new OpenLayers.Bounds(1,2,3,4);
var borderColor = "blue";
var borderWidth = 55;
g_Destroy = null;
box = new OpenLayers.Marker.Box(bounds, borderColor, borderWidth);
box.destroy();
t.eq(box.bounds, null, "bounds nullified");
t.eq(box.div, null, "div nullified");
t.ok(g_Destroy == true, "OpenLayers.Marker.destroy() called");
OpenLayers.Marker.prototype.destroy =
OpenLayers.Marker.prototype._destroy;
}
// -->
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
</body>
</html>
</html>

View File

@@ -17,6 +17,7 @@
<li>Geometry/test_Rectangle.html</li>
<li>Geometry/test_Surface.html</li>
<li>test_Format.html</li>
<li>Format/test_GML.html</li>
<li>Format/test_WKT.html</li>
<li>test_Icon.html</li>
<li>test_Marker.html</li>