Fixed fatal typo that broke getComponentString when working with two-point geometries. Added tests to check that everything works as expected now. r=pagameba (pullup #1730)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8016 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2008-09-15 11:51:50 +00:00
parent 508ebc58c1
commit 658953b130
2 changed files with 19 additions and 6 deletions

View File

@@ -661,7 +661,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
// If so, add the coordinate of the intersection with the
// valid range bounds.
if (i > 0) {
if (this.getShortString(components[i + 1])) {
if (this.getShortString(components[i - 1])) {
strings.push(this.clipLine(components[i],
components[i-1]));
}

View File

@@ -437,7 +437,7 @@
return;
}
t.plan(1);
t.plan(3);
var r = new OpenLayers.Renderer.SVG(document.body);
r.setSize(new OpenLayers.Size(0, 0));
@@ -448,16 +448,29 @@
}
r.setExtent(new OpenLayers.Bounds(0, 0, 0, 0));
var node = document.createElement('div');
var geometry = new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(0, -5000),
new OpenLayers.Geometry.Point(10000, 0),
new OpenLayers.Geometry.Point(0, 5000)
]);
var node = document.createElement('div');
r.drawLineString(node, geometry);
t.eq(node.getAttribute("points"), "0,10000,15000,2500,15000,-2500,0,-10000", "Geometry correctly clipped at inValidRange bounds");
t.eq(node.getAttribute("points"), "0,10000,15000,2500,15000,-2500,0,-10000", "Line with 3 points correctly clipped at inValidRange bounds");
geometry = new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(0, -5000),
new OpenLayers.Geometry.Point(10000, 0)
]);
r.drawLineString(node, geometry);
t.eq(node.getAttribute("points"), "0,10000,15000,2500", "2-point line with 2nd point outside range correctly clipped at inValidRange bounds");
var geometry = new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(10000, 0),
new OpenLayers.Geometry.Point(0, 5000)
]);
r.drawLineString(node, geometry);
t.eq(node.getAttribute("points"), "15000,-2500,0,-10000", "2-point line with 1st point outside range correctly clipped at inValidRange bounds");
}
</script>