ThinkGeo.com    |     Documentation    |     Premium Support

Percentage of PointShape Along a Line

MapSuite Team,

Is there a MapSuite api that will return what percentage a PointShape is along a specified line?

This would be the counterpart to GetPointOnALine and would have a format of:

PercentageOfLine = TheFeatureShape.GetPercentageOfALine(StartingPoint.FirstPoint, ThePointShape);

I’m asking about this because I’m attempting to determine how to do a reverse address lookup based on Lat/Long. I actually already do this, but only return a range of addresses, but would like to return a single address.

The api mentioned above will allow me to determine a single address, but how is it determined what side of the street a point is?

Thanks,
Dennis

Hi Dennis,

This API don’t know which side the point is, the percent direction is just from the start point of the line to the end point.

It looks you are working for something looks like Geocoding, but the Geocoding is not implement by Mathematical method, so if your question looks like how to know which side of line a point lies.

I found a topic about it: https://math.stackexchange.com/questions/274712/calculate-on-which-side-of-a-straight-line-is-a-given-point-located

I think you can write a simple function to locate it.

Wish that’s helpful.

Regards,

Ethan

Ethan,

The api I mentioned, GetPercentageOfALine, is not an api, it doesn’t exist. I’m looking for two things:

  1. An api that will calculate the percentage a PointShape is along a specified line. Do you have such code to do this?

  2. Based on a PointShape determine whether point is above, below, left, right, or on a given line. Do you have such code to do this?

My goal is to Reverse GeoCode based on an originating PointShape corresponding to Lat/Long, the nearest PointShape that Lat/Long is along a line from which to calculate percentage that point is along the line, and finally on what side of the line is the originating PointShape in order to determine odd/even side of the street.

Your thoughts?

Thanks,
Dennis

Hi Dennis,

Sorry I hadn’t notice it’s not the GetPointOnALine API.

For your requirement:

  1. I think you can calculate that like this:
    a. GetLength of entire line
    b. build a new line with your point and the start point or end point of base line
    c. GeLength of the new line
    d. Calculate the percentage

  2. Location relationship between a point and a line should only have three cases: Point in line, point in left of line direction, point in right of line direction. We don’t have existing API for it, I think you can view the topic I mentioned last reply, and write a custom function to make sure that.

Wish that’s helpful.

Regards,

Ethan

Ethan,

Thanks for the information. I can see how this works for a straight line, but how does it work for a curved line with multiple vertices?

I would think the lengths of the individual vertices would have to be added until reaching the vertex the point is within and then calculating the position of the point in that vertex and then add that length to the total.

Thanks,
Dennis

Hi Dennis,

The curved line is connected by lost of straight line, so you can find the nearest vertex to get length in the nearest part and then loop other parts of the curved line.

In fact I think the API GetLineOnALine should be helpful.

Regards,

Ethan