PostGIS - route determination solution

We are creating an application in which I am a driver, and I travel from point A to point B. On the way, I can find passengers who travel along the same route.

We use PostgreSQL with the PostGIS extension.

After a multiplayer game, I found out that we can use linestring to achieve this. I'm not quite sure if this approach will work.

Suppose I have the coordinates of my source and destination.

    var RouteCoordinates = [
      {lat: 37.772, lng: -122.214},
      {lat: 21.291, lng: -157.821},
      {lat: -18.142, lng: 178.431},
      {lat: -27.467, lng: 153.027}
    ];

I need to save this as linestring in my db.

After you go on a trip, if the passenger also goes on this route, but, as we know, its source and destination will not exactly correspond to my line, but they will be nearby. For example, a radius of 1 km

enter image description here

, - . , , ( ) ( )

, ,

SELECT id, name, address, geom  
FROM Seattle_Starbucks  
WHERE ST_DWithin(geom, ST_MakePoint(-122.325959,47.625138)::geography, 1000);

, postGIS,

  • DB

ANS: linestring, ST_MakeLine, , ?

  1. , , .

, . .

+6

All Articles