How to read formats other than OSM?

In the documentation, I saw the following text:
Other map data will need a custom import procedure, see e.g. Ordnance Survey, Shapefile like ESRI.

but the code is so old, the “datareader” interface no longer exists (version 7.0).
the graphhopper-core module just contains “OSMReader”, and this class have not implements any interface, does graphHopper now only support OSM data?

how can i do?

Only OSM is inbuilt, yes. But it should be easy to adapt it to import any data format. E.g. you can use the existing code of the Shapefile repository and adapt it a bit. E.g. have a look into addEdge of OSMReader which is the crucial part for the ShapefileReader too.

i don’t understand how to adopt to other data format.
the GraphHopper class has setOSMFile() method, and its internal methods also directly use OSMReader to read data. How can it support other formats? Is it by modifying the source code?

You’ll have to adapt the OSMShapeFileReader to the latest version, yes.

I read some of the code for reader-gtfs, which implemented the GraphHopperGtfs class, inheriting from the Graphhopper class, and overloaded the importOSM and importPublicTransit methods. I think this design is not very elegant, since GTFS data itself is also of the OSM data type, so it seems not to be a big issue. However, what about other data formats? For example, SHP data. Would it still involve overloading these methods? This feels a bit odd.

Yes, you could start with a new GraphHopperShp class and overloading the importOSM method. Doesn’t sound too bad to me :). Alternatively you could use the low level API and implement all things from scratch.

ok, thanks a lot.

You can also import commercial HERE files if you convert them using morituri :wink:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.