diff --git a/CMakeLists.txt b/CMakeLists.txt index b1034b1fd..331478e49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8.8) -if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE) message(FATAL_ERROR "In-source builds are not allowed. Please create a directory and run cmake from there, passing the path to this source directory as the last argument. This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. Please delete them.") @@ -54,6 +54,7 @@ file(GLOB ExtractorGlob Extractor/*.cpp) file(GLOB ImporterGlob DataStructures/Import*.cpp) add_library(IMPORT OBJECT ${ImporterGlob}) add_library(LOGGER OBJECT Util/simple_logger.cpp) +add_library(PHANTOMNODE OBJECT DataStructures/phantom_node.cpp) set(ExtractorSources extractor.cpp ${ExtractorGlob}) add_executable(osrm-extract ${ExtractorSources} $ $ $ $ $) @@ -84,7 +85,7 @@ set( add_library(COORDINATE OBJECT ${CoordinateGlob}) add_library(FINGERPRINT OBJECT Util/FingerPrint.cpp) add_library(GITDESCRIPTION OBJECT Util/GitDescription.cpp) -add_library(OSRM ${OSRMSources} $ $ $ $) +add_library(OSRM ${OSRMSources} $ $ $ $ $) add_dependencies(FINGERPRINT FingerPrintConfigure) add_executable(osrm-routed routed.cpp ${ServerGlob}) diff --git a/DataStructures/RawRouteData.h b/DataStructures/RawRouteData.h index 53d1579a4..af34cc58e 100644 --- a/DataStructures/RawRouteData.h +++ b/DataStructures/RawRouteData.h @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef RAW_ROUTE_DATA_H #define RAW_ROUTE_DATA_H -#include "../DataStructures/PhantomNodes.h" +#include "../DataStructures/phantom_node.hpp" #include "../DataStructures/TravelMode.h" #include "../DataStructures/TurnInstructions.h" #include "../typedefs.h" diff --git a/DataStructures/StaticRTree.h b/DataStructures/StaticRTree.h index 62e194e66..b02a541b5 100644 --- a/DataStructures/StaticRTree.h +++ b/DataStructures/StaticRTree.h @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "DeallocatingVector.h" #include "HilbertValue.h" -#include "PhantomNodes.h" +#include "phantom_node.hpp" #include "QueryNode.h" #include "SharedMemoryFactory.h" #include "SharedMemoryVectorWrapper.h" diff --git a/DataStructures/phantom_node.cpp b/DataStructures/phantom_node.cpp new file mode 100644 index 000000000..499991b62 --- /dev/null +++ b/DataStructures/phantom_node.cpp @@ -0,0 +1,119 @@ +/* + +Copyright (c) 2013, 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. + +*/ + +#include "phantom_node.hpp" + +PhantomNode::PhantomNode(NodeID forward_node_id, NodeID reverse_node_id, unsigned name_id, + int forward_weight, int reverse_weight, int forward_offset, int reverse_offset, + unsigned packed_geometry_id, FixedPointCoordinate &location, + unsigned short fwd_segment_position, + TravelMode forward_travel_mode, TravelMode backward_travel_mode) : + forward_node_id(forward_node_id), + reverse_node_id(reverse_node_id), + name_id(name_id), + forward_weight(forward_weight), + reverse_weight(reverse_weight), + forward_offset(forward_offset), + reverse_offset(reverse_offset), + packed_geometry_id(packed_geometry_id), + location(location), + fwd_segment_position(fwd_segment_position), + forward_travel_mode(forward_travel_mode), + backward_travel_mode(backward_travel_mode) +{ } + +PhantomNode::PhantomNode() : + forward_node_id(SPECIAL_NODEID), + reverse_node_id(SPECIAL_NODEID), + name_id(std::numeric_limits::max()), + forward_weight(INVALID_EDGE_WEIGHT), + reverse_weight(INVALID_EDGE_WEIGHT), + forward_offset(0), + reverse_offset(0), + packed_geometry_id(SPECIAL_EDGEID), + fwd_segment_position(0), + forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), + backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) +{ } + +int PhantomNode::GetForwardWeightPlusOffset() const +{ + if (SPECIAL_NODEID == forward_node_id) + { + return 0; + } + const int result = (forward_offset + forward_weight); + return result; +} + +int PhantomNode::GetReverseWeightPlusOffset() const +{ + if (SPECIAL_NODEID == reverse_node_id) + { + return 0; + } + const int result = (reverse_offset + reverse_weight); + return result; +} + +bool PhantomNode::isBidirected() const +{ + return (forward_node_id != SPECIAL_NODEID) && + (reverse_node_id != SPECIAL_NODEID); +} + +bool PhantomNode::IsCompressed() const +{ + return (forward_offset != 0) || (reverse_offset != 0); +} + +bool PhantomNode::isValid(const unsigned numberOfNodes) const +{ + return + location.isValid() && + ( + (forward_node_id < numberOfNodes) || + (reverse_node_id < numberOfNodes) + ) && + ( + (forward_weight != INVALID_EDGE_WEIGHT) || + (reverse_weight != INVALID_EDGE_WEIGHT) + ) && + (name_id != std::numeric_limits::max() + ); +} + +bool PhantomNode::isValid() const +{ + return location.isValid() && + (name_id != std::numeric_limits::max()); +} + +bool PhantomNode::operator==(const PhantomNode & other) const +{ + return location == other.location; +} diff --git a/DataStructures/PhantomNodes.h b/DataStructures/phantom_node.hpp similarity index 59% rename from DataStructures/PhantomNodes.h rename to DataStructures/phantom_node.hpp index 7c1279072..5f9d1387e 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/phantom_node.hpp @@ -41,34 +41,9 @@ struct PhantomNode int forward_weight, int reverse_weight, int forward_offset, int reverse_offset, unsigned packed_geometry_id, FixedPointCoordinate &location, unsigned short fwd_segment_position, - TravelMode forward_travel_mode, TravelMode backward_travel_mode) : - forward_node_id(forward_node_id), - reverse_node_id(reverse_node_id), - name_id(name_id), - forward_weight(forward_weight), - reverse_weight(reverse_weight), - forward_offset(forward_offset), - reverse_offset(reverse_offset), - packed_geometry_id(packed_geometry_id), - location(location), - fwd_segment_position(fwd_segment_position), - forward_travel_mode(forward_travel_mode), - backward_travel_mode(backward_travel_mode) - { } + TravelMode forward_travel_mode, TravelMode backward_travel_mode); - PhantomNode() : - forward_node_id(SPECIAL_NODEID), - reverse_node_id(SPECIAL_NODEID), - name_id(std::numeric_limits::max()), - forward_weight(INVALID_EDGE_WEIGHT), - reverse_weight(INVALID_EDGE_WEIGHT), - forward_offset(0), - reverse_offset(0), - packed_geometry_id(SPECIAL_EDGEID), - fwd_segment_position(0), - forward_travel_mode(TRAVEL_MODE_INACCESSIBLE), - backward_travel_mode(TRAVEL_MODE_INACCESSIBLE) - { } + PhantomNode(); NodeID forward_node_id; NodeID reverse_node_id; @@ -83,63 +58,19 @@ struct PhantomNode TravelMode forward_travel_mode : 4; TravelMode backward_travel_mode : 4; - int GetForwardWeightPlusOffset() const - { - if (SPECIAL_NODEID == forward_node_id) - { - return 0; - } - const int result = (forward_offset + forward_weight); - return result; - } + int GetForwardWeightPlusOffset() const; - int GetReverseWeightPlusOffset() const - { - if (SPECIAL_NODEID == reverse_node_id) - { - return 0; - } - const int result = (reverse_offset + reverse_weight); - return result; - } + int GetReverseWeightPlusOffset() const; - bool isBidirected() const - { - return (forward_node_id != SPECIAL_NODEID) && - (reverse_node_id != SPECIAL_NODEID); - } + bool isBidirected() const; - bool IsCompressed() const - { - return (forward_offset != 0) || (reverse_offset != 0); - } + bool IsCompressed() const; - bool isValid(const unsigned numberOfNodes) const - { - return - location.isValid() && - ( - (forward_node_id < numberOfNodes) || - (reverse_node_id < numberOfNodes) - ) && - ( - (forward_weight != INVALID_EDGE_WEIGHT) || - (reverse_weight != INVALID_EDGE_WEIGHT) - ) && - (name_id != std::numeric_limits::max() - ); - } + bool isValid(const unsigned numberOfNodes) const; - bool isValid() const - { - return location.isValid() && - (name_id != std::numeric_limits::max()); - } + bool isValid() const; - bool operator==(const PhantomNode & other) const - { - return location == other.location; - } + bool operator==(const PhantomNode & other) const; }; using PhantomNodeArray = std::vector>; diff --git a/Descriptors/BaseDescriptor.h b/Descriptors/BaseDescriptor.h index 4cf6708e9..c793bbda1 100644 --- a/Descriptors/BaseDescriptor.h +++ b/Descriptors/BaseDescriptor.h @@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef BASE_DESCRIPTOR_H #define BASE_DESCRIPTOR_H -#include "../DataStructures/PhantomNodes.h" +#include "../DataStructures/phantom_node.hpp" #include "../DataStructures/RawRouteData.h" #include "../typedefs.h" @@ -44,14 +44,14 @@ struct DescriptorTable : public std::unordered_map unsigned get_id(const std::string &key) { auto iter = find(key); - if (iter != end()) + if (iter != end()) { return iter->second; - } + } return 0; } }; - + struct DescriptorConfig { @@ -60,9 +60,9 @@ struct DescriptorConfig } template - DescriptorConfig(const OtherT &other) : instructions(other.print_instructions), - geometry(other.geometry), - encode_geometry(other.compression), + DescriptorConfig(const OtherT &other) : instructions(other.print_instructions), + geometry(other.geometry), + encode_geometry(other.compression), zoom_level(other.zoom_level) { } bool instructions; bool geometry; diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 6eb22c927..4d790997f 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../typedefs.h" #include "../Algorithms/PolylineCompressor.h" -#include "../DataStructures/PhantomNodes.h" #include "../DataStructures/RawRouteData.h" #include "../DataStructures/SegmentInformation.h" #include "../DataStructures/TurnInstructions.h" diff --git a/Descriptors/DescriptionFactory.h b/Descriptors/DescriptionFactory.h index b3c6e42a5..6b8474658 100644 --- a/Descriptors/DescriptionFactory.h +++ b/Descriptors/DescriptionFactory.h @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../Algorithms/DouglasPeucker.h" #include "../Algorithms/PolylineCompressor.h" -#include "../DataStructures/PhantomNodes.h" +#include "../DataStructures/phantom_node.hpp" #include "../DataStructures/SegmentInformation.h" #include "../DataStructures/TurnInstructions.h" #include "../typedefs.h" diff --git a/Plugins/HelloWorldPlugin.h b/Plugins/HelloWorldPlugin.h index d9b4a8d0e..662758d1f 100644 --- a/Plugins/HelloWorldPlugin.h +++ b/Plugins/HelloWorldPlugin.h @@ -77,8 +77,8 @@ class HelloWorldPlugin final : public BasePlugin JSON::Object json_location; JSON::Array json_coordinates; - json_coordinates.values.push_back(coordinate.lat / COORDINATE_PRECISION); - json_coordinates.values.push_back(coordinate.lon / COORDINATE_PRECISION); + json_coordinates.values.push_back(static_cast(coordinate.lat / COORDINATE_PRECISION)); + json_coordinates.values.push_back(static_cast(coordinate.lon / COORDINATE_PRECISION)); json_location.values[cast::integral_to_string(counter)] = json_coordinates; json_locations.values.push_back(json_location); ++counter; diff --git a/Plugins/NearestPlugin.h b/Plugins/NearestPlugin.h index e4fec91c1..4eedf0437 100644 --- a/Plugins/NearestPlugin.h +++ b/Plugins/NearestPlugin.h @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "BasePlugin.h" #include "../DataStructures/JSONContainer.h" -#include "../DataStructures/PhantomNodes.h" +#include "../DataStructures/phantom_node.hpp" #include "../DataStructures/Range.h" #include diff --git a/Server/DataStructures/BaseDataFacade.h b/Server/DataStructures/BaseDataFacade.h index b7ee411af..9b77b292a 100644 --- a/Server/DataStructures/BaseDataFacade.h +++ b/Server/DataStructures/BaseDataFacade.h @@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../../DataStructures/EdgeBasedNode.h" #include "../../DataStructures/ImportNode.h" -#include "../../DataStructures/PhantomNodes.h" +#include "../../DataStructures/phantom_node.hpp" #include "../../DataStructures/Range.h" #include "../../DataStructures/TurnInstructions.h" #include "../../Util/OSRMException.h"