[Shapelib] Shapelib for mobile navigation purposes

Mateusz Loskot mateusz at loskot.net
Mon Feb 5 07:54:13 PST 2007


Constanze Tschritter wrote:
> I'll probably use the A Star algorithm, because of it's working
> speed.

Sounds good. I've played with Dijkstra mostly.

> My Shapefile is a PolyLine road shapefile and I've got POIs in
> a xml file.

You need to generate graph from a shapefile.
Ideally, you can have a shapefile with lines and a shapefile with
points - locations of intersections.
Plus, attributes of lines shapefile consist of weights for every segment.
Second part of data is a set of POI which will be searched for
a path between them.


> I know how to read the coordinates out of the xml files, but I can't
> figure out how to access the data in the shapefile for the route
> planning algorithm.

You can use Shapelib or OGR (http://www.gdal.org/ogr/) to read data from
a shapefile into your structures.
But first you need to design structures and decide what data (or
processing) you need except the lines and POIs.
For example, you will need a to have weight for every segment, you will
need to know the lenght of every segment (hardcoded or dynamically
calculated).

If you have all necessary data collected, for particular algorithm,
you will be able to decided about how to read & process data do compose
a graph in memory in runtime.
IMHO it's one of simplest solution to read data, process data and
build graphs in memory and search through such graph.

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Shapelib mailing list