Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 896445a337 | |||
| 8c21e1267e | |||
| ad3fd46da5 | |||
| 62f0e11bfa | |||
| 03d653c0bb | |||
| cbfb055f81 | |||
| 2288704bb5 | |||
| 97dcf4eef9 |
@@ -29,6 +29,7 @@
|
||||
- fixed a bug that could result in crashes when leaving a ferry directly onto a motorway ramp
|
||||
- fixed a bug in the tile plugin that resulted in discovering invalid edges for connections
|
||||
- improved error messages when missing files during traffic updates (#3114)
|
||||
- For single coordinate geometries the GeoJSON `Point` encoding was broken. We now always emit `LineString`s even in the one-coordinate-case (backwards compatible) (#3425)
|
||||
- Debug Tiles
|
||||
- Added support for turn penalties
|
||||
- Internals
|
||||
|
||||
+1
-1
@@ -519,7 +519,7 @@ step.
|
||||
|------------|--------------------------------------------------------------------|
|
||||
| polyline | [polyline](https://www.npmjs.com/package/polyline) with precision 5 in [latitude,longitude] encoding |
|
||||
| polyline6 | [polyline](https://www.npmjs.com/package/polyline) with precision 6 in [latitude,longitude] encoding |
|
||||
| geojson | [GeoJSON `LineString`](http://geojson.org/geojson-spec.html#linestring) or [GeoJSON `Point`](http://geojson.org/geojson-spec.html#point) if it is only one coordinate (not wrapped by a GeoJSON feature)|
|
||||
| geojson | [GeoJSON `LineString`](http://geojson.org/geojson-spec.html#linestring) |
|
||||
|
||||
- `name`: The name of the way along which travel proceeds.
|
||||
- `ref`: A reference number or code for the way. Optionally included, if ref data is available for the given way.
|
||||
|
||||
@@ -54,22 +54,25 @@ util::json::Object makeGeoJSONGeometry(ForwardIter begin, ForwardIter end)
|
||||
auto num_coordinates = std::distance(begin, end);
|
||||
BOOST_ASSERT(num_coordinates != 0);
|
||||
util::json::Object geojson;
|
||||
geojson.values["type"] = "LineString";
|
||||
util::json::Array coordinates;
|
||||
if (num_coordinates > 1)
|
||||
{
|
||||
geojson.values["type"] = "LineString";
|
||||
util::json::Array coordinates;
|
||||
coordinates.values.reserve(num_coordinates);
|
||||
std::transform(
|
||||
begin, end, std::back_inserter(coordinates.values), &detail::coordinateToLonLat);
|
||||
geojson.values["coordinates"] = std::move(coordinates);
|
||||
auto into = std::back_inserter(coordinates.values);
|
||||
std::transform(begin, end, into, &detail::coordinateToLonLat);
|
||||
}
|
||||
else if (num_coordinates > 0)
|
||||
{
|
||||
geojson.values["type"] = "Point";
|
||||
util::json::Array coordinates;
|
||||
coordinates.values.push_back(detail::coordinateToLonLat(*begin));
|
||||
geojson.values["coordinates"] = std::move(coordinates);
|
||||
// For a single location we create a [location, location] LineString
|
||||
// instead of a single Point making the GeoJSON output consistent.
|
||||
coordinates.values.reserve(2);
|
||||
auto location = detail::coordinateToLonLat(*begin);
|
||||
coordinates.values.push_back(location);
|
||||
coordinates.values.push_back(location);
|
||||
}
|
||||
geojson.values["coordinates"] = std::move(coordinates);
|
||||
|
||||
return geojson;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,22 +46,27 @@ class SharedMemoryDataFacade : public ContiguousInternalMemoryDataFacadeBase
|
||||
// if this returns false this is still in use
|
||||
if (exclusive_lock.try_lock())
|
||||
{
|
||||
// Now check if this is still the newest dataset
|
||||
const boost::interprocess::sharable_lock<boost::interprocess::named_upgradable_mutex>
|
||||
lock(shared_barriers->current_regions_mutex);
|
||||
|
||||
auto shared_regions = storage::makeSharedMemory(storage::CURRENT_REGIONS);
|
||||
const auto current_timestamp =
|
||||
static_cast<const storage::SharedDataTimestamp *>(shared_regions->Ptr());
|
||||
|
||||
if (current_timestamp->timestamp == shared_timestamp)
|
||||
if (storage::SharedMemory::RegionExists(data_region))
|
||||
{
|
||||
util::Log(logDEBUG) << "Retaining data with shared timestamp " << shared_timestamp;
|
||||
}
|
||||
else
|
||||
{
|
||||
storage::SharedMemory::Remove(data_region);
|
||||
storage::SharedMemory::Remove(layout_region);
|
||||
BOOST_ASSERT(storage::SharedMemory::RegionExists(layout_region));
|
||||
|
||||
// Now check if this is still the newest dataset
|
||||
const boost::interprocess::sharable_lock<boost::interprocess::named_upgradable_mutex>
|
||||
lock(shared_barriers->current_regions_mutex);
|
||||
|
||||
auto shared_regions = storage::makeSharedMemory(storage::CURRENT_REGIONS);
|
||||
const auto current_timestamp =
|
||||
static_cast<const storage::SharedDataTimestamp *>(shared_regions->Ptr());
|
||||
|
||||
if (current_timestamp->timestamp == shared_timestamp)
|
||||
{
|
||||
util::Log(logDEBUG) << "Retaining data with shared timestamp " << shared_timestamp;
|
||||
}
|
||||
else
|
||||
{
|
||||
storage::SharedMemory::Remove(data_region);
|
||||
storage::SharedMemory::Remove(layout_region);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ template <typename IntersectionType> // works with Intersection and Intersection
|
||||
std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
const IntersectionType &intersection) const
|
||||
{
|
||||
using Road = typename IntersectionType::value_type;
|
||||
using EdgeData = osrm::util::NodeBasedDynamicGraph::EdgeData;
|
||||
using osrm::util::angularDeviation;
|
||||
|
||||
@@ -269,7 +270,7 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
|
||||
// checks if continue candidates are sharp turns
|
||||
const bool all_continues_are_narrow = [&]() {
|
||||
return std::count_if(begin(intersection), end(intersection), [&](const auto &road) {
|
||||
return std::count_if(begin(intersection), end(intersection), [&](const Road &road) {
|
||||
const EdgeData &road_data = node_based_graph.GetEdgeData(road.eid);
|
||||
const double &road_angle = angularDeviation(road.angle, STRAIGHT_ANGLE);
|
||||
return IsContinueRoad(road_data) && (road_angle < NARROW_TURN_ANGLE);
|
||||
|
||||
@@ -161,7 +161,7 @@ class FileReader
|
||||
{
|
||||
std::getline(input_stream, thisline);
|
||||
}
|
||||
catch (const std::ios_base::failure &e)
|
||||
catch (const std::ios_base::failure & /*e*/)
|
||||
{
|
||||
// EOF is OK here, everything else, re-throw
|
||||
if (!input_stream.eof())
|
||||
|
||||
@@ -63,11 +63,11 @@ class GeojsonLogger
|
||||
// make sure to syncronize logging output, our writing should be sequential
|
||||
std::lock_guard<std::mutex> guard(lock);
|
||||
|
||||
// if there is no logfile, we cannot write
|
||||
// if there is no logfile, we cannot write (possible reason: the guard might be out of scope
|
||||
// (e.g. if it is anonymous))
|
||||
if (!ofs.is_open() || (nullptr == policy))
|
||||
{
|
||||
// this can only happend between two guards when concurrent writing occurs
|
||||
return false;
|
||||
throw util::exception("Trying to use the geojson printer without an open logger.");
|
||||
}
|
||||
|
||||
// use our policy to convert the arguments into geojson, this can be done in parallel
|
||||
|
||||
+13
-6
@@ -1,11 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# here we set up the node version on the fly. currently only node 4, but can be used for more values if need be
|
||||
# This is done manually so that the build works the same on OS X
|
||||
rm -rf ~/.nvm/ && git clone --depth 1 --branch v0.30.1 https://github.com/creationix/nvm.git ~/.nvm
|
||||
source ~/.nvm/nvm.sh
|
||||
nvm install $1
|
||||
nvm use $1
|
||||
NODE_HOME=$HOME/node
|
||||
export NODE_HOME
|
||||
mkdir ${NODE_HOME}
|
||||
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
|
||||
curl https://s3.amazonaws.com/mapbox/apps/install-node/v2.0.0/run | NV=4.4.2 NP=darwin-x64 OD=${NODE_HOME} sh
|
||||
else
|
||||
curl https://s3.amazonaws.com/mapbox/apps/install-node/v2.0.0/run | NV=4.4.2 NP=linux-x64 OD=${NODE_HOME} sh
|
||||
fi
|
||||
|
||||
PATH="${NODE_HOME}/bin:$PATH"
|
||||
export PATH
|
||||
node --version
|
||||
npm --version
|
||||
which node
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ target_include_directories(util-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(engine-tests ${ENGINE_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(extractor-tests ${EXTRACTOR_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(library-tests osrm ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(library-tests osrm ${ENGINE_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(server-tests osrm ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(util-tests ${UTIL_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "coordinates.hpp"
|
||||
#include "equal_json.hpp"
|
||||
|
||||
#include "engine/api/json_factory.hpp"
|
||||
#include "osrm/coordinate.hpp"
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(json)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_json_linestring)
|
||||
{
|
||||
const std::vector<util::Coordinate> locations{get_dummy_location(), //
|
||||
get_dummy_location(), //
|
||||
get_dummy_location()}; //
|
||||
|
||||
auto geom = engine::api::json::makeGeoJSONGeometry(begin(locations), end(locations));
|
||||
|
||||
const auto type = geom.values["type"].get<util::json::String>().value;
|
||||
BOOST_CHECK_EQUAL(type, "LineString");
|
||||
|
||||
const auto coords = geom.values["coordinates"].get<util::json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(coords.size(), 3); // array of three location arrays
|
||||
|
||||
for (const auto each : coords)
|
||||
{
|
||||
const auto loc = each.get<util::json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(loc.size(), 2);
|
||||
|
||||
const auto lon = loc[0].get<util::json::Number>().value;
|
||||
const auto lat = loc[1].get<util::json::Number>().value;
|
||||
|
||||
(void)lon;
|
||||
(void)lat;
|
||||
// cast fails if type do not match
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_json_single_point)
|
||||
{
|
||||
const std::vector<util::Coordinate> locations{get_dummy_location()};
|
||||
|
||||
auto geom = engine::api::json::makeGeoJSONGeometry(begin(locations), end(locations));
|
||||
|
||||
const auto type = geom.values["type"].get<util::json::String>().value;
|
||||
BOOST_CHECK_EQUAL(type, "LineString");
|
||||
|
||||
const auto coords = geom.values["coordinates"].get<util::json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(coords.size(), 2); // array of two location arrays
|
||||
|
||||
for (const auto each : coords)
|
||||
{
|
||||
const auto loc = each.get<util::json::Array>().values;
|
||||
BOOST_CHECK_EQUAL(loc.size(), 2);
|
||||
|
||||
const auto lon = loc[0].get<util::json::Number>().value;
|
||||
const auto lat = loc[1].get<util::json::Number>().value;
|
||||
|
||||
(void)lon;
|
||||
(void)lat;
|
||||
// cast fails if type do not match
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user