[OpenLayers-Users] Possible error with the split control.

Atle Frenvik Sveen atle.sveen at bouvet.no
Wed Apr 11 06:00:21 EDT 2012


Hello list, I think i might have found a bug in the split control (or, more likely, the split-function of LineString, which the split control uses)

Look at the following example:

var line1 = new OpenLayers.Geometry.LineString([new OpenLayers.Geometry.Point(1,1),new OpenLayers.Geometry.Point(6,1)]);
var line2 = new OpenLayers.Geometry.LineString([new OpenLayers.Geometry.Point(2,1),new OpenLayers.Geometry.Point(3,1),new OpenLayers.Geometry.Point(6,3)]);
var split = line1.split(line2,{mutual:true});

this returns two lists, line1 is split into:
LINESTRING(1 1, 3 1)
LINESTRING(3 1, 6 1)

And line2 is split into
LINESTRING(2 1, 3 1);
LINESTRING(3 1, 6 3);

I would expect that line1 would be split into three lines:
LINESTRING(1 1, 2 1)
LINESTRING(2 1, 3 1)
LINESTRING(3 1, 6 1)

If we reverse line2, and try to split, like this:


var line1 = new OpenLayers.Geometry.LineString([new OpenLayers.Geometry.Point(1,1),new OpenLayers.Geometry.Point(6,1)]);
var line3 = new OpenLayers.Geometry.LineString([new OpenLayers.Geometry.Point(6,3),new OpenLayers.Geometry.Point(3,1),new OpenLayers.Geometry.Point(2,1)]);

var split = line1.split(line3,{mutual:true});

We see that line1 is split into
LINESTRING(1 1, 3 1)
LINESTRING(3 1, 6 1)

But line3 is not split at all.

So, to me it seems that if segments are  fully overlapping they do not split. Is this a feature or a bug?

And in any case, any pointers on how to solve this?

Regards
Atle






--
Atle Frenvik Sveen | Konsulent, Trondheim
Bouvet ASA Kjøpmannsgt. 35, 7416 Trondheim
Mob: + 47 45 27 86 89
http://www.bouvet.no/ | atle.sveen at bouvet.no<mailto:atle.sveen at bouvet.no>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120411/82866b55/attachment-0001.html


More information about the Users mailing list