[gdal-dev] GDAL C++ Api, create new line segments from point layer

Jukka Rahkonen jukka.rahkonen at maanmittauslaitos.fi
Wed Mar 25 01:51:46 PDT 2015


ChiefDan <ChiefDan <at> gmail.com> writes:

> 
> Jukka Rahkonen wrote
> > Hi,
> > 
> > Could you make a drawing about what you have and what you want to get?
> > 
> > If your aim is to cut long linestrings only where they intersect with
> > points
> > from the point layer I believe that it is not easy with plain GDAL. There
> > are some useful functions in the SQLite/Spatialite SQL dialect
> > https://www.gaia-gis.it/gaia-sins/xmlBlob/spatialite-sql-latest.html, like
> > LinesCutAtNodes and Snap if you lines are only close to vertex a a
> > linestring. LinesCutAtNodes is making multilinestrings so you should
> > continue with something like the -explodecollections option in ogr2ogr.
> > 
> > -Jukka Rahkonen-
> 
> --I'm thinking to have a network of point-line-points for path finding. Pick
> any one of the green points above, I need to create line segments from that
> point to any point in any direction on the line that point is on to the next
> point. In the end, the layers would visualize in the same manner, however
> the original line(s) would now have end points at those green points. 
> 
> I'll look into Spatialite, I knew it had networking api as well.

Hi,

I did not mean that you should use Spatialite instead of GDAL but that you
can utilize all that is supported by spatialite with GDAL through the SQLite
SQL dialect http://www.gdal.org/ogr_sql_sqlite.html.

Thanks for the image which I saw by accident from the Nabble thread. It does
not appear in any way gmane which I usually use for reading the mails.

You seem to be interested in on which track trains are standing. How about
this plan:
Cut all the linestrings which present tracks to reasonably short segments.
Trains are long so perhaps segments could be about 200 meters or even
longer. You can do the densification with ogr2ogr -segmentize 200. Build the
routing graph based on this segmentized data.

When you start routing you could now
- Select the segment that is closest to your train
- Select the start point/end point of that segment to be used as
node_from/node_to for your routing algorithm.

Because segments can be 200 m long the selected start/end node can be nearly
200 meters away from the reference point but because trains and platforms
are so long that should not matter so much. After all, both the first and
last car in a train are following the same route.

-Jukka Rahkonen-




More information about the gdal-dev mailing list