diff --git a/Algorithms/PolylineCompressor.cpp b/Algorithms/PolylineCompressor.cpp index 4d3609d99..acab45656 100644 --- a/Algorithms/PolylineCompressor.cpp +++ b/Algorithms/PolylineCompressor.cpp @@ -108,10 +108,10 @@ void PolylineCompressor::printUnencodedString( output += "["; std::string tmp; for(unsigned i = 0; i < polyline.size(); i++) { - convertInternalLatLonToString(polyline[i].lat, tmp); + FixedPointCoordinate::convertInternalLatLonToString(polyline[i].lat, tmp); output += "["; output += tmp; - convertInternalLatLonToString(polyline[i].lon, tmp); + FixedPointCoordinate::convertInternalLatLonToString(polyline[i].lon, tmp); output += ", "; output += tmp; output += "]"; @@ -132,10 +132,10 @@ void PolylineCompressor::printUnencodedString( if(!polyline[i].necessary) { continue; } - convertInternalLatLonToString(polyline[i].location.lat, tmp); + FixedPointCoordinate::convertInternalLatLonToString(polyline[i].location.lat, tmp); output += "["; output += tmp; - convertInternalLatLonToString(polyline[i].location.lon, tmp); + FixedPointCoordinate::convertInternalLatLonToString(polyline[i].location.lon, tmp); output += ", "; output += tmp; output += "]"; diff --git a/Algorithms/StronglyConnectedComponents.h b/Algorithms/StronglyConnectedComponents.h index d3a1b3cd7..51b2f76bc 100644 --- a/Algorithms/StronglyConnectedComponents.h +++ b/Algorithms/StronglyConnectedComponents.h @@ -385,7 +385,7 @@ public: } const TarjanDynamicGraph::NodeIterator v = m_node_based_graph->GetTarget(e1); - total_network_distance += 100*ApproximateDistance( + total_network_distance += 100*FixedPointCoordinate::ApproximateDistance( m_coordinate_list[u].lat, m_coordinate_list[u].lon, m_coordinate_list[v].lat, diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c0e392b8..7884fe70a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,11 +43,12 @@ add_executable( osrm-prepare ${PrepareSources} ) file(GLOB ServerGlob Server/*.cpp) file(GLOB DescriptorGlob Descriptors/*.cpp) file(GLOB DatastructureGlob DataStructures/SearchEngineData.cpp) +file(GLOB CoordinateGlob DataStructures/Coordinate.cpp) file(GLOB AlgorithmGlob Algorithms/*.cpp) file(GLOB HttpGlob Server/Http/*.cpp) file(GLOB LibOSRMGlob Library/*.cpp) -set(OSRMSources ${LibOSRMGlob} ${DescriptorGlob} ${DatastructureGlob} ${AlgorithmGlob} ${HttpGlob}) +set(OSRMSources ${LibOSRMGlob} ${DescriptorGlob} ${DatastructureGlob} ${CoordinateGlob} ${AlgorithmGlob} ${HttpGlob}) add_library( OSRM SHARED ${OSRMSources} ) add_library( UUID STATIC Util/UUID.cpp ) add_library( GITDESCRIPTION STATIC Util/GitDescription.cpp ) @@ -56,7 +57,7 @@ add_dependencies( GITDESCRIPTION GIT_DESCRIPTION ) add_executable(osrm-routed routed.cpp ${ServerGlob}) set_target_properties(osrm-routed PROPERTIES COMPILE_FLAGS -DROUTED) -add_executable(osrm-datastore datastore.cpp) +add_executable(osrm-datastore datastore.cpp ${CoordinateGlob}) # Check the release mode if(NOT CMAKE_BUILD_TYPE MATCHES Debug) @@ -121,7 +122,7 @@ IF( APPLE ) ELSE( APPLE ) target_link_libraries( OSRM ${Boost_LIBRARIES} ) ENDIF( APPLE ) -target_link_libraries( osrm-extract ${Boost_LIBRARIES} UUID GITDESCRIPTION ) +target_link_libraries( osrm-extract ${CoordinateGlob} ${Boost_LIBRARIES} UUID GITDESCRIPTION ) target_link_libraries( osrm-prepare ${Boost_LIBRARIES} UUID GITDESCRIPTION ) target_link_libraries( osrm-routed ${Boost_LIBRARIES} OSRM UUID GITDESCRIPTION ) target_link_libraries( osrm-datastore ${Boost_LIBRARIES} UUID GITDESCRIPTION ) @@ -156,10 +157,10 @@ IF ( LUAJIT_FOUND ) ELSE () target_link_libraries( osrm-extract ${LUA_LIBRARY} ) target_link_libraries( osrm-prepare ${LUA_LIBRARY} ) + target_link_libraries( osrm-prepare ${CoordinateGlob} ) ENDIF () include_directories(${LUA_INCLUDE_DIR}) - find_package( LibXml2 REQUIRED ) include_directories(${LIBXML2_INCLUDE_DIR}) target_link_libraries (osrm-extract ${LIBXML2_LIBRARIES}) @@ -185,12 +186,6 @@ include_directories(${OSMPBF_INCLUDE_DIR}) target_link_libraries (osrm-extract ${OSMPBF_LIBRARY}) target_link_libraries (osrm-prepare ${OSMPBF_LIBRARY}) -install (TARGETS osrm-extract DESTINATION bin) -install (TARGETS osrm-prepare DESTINATION bin) -install (TARGETS osrm-datastore DESTINATION bin) -install (TARGETS osrm-routed DESTINATION bin) -install (TARGETS OSRM DESTINATION lib) - if(WITH_TOOLS) message(STATUS "Activating OSRM internal tools") find_package( GDAL ) @@ -198,11 +193,11 @@ if(WITH_TOOLS) add_executable(osrm-components Tools/componentAnalysis.cpp) include_directories(${GDAL_INCLUDE_DIR}) target_link_libraries( - osrm-components ${GDAL_LIBRARIES} ${Boost_LIBRARIES} UUID GITDESCRIPTION + osrm-components ${GDAL_LIBRARIES} ${Boost_LIBRARIES} UUID GITDESCRIPTION ${CoordinateGlob} ) endif(GDAL_FOUND) add_executable ( osrm-cli Tools/simpleclient.cpp) - target_link_libraries( osrm-cli ${Boost_LIBRARIES} OSRM UUID GITDESCRIPTION ) + target_link_libraries( osrm-cli ${Boost_LIBRARIES} OSRM UUID GITDESCRIPTION) add_executable ( osrm-io-benchmark Tools/io-benchmark.cpp ) target_link_libraries( osrm-io-benchmark ${Boost_LIBRARIES} GITDESCRIPTION) add_executable ( osrm-unlock-all Tools/unlock_all_mutexes.cpp ) @@ -211,3 +206,9 @@ if(WITH_TOOLS) target_link_libraries( osrm-unlock-all rt ) endif(UNIX AND NOT APPLE) endif(WITH_TOOLS) + +install (TARGETS osrm-extract DESTINATION bin) +install (TARGETS osrm-prepare DESTINATION bin) +install (TARGETS osrm-datastore DESTINATION bin) +install (TARGETS osrm-routed DESTINATION bin) +install (TARGETS OSRM DESTINATION lib) diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index 9d56c9ee3..e6cce3a44 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -27,6 +27,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "EdgeBasedGraphFactory.h" +#include "../Util/ComputeAngle.h" + //TODO: CompressionWorker //TODO: EdgeBasedEdgeGenerator diff --git a/DataStructures/Coordinate.cpp b/DataStructures/Coordinate.cpp new file mode 100644 index 000000000..e90a96625 --- /dev/null +++ b/DataStructures/Coordinate.cpp @@ -0,0 +1,162 @@ +/* + +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 "Coordinate.h" +#include "../Util/StringUtil.h" + +#include +#include +#include + +FixedPointCoordinate::FixedPointCoordinate() + : lat(INT_MIN), + lon(INT_MIN) +{ } + +FixedPointCoordinate::FixedPointCoordinate(int lat, int lon) + : lat(lat), + lon(lon) +{ } + +void FixedPointCoordinate::Reset() { + lat = INT_MIN; + lon = INT_MIN; +} +bool FixedPointCoordinate::isSet() const { + return (INT_MIN != lat) && (INT_MIN != lon); +} +bool FixedPointCoordinate::isValid() const { + if( + lat > 90*COORDINATE_PRECISION || + lat < -90*COORDINATE_PRECISION || + lon > 180*COORDINATE_PRECISION || + lon < -180*COORDINATE_PRECISION + ) { + return false; + } + return true; +} +bool FixedPointCoordinate::operator==(const FixedPointCoordinate & other) const { + return lat == other.lat && lon == other.lon; +} + +double FixedPointCoordinate::ApproximateDistance( + const int lat1, + const int lon1, + const int lat2, + const int lon2 +) { + BOOST_ASSERT(lat1 != INT_MIN); + BOOST_ASSERT(lon1 != INT_MIN); + BOOST_ASSERT(lat2 != INT_MIN); + BOOST_ASSERT(lon2 != INT_MIN); + double RAD = 0.017453292519943295769236907684886; + double lt1 = lat1/COORDINATE_PRECISION; + double ln1 = lon1/COORDINATE_PRECISION; + double lt2 = lat2/COORDINATE_PRECISION; + double ln2 = lon2/COORDINATE_PRECISION; + double dlat1=lt1*(RAD); + + double dlong1=ln1*(RAD); + double dlat2=lt2*(RAD); + double dlong2=ln2*(RAD); + + double dLong=dlong1-dlong2; + double dLat=dlat1-dlat2; + + double aHarv= pow(sin(dLat/2.0),2.0)+cos(dlat1)*cos(dlat2)*pow(sin(dLong/2.),2); + double cHarv=2.*atan2(sqrt(aHarv),sqrt(1.0-aHarv)); + //earth radius varies between 6,356.750-6,378.135 km (3,949.901-3,963.189mi) + //The IUGG value for the equatorial radius is 6378.137 km (3963.19 miles) + const double earth=6372797.560856; + double distance=earth*cHarv; + return distance; +} + +double FixedPointCoordinate::ApproximateDistance( + const FixedPointCoordinate &c1, + const FixedPointCoordinate &c2 +) { + return ApproximateDistance( c1.lat, c1.lon, c2.lat, c2.lon ); +} + +double FixedPointCoordinate::ApproximateEuclideanDistance( + const FixedPointCoordinate &c1, + const FixedPointCoordinate &c2 +) { + BOOST_ASSERT(c1.lat != INT_MIN); + BOOST_ASSERT(c1.lon != INT_MIN); + BOOST_ASSERT(c2.lat != INT_MIN); + BOOST_ASSERT(c2.lon != INT_MIN); + const double RAD = 0.017453292519943295769236907684886; + const double lat1 = (c1.lat/COORDINATE_PRECISION)*RAD; + const double lon1 = (c1.lon/COORDINATE_PRECISION)*RAD; + const double lat2 = (c2.lat/COORDINATE_PRECISION)*RAD; + const double lon2 = (c2.lon/COORDINATE_PRECISION)*RAD; + + const double x = (lon2-lon1) * cos((lat1+lat2)/2.); + const double y = (lat2-lat1); + const double earthRadius = 6372797.560856; + const double d = sqrt(x*x + y*y) * earthRadius; + return d; +} + +void FixedPointCoordinate::convertInternalLatLonToString( + const int value, + std::string & output +) { + char buffer[100]; + buffer[11] = 0; // zero termination + char* string = printInt< 11, 6 >( buffer, value ); + output = string; +} + +void FixedPointCoordinate::convertInternalCoordinateToString( + const FixedPointCoordinate & coord, + std::string & output +) { + std::string tmp; + tmp.reserve(23); + convertInternalLatLonToString(coord.lon, tmp); + output = tmp; + output += ","; + convertInternalLatLonToString(coord.lat, tmp); + output += tmp; +} + +void FixedPointCoordinate::convertInternalReversedCoordinateToString( + const FixedPointCoordinate & coord, + std::string & output +) { + std::string tmp; + tmp.reserve(23); + convertInternalLatLonToString(coord.lat, tmp); + output = tmp; + output += ","; + convertInternalLatLonToString(coord.lon, tmp); + output += tmp; +} diff --git a/DataStructures/Coordinate.h b/DataStructures/Coordinate.h index 04380f1ec..1f7a27a28 100644 --- a/DataStructures/Coordinate.h +++ b/DataStructures/Coordinate.h @@ -28,13 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef FIXED_POINT_COORDINATE_H_ #define FIXED_POINT_COORDINATE_H_ -#include "../DataStructures/MercatorUtil.h" -#include "../Util/StringUtil.h" - -#include -#include -#include - #include static const double COORDINATE_PRECISION = 1000000.; @@ -42,30 +35,45 @@ static const double COORDINATE_PRECISION = 1000000.; struct FixedPointCoordinate { int lat; int lon; - FixedPointCoordinate () : lat(INT_MIN), lon(INT_MIN) {} - explicit FixedPointCoordinate (int lat, int lon) : lat(lat) , lon(lon) {} - void Reset() { - lat = INT_MIN; - lon = INT_MIN; - } - bool isSet() const { - return (INT_MIN != lat) && (INT_MIN != lon); - } - inline bool isValid() const { - if( - lat > 90*COORDINATE_PRECISION || - lat < -90*COORDINATE_PRECISION || - lon > 180*COORDINATE_PRECISION || - lon < -180*COORDINATE_PRECISION - ) { - return false; - } - return true; - } - bool operator==(const FixedPointCoordinate & other) const { - return lat == other.lat && lon == other.lon; - } + FixedPointCoordinate(); + explicit FixedPointCoordinate (int lat, int lon); + void Reset(); + bool isSet() const; + bool isValid() const; + bool operator==(const FixedPointCoordinate & other) const; + + static double ApproximateDistance( + const int lat1, + const int lon1, + const int lat2, + const int lon2 + ); + + static double ApproximateDistance( + const FixedPointCoordinate & c1, + const FixedPointCoordinate & c2 + ); + + static double ApproximateEuclideanDistance( + const FixedPointCoordinate & c1, + const FixedPointCoordinate & c2 + ); + + static void convertInternalLatLonToString( + const int value, + std::string & output + ); + + static void convertInternalCoordinateToString( + const FixedPointCoordinate & coord, + std::string & output + ); + + static void convertInternalReversedCoordinateToString( + const FixedPointCoordinate & coord, + std::string & output + ); }; inline std::ostream & operator<<(std::ostream & out, const FixedPointCoordinate & c){ @@ -73,98 +81,4 @@ inline std::ostream & operator<<(std::ostream & out, const FixedPointCoordinate return out; } -inline double ApproximateDistance( const int lat1, const int lon1, const int lat2, const int lon2 ) { - BOOST_ASSERT(lat1 != INT_MIN); - BOOST_ASSERT(lon1 != INT_MIN); - BOOST_ASSERT(lat2 != INT_MIN); - BOOST_ASSERT(lon2 != INT_MIN); - double RAD = 0.017453292519943295769236907684886; - double lt1 = lat1/COORDINATE_PRECISION; - double ln1 = lon1/COORDINATE_PRECISION; - double lt2 = lat2/COORDINATE_PRECISION; - double ln2 = lon2/COORDINATE_PRECISION; - double dlat1=lt1*(RAD); - - double dlong1=ln1*(RAD); - double dlat2=lt2*(RAD); - double dlong2=ln2*(RAD); - - double dLong=dlong1-dlong2; - double dLat=dlat1-dlat2; - - double aHarv= pow(sin(dLat/2.0),2.0)+cos(dlat1)*cos(dlat2)*pow(sin(dLong/2.),2); - double cHarv=2.*atan2(sqrt(aHarv),sqrt(1.0-aHarv)); - //earth's radius from wikipedia varies between 6,356.750 km — 6,378.135 km (˜3,949.901 — 3,963.189 miles) - //The IUGG value for the equatorial radius of the Earth is 6378.137 km (3963.19 mile) - const double earth=6372797.560856;//I am doing miles, just change this to radius in kilometers to get distances in km - double distance=earth*cHarv; - return distance; -} - -inline double ApproximateDistance(const FixedPointCoordinate &c1, const FixedPointCoordinate &c2) { - return ApproximateDistance( c1.lat, c1.lon, c2.lat, c2.lon ); -} - -inline double ApproximateEuclideanDistance(const FixedPointCoordinate &c1, const FixedPointCoordinate &c2) { - BOOST_ASSERT(c1.lat != INT_MIN); - BOOST_ASSERT(c1.lon != INT_MIN); - BOOST_ASSERT(c2.lat != INT_MIN); - BOOST_ASSERT(c2.lon != INT_MIN); - const double RAD = 0.017453292519943295769236907684886; - const double lat1 = (c1.lat/COORDINATE_PRECISION)*RAD; - const double lon1 = (c1.lon/COORDINATE_PRECISION)*RAD; - const double lat2 = (c2.lat/COORDINATE_PRECISION)*RAD; - const double lon2 = (c2.lon/COORDINATE_PRECISION)*RAD; - - const double x = (lon2-lon1) * cos((lat1+lat2)/2.); - const double y = (lat2-lat1); - const double earthRadius = 6372797.560856; - const double d = sqrt(x*x + y*y) * earthRadius; - return d; -} - -static inline void convertInternalLatLonToString(const int value, std::string & output) { - char buffer[100]; - buffer[11] = 0; // zero termination - char* string = printInt< 11, 6 >( buffer, value ); - output = string; -} - -static inline void convertInternalCoordinateToString(const FixedPointCoordinate & coord, std::string & output) { - std::string tmp; - tmp.reserve(23); - convertInternalLatLonToString(coord.lon, tmp); - output = tmp; - output += ","; - convertInternalLatLonToString(coord.lat, tmp); - output += tmp; -} -static inline void convertInternalReversedCoordinateToString(const FixedPointCoordinate & coord, std::string & output) { - std::string tmp; - tmp.reserve(23); - convertInternalLatLonToString(coord.lat, tmp); - output = tmp; - output += ","; - convertInternalLatLonToString(coord.lon, tmp); - output += tmp; -} - - -/* Get angle of line segment (A,C)->(C,B), atan2 magic, formerly cosine theorem*/ -template -static inline double GetAngleBetweenThreeFixedPointCoordinates ( - const CoordinateT & A, - const CoordinateT & C, - const CoordinateT & B -) { - const double v1x = (A.lon - C.lon)/COORDINATE_PRECISION; - const double v1y = lat2y(A.lat/COORDINATE_PRECISION) - lat2y(C.lat/COORDINATE_PRECISION); - const double v2x = (B.lon - C.lon)/COORDINATE_PRECISION; - const double v2y = lat2y(B.lat/COORDINATE_PRECISION) - lat2y(C.lat/COORDINATE_PRECISION); - - double angle = (atan2(v2y,v2x) - atan2(v1y,v1x) )*180/M_PI; - while(angle < 0) - angle += 360; - return angle; -} #endif /* FIXED_POINT_COORDINATE_H_ */ diff --git a/DataStructures/EdgeBasedNode.h b/DataStructures/EdgeBasedNode.h index 8fafed71c..117758c13 100644 --- a/DataStructures/EdgeBasedNode.h +++ b/DataStructures/EdgeBasedNode.h @@ -1,6 +1,8 @@ #ifndef EDGE_BASED_NODE_H #define EDGE_BASED_NODE_H +#include + #include "Coordinate.h" struct EdgeBasedNode { diff --git a/DataStructures/MercatorUtil.h b/DataStructures/MercatorUtil.h deleted file mode 100644 index 633a749d0..000000000 --- a/DataStructures/MercatorUtil.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - -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. - -*/ - -#ifndef MERCATORUTIL_H_ -#define MERCATORUTIL_H_ - -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -inline double y2lat(double a) { - return 180./M_PI * (2. * atan(exp(a*M_PI/180.)) - M_PI/2.); -} - -inline double lat2y(double a) { - return 180./M_PI * log(tan(M_PI/4.+a*(M_PI/180.)/2.)); -} - -#endif /* MERCATORUTIL_H_ */ diff --git a/DataStructures/StaticRTree.h b/DataStructures/StaticRTree.h index ed1e5d4bb..1b397270c 100644 --- a/DataStructures/StaticRTree.h +++ b/DataStructures/StaticRTree.h @@ -31,11 +31,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Coordinate.h" #include "DeallocatingVector.h" #include "HilbertValue.h" -#include "MercatorUtil.h" #include "PhantomNodes.h" #include "SharedMemoryFactory.h" #include "SharedMemoryVectorWrapper.h" +#include "../Util/MercatorUtil.h" #include "../Util/OSRMException.h" #include "../Util/SimpleLogger.h" #include "../Util/TimingUtil.h" @@ -140,7 +140,7 @@ public: double min_dist = std::numeric_limits::max(); min_dist = std::min( min_dist, - ApproximateDistance( + FixedPointCoordinate::ApproximateDistance( location.lat, location.lon, max_lat, @@ -149,7 +149,7 @@ public: ); min_dist = std::min( min_dist, - ApproximateDistance( + FixedPointCoordinate::ApproximateDistance( location.lat, location.lon, max_lat, @@ -158,7 +158,7 @@ public: ); min_dist = std::min( min_dist, - ApproximateDistance( + FixedPointCoordinate::ApproximateDistance( location.lat, location.lon, min_lat, @@ -167,7 +167,7 @@ public: ); min_dist = std::min( min_dist, - ApproximateDistance( + FixedPointCoordinate::ApproximateDistance( location.lat, location.lon, min_lat, @@ -188,32 +188,32 @@ public: min_max_dist = std::min( min_max_dist, std::max( - ApproximateDistance(location, upper_left ), - ApproximateDistance(location, upper_right) + FixedPointCoordinate::ApproximateDistance(location, upper_left ), + FixedPointCoordinate::ApproximateDistance(location, upper_right) ) ); min_max_dist = std::min( min_max_dist, std::max( - ApproximateDistance(location, upper_right), - ApproximateDistance(location, lower_right) + FixedPointCoordinate::ApproximateDistance(location, upper_right), + FixedPointCoordinate::ApproximateDistance(location, lower_right) ) ); min_max_dist = std::min( min_max_dist, std::max( - ApproximateDistance(location, lower_right), - ApproximateDistance(location, lower_left ) + FixedPointCoordinate::ApproximateDistance(location, lower_right), + FixedPointCoordinate::ApproximateDistance(location, lower_left ) ) ); min_max_dist = std::min( min_max_dist, std::max( - ApproximateDistance(location, lower_left ), - ApproximateDistance(location, upper_left ) + FixedPointCoordinate::ApproximateDistance(location, lower_left ), + FixedPointCoordinate::ApproximateDistance(location, upper_left ) ) ); return min_max_dist; @@ -676,7 +676,7 @@ public: continue; } - double current_minimum_distance = ApproximateDistance( + double current_minimum_distance = FixedPointCoordinate::ApproximateDistance( input_coordinate.lat, input_coordinate.lon, current_edge.lat1, @@ -690,7 +690,7 @@ public: found_a_nearest_edge = true; } - current_minimum_distance = ApproximateDistance( + current_minimum_distance = FixedPointCoordinate::ApproximateDistance( input_coordinate.lat, input_coordinate.lon, current_edge.lat2, @@ -856,8 +856,8 @@ public: } const double ratio = (found_a_nearest_edge ? - std::min(1., ApproximateDistance(current_start_coordinate, - result_phantom_node.location)/ApproximateDistance(current_start_coordinate, current_end_coordinate) + std::min(1., FixedPointCoordinate::ApproximateDistance(current_start_coordinate, + result_phantom_node.location)/FixedPointCoordinate::ApproximateDistance(current_start_coordinate, current_end_coordinate) ) : 0 ); result_phantom_node.weight1 *= ratio; @@ -899,7 +899,12 @@ private: thread_local_rtree_stream->read((char *)&result_node, sizeof(LeafNode)); } - inline bool EdgesAreEquivalent(const FixedPointCoordinate & a, const FixedPointCoordinate & b, const FixedPointCoordinate & c, const FixedPointCoordinate & d) const { + inline bool EdgesAreEquivalent( + const FixedPointCoordinate & a, + const FixedPointCoordinate & b, + const FixedPointCoordinate & c, + const FixedPointCoordinate & d + ) const { return (a == b && c == d) || (a == c && b == d) || (a == d && b == c); } diff --git a/Descriptors/DescriptionFactory.h b/Descriptors/DescriptionFactory.h index c5780bcb2..549191c79 100644 --- a/Descriptors/DescriptionFactory.h +++ b/Descriptors/DescriptionFactory.h @@ -106,7 +106,7 @@ public: /** starts at index 1 */ pathDescription[0].length = 0; for(unsigned i = 1; i < pathDescription.size(); ++i) { - pathDescription[i].length = ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location); + pathDescription[i].length = FixedPointCoordinate::ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location); } // std::string string0 = facade->GetEscapedNameForNameID(pathDescription[0].name_id); diff --git a/Descriptors/GPXDescriptor.h b/Descriptors/GPXDescriptor.h index af9feca04..82a435200 100644 --- a/Descriptors/GPXDescriptor.h +++ b/Descriptors/GPXDescriptor.h @@ -64,12 +64,12 @@ public: bool found_route = (raw_route.lengthOfShortestPath != INT_MAX) && (raw_route.unpacked_path_segments[0].size()); if( found_route ) { - convertInternalLatLonToString( + FixedPointCoordinate::convertInternalLatLonToString( phantom_node_list.startPhantom.location.lat, tmp ); reply.content.push_back("GetCoordinateOfNode(pathData.node); - convertInternalLatLonToString(current.lat, tmp); + FixedPointCoordinate::convertInternalLatLonToString(current.lat, tmp); reply.content.push_back(""); } - // TODO: Add the via point or the end coordinate - convertInternalLatLonToString( + // Add the via point or the end coordinate + FixedPointCoordinate::convertInternalLatLonToString( phantom_node_list.targetPhantom.location.lat, tmp ); reply.content.push_back("targetCoord.lat = node_iterator->lat; edge_iterator->targetCoord.lon = node_iterator->lon; - const double distance = ApproximateDistance( + const double distance = FixedPointCoordinate::ApproximateDistance( edge_iterator->startCoord.lat, edge_iterator->startCoord.lon, node_iterator->lat, diff --git a/Plugins/LocatePlugin.h b/Plugins/LocatePlugin.h index 58e2fd0fc..7994b0edf 100644 --- a/Plugins/LocatePlugin.h +++ b/Plugins/LocatePlugin.h @@ -81,10 +81,10 @@ public: reply.status = http::Reply::ok; reply.content.push_back ("\"status\":0,"); reply.content.push_back ("\"mapped_coordinate\":"); - convertInternalLatLonToString(result.lat, tmp); + FixedPointCoordinate::convertInternalLatLonToString(result.lat, tmp); reply.content.push_back("["); reply.content.push_back(tmp); - convertInternalLatLonToString(result.lon, tmp); + FixedPointCoordinate::convertInternalLatLonToString(result.lon, tmp); reply.content.push_back(","); reply.content.push_back(tmp); reply.content.push_back("]"); diff --git a/Plugins/NearestPlugin.h b/Plugins/NearestPlugin.h index 1a570bd6d..d3a8ce11b 100644 --- a/Plugins/NearestPlugin.h +++ b/Plugins/NearestPlugin.h @@ -85,9 +85,9 @@ public: reply.content.push_back("\"mapped_coordinate\":"); reply.content.push_back("["); if(UINT_MAX != result.edgeBasedNode) { - convertInternalLatLonToString(result.location.lat, temp_string); + FixedPointCoordinate::convertInternalLatLonToString(result.location.lat, temp_string); reply.content.push_back(temp_string); - convertInternalLatLonToString(result.location.lon, temp_string); + FixedPointCoordinate::convertInternalLatLonToString(result.location.lon, temp_string); reply.content.push_back(","); reply.content.push_back(temp_string); } diff --git a/Server/RequestHandler.h b/Server/RequestHandler.h index 1250230c0..c19533182 100644 --- a/Server/RequestHandler.h +++ b/Server/RequestHandler.h @@ -39,11 +39,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include class RequestHandler : private boost::noncopyable { + public: typedef APIGrammar APIGrammarParser; - explicit RequestHandler(); + + RequestHandler(); + void handle_request(const http::Request& req, http::Reply& rep); void RegisterRoutingMachine(OSRM * osrm); + private: OSRM * routing_machine; }; diff --git a/Tools/simpleclient.cpp b/Tools/simpleclient.cpp index 702aabf0a..5d3cd2686 100644 --- a/Tools/simpleclient.cpp +++ b/Tools/simpleclient.cpp @@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../Util/ProgramOptions.h" #include "../Util/SimpleLogger.h" +#include #include #include