Commit 8025f5af authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

Creating route from pbf

parent 26d70e0f
......@@ -5,10 +5,12 @@ CXXFLAGS=-O2 -std=c++11
LDFLAGS=-O2 -fwhole-program -flto
LDLIBS_LMDB=-llmdb
LDLIBS_PQXX=-lpqxx
LDLIBS_OSMPBF=-L/home/rv/osmpbf/osmpbf -losmpbf -lprotobuf -lz
INCLUDE_OSMPBF=-I/home/rv/osmpbf -I/home/rv/osmpbf/osmpbf/include
.PHONY: clean
all: elevation_create_database elevation_query_database route_create_databases route_query_nodes_database route_query_lookup_database route
all: elevation_create_database elevation_query_database route_create_databases route_query_nodes_database route_query_lookup_database route route_create_databases_from_pbf
elevation_create_database: elevation.o elevation_create_database.o
$(CC) $(LDFLAGS) -o $@ $+ $(LDLIBS_LMDB)
......@@ -28,6 +30,9 @@ route_query_lookup_database: route_query_lookup_database.o lookup.o functions.o
route: route.o route_db.o lookup.o functions.o nodes_db.o lookup_db.o conv_functions.o get_route.o
$(CC) $(LDFLAGS) -o $@ $+ $(LDLIBS_LMDB)
route_create_databases_from_pbf: route_create_databases_from_pbf.o lookup_db.o nodes_db.o elevation.o parse_way.o conv_functions.o
$(CC) $(LDFLAGS) -o $@ $+ $(LDLIBS_LMDB) $(LDLIBS_OSMPBF)
elevation.o: elevation.cc elevation.h conf.h
$(CC) $(CXXFLAGS) -c $< -o $@
......@@ -70,5 +75,8 @@ get_route.o: get_route.cc get_route.h
route.o: route.cc
$(CC) $(CXXFLAGS) -c $< -o $@
route_create_databases_from_pbf.o: route_create_databases_from_pbf.cc
$(CC) $(CXXFLAGS) $(INCLUDE_OSMPBF) -c $< -o $@
clean:
rm -f *.o
#include "parse_way.h"
// For parsing
std::string no_str = "no";
std::string false_str = "false";
std::string motorway_str = "motorway";
std::string trunk_str = "trunk";
std::string construction_str = "construction";
std::string steps_str = "steps";
std::string foot_str = "foot";
std::string pedestrian_str = "pedestrian";
std::string track_str = "track";
std::string m1_str = "-1";
std::string p1_str = "1";
std::string yes_str = "yes";
std::string true_str = "true";
std::string roundabout_str = "roundabout";
std::string opposite_str = "opposite";
void parse_way(
bool& we_use_it,
way_kind_t& way_kind,
int& oneway,
std::string& tag_highway,
std::string& tag_cycleway,
std::string& tag_bicycle,
std::string& tag_oneway,
std::string& tag_junction)
{
we_use_it = false;
// if the tag cycleway is present and different of no and false
// we take the way in kind RV_WK_CYCLEWAY
if(tag_cycleway.size()>=2 && tag_cycleway.substr(0,2) != no_str)
{
if(tag_cycleway.size()>=5)
{
if(tag_cycleway.substr(0,5) != false_str)
{
way_kind = RV_WK_CYCLEWAY;
we_use_it = true;
}
}
else
{
way_kind = RV_WK_CYCLEWAY;
we_use_it = true;
}
}
// else if the tag bicycle is present and different of no and false
// we take the way in kind RV_WK_OTHERS
if(!we_use_it)
{
if(tag_bicycle.size()>=2 && tag_bicycle.substr(0,2) != no_str)
{
if(tag_bicycle.size()>=5)
{
if(tag_bicycle.substr(0,5) != false_str)
{
way_kind = RV_WK_OTHERS;
we_use_it = true;
}
}
else
{
way_kind = RV_WK_OTHERS;
we_use_it = true;
}
}
}
// else if the tag highway is present and begin by foot or pedestrian
// we take the way in kind RV_WK_FOOTWAY
if(!we_use_it)
{
if(tag_highway.size()>=10 && tag_highway.substr(0,10) == pedestrian_str)
{
way_kind = RV_WK_FOOTWAY;
we_use_it = true;
}
if(tag_highway.size()>=4 && tag_highway.substr(0,4) == foot_str)
{
way_kind = RV_WK_FOOTWAY;
we_use_it = true;
}
}
// else if the tag highway is present and different of motorway /
// trunk / construction / steps / track we take in in kind
// RV_WK_OTHERS
if(!we_use_it)
{
if(tag_highway.size()>0)
{
we_use_it = true;
if(tag_highway.size()>=8 && tag_highway.substr(0,8) == motorway_str)
we_use_it=false;
if(tag_highway.size()>=5 && tag_highway.substr(0,5) == trunk_str)
we_use_it=false;
if(tag_highway.size()>=12 && tag_highway.substr(0,12) == construction_str)
we_use_it=false;
if(tag_highway.size()>=5 && tag_highway.substr(0,5) == steps_str)
we_use_it=false;
if(tag_highway.size()>=5 && tag_highway.substr(0,5) == track_str)
we_use_it=false;
// and we check for the exception
if(tag_bicycle.size()>=2 && tag_bicycle.substr(0,2) == no_str)
we_use_it=false;
if(tag_bicycle.size()>=5 && tag_bicycle.substr(0,5) == false_str)
we_use_it=false;
if(we_use_it)
way_kind = RV_WK_OTHERS;
}
}
if(we_use_it)
{
oneway=0;
if(tag_oneway.size()>=2 && tag_oneway.substr(0,2) == m1_str)
oneway=-1;
if(tag_oneway.size()>=1 && tag_oneway.substr(0,1) == p1_str)
oneway=1;
if(tag_oneway.size()>=3 && tag_oneway.substr(0,3) == yes_str)
oneway=1;
if(tag_oneway.size()>=4 && tag_oneway.substr(0,4) == true_str)
oneway=1;
if(tag_junction.size()>=10 && tag_junction.substr(0,10) == roundabout_str)
oneway=1;
if(tag_cycleway.size()>=8 && tag_cycleway.substr(0,8) == opposite_str)
oneway=0;
}
}
#ifndef H_PARSE_WAY
#define H_PARSE_WAY
#include "conf.h"
#include "types.h"
void parse_way(
bool& we_use_it,
way_kind_t& way_kind,
int& oneway,
std::string& tag_highway,
std::string& tag_cycleway,
std::string& tag_bicycle,
std::string& tag_oneway,
std::string& tag_junction);
#endif
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment