Select to view content in your preferred language

Polygon point relation problem. Help!

2448
5
02-07-2011 08:46 AM
SamuelDantas
Emerging Contributor
Hi,

I'm just asking about this problem because I can't think of anything else.
Let me explain.

I have a map with 2 layers, polygons and points, just like attached picture 01.
What I need to do is to display a line and a text to identify each point inside a polygon, just like picture 02.

The problem is that I need to know in which direction and angle I should draw the line and the text. They must be drawn in the nearest outside region of the polygon.

That's why I can't make it work.

I tried to scan the region near to the point using the circle equation and rising the radius to find the nearest point in the outside region (x = a * r + cos t, y = b * r + sin t) and it works (picture 03), but takes too long (a LOT of steps in loop) to consult the server using RelationWithin.

Maybe there is a way to do all the consult stuff on the server side... Or a fastest way to do that...

I really need help here.

Thanks a lot.
0 Kudos
5 Replies
by Anonymous User
Not applicable
Original User: danwallie

If you're safe in assuming that your polygons are simple (in the trigonometric sense), you could do it all in the client using a simple PointInPolygon routine (see this post). You could simplify the search pattern by only testing points N,E,W,S of the original point (which would mean your leader lines would be horizontal or vertical only), and stop as soon as you find a point outside the polygon, and use that point as the first line vertex, and you can easily extrapolate the second vertex and annotation position. This would be much faster than doing a bunch of server roundtrips.
0 Kudos
SamuelDantas
Emerging Contributor
Thanks for answering Daniel.

The problem is that the polygons are not simple. I have attached 2 screenshots with samples of the real map. Notice that the angle in picture 04 is tangent to the line between the point and the outside region.
0 Kudos
by Anonymous User
Not applicable
Original User: danwallie

All those polygons in the pictures are geometrically simple. I still think its doable even if you sample along, say, 30 degree steps.
0 Kudos
SamuelDantas
Emerging Contributor
I see what you meant Daniel. I will try that and let you know if it worked.

Thanks again.
0 Kudos
by Anonymous User
Not applicable
Original User: sdantas

Thanks a lot Daniel. I changed the code to work on client with the method you gave and it's working like a charm.
0 Kudos