Select to view content in your preferred language

How to find side of point according to polyline in ArcGIS Runtime SDK for Qt QML API

4667
4
Jump to solution
11-19-2015 07:54 AM
tanerkoka1
Deactivated User

Hi,

I want to find where is the point. Is point in left side of polyline or the right side.How can I find point side according to polyline ?

Here is the picture below ,my red point is the right of polyline.But I want to find with code.

Thanks for helping.

polyline.png

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi Taner

Thomas is correct in that 'left' and 'right' are kind of arbitrary terms relative to the view of the user - better to think in terms similar to boats where 'port' and 'starboard' relate to the object. Which for lines, the direction it was drawn determines this.

The following might be one way to check, note I haven't tested.

Use the nearestCoordinate method of your line geometry with your point as input. Get the distance from the original point to this new calculated point. Draw two new lines offset either side of your line by that distance. Check to see which line intersects the original point and that will tell you which side the point is offset by.

Might not be the most elegant solution but should work if no one else has any other suggestions...

Cheers,

-Paul

View solution in original post

4 Replies
LucasDanzinger
Esri Frequent Contributor

Taner,

We do not have anything built into the runtime's geometry engine to determine this automatically. You could write your own little algorithm to determine this. I imagine it would involve finding the nearest vertex on the polyline and determining the direction from the point to that vertex, while taking into account the direction which the line is heading.

-Luke

ThomasDunn
Deactivated User

Taner,

The best way to start is to decide what is meant by left side and right side. Is the meaning as simple as whether the point is left of the center line? If so, just find the x value midway between the x-min and x-max of the polygon, and compare the point's x value to that. But note that this is not perfect. The corner point below marked Right of center might be considered by an observer to be on one of the left sides of the polygon.

11-19-2015 9-50-28 AM.jpg

Or, is it most sophisticated? The key is defining what the terms left side and right side mean.

ThomasDunn
Deactivated User

Taner,

I re-read your posting. Instead of the side of the polygon, you are asking about figuring out on which side of the polyline the point falls. As Lucas mentioned, this has everything to do with the point order of the polyline and the closest approach of that polyline to the point.

Hopefully, someone in the community has a favorite algorithm to offer.

by Anonymous User
Not applicable

Hi Taner

Thomas is correct in that 'left' and 'right' are kind of arbitrary terms relative to the view of the user - better to think in terms similar to boats where 'port' and 'starboard' relate to the object. Which for lines, the direction it was drawn determines this.

The following might be one way to check, note I haven't tested.

Use the nearestCoordinate method of your line geometry with your point as input. Get the distance from the original point to this new calculated point. Draw two new lines offset either side of your line by that distance. Check to see which line intersects the original point and that will tell you which side the point is offset by.

Might not be the most elegant solution but should work if no one else has any other suggestions...

Cheers,

-Paul