[OpenLayers-Users] Get point on line?
xiaying4415139 at 163.com
Sat May 2 00:00:53 EDT 2009
Hi, Bill Thoen, I go to the website and find the formulary I want. As
Point(s) known distance from a great circle
Let points A and B define a great circle route and D be a third point. Find
the points on the great circle through A and B that lie a distance d from D,
if they exist.
A = crs_AD - crs_AB
( crs_AB and crs_AD are the initial GC bearings from A to B and D,
respectively. Compute using Course between points)
b = dist_AD
(dist_AD is the distance from A to D. Compute using Distance between points)
(acos(r) is the XTD)
(p is the ATD)
IF (cos(d)^2 > r^2) THEN
No points exist
Two points exist
dp = p +- acos(cos(d)/r)
dp are the distances of the desired points from A along AB. Their lat/lons
can be computed using Lat/lon given radial and distance
But I want to know, Is there any such fomulary in OpenLayers to help me
simplify the algorithm? For example, I know "OpenLayers.Util.distVencenty",
this method can calculate the distance between two points. Does openlayers
also have such functions can help me? Thank you.
My math is not so good. Write the algorithm in js all by myself is so
difficult for me.
Bill Thoen wrote:
> Yes, it's a little different for the spherical (Lon/Lat) case. For those
> formulas, check out Ed Williams' Aviation Formulary website at
> http://williams.best.vwh.net/avform.htm. What you're looking for is
> determining waypoint locations, i think.
> - Bill Thoen
> shane_china wrote:
>> Bill Thoen wrote:
>>> shane_china wrote:
>>>> In openlayers,
>>>> I have a straight line with two endpoints. How could I get a point on
>>>> line with given distance to one endpoint? Thank you.
>>> You can find a point anywhere on a line by using a ratio calculation.
>>> Start with the distance to your point divided by the total distance of
>>> your line, then your new X coordinate = the difference between the X
>>> coordinates of the endpoints times the ratio (plus the X coordinate of
>>> the starting line endpoint. For example, if your endpoints are at
>>> coordinates (X0, Y0) and (X1,Y1) then the Cartesian distance is
>>> D = sqrt((X1-X0)*(X1-X0) + (Y1-Y0)*(Y1-Y0))
>>> Then if the ratio between this and the distance to your point is d, your
>>> new point's coordinates will be:
>>> X= X0+(X1-X0)*d/D
>> So thank you for your answer. Your advise is in X-Y coodinates. Does this
>> method also apply to lon lat coodinates? Our earth is a ball, so is it
>> I haven't demonstrate it yet.
> Users mailing list
> Users at openlayers.org
View this message in context: http://n2.nabble.com/Get-point-on-line--tp2739966p2759313.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users