Re: [OSRM-talk] Getting OSMNodeIDs in OSRM

2016-02-01 Thread Kerrick Staley
It doesn't look like PhantomNode's forward_node_id and reverse_node_id are
indexes into InternalDataFacade's m_coordinate_list (and hence the
m_osmnodeid_list I created). When I look up forward_node_id/reverse_node_id
I get OSM nodes that are far away from the query point.
(PhantomNode.name_id and PhantomNode.location *are* set correctly however).

So I should probably follow Patrick's suggestion and have a separate loop
that reads the .nodes file? Does the .nodes file contain
ExternalMemoryNodes or QueryNodes? (graph_loader.hpp reads one and
internal_datafacade.hpp reads the other, although it won't matter if the
two structs have the same size due to padding).

On Mon, Feb 1, 2016 at 9:25 AM, Daniel Patterson  wrote:

> Hi Kerrick,
>
>   Yup, the node ids are renumbered to pack them more densely and ensure
> that values fit inside an unsigned int (32 bits).
>
>   The mapping *is* written to the `.nodes` file though, here:
>
>
> https://github.com/Project-OSRM/osrm-backend/blob/d189339495e223a6ceea21a73bb7e434775172fa/src/extractor/extractor.cpp#L550-L561
>
>   when this file is later read, we only load the coordinates from it, so
> the OSM values are there, but not used:
>
>
> https://github.com/Project-OSRM/osrm-backend/blob/d189339495e223a6ceea21a73bb7e434775172fa/include/engine/datafacade/internal_datafacade.hpp#L116-L129
>
>   here, you could add the OSM node values to a new array, then you'd have
> the lookup table you need to map the NodeIDs you have to the original OSM
> values.
>
>   This will require extra RAM, which may or may not be a problem for you.
>
> daniel
>
>
> On Feb 1, 2016, at 9:03 AM, Kerrick Staley  wrote:
>
> I want to create a binary that will take an input lat/long and give the
> two OSMNodeIDs representing the nearest road segment. I was able to hack
> something together using NearestPhantomNodes in the OSRM codebase, but I
> can't figure out how to go from the NodeIDs in the PhantomNode to
> OSMNodeIDs.
>
> It looks like the NodeID -> OSMNodeID mapping is dropped in
> osrm-extract/osrm-prepare. Is this the case? Can I use the .osrm or
> .osrm.nodes file to re-build the mapping?
>
> Thanks,
> Kerrick
> ___
> OSRM-talk mailing list
> OSRM-talk@openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk
>
>
>
> ___
> OSRM-talk mailing list
> OSRM-talk@openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk
>
>


-- 
- Kerrick
___
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk


Re: [OSRM-talk] Getting OSMNodeIDs in OSRM

2016-02-01 Thread Daniel Patterson
Kerrick,

  The node ids you have refer to nodes in the edge-based graph.  That's a level 
removed from what you want, so you'll need to work your way backwards.

  This shows how to unpack the edge-based-node ids into a sequence of node ids 
in the node-based graph (that you can then convert to OSMNodeIDS):

https://github.com/Project-OSRM/osrm-backend/blob/fefe5e241a7ec62c7ca102f93834308411dfe58c/include/engine/routing_algorithms/routing_base.hpp#L295-L326

  The GetUncompressedGeometry call returns an array of node-based-node ids that 
represents a road section between two intersections.

   The PhantomNode's fwd_segment_position attribute is the position in that 
array that the PhantomNode was nearest.  The PhantomNode is probably between two
   nodeIDs, so you'll have to figure out which one you want.  You can duplicate 
this logic to figure out which one is closer:

https://github.com/Project-OSRM/osrm-backend/blob/fefe5e241a7ec62c7ca102f93834308411dfe58c/include/engine/geospatial_query.hpp#L141-L145

daniel


> On Feb 1, 2016, at 3:51 PM, Kerrick Staley  wrote:
> 
> It doesn't look like PhantomNode's forward_node_id and reverse_node_id are 
> indexes into InternalDataFacade's m_coordinate_list (and hence the 
> m_osmnodeid_list I created). When I look up forward_node_id/reverse_node_id I 
> get OSM nodes that are far away from the query point. (PhantomNode.name_id 
> and PhantomNode.location *are* set correctly however).
> 
> So I should probably follow Patrick's suggestion and have a separate loop 
> that reads the .nodes file? Does the .nodes file contain ExternalMemoryNodes 
> or QueryNodes? (graph_loader.hpp reads one and internal_datafacade.hpp reads 
> the other, although it won't matter if the two structs have the same size due 
> to padding).
> 
> On Mon, Feb 1, 2016 at 9:25 AM, Daniel Patterson  wrote:
> Hi Kerrick,
> 
>   Yup, the node ids are renumbered to pack them more densely and ensure that 
> values fit inside an unsigned int (32 bits).
> 
>   The mapping *is* written to the `.nodes` file though, here:
> 
> https://github.com/Project-OSRM/osrm-backend/blob/d189339495e223a6ceea21a73bb7e434775172fa/src/extractor/extractor.cpp#L550-L561
> 
>   when this file is later read, we only load the coordinates from it, so the 
> OSM values are there, but not used:
> 
> https://github.com/Project-OSRM/osrm-backend/blob/d189339495e223a6ceea21a73bb7e434775172fa/include/engine/datafacade/internal_datafacade.hpp#L116-L129
> 
>   here, you could add the OSM node values to a new array, then you'd have the 
> lookup table you need to map the NodeIDs you have to the original OSM values.
> 
>   This will require extra RAM, which may or may not be a problem for you.
> 
> daniel
>   
> 
>> On Feb 1, 2016, at 9:03 AM, Kerrick Staley  wrote:
>> 
>> I want to create a binary that will take an input lat/long and give the two 
>> OSMNodeIDs representing the nearest road segment. I was able to hack 
>> something together using NearestPhantomNodes in the OSRM codebase, but I 
>> can't figure out how to go from the NodeIDs in the PhantomNode to OSMNodeIDs.
>> 
>> It looks like the NodeID -> OSMNodeID mapping is dropped in 
>> osrm-extract/osrm-prepare. Is this the case? Can I use the .osrm or 
>> .osrm.nodes file to re-build the mapping?
>> 
>> Thanks,
>> Kerrick
>> 
>> ___
>> OSRM-talk mailing list
>> OSRM-talk@openstreetmap.org
>> https://lists.openstreetmap.org/listinfo/osrm-talk
> 
> 
> ___
> OSRM-talk mailing list
> OSRM-talk@openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk
> 
> 
> 
> 
> -- 
> - Kerrick
> ___
> OSRM-talk mailing list
> OSRM-talk@openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk


___
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk


Re: [OSRM-talk] Getting OSMNodeIDs in OSRM

2016-02-01 Thread Daniel Patterson
Hi Kerrick,

  Yup, the node ids are renumbered to pack them more densely and ensure that 
values fit inside an unsigned int (32 bits).

  The mapping *is* written to the `.nodes` file though, here:

https://github.com/Project-OSRM/osrm-backend/blob/d189339495e223a6ceea21a73bb7e434775172fa/src/extractor/extractor.cpp#L550-L561
 


  when this file is later read, we only load the coordinates from it, so the 
OSM values are there, but not used:

https://github.com/Project-OSRM/osrm-backend/blob/d189339495e223a6ceea21a73bb7e434775172fa/include/engine/datafacade/internal_datafacade.hpp#L116-L129
 


  here, you could add the OSM node values to a new array, then you'd have the 
lookup table you need to map the NodeIDs you have to the original OSM values.

  This will require extra RAM, which may or may not be a problem for you.

daniel
  

> On Feb 1, 2016, at 9:03 AM, Kerrick Staley  wrote:
> 
> I want to create a binary that will take an input lat/long and give the two 
> OSMNodeIDs representing the nearest road segment. I was able to hack 
> something together using NearestPhantomNodes in the OSRM codebase, but I 
> can't figure out how to go from the NodeIDs in the PhantomNode to OSMNodeIDs.
> 
> It looks like the NodeID -> OSMNodeID mapping is dropped in 
> osrm-extract/osrm-prepare. Is this the case? Can I use the .osrm or 
> .osrm.nodes file to re-build the mapping?
> 
> Thanks,
> Kerrick
> 
> ___
> OSRM-talk mailing list
> OSRM-talk@openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk

___
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk


Re: [OSRM-talk] Getting OSMNodeIDs in OSRM

2016-02-01 Thread Patrick Niklaus
Hey Kerrick,

the data is not available in the server anymore, but you can load it
to memory if you like (which will increase the memory consumption
quite a bit on large datasets). The idea is to adapt this [1] function
to load a exteractor::ExternalMemoryNode vector to array that can
translate from NodeID (the index to that array) to the OSM id (the id
property of the struct).

[1] 
https://github.com/Project-OSRM/osrm-backend/blob/f5c12ec4330c0c835fc09dc349878e4fc670b861/include/util/graph_loader.hpp#L65-L105

Hope this helps!

Cheers,
Patrick

On Mon, Feb 1, 2016 at 6:03 PM, Kerrick Staley  wrote:
> I want to create a binary that will take an input lat/long and give the two
> OSMNodeIDs representing the nearest road segment. I was able to hack
> something together using NearestPhantomNodes in the OSRM codebase, but I
> can't figure out how to go from the NodeIDs in the PhantomNode to
> OSMNodeIDs.
>
> It looks like the NodeID -> OSMNodeID mapping is dropped in
> osrm-extract/osrm-prepare. Is this the case? Can I use the .osrm or
> .osrm.nodes file to re-build the mapping?
>
> Thanks,
> Kerrick
>
>
> ___
> OSRM-talk mailing list
> OSRM-talk@openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk
>

___
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk