Hi, My mistake was putting the tag elements in way elements in the first order, before nd elements. I think gh cares about it. Now it's working.
Thanks to your help, I finally implemented my very simple shp to osm converter with geo-tools library. What I do is; - Read the shp file - Keep a hashmap to generate one nodeId for the same points. - Iterate through edges, find each edge's touching edges. Add intersection points to way's nodes. (So we dont lose points if we simplfy geometry) - Simplify geometry with DouglasPeuckerSimplifier (optional) - Iterate each edge's coordinates and add them to way's nodes. - Sort each edge's points accorging to LengthIndexedLine value. (Because we added touching nodes, we need to sort for a proper way) - Write xml. It was fun. Now I should improve it and learn gh better. If anyone's interested I can make more the code generic and add it to github. Thank you so much, Bulut On Sat, May 2, 2015 at 6:53 PM, Peter <[email protected]> wrote: > Hi Bulut, > > as you can see from some of the test OSM files, the tagging is only required > for the ways and only if you require this in the encoder: > > https://github.com/graphhopper/graphhopper/tree/master/core/src/test/resources/com/graphhopper/reader > > https://github.com/graphhopper/graphhopper/blob/master/core/src/test/java/com/graphhopper/reader/OSMReaderTest.java > >> But now, routing is not working even on a single way element. > > What does 'not working' mean? Is your code working with a standard OSM file > or with one of these test files? > > Kind Regards, > Peter > > > On 02.05.2015 16:09, Sander van Tulden wrote: > > Hi Bulut, > > I don't think the relation elements are needed for routing via a shapefile > network. They aren't present in mine, but you can add some if you want > customization in your flagencoder. > > I think tagging the nodes is also needed indeed, maybe for the index lookup > when you set start and end points? > > Greetz, > > Sander van Tulden > > _____________________________ > From: Bulut Aras <[email protected]> > Sent: zaterdag, mei 2, 2015 10:39 > Subject: Re: [GraphHopper] Any ideas to convert shape file to routable osm > data? > To: GraphHopper Java routing engine <[email protected]> > > > Hi Sander, > After adding tag element with "highway" key, I successfully generated > graph, with no exception. But now, routing is not working even on a > single way element. I will try to add "tag" to node element also. > > Beside these, is "relation" element needed for graphhopper to work properly? > > Thanks, > Bulut Aras > > On Fri, May 1, 2015 at 9:18 AM, Sander van Tulden > <[email protected]> wrote: >> Hi, >> >> The negative ids are normal for JOSM generation, and wouldn't affect the >> OSM parsing by Graphhopper. Did you mark your nodes and ways with a custom >> tag to be parsed by Graphhopper? I had that error too, before I added my >> custom tag to a Graphhopper flagencoder and to my nodes/ways in JOSM. >> >> Does your .osm xml consist of the following structure? >> >> <osm version='0.6'> >> <node id='-1241' lat='51.521' lon='5.64214'> >> <tag k='highway' v='customtag' /> >> </node> >> <way id='-5152'> >> <nd ref='-1241' /> >> <nd ref='-5225' /> >> <tag k='highway' v='customtag' /> >> </way> >> </osm> >> >> Greets, >> >> >> Sander van Tulden >> >> >> >> >> >> Op 25-04-15 23:01 schreef Bulut Aras <[email protected]>: >> >>>Hi Sander, >>>I tried to do what you described, but when I call importOrLoad >>>function it fails: >>>"java.lang.IllegalStateException: osm must not be empty. read 1684108 >>>lines and 0 locations". >>> >>>Interesting thing is when I inspect the osm file generated by JOSM, I >>>see negative nodeId values like; >>> <nd ref='-305' /> >>> <nd ref='-306' /> >>> <nd ref='-307' /> >>> <nd ref='-308' /> >>> <nd ref='-309' /> >>> >>>Actually, I'm not sure if this is the problem. >>> >>>Thanks. >>> >>>On Tue, Apr 21, 2015 at 9:57 AM, Peter <[email protected]> wrote: >>>> Hi there, >>>> >>>> we are interested in this as well for a custom shapefile import. If >>>> someone is willing to put this under an open source we would love to >>>> support this and integrate it etc :) ! >>>> >>>> Kind Regards, >>>> Peter >>>> >>>> On 21.04.2015 08:26, Sander van Tulden wrote: >>>>> Hi, >>>>> >>>>> We have a similar use case, where we use our shapefile network within >>>>> Graphhopper. The way we solve this is by first converting the shapefile >>>>> network with JOSM and plugin "OpenData" to .osm (xml). We then use >>>>> Graphhopper with minimum settings (using chWeighting = no and >>>>> prepare.minNetworkSize=1) to parse the shapefile by using a custom >>>>> Graphhopper encoder class that uses the tags that the shapefile >>>>>segments >>>>> contain. In our case we had no initial tags, so in JOSM we just >>>>>selected >>>>> the whole network and gave it a custom tag to be used in the >>>>>Graphhopper >>>>> encoder class. If you don't yet know how to make a custom encoder, you >>>>> could use the Bike/Foot one and just add your custom tag for testing >>>>> purposes. >>>>> >>>>> In our case this works pretty well. We don't have very frequent >>>>>changes to >>>>> the network, so we just prepare the set again when we need to change >>>>>it. >>>>> >>>>> Good luck, >>>>> >>>>> >>>>> Sander van Tulden >>>>> >>>>> >>>>> >>>>> >>>>> Op 20-04-15 19:28 schreef Bulut Aras <[email protected]>: >>>>> >>>>>> Hi, >>>>>> We have our own road data. We use Esri products and want to abandon >>>>>> network analyst tool. How can we export our data (from un-routable >>>>>> shapefile for example) to use with graphhopper, manually or >>>>>> programmatically? Out data changes frequently. >>>>>> >>>>>> May networkx library work for us? >>>>>> >>>>>> >>>>>> Thanks in advance. >>>>>> > > > > _______________________________________________ > GraphHopper mailing list > [email protected] > https://lists.openstreetmap.org/listinfo/graphhopper > _______________________________________________ GraphHopper mailing list [email protected] https://lists.openstreetmap.org/listinfo/graphhopper
