This is a migrated thread and some comments may be shown as answers.

LocationRectangle.IntersectWithLine does not work as expected

1 Answer 57 Views
Map
This is a migrated thread and some comments may be shown as answers.
dilsah
Top achievements
Rank 1
dilsah asked on 17 Oct 2012, 01:04 PM
I have a collection of mapshapes which mostly consists of mappolygons. I want to draw lines on the map only if the line does not intersect with another shape. For this purpose i am using the "IntersectWithLine" but when the line comes near the shape, even if they do not intersect the result is always true. Below is the code:

        Location point = somevalue;
        Location point1 = somevalue1;


            foreach (var item in myLayer.Items)
            {
                LocationRect rect = (item as MapShape).GeographicalBounds;
                if (rect.IntersectWithLine(point, point1))
                {
    //change the color of the shape that intersects with the line
                    (item as MapShape).Fill = new SolidColorBrush(Colors.Black);
                }
            }

What am i doing wrong?? Can you provide me a sample project? 
Thanks

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 22 Oct 2012, 07:05 AM
Hello Dilsah,

Unfortunately you can't use this approach to detect intersection of line and arbitrary map shape. The IntersectWithLine is the method of the location rectangle. When you call it you check whether the given line intersects with bounding rectangle (not with the original shape). The original shape can occupy just a small part of the bounding rectangle.

Calculation of the intersection of the line with arbitrary shape (even with arbitrary polygon) is a quite complex geometrical task for which we have not ready for use solution. However I suggest that you search for this in stackoverflow for example, where I believe you'll find the answer.

Regards,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Map
Asked by
dilsah
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or