Skip to content

Include elevation data for hiking/biking/horse/wheelchair #43

Closed

Activity

  1. NopMap commented on May 24, 2013

    @NopMap
    Contributor

    I would suggest using CGIAR as a source.

    I have used both SRTM and CGIAR for building contour lines. SRTM has bad holes and mistakes in it that make it unusable in some areas. This is fixed in CGIAR which is otherwise identical. It still has systematical errors in absolute height, but for routing only relative height matters.

    I would not use ele-Tags but only data from the same DEM. Ele tags are punctual, the graph requires a continuous, matching flow of relative values to work. Also, the ele tag is messed up: Originally it was given above sea level, later someone added to the wiki it was supposed to be in WGS84 Geoid. So now you never know what the reference is and it will always differ from DEM values.

  2. karussell commented on May 24, 2013

    @karussell
    MemberAuthor

    Thanks for the insights, this OSM background information is very important for graphhopper as I'm still a newbie even after one intense year ;) !

    DEM

    what's that?

  3. NopMap commented on May 24, 2013

    @NopMap
    Contributor

    DEM stands for Digital Elevation Model.

    I have been doing more than enough parsing OSM for my map during the last 4 years. :-)

  4. karussell commented on May 24, 2013

    @karussell
    MemberAuthor

    I have been doing more than enough parsing OSM for my map during the last 4 years. :-)

    very good :) !

  5. NopMap commented on Jun 5, 2013

    @NopMap
    Contributor

    As discussed, reading the elevations is the most simple part, I already have code for that.

    In preparation:
    (1) how would we connect the DEM processor to graphhopper import. It definitely needs to be optional and it will bring another jar library for reading the TIF-Files with the elevation data

    (2) the data needs to be downloaded. This is only required once. The CIAT server is rather slow and unreliable, so how would we do that?

    a) try to download it directly in Java, would need some error handling for stuck downloads
    b) provide a list of filenames, urls or a script with wget calls and ask the user to do it himself
    c) provide a mirror that makes download success more likely

  6. NopMap commented on Jun 5, 2013

    @NopMap
    Contributor

    I ran a check during import for long ways without sufficient pillar nodes for a good elevation analysis. As the grid of the DEM is 90m, I counted all ways with straight segments longer than 150m. In the Bavaria data there are ~330000 such ways. They will need additional points for proper elevation analysis. It might be sufficient to add those points temporarily and only store the results of the analysis with the edge data. There are still more than 90000 straight ways with more than 250m.

  7. karussell commented on Jun 6, 2013

    @karussell
    MemberAuthor

    (1) how would we connect the DEM processor to graphhopper import.

    Either post processing or as an if clause (or extends?) in the the OSMReader. We should do the simplest first and add unit tests to make later migration error free and easy.

    It definitely needs to be optional and it will bring another jar library for reading the TIF-Files with the elevation data

    We just include the jars, if they're not that big. Later on we separate the import from the core, but this will bring some difficulties as IDEs are not that good with multi-module maven projects.

    b) provide a list of filenames, urls or a script with wget calls and ask the user to do it himself

    For now I would do it this way with a simple script.

    I ran a check during import for long ways without sufficient pillar nodes for a good elevation analysis.

    Again I would see that as optimization which we should attack at a later time, although we can think about it while implementing. Or even provide an implementation if we have a simple idea - but nothing complex at the beginning I would say :)

  8. NopMap commented on Jun 6, 2013

    @NopMap
    Contributor

    b) provide a list of filenames, urls or a script with wget calls and ask the user to do it himself
    For now I would do it this way with a simple script.

    If we want to go for a simple solution that should be

    • read the bounding box from the osm data. Every planet file has a bounds object as the first entry. It can be missing if the data comes from a different source. This would limit elevation processing to normal planet files.
    • check what files are present on the server but missing on the disk. For empty sea areas there are no files, so not every possible DEM tile does actually exist.
    • output a wget script

    I ran a check during import for long ways without sufficient pillar nodes for a good elevation analysis.
    Again I would see that as optimization which we should attack at a later time, although we can think about it while implementing. Or even provide an implementation if we have a simple idea - but nothing complex at the beginning I would say :)

    Actually, I think we need to think about how we want to use the elevation data first. Just putting an elevation on the tower nodes will not help to establish reasonable routing as the way may go up and down along the edge and the most important information is not the elevation delta between starting point and end point. It might not even be the total, real meters climbed and descended along the way geometry if you have them but the steepest ascend or descend along the way.

    Currently I am thinking whether it is required to put elevations in the graph at all. It might be more helpful to analyze the geometry during reading and just encode the relevant information into the edge flags, e.g. an incline and decline classification of some sort. But first we need to figure out what this relevant information is.

  9. karussell commented on Jun 6, 2013

    @karussell
    MemberAuthor

    If we want to go for a simple solution that should be

    Oh, ok. If that is that complicated I would rather go for a Java solution which can be tested and more easily evolve. (BTW: after reading OSM date we have the needed bounding box in the graph)

    just encode the relevant information into the edge flags

    Good catch!

    But first we need to figure out what this relevant information is.

    The only important information for e.g. bike routing would be to count the part(s) which goes up and which goes down and how much. So three numbers for one edge: a factor (the percentage of the distance for which it increases), the percentage of the incline and of the decline. This could even fit into 2 bytes (and needs to be swapped for the opposite direction) and the 'percentage' (instead of a total meter value) would allow us to even further reduce precision.

  10. karussell commented on Jun 6, 2013

    @karussell
    MemberAuthor

    But first we need to figure out what this relevant information is.

    Hmmh, why don't we just introduce one speed value per direction calculated while import of the elevation data? (And an increase of the distance will be neccessary.) But then we only need one further value not three.

  11. NopMap commented on Jun 6, 2013

    @NopMap
    Contributor

    Two directional speeds would be a possible way.

    Another way might be an abstract incline classification, e.g. an enumeration for flat, moderate incline, moderate with some steep places and very steep.

    Depends on how you want to evaluate the data. For a racing bike the speed might be enough, for pedestrians you might want to avoid short, very steep parts even if the overall incline is not so bad.

  12. karussell commented on Jun 6, 2013

    @karussell
    MemberAuthor

    for pedestrians you might want to avoid short, very steep parts even if the overall incline is not so bad.

    hmmh, that is an argument. Not sure yet

  13. NopMap commented on Jun 6, 2013

    @NopMap
    Contributor

    I guess it boils down to: Enable the encoders to access the geometry in 3D and then build some different encoders and experiment.

  14. ghost assigned on Jun 10, 2013
  15. NopMap commented on Jun 10, 2013

    @NopMap
    Contributor

    I have started moving my DEM provider from my map compiler into graphhopper.

    However, there is a problem. To read the TIFF tiles I need a library, which is listed at maven central, but the download fails:
    http://search.maven.org/#artifactdetails|com.sun.media|jai_codec|1.1.2_01|jar

    I'm not sure, but it looks like the distributionUrl is no longer valid due to restructuring by Oracle. Can you have a look at it? How can we get the jar into the project?

  16. 8 remaining items

  17. NopMap commented on Jun 12, 2013

    @NopMap
    Contributor

    Ok, I have my sample elevation dependent routing working. I have pushed it to the branch provide_elevation_data so you can play around with it. It has not received a lot of fine tuning, but it is a proof of concept.

    To activate DEM handling you need in your config file:
    osmreader.demLocation= path for the dem data

    I tried it with these vehicles to check for differences:
    osmreader.acceptWay=BIKE,BIKE3D:com.graphhopper.routing.util.BikeDemFlagEncoder

    The new encoder is not hardcoded into GH. You might notice a few hiccups though when GH assumes that every graph must have a CAR encoding.

    I have played around with it and it seems to work - the 3D encoder avoids going over unnecessary hills. (use the RWK as map background or put the route in google earth to check it)

    Here's some routes where you can see the difference:
    http://localhost:8989/?point=49.498124,11.390076&point=49.427612,11.544056&vehicle=BIKE
    http://localhost:8989/?point=49.57065,11.190948&point=49.981695,11.322098&vehicle=BIKE
    http://localhost:8989/?point=49.940836,12.015953&point=50.045014,11.665077&vehicle=BIKE
    http://localhost:8989/?point=47.477304,10.941353&point=47.597829,11.063232&vehicle=BIKE

  18. karussell commented on Jun 13, 2013

    @karussell
    MemberAuthor

    That is really nice! I'll try later this week!

    Some early notes:

    • missing unit tests: BikeDemFlagEncoder -> ensures that both are switched; OSMReader -> that import works; Graph&Routing -> that routing works different with elevation; ElevationAnalyzer -> that the data is correctly analyzed
    • scaling -> indeed a problem if that needs so much memory; -> can we process elevation data in a post processing step? then we would be able to do a 'sorted' traversal where we only need one tile at a moment
    • warning: graphStorage.bounds() -> this is only available AFTER successfully importing OSM data!
    • I found this one here: http://www.yale.edu/ceo/Documentation/dem.html
    • why do we need a tiff file? shouldn't we abstract this to just a simple float array? What is rasterSample in TiffTile?
    • You are using getters&setters. I'm still hesitating with this :) -> shouldn't we switch the entire code base to getters&setters but make chaining still possible?
  19. NopMap commented on Jun 13, 2013

    @NopMap
    Contributor

    missing unit tests:

    Sure, it is still work in progress.

    scaling -> indeed a problem if that needs so much memory; -> can we process elevation data in a post processing step?

    Rather a middle processing step, between processing the nodes and the ways. Elevation is needed as input for the ways/edges.

    warning: graphStorage.bounds() -> this is only available AFTER successfully importing OSM data!

    Yes, i am aware of that.

    I found this one here: http://www.yale.edu/ceo/Documentation/dem.html

    Nothing new. The only interesting one is ASTER, but that has some problems and a rally weird license that in my opinion does not allow reuse on the internet. http://wiki.openstreetmap.org/wiki/ASTER

    Oh, another problem with scaling: SRTM data is not availabe for the whole globe, just between 60° north and 60° south.

    why do we need a tiff file? shouldn't we abstract this to just a simple float array?

    The DEM data is served in GeoTIFF format. Those TIFs can be opened, looked at and processed with standard geo software.

    Maybe converting them into a different format will make loading faster. I'll try that. But then it should be a short array.

    What is rasterSample in TiffTile?

    A predefined array to receive the elevation result to avoid creating new instances.

    You are using getters&setters. I'm still hesitating with this :) -> shouldn't we switch the entire code base to getters&setters but make chaining still possible?

    I just didn't feel like converting the code I am donating to your style. But you may change that if you like.New code won't have getters/setters unless they are real getters for a reason.

    After playing around a little bit I have decided that it is not such a good idea to get the elevation data only locally in the encoder. I'll try to make the whole graph (optionally) elevation aware so it's an overall concept.

  20. NopMap commented on Jun 13, 2013

    @NopMap
    Contributor

    why do we need a tiff file?

    As it turned out a very good point. After conversion to a simple short[], loading is 40 times faster.

  21. karussell commented on Jun 13, 2013

    @karussell
    MemberAuthor

    missing unit tests:

    Sure, it is still work in progress.

    ah, ok. I create unit tests to implement stuff. Writing them afterwards they are much less fun :) (and so I would write fewer than necessary I think)

    Rather a middle processing step, between processing the nodes and the ways.
    Elevation is needed as input for the ways/edges.

    But assume that we do the OSM import as normal and then we just traverse the edges (within a bounding box). This way we could rewrite the edge properties (distance+flag) without consuming much memory.

    As it turned out a very good point. After conversion to a simple short[], loading is 40 times faster.

    Nice! short is also a good idea!

    A predefined array to receive the elevation result to avoid creating new instances.

    If it changes - can you remove the 'static'? I don't like static due to the singleton behavior etc (although sometimes they are necessary)

    Oh, another problem with scaling: SRTM data is not availabe for the whole globe

    Good to know! Is this data outside of 60° not available for our provider or not available at all? (why that?)

    I just didn't feel like converting the code I am donating to your style.

    No, no. Really no problem. I for myself am struggling with this and sometimes wish I wouldn't have done it this way. Could this be an adoption problem in the Java world? If yes, I'll change it to the standard set+get pattern (still with chaining possibilities for the setters).

    E.g. years ago in some code generation tools (or json stuff) setters+getters were necessary. But not sure if this is still the case today.

    After playing around a little bit I have decided that it is not such a good idea to get the
    elevation data only locally in the encoder.

    what problems did you encounter? Because having them available all the time means also more RAM :)

  22. NopMap commented on Jun 14, 2013

    @NopMap
    Contributor
    A predefined array to receive the elevation result to avoid creating new instances.
    

    If it changes - can you remove the 'static'? I don't like static due to the singleton behavior etc (although sometimes they are necessary)

    That thing is gone completely.

    Good to know! Is this data outside of 60° not available for our provider or not available at all? (why that?)

    The space shuttle could only measure that area from its orbit. All SRTM based data is within this range.

    After playing around a little bit I have decided that it is not such a good idea to get the
    elevation data only locally in the encoder.
    what problems did you encounter? Because having them available all the time means also more RAM :)

    Several reasons:

    • you wanted to do terrain profiling and it's needed for that
    • the current local way is wasteful if you look at the larger picture. The elevation for each tower node is fetched at least twice, if you have 3 3D-enabled encoders it's done at least 6 times. In the long run, fetching it once and integrating it with the nodes is more effcient.
    • better control. As I said, local access to elevations is rather random and does not scale well. If you do it in one place you have a chance to do it reasonably.
  23. karussell commented on Jun 14, 2013

    @karussell
    MemberAuthor

    The space shuttle could only measure that area from its orbit. All SRTM based data is within this range.

    Aha, ok!

    you wanted to do terrain profiling and it's needed for that

    yes, users could need that. But if we include it: I would rather externalize this elevation data like the locationIndex (and not in graphstorage) but still calculate the distance and speed changes while import. This way we could e.g. avoid wasting expensive RAM for it and read it only for a resulting path from disc.

    integrating it with the nodes is more effcient.

    I don't think this will make a big difference in terms of speed. Because you said you already have this data in memory via a short array?

    If you do it in one place you have a chance to do it reasonably.

    Even if it is slower: if you do it while the import you need to calculate it only once. IF you do it like in your new proposal then we'll have to calculate distance and speed changes for every request!

    And for CH we'll have to calculate it anyway in the import.

  24. NopMap commented on Jun 29, 2013

    @NopMap
    Contributor

    I pushed a new intermediate version of the elevation evaluation to the branch elevation_data. The old branch provide_elevation_data has become unusable due to the interface refactoring on main.

    The elevation data is now copied from the DEM into the osmID index BTree which was cloned and extended for that purpose. Reasons:

    • it is possible to do this in a controlled way by regions to make it scale to areas of any size
    • every node is processed only once
    • the huge tiles of DEM data can be removed for the actual processing of the ways, saving a lot of memory
    • efficient: no redundant accesses, no data needs to be moved around when a node changes from pillar to tower

    Only if interpolation between OSM nodes is used, the elevation handling does still not scale, but that is strictly optional.

    The elevation data is currently used in these places

    • Flag encoders can evaluate it, example is a special elevation aware bike flag encoder
    • distance calculation: distance is modfied with elevation so the standard routing should also change slightly.
    • elevation is present in the point lists when creating edges. It can be stored like the geometry to be later used for height profiles, but I have not implemented that.

    It is not finished yet, but everything seems to work.

  25. karussell commented on Jan 21, 2014

    @karussell
    MemberAuthor
  26. karussell commented on Mar 27, 2014

    @karussell
    MemberAuthor

    Will be handled here #169

  27. added a commit that references this issue on Apr 11, 2018
  28. added a commit that references this issue on Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions