Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/protobuf output #1273

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b58076d
Initial commit for protobuf descriptor.
Zhdanovich Aug 12, 2014
0094138
Update cmake file to generate protobuf files and create a dependancy
Zhdanovich Aug 15, 2014
c47989c
Add protobuf file.
Zhdanovich Aug 15, 2014
f889006
Update ViaRoutePlugin to use protobuf descriptor.
Zhdanovich Aug 15, 2014
d0cb465
Create functions for Polyline Compressor and Description Factory to r…
Zhdanovich Aug 16, 2014
1a7c798
Intermediate result for adding data to protobuf response.
Zhdanovich Aug 16, 2014
5982cee
Add protobuf message Route. In response message create main and addit…
Zhdanovich Aug 16, 2014
086e0e8
Add alternative way description
Zhdanovich Aug 16, 2014
02540e9
Add route names.
Zhdanovich Aug 16, 2014
2bc8029
add Hint.
Zhdanovich Aug 16, 2014
0c28050
Add RouteInstructions
Zhdanovich Aug 16, 2014
da9a26d
Pass vector as reference.
Zhdanovich Aug 16, 2014
41ff46a
Refactoring. Move common parts to Descriptor.h
Zhdanovich Aug 17, 2014
dba2497
Code review fixes
Zhdanovich Aug 18, 2014
e461955
Add route instructions travel mode
Zhdanovich Aug 21, 2014
7e7c417
simplify parameter passing
DennisOSRM Nov 17, 2014
32ecb63
rename new file
DennisOSRM Nov 17, 2014
749b65a
add better check if protobuf is found
DennisOSRM Nov 17, 2014
bfbd7a8
remove dead code from polyline formatter
DennisOSRM Nov 17, 2014
443d551
fix linkage after rebase
DennisOSRM Nov 20, 2014
89eb6f6
build fixes after a painful rebase
DennisOSRM Jan 7, 2015
cd4a463
fix implicit conversion
DennisOSRM Jan 7, 2015
d0d706b
fix linkage of algorithm-tests post rebase
DennisOSRM Jan 7, 2015
4dfd61e
add char_array type plus dummy rendering methods to JSON container
DennisOSRM Jan 7, 2015
efabccc
implement rendering of char_array in json renderer
DennisOSRM Jan 8, 2015
55e194f
add files from skipped change in rebase
DennisOSRM Jan 8, 2015
0b118ec
use pbf suffix to request protobuffer encoded response
DennisOSRM Jan 8, 2015
fdbe96c
revert addition of vector<char> into json container
DennisOSRM Jan 8, 2015
f8814de
add rendering visitor for protocol buffer formatted replies
DennisOSRM Jan 8, 2015
5134cf2
remove duplicated directory
DennisOSRM Jan 8, 2015
3026c37
simplify pbf rendering code by applying type_traits
DennisOSRM Jan 8, 2015
2f74d83
add response format for distance matrix queries
DennisOSRM Jan 9, 2015
7ecd67f
move DescriptorTable into base class, add move c'tor to initializatio…
DennisOSRM Jan 9, 2015
64bb1b3
streamline code after re-structuring
DennisOSRM Jan 9, 2015
185764d
rename package in protocol buffer to get rid of camel case
DennisOSRM Jan 9, 2015
d6ecc7e
remove camel case from distance table response
DennisOSRM Jan 9, 2015
7385eac
implement protobuffer encoded output for distance table queries
DennisOSRM Jan 9, 2015
bec5c9d
add protobuffer encoded location_response for locate/nearest queries
DennisOSRM Jan 9, 2015
ec73305
remove unnecessary typename keyword, used outside template function
DennisOSRM Jan 9, 2015
5c782c3
rename location in response
DennisOSRM Jan 9, 2015
131eca9
implement protobuffer encoded reponse for locate plugin
DennisOSRM Jan 9, 2015
5fd6958
reformat locate plugin
DennisOSRM Jan 9, 2015
c103a29
added explicit nearest/locate responses in proto definition
DennisOSRM Jan 9, 2015
4b7b40b
use new protobuffer defs in locate plugin
DennisOSRM Jan 9, 2015
00de820
rename proto definition location to named_location. more telling
DennisOSRM Jan 9, 2015
8f29e7d
implement protocol buffer encoded output for nearest plugin call
DennisOSRM Jan 9, 2015
5a45aeb
removed camel case from all structure in protobuffer encoded response
DennisOSRM Jan 12, 2015
e7cf629
Revert "implement protocol buffer encoded output for nearest plugin c…
DennisOSRM Jan 12, 2015
6fc5d58
write locate response to stream
DennisOSRM Jan 12, 2015
f477d00
reimplement protobuffer encoded nearest call
DennisOSRM Jan 12, 2015
62ea95f
fix move ctor to not pass data into nirvana
DennisOSRM Jan 12, 2015
a9314d9
remove debug output
DennisOSRM Jan 12, 2015
cccad44
cuke: add tests for protobuffer output
emiltin Jan 13, 2015
ceaa832
cuke: change protobuf gem, update protobug output testing
Jan 13, 2015
59cca36
cuke fix pbf data conversion, add more pbf tests
Jan 13, 2015
f451987
fix typo in test description
DennisOSRM Jan 14, 2015
ecf9a58
use coordinate calculations in douglas peucker
DennisOSRM Jan 22, 2015
a384955
backport protobuf output to develop branch
DennisOSRM Feb 23, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(CheckCXXCompilerFlag)
include(FindPackageHandleStandardArgs)

find_package(Protobuf REQUIRED)
if(PROTOBUF_PROTOC_EXECUTABLE STREQUAL "PROTOBUF_PROTOC_EXECUTABLE-NOTFOUND")
message(SEND_ERROR "protoc executable not found! Missing protobuf-compiler package?")
endif()

include_directories(${PROTOBUF_INCLUDE_DIRS})
file(GLOB ProtoFiles "${CMAKE_CURRENT_SOURCE_DIR}/descriptors/*.proto")
PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
add_library(PBFoutput OBJECT ${ProtoSources} ${ProtoHeaders})

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(GetGitRevisionDescription)
git_describe(GIT_DESCRIPTION)
Expand Down Expand Up @@ -52,14 +62,16 @@ configure_file(
${CMAKE_SOURCE_DIR}/util/git_sha.cpp.in
${CMAKE_SOURCE_DIR}/util/git_sha.cpp
)

file(GLOB ExtractorGlob extractor/*.cpp)
file(GLOB ImporterGlob data_structures/import_edge.cpp data_structures/external_memory_node.cpp)
add_library(IMPORT OBJECT ${ImporterGlob})
add_library(IMPORT OBJECT ${ImporterGlob} ${ProtoHeaders})
add_library(LOGGER OBJECT util/simple_logger.cpp)
add_library(PHANTOMNODE OBJECT data_structures/phantom_node.cpp)
add_library(EXCEPTION OBJECT util/osrm_exception.cpp)
add_library(MERCATOR OBJECT util/mercator.cpp)

include_directories(${CMAKE_BINARY_DIR})
set(ExtractorSources extract.cpp ${ExtractorGlob})
add_executable(osrm-extract ${ExtractorSources} $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:IMPORT> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR>)

Expand Down Expand Up @@ -93,7 +105,8 @@ set(
add_library(COORDINATE OBJECT ${CoordinateGlob})
add_library(FINGERPRINT OBJECT util/fingerprint.cpp)
add_library(GITDESCRIPTION OBJECT util/git_sha.cpp)
add_library(OSRM ${OSRMSources} $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR>)

add_library(OSRM ${OSRMSources} $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:FINGERPRINT> $<TARGET_OBJECTS:COORDINATE> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:PHANTOMNODE> $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:MERCATOR> $<TARGET_OBJECTS:PBFoutput>)
add_dependencies(FINGERPRINT FingerPrintConfigure)

add_executable(osrm-routed routed.cpp ${ServerGlob} $<TARGET_OBJECTS:EXCEPTION>)
Expand Down Expand Up @@ -220,8 +233,8 @@ target_link_libraries(osrm-extract ${Boost_LIBRARIES})
target_link_libraries(osrm-prepare ${Boost_LIBRARIES})
target_link_libraries(osrm-routed ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} OSRM)
target_link_libraries(osrm-datastore ${Boost_LIBRARIES})
target_link_libraries(datastructure-tests ${Boost_LIBRARIES})
target_link_libraries(algorithm-tests ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} OSRM)
target_link_libraries(datastructure-tests ${Boost_LIBRARIES})
target_link_libraries(rtree-bench ${Boost_LIBRARIES})

find_package(Threads REQUIRED)
Expand Down Expand Up @@ -262,6 +275,10 @@ else()
endif()
include_directories(${LUA_INCLUDE_DIR})

target_link_libraries(osrm-extract ${PROTOBUF_LIBRARY})
target_link_libraries(osrm-prepare ${PROTOBUF_LIBRARY})
target_link_libraries(osrm-routed ${PROTOBUF_LIBRARY})

find_package(EXPAT REQUIRED)
include_directories(${EXPAT_INCLUDE_DIRS})
target_link_libraries(osrm-extract ${EXPAT_LIBRARIES})
Expand All @@ -284,11 +301,6 @@ include_directories(${OSMPBF_INCLUDE_DIR})
target_link_libraries(osrm-extract ${OSMPBF_LIBRARY})
target_link_libraries(osrm-prepare ${OSMPBF_LIBRARY})

find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
target_link_libraries(osrm-extract ${PROTOBUF_LIBRARY})
target_link_libraries(osrm-prepare ${PROTOBUF_LIBRARY})

find_package(BZip2 REQUIRED)
include_directories(${BZIP_INCLUDE_DIRS})
target_link_libraries(osrm-extract ${BZIP2_LIBRARIES})
Expand All @@ -314,7 +326,7 @@ if(WITH_TOOLS OR BUILD_TOOLS)
endif()
add_executable(osrm-cli tools/simpleclient.cpp $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:COORDINATE>)
target_link_libraries(osrm-cli ${Boost_LIBRARIES} ${OPTIONAL_SOCKET_LIBS} OSRM)
target_link_libraries(osrm-cli ${TBB_LIBRARIES})
target_link_libraries(osrm-cli ${TBB_LIBRARIES} ${PROTOBUF_LIBRARY})
add_executable(osrm-io-benchmark tools/io-benchmark.cpp $<TARGET_OBJECTS:EXCEPTION> $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:LOGGER>)
target_link_libraries(osrm-io-benchmark ${Boost_LIBRARIES})
add_executable(osrm-unlock-all tools/unlock_all_mutexes.cpp $<TARGET_OBJECTS:GITDESCRIPTION> $<TARGET_OBJECTS:LOGGER> $<TARGET_OBJECTS:EXCEPTION>)
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ gem "rake"
gem "osmlib-base"
gem "sys-proctable"
gem "rspec-expectations"
gem "protobuf"
20 changes: 20 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
GEM
remote: http://rubygems.org/
specs:
activesupport (4.2.0)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
builder (3.2.2)
cucumber (1.3.8)
builder (>= 2.1.2)
Expand All @@ -11,20 +17,34 @@ GEM
diff-lcs (1.2.4)
gherkin (2.12.1)
multi_json (~> 1.3)
i18n (0.7.0)
json (1.8.2)
middleware (0.1.0)
minitest (5.5.1)
multi_json (1.8.0)
multi_test (0.0.2)
osmlib-base (0.1.4)
protobuf (3.4.2)
activesupport (>= 3.2)
middleware
thor
thread_safe
rake (10.1.0)
rspec-expectations (2.14.3)
diff-lcs (>= 1.1.3, < 2.0)
sys-proctable (0.9.3)
thor (0.19.1)
thread_safe (0.3.4)
tzinfo (1.2.2)
thread_safe (~> 0.1)

PLATFORMS
ruby

DEPENDENCIES
cucumber
osmlib-base
protobuf
rake
rspec-expectations
sys-proctable
67 changes: 67 additions & 0 deletions Util/pbf_renderer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*

Copyright (c) 2015, Project OSRM, Dennis Luxen, others
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

#ifndef PBF_RENDERER_HPP
#define PBF_RENDERER_HPP

#include "cast.hpp"

#include <osrm/json_container.hpp>

#include <type_traits>

namespace JSON {

struct PBFToArrayRenderer : mapbox::util::static_visitor<>
{
explicit PBFToArrayRenderer(std::vector<char> &_out) : out(_out) {}

void operator()(const String &string) const
{
out.insert(out.end(), string.value.begin(), string.value.end());
}

template<class Other>
typename std::enable_if<!std::is_same<Other, String>::value, void>::type
operator()(const Other &other) const
{
}

private:
std::vector<char> &out;
};

template<class JSONObject>
void pbf_render(std::vector<char> &out, const JSONObject &object)
{
Value value = object;
mapbox::util::apply_visitor(PBFToArrayRenderer(out), value);
}

} // namespace JSON

#endif // PBF_RENDERER_HPP
1 change: 1 addition & 0 deletions algorithms/douglas_peucker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "douglas_peucker.hpp"

#include "../data_structures/segment_information.hpp"
#include "../util/integer_range.hpp"

#include <boost/assert.hpp>
#include <osrm/coordinate.hpp>
Expand Down
24 changes: 12 additions & 12 deletions algorithms/polyline_formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "polyline_formatter.hpp"

#include "polyline_compressor.hpp"
#include "../data_structures/coordinate_calculation.hpp"
#include "../data_structures/segment_information.hpp"

#include <osrm/coordinate.hpp>

osrm::json::String
PolylineFormatter::printEncodedString(const std::vector<SegmentInformation> &polyline) const
std::string PolylineFormatter::printEncodedStr(const std::vector<SegmentInformation> &polyline) const
{
return osrm::json::String(PolylineCompressor().get_encoded_string(polyline));
return PolylineCompressor().get_encoded_string(polyline);
}

osrm::json::Array
PolylineFormatter::printUnencodedString(const std::vector<SegmentInformation> &polyline) const
std::vector<std::string> PolylineFormatter::printUnencodedStr(const std::vector<SegmentInformation> &polyline) const
{
osrm::json::Array json_geometry_array;
std::vector<std::string> output;
for (const auto &segment : polyline)
{
if (segment.necessary)
{
osrm::json::Array json_coordinate;
json_coordinate.values.push_back(segment.location.lat / COORDINATE_PRECISION);
json_coordinate.values.push_back(segment.location.lon / COORDINATE_PRECISION);
json_geometry_array.values.push_back(json_coordinate);
std::string tmp, res;
coordinate_calculation::lat_or_lon_to_string(segment.location.lat, tmp);
res += (tmp + ",");
coordinate_calculation::lat_or_lon_to_string(segment.location.lon, tmp);
res += tmp;
output.push_back(res);
}
}
return json_geometry_array;
return output;
}
12 changes: 8 additions & 4 deletions algorithms/polyline_formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

struct SegmentInformation;

#include <osrm/json_container.hpp>

#include <string>
#include <vector>

struct PolylineFormatter
{
osrm::json::String printEncodedString(const std::vector<SegmentInformation> &polyline) const;
private:
void encodeVectorSignedNumber(std::vector<int> &numbers, std::string &output) const;

void encodeNumber(int number_to_encode, std::string &output) const;

public:
std::string printEncodedStr(const std::vector<SegmentInformation> &polyline) const;

osrm::json::Array printUnencodedString(const std::vector<SegmentInformation> &polyline) const;
std::vector<std::string> printUnencodedStr(const std::vector<SegmentInformation> &polyline) const;
};

#endif /* POLYLINE_FORMATTER_HPP */
13 changes: 7 additions & 6 deletions descriptors/description_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate,
turn, path_point.travel_mode);
}

osrm::json::Value DescriptionFactory::AppendGeometryString(const bool return_encoded)
std::string DescriptionFactory::AppendEncodedPolylineStringEncoded()
{
if (return_encoded)
{
return PolylineFormatter().printEncodedString(path_description);
}
return PolylineFormatter().printUnencodedString(path_description);
return PolylineFormatter().printEncodedStr(path_description);
}

std::vector<std::string> DescriptionFactory::AppendEncodedPolylineStringUnencoded()
{
return PolylineFormatter().printUnencodedStr(path_description);
}

void DescriptionFactory::BuildRouteSummary(const double distance, const unsigned time)
Expand Down
8 changes: 6 additions & 2 deletions descriptors/description_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ class DescriptionFactory
void SetEndSegment(const PhantomNode &start_phantom,
const bool traversed_in_reverse,
const bool is_via_location = false);
osrm::json::Value AppendGeometryString(const bool return_encoded);
std::vector<unsigned> const &GetViaIndices() const;

double get_entire_length() const { return entire_length; }
double get_entire_length() const
{
return entire_length;
}
std::string AppendEncodedPolylineStringEncoded();
std::vector<std::string> AppendEncodedPolylineStringUnencoded();

void Run(const unsigned zoom_level);
};
Expand Down
Loading