Skip to content

Latest commit

 

History

History
248 lines (195 loc) · 13.3 KB

File metadata and controls

248 lines (195 loc) · 13.3 KB

.osrm

This is temporary file generated by osrm-extract, which contains original filtered graph data (nodes and edges).

List

tar tvf nevada-latest.osrm 
-rw-rw-r--  0 0      0           8 Jan  1  1970 osrm_fingerprint.meta
-rw-rw-r--  0 0      0           8 Jan  1  1970 /extractor/nodes.meta
-rw-rw-r--  0 0      0    18275776 Jan  1  1970 /extractor/nodes
-rw-rw-r--  0 0      0           8 Jan  1  1970 /extractor/barriers.meta
-rw-rw-r--  0 0      0         608 Jan  1  1970 /extractor/barriers
-rw-rw-r--  0 0      0           8 Jan  1  1970 /extractor/traffic_lights.meta
-rw-rw-r--  0 0      0       16144 Jan  1  1970 /extractor/traffic_lights
-rw-rw-r--  0 0      0           8 Jan  1  1970 /extractor/edges.meta
-rw-rw-r--  0 0      0    39504672 Jan  1  1970 /extractor/edges
-rw-rw-r--  0 0      0           8 Jan  1  1970 /extractor/annotations.meta
-rw-rw-r--  0 0      0     1355088 Jan  1  1970 /extractor/annotations

osrm_fingerprint.meta

/extractor/nodes, /extractor/nodes.meta

Stores all used OSM Nodes(Coordinate and OSM NodeID).

Layout

Implementation

OSM Nodes will be written into .osrm once OSM parsed by Extractor::ParseOSMData() in osrm-extract. They'll be written by ExtractionContainers::WriteNodes() which will be called by ExtractionContainers::PrepareData(). Every Node written into /extractor/nodes is a QueryNode structure.

struct QueryNode
{
    using key_type = OSMNodeID;      // type of NodeID
    using value_type = std::int32_t; // type of lat,lons

    util::FixedLongitude lon;   // [Jay] int32 lon, e.g. -120011751 (i.e. -120.011751)
    util::FixedLatitude lat;    // [Jay] int32 lat, e.g. 39443340 (i.e. 39.443340)
    key_type node_id;           // [Jay] uint64 Node ID from OSM PBF, e.g. 26798725

    // [Jay] ...
}

/extractor/barriers, /extractor/barriers.meta

Stores all OSM Nodes(Internal NodeID) which has barrier.

Layout

Implementation

The /extractor/barriers stores Internal NodeID inside. It represents an OSM Node which contains barrier on it.
Same with /extractor/nodes, the /extractor/barriers will be written by ExtractionContainers::WriteNodes() which will be called by ExtractionContainers::PrepareData().

See Writing barrier nodes in detail.

    {
        util::UnbufferedLog log;
        log << "Writing barrier nodes     ... ";
        TIMER_START(write_nodes);
        std::vector<NodeID> internal_barrier_nodes;
        for (const auto osm_id : barrier_nodes)
        {
            // [Jay] OSM Node -> Internal NodeID
            const auto node_id = mapExternalToInternalNodeID(
                used_node_id_list.begin(), used_node_id_list.end(), osm_id);
            if (node_id != SPECIAL_NODEID)
            {
                internal_barrier_nodes.push_back(node_id);
            }
        }
        storage::serialization::write(writer, "/extractor/barriers", internal_barrier_nodes);
        log << "ok, after " << TIMER_SEC(write_nodes) << "s";
    }

Internal NodeID

Its base type is uint32, and use max uint32 as invalid(i.e. SPECIAL_NODEID).
See definition in https://github.com/Telenav/osrm-backend/blob/6283c6074066f98e6d4a9f774f21ea45407c0d52/include/util/typedefs.hpp#L72.

using NodeID = std::uint32_t;

static const NodeID SPECIAL_NODEID = std::numeric_limits<NodeID>::max();

The Internal NodeID is index of the OSM Node in /extractor/nodes(calculated by std::distance between the OSM Node's iterator and the first iterator of the std::vector<OSM Node>). Note that the Internal NodeID will overflow if use more than 2^32 OSM Nodes, otherwise exception happens.
See mapExternalToInternalNodeID()

    template <typename Iter>
    inline NodeID mapExternalToInternalNodeID(Iter first, Iter last, const OSMNodeID value)
    {
        const auto it = std::lower_bound(first, last, value);
        return (it == last || value < *it) ? SPECIAL_NODEID
                                           : static_cast<NodeID>(std::distance(first, it));
    }

/extractor/traffic_lights, /extractor/traffic_lights.meta

Stores all OSM Nodes(Internal NodeID) which has traffic lights.

Layout

Implementation

The /extractor/traffic_lights stores Internal NodeID inside. It represents an OSM Node which contains traffic_lights on it.
Same with /extractor/nodes, the /extractor/traffic_lights will be written by ExtractionContainers::WriteNodes() which will be called by ExtractionContainers::PrepareData().

See Writing traffic light nodes in detail.

    {
        util::UnbufferedLog log;
        log << "Writing traffic light nodes     ... ";
        TIMER_START(write_nodes);
        std::vector<NodeID> internal_traffic_signals;
        for (const auto osm_id : traffic_signals)
        {
            // [Jay] OSM Node -> Internal NodeID
            const auto node_id = mapExternalToInternalNodeID(
                used_node_id_list.begin(), used_node_id_list.end(), osm_id);
            if (node_id != SPECIAL_NODEID)
            {
                internal_traffic_signals.push_back(node_id);
            }
        }
        storage::serialization::write(
            writer, "/extractor/traffic_lights", internal_traffic_signals);
        log << "ok, after " << TIMER_SEC(write_nodes) << "s";
    }

/extractor/edges, /extractor/edges.meta

Stores all Node Based Edges.

Layout

Implementation

The /extractor/edges stores struct NodeBasedEdge. It represents an NodeBasedEdge which defines by OSRM.
In ExtractionContainers::PrepareData(), the edges will be prepared by ExtractionContainers::PrepareEdges() and then wrote by ExtractionContainers::WriteEdges(). Both source and target are Internal NodeID. The stored edges will be sorted by source before write.

// [Jay] NodeBasedEdge structure
struct NodeBasedEdge
{
    NodeID source;                     // 32 4
    NodeID target;                     // 32 4
    EdgeWeight weight;                 // 32 4
    EdgeDuration duration;             // 32 4
    EdgeDistance distance;             // 32 4
    GeometryID geometry_id;            // 32 4
    AnnotationID annotation_data;      // 32 4
    NodeBasedEdgeClassification flags; // 32 4
};

// [Jay] Write edges
void ExtractionContainers::WriteEdges(storage::tar::FileWriter &writer) const
{
    std::vector<NodeBasedEdge> normal_edges;    // [Jay] each edge structure is NodeBasedEdge
    normal_edges.reserve(all_edges_list.size());
    {
        util::UnbufferedLog log;
        log << "Writing used edges       ... " << std::flush;

        // [Jay] ...

        // [Jay] write edges
        storage::serialization::write(writer, "/extractor/edges", normal_edges);

    }
}

/extractor/annotations, /extractor/annotations.meta

Stores annotation data(i.e. NodeBasedEdgeAnnotation) for parsed Node Based Edges. Each NodeBasedEdge has a AnnotationID annotation_data to index related NodeBasedEdgeAnnotation.

Layout

Implementation

Annotation data defined as vector of NodeBasedEdgeAnnotation in implementation. It constructed in ExtractorCallbacks::ProcessWay together with NodeBasedEdge construction, see details in extractor_callbacks.cpp#L403 and extractor_callbacks.cpp#L440. It'll be written in ExtractionContainers::WriteMetadata() which will be call by ExtractionContainers::PrepareData() too.

struct NodeBasedEdgeAnnotation
{
    NameID name_id;                        // 32 4
    LaneDescriptionID lane_description_id; // 16 2
    ClassData classes;                     // 8  1
    TravelMode travel_mode : 4;            // 4
    bool is_left_hand_driving : 1;         // 1
}

// [Jay] forward annotation data construction
// [Jay] https://github.com/Telenav/osrm-backend/blob/6283c6074066f98e6d4a9f774f21ea45407c0d52/src/extractor/extractor_callbacks.cpp#L403
        const auto annotation_data_id = external_memory.all_edges_annotation_data_list.size();
        external_memory.all_edges_annotation_data_list.push_back({forward_name_id,
                                                                  turn_lane_id_forward,
                                                                  forward_classes,
                                                                  parsed_way.forward_travel_mode,
                                                                  parsed_way.is_left_hand_driving});


void ExtractionContainers::WriteMetadata(storage::tar::FileWriter &writer) const
{
    // [Jay] ...

    // [Jay] same as before, write vector to file
    storage::serialization::write(writer, "/extractor/annotations", all_edges_annotation_data_list);

    // [Jay] ...
}