[OpenLayers-Users] Re: no intersection when features snap
Peter
pfischer at proveo.com
Wed May 23 06:30:37 PDT 2012
hey guys,
first thanks for your help. i found a solution with the jsts framework. i
will post my code if someone has got the same problem.
Here it is:
function validateDrawing()
{
//initialize openLayers parser
var openLayersParser = new jsts.io.OpenLayersParser();
//array needed to check if the feature is already overlaping one so it is
not called twice
var alreadyOverlapping = [];
//each layes
for(var i = 1; i < priorityLayerArray.length;i++)
{
var intersectableFeatures = priorityLayerArray[i].features;
//each features
for (var j = 0; j < intersectableFeatures.length; j++)
{
//current feature to comapre
var currentfeature = intersectableFeatures[j];
//parse it so the jsts framework is able to use it
var currentGeometry =
openLayersParser.read(intersectableFeatures[j].geometry);
//Compare with others
for (var x = 0; x < intersectableFeatures.length; x++)
{
//compared fieature
var comparefeature = intersectableFeatures[x];
//parse it so the jsts framework is able to use it
var compareGeometry =
openLayersParser.read(intersectableFeatures[x].geometry);
//check if not same feature
if(currentfeature.attributes.name === comparefeature.attributes.name)
{
continue;
}
else
{
//the jsts method
var isOverlaping = currentGeometry.overlaps(compareGeometry);
if(isOverlaping &&
alreadyOverlapping[currentfeature.attributes.name] == undefined)
{
alreadyOverlapping[comparefeature.attributes.name] = "";
alert(currentfeature.attributes.name + " intersects with: " +
comparefeature.attributes.name);
}
}
}
}
the priorityLayerArray[] is an array where i save different layers, so the
priorityLayerArray[i] is the layer i want to check if it has some features
wich intersects.
Greetings peter
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/no-intersection-when-features-snap-tp4967965p4976393.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list