简体   繁体   中英

Perpendicular Projection of point onto line using GeoDjango

I have a point C and a Linestring AB , both with SRID 4326 . I'd like to find the perpendicular projection of C onto B , which would be point D .

在此处输入图片说明

I currently have a 2D implementation of this perpendicular projection using unit vectors. But it does not return the correct point on a world map (as it is 2D). Found here: Perpendicular on a line segment from a given point

I have thought of two ways to do this with PostGIS:

1) Create a line from C to point E , where CE is parallel to AB . Then rotate CE 90 degrees around C and find the intersection, which should be D .

2) Find a bearing and distance method similar to the Google Maps geometry library here (the computeOffset method: https://developers.google.com/maps/documentation/javascript/geometry

How would I do this with the GeoDjango methods. It does not seem to expose the ST_AZIMUTH or ST_ROTATE ?

It also seems like using raw SQL in GeoDjango would be an antipattern. But in this case, it seems like I need more granular control than what the GeoDjango API allows.

Any help would be appreciated.

对于PostGIS返回的点和LineString最接近点, ST_ClosestPoint http://postgis.net/docs/ST_ClosestPoint.html将是点到LineString上的正交投影

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM