Merge commit '0c6dee4befebf823d839d1092bcae79afbf4f12e' into merge/libosmium-2.11.0
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace osmium {
|
||||
* class given as template argument.
|
||||
*
|
||||
* @tparam TAssembler Multipolygon Assembler class.
|
||||
* @pre The Ids of all objects must be unique in the input data.
|
||||
*/
|
||||
template <typename TAssembler>
|
||||
class MultipolygonCollector : public osmium::relations::Collector<MultipolygonCollector<TAssembler>, false, true, false> {
|
||||
@@ -87,7 +88,7 @@ namespace osmium {
|
||||
|
||||
void flush_output_buffer() {
|
||||
if (this->callback()) {
|
||||
osmium::memory::Buffer buffer(initial_output_buffer_size);
|
||||
osmium::memory::Buffer buffer{initial_output_buffer_size};
|
||||
using std::swap;
|
||||
swap(buffer, m_output_buffer);
|
||||
this->callback()(std::move(buffer));
|
||||
@@ -195,7 +196,7 @@ namespace osmium {
|
||||
}
|
||||
|
||||
osmium::memory::Buffer read() {
|
||||
osmium::memory::Buffer buffer(initial_output_buffer_size, osmium::memory::Buffer::auto_grow::yes);
|
||||
osmium::memory::Buffer buffer{initial_output_buffer_size, osmium::memory::Buffer::auto_grow::yes};
|
||||
|
||||
using std::swap;
|
||||
swap(buffer, m_output_buffer);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -84,8 +84,8 @@ namespace osmium {
|
||||
|
||||
template <typename TSource, typename... THandlers>
|
||||
inline void apply_diff(TSource& source, THandlers&... handlers) {
|
||||
apply_diff(osmium::io::InputIterator<TSource, osmium::OSMObject> {source},
|
||||
osmium::io::InputIterator<TSource, osmium::OSMObject> {},
|
||||
apply_diff(osmium::io::InputIterator<TSource, osmium::OSMObject>{source},
|
||||
osmium::io::InputIterator<TSource, osmium::OSMObject>{},
|
||||
handlers...);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -104,7 +104,8 @@ auto _name_##_dispatch(THandler& handler, const osmium::_type_& object, long) ->
|
||||
}
|
||||
|
||||
template <typename THandler>
|
||||
void flush_dispatch(THandler&, long) {}
|
||||
void flush_dispatch(THandler&, long) {
|
||||
}
|
||||
|
||||
template <typename THandler>
|
||||
class HandlerWrapper : public HandlerWrapperBase {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+70
-8
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,7 +33,9 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <iosfwd>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include <osmium/osm/location.hpp>
|
||||
@@ -48,18 +50,71 @@ namespace osmium {
|
||||
double x;
|
||||
double y;
|
||||
|
||||
explicit Coordinates(double cx, double cy) noexcept : x(cx), y(cy) {
|
||||
/**
|
||||
* Default constructor creates invalid coordinates.
|
||||
*/
|
||||
Coordinates() noexcept :
|
||||
x(std::numeric_limits<double>::quiet_NaN()),
|
||||
y(std::numeric_limits<double>::quiet_NaN()) {
|
||||
}
|
||||
|
||||
Coordinates(const osmium::Location& location) : x(location.lon()), y(location.lat()) {
|
||||
/**
|
||||
* Create Coordinates from doubles. If any of them is NaN, the
|
||||
* coordinates are invalid.
|
||||
*/
|
||||
explicit Coordinates(double cx, double cy) noexcept :
|
||||
x(cx),
|
||||
y(cy) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Coordinates from a Location. Will throw
|
||||
* osmium::invalid_location if the location is not valid.
|
||||
*/
|
||||
Coordinates(const osmium::Location& location) :
|
||||
x(location.lon()),
|
||||
y(location.lat()) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Coordinates are invalid if they have been default constructed.
|
||||
*/
|
||||
bool valid() const noexcept {
|
||||
return !std::isnan(x) && !std::isnan(y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert coordinates to text and append to given string. If the
|
||||
* coordinate is invalid, the fixed string "invalid" will be
|
||||
* added to the string.
|
||||
*
|
||||
* @param s String to append the coordinates to.
|
||||
* @param infix Character to print between the two coordinates.
|
||||
* @param precision Number of digits after the decimal point the
|
||||
* coordinate will be rounded to.
|
||||
*/
|
||||
void append_to_string(std::string& s, const char infix, int precision) const {
|
||||
osmium::util::double2string(s, x, precision);
|
||||
s += infix;
|
||||
osmium::util::double2string(s, y, precision);
|
||||
if (valid()) {
|
||||
osmium::util::double2string(s, x, precision);
|
||||
s += infix;
|
||||
osmium::util::double2string(s, y, precision);
|
||||
} else {
|
||||
s.append("invalid");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert coordinates to text and append to given string. If the
|
||||
* coordinate is invalid, the fixed string "invalid" will be
|
||||
* added to the string between the prefix and suffix characters.
|
||||
*
|
||||
* @param s String to append the coordinates to.
|
||||
* @param prefix Character to print before the first coordinate.
|
||||
* @param infix Character to print between the two coordinates.
|
||||
* @param suffix Character to print after the second coordinate.
|
||||
* @param precision Number of digits after the decimal point the
|
||||
* coordinate will be rounded to.
|
||||
*/
|
||||
void append_to_string(std::string& s, const char prefix, const char infix, const char suffix, int precision) const {
|
||||
s += prefix;
|
||||
append_to_string(s, infix, precision);
|
||||
@@ -69,11 +124,18 @@ namespace osmium {
|
||||
}; // struct coordinates
|
||||
|
||||
/**
|
||||
* Compare whether two Coordinates are identical. Might not give the
|
||||
* right result if the coordinates have been the result of some
|
||||
* Check whether two Coordinates are equal. Invalid coordinates are
|
||||
* equal to other invalid coordinates but not equal to any valid
|
||||
* coordinates.
|
||||
*
|
||||
* Because this is comparing floating point values, it might not give
|
||||
* the right result if the coordinates have been the result of some
|
||||
* calculation that introduced rounding errors.
|
||||
*/
|
||||
inline bool operator==(const Coordinates& lhs, const Coordinates& rhs) noexcept {
|
||||
if (!lhs.valid() && !rhs.valid()) {
|
||||
return true;
|
||||
}
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
return lhs.x == rhs.x && lhs.y == rhs.y;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+3
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace osmium {
|
||||
|
||||
/**
|
||||
* Calculate distance in meters between two sets of coordinates.
|
||||
*
|
||||
* @pre @code c1.valid() && c2.valid() @endcode
|
||||
*/
|
||||
inline double distance(const osmium::geom::Coordinates& c1, const osmium::geom::Coordinates& c2) {
|
||||
double lonh = sin(deg_to_rad(c1.x - c2.x) * 0.5);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -53,10 +53,49 @@ namespace osmium {
|
||||
return earth_radius_for_epsg3857 * deg_to_rad(lon);
|
||||
}
|
||||
|
||||
inline double lat_to_y(double lat) { // not constexpr because math functions aren't
|
||||
inline double lat_to_y_with_tan(double lat) { // not constexpr because math functions aren't
|
||||
return earth_radius_for_epsg3857 * std::log(std::tan(osmium::geom::PI/4 + deg_to_rad(lat)/2));
|
||||
}
|
||||
|
||||
#ifdef OSMIUM_USE_SLOW_MERCATOR_PROJECTION
|
||||
inline double lat_to_y(double lat) {
|
||||
return lat_to_y_with_tan(lat);
|
||||
}
|
||||
#else
|
||||
|
||||
// This is a much faster implementation than the canonical
|
||||
// implementation using the tan() function. For details
|
||||
// see https://github.com/osmcode/mercator-projection .
|
||||
inline double lat_to_y(double lat) { // not constexpr because math functions aren't
|
||||
if (lat < -78.0 || lat > 78.0) {
|
||||
return lat_to_y_with_tan(lat);
|
||||
}
|
||||
|
||||
return earth_radius_for_epsg3857 *
|
||||
((((((((((-3.1112583378460085319e-23 * lat +
|
||||
2.0465852743943268009e-19) * lat +
|
||||
6.4905282018672673884e-18) * lat +
|
||||
-1.9685447939983315591e-14) * lat +
|
||||
-2.2022588158115104182e-13) * lat +
|
||||
5.1617537365509453239e-10) * lat +
|
||||
2.5380136069803016519e-9) * lat +
|
||||
-5.1448323697228488745e-6) * lat +
|
||||
-9.4888671473357768301e-6) * lat +
|
||||
1.7453292518154191887e-2) * lat)
|
||||
/
|
||||
((((((((((-1.9741136066814230637e-22 * lat +
|
||||
-1.258514031244679556e-20) * lat +
|
||||
4.8141483273572351796e-17) * lat +
|
||||
8.6876090870176172185e-16) * lat +
|
||||
-2.3298743439377541768e-12) * lat +
|
||||
-1.9300094785736130185e-11) * lat +
|
||||
4.3251609106864178231e-8) * lat +
|
||||
1.7301944508516974048e-7) * lat +
|
||||
-3.4554675198786337842e-4) * lat +
|
||||
-5.4367203601085991108e-4) * lat + 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
constexpr inline double x_to_lon(double x) {
|
||||
return rad_to_deg(x) / earth_radius_for_epsg3857;
|
||||
}
|
||||
@@ -73,10 +112,20 @@ namespace osmium {
|
||||
*/
|
||||
constexpr double MERCATOR_MAX_LAT = 85.0511288;
|
||||
|
||||
/**
|
||||
* Convert the coordinates from WGS84 lon/lat to web mercator.
|
||||
*
|
||||
* @pre @code c.valid() @endcode
|
||||
*/
|
||||
inline Coordinates lonlat_to_mercator(const Coordinates& c) {
|
||||
return Coordinates(detail::lon_to_x(c.x), detail::lat_to_y(c.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the coordinates from web mercator to WGS84 lon/lat.
|
||||
*
|
||||
* @pre @code c.valid() @endcode
|
||||
*/
|
||||
inline Coordinates mercator_to_lonlat(const Coordinates& c) {
|
||||
return Coordinates(detail::x_to_lon(c.x), detail::y_to_lat(c.y));
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+68
-14
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -47,14 +47,52 @@ namespace osmium {
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
inline T restrict_to_range(T value, T min, T max) {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
return value;
|
||||
inline constexpr const T& clamp(const T& value, const T& min, const T& max) {
|
||||
return value < min ? min : (max < value ? max : value);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* Returns the number of tiles (in each direction) for the given zoom
|
||||
* level.
|
||||
*/
|
||||
inline constexpr uint32_t num_tiles_in_zoom(uint32_t zoom) noexcept {
|
||||
return 1u << zoom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width or hight of a tile in web mercator coordinates for
|
||||
* the given zoom level.
|
||||
*/
|
||||
inline constexpr double tile_extent_in_zoom(uint32_t zoom) noexcept {
|
||||
return detail::max_coordinate_epsg3857 * 2 / num_tiles_in_zoom(zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tile x number from an x coordinate in web mercator
|
||||
* projection in the given zoom level. Tiles are numbered from left
|
||||
* to right.
|
||||
*/
|
||||
inline constexpr uint32_t mercx_to_tilex(uint32_t zoom, double x) noexcept {
|
||||
return static_cast<uint32_t>(detail::clamp<int32_t>(
|
||||
static_cast<int32_t>((x + detail::max_coordinate_epsg3857) / tile_extent_in_zoom(zoom)),
|
||||
0, num_tiles_in_zoom(zoom) -1
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tile y number from an y coordinate in web mercator
|
||||
* projection in the given zoom level. Tiles are numbered from top
|
||||
* to bottom.
|
||||
*/
|
||||
inline constexpr uint32_t mercy_to_tiley(uint32_t zoom, double y) noexcept {
|
||||
return static_cast<uint32_t>(detail::clamp<int32_t>(
|
||||
static_cast<int32_t>((detail::max_coordinate_epsg3857 - y) / tile_extent_in_zoom(zoom)),
|
||||
0, num_tiles_in_zoom(zoom) -1
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* A tile in the usual Mercator projection.
|
||||
*/
|
||||
@@ -77,10 +115,13 @@ namespace osmium {
|
||||
*
|
||||
* @pre @code zoom <= 30 && x < 2^zoom && y < 2^zoom @endcode
|
||||
*/
|
||||
explicit Tile(uint32_t zoom, uint32_t tx, uint32_t ty) noexcept : x(tx), y(ty), z(zoom) {
|
||||
explicit Tile(uint32_t zoom, uint32_t tx, uint32_t ty) noexcept :
|
||||
x(tx),
|
||||
y(ty),
|
||||
z(zoom) {
|
||||
assert(zoom <= 30u);
|
||||
assert(x < (1u << zoom));
|
||||
assert(y < (1u << zoom));
|
||||
assert(x < num_tiles_in_zoom(zoom));
|
||||
assert(y < num_tiles_in_zoom(zoom));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,11 +136,24 @@ namespace osmium {
|
||||
z(zoom) {
|
||||
assert(zoom <= 30u);
|
||||
assert(location.valid());
|
||||
const osmium::geom::Coordinates c = lonlat_to_mercator(location);
|
||||
const int32_t n = 1 << zoom;
|
||||
const double scale = detail::max_coordinate_epsg3857 * 2 / n;
|
||||
x = uint32_t(detail::restrict_to_range<int32_t>(int32_t((c.x + detail::max_coordinate_epsg3857) / scale), 0, n-1));
|
||||
y = uint32_t(detail::restrict_to_range<int32_t>(int32_t((detail::max_coordinate_epsg3857 - c.y) / scale), 0, n-1));
|
||||
const auto coordinates = lonlat_to_mercator(location);
|
||||
x = mercx_to_tilex(zoom, coordinates.x);
|
||||
y = mercy_to_tiley(zoom, coordinates.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a tile with the given zoom level that contains the given
|
||||
* coordinates in Mercator projection.
|
||||
*
|
||||
* The values are not checked for validity.
|
||||
*
|
||||
* @pre @code coordinates.valid() && zoom <= 30 @endcode
|
||||
*/
|
||||
explicit Tile(uint32_t zoom, const osmium::geom::Coordinates& coordinates) :
|
||||
z(zoom) {
|
||||
assert(zoom <= 30u);
|
||||
x = mercx_to_tilex(zoom, coordinates.x);
|
||||
y = mercy_to_tiley(zoom, coordinates.y);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +165,7 @@ namespace osmium {
|
||||
if (z > 30) {
|
||||
return false;
|
||||
}
|
||||
const uint32_t max = 1 << z;
|
||||
const auto max = num_tiles_in_zoom(z);
|
||||
return x < max && y < max;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace osmium {
|
||||
struct call_flush {
|
||||
void operator()(THandlers& handlers) {
|
||||
std::get<N>(handlers).flush();
|
||||
call_flush<N+1, SIZE, THandlers>()(handlers);
|
||||
call_flush<N + 1, SIZE, THandlers>()(handlers);
|
||||
}
|
||||
}; // struct call_flush
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace osmium {
|
||||
call_relation<0, sizeof...(THandler), handlers_type>()(m_handlers, relation);
|
||||
}
|
||||
|
||||
void changeset( osmium::Changeset& changeset) {
|
||||
void changeset(osmium::Changeset& changeset) {
|
||||
call_changeset<0, sizeof...(THandler), handlers_type>()(m_handlers, changeset);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -67,8 +67,10 @@ namespace osmium {
|
||||
* Handler that can be used to check that an OSM file is ordered
|
||||
* correctly. Ordered in this case refers to the usual order in OSM
|
||||
* files: First nodes in the order of their IDs, then ways in the order
|
||||
* of their IDs, then relations in the order or their IDs. IDs have to
|
||||
* be unique for each type.
|
||||
* of their IDs, then relations in the order or their IDs.
|
||||
*
|
||||
* IDs have to be unique for each type. This check will fail for
|
||||
* history files.
|
||||
*
|
||||
* To use this add a CheckOrder member variable to your handler and
|
||||
* call the node(), way(), and relation() methods from your node(),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -83,9 +83,9 @@ namespace osmium {
|
||||
|
||||
osmium::unsigned_object_id_type m_last_id{0};
|
||||
|
||||
bool m_ignore_errors {false};
|
||||
bool m_ignore_errors{false};
|
||||
|
||||
bool m_must_sort {false};
|
||||
bool m_must_sort{false};
|
||||
|
||||
// It is okay to have this static dummy instance, even when using several threads,
|
||||
// because it is read-only.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -103,22 +103,27 @@ namespace osmium {
|
||||
return m_size == 0;
|
||||
}
|
||||
|
||||
const T* data() const {
|
||||
const_pointer data() const {
|
||||
return m_mapping.begin();
|
||||
}
|
||||
|
||||
T* data() {
|
||||
pointer data() {
|
||||
return m_mapping.begin();
|
||||
}
|
||||
|
||||
T& operator[](size_t n) {
|
||||
const_reference operator[](size_t n) const {
|
||||
assert(n < m_size);
|
||||
return data()[n];
|
||||
}
|
||||
|
||||
T at(size_t n) const {
|
||||
reference operator[](size_t n) {
|
||||
assert(n < m_size);
|
||||
return data()[n];
|
||||
}
|
||||
|
||||
value_type at(size_t n) const {
|
||||
if (n >= m_size) {
|
||||
throw std::out_of_range("out of range");
|
||||
throw std::out_of_range{"out of range"};
|
||||
}
|
||||
return data()[n];
|
||||
}
|
||||
@@ -128,21 +133,21 @@ namespace osmium {
|
||||
}
|
||||
|
||||
void shrink_to_fit() {
|
||||
while (m_size > 0 && data()[m_size - 1] == osmium::index::empty_value<T>()) {
|
||||
while (m_size > 0 && data()[m_size - 1] == osmium::index::empty_value<value_type>()) {
|
||||
--m_size;
|
||||
}
|
||||
}
|
||||
|
||||
void push_back(const T& value) {
|
||||
resize(m_size+1);
|
||||
data()[m_size-1] = value;
|
||||
void push_back(const_reference value) {
|
||||
resize(m_size + 1);
|
||||
data()[m_size - 1] = value;
|
||||
}
|
||||
|
||||
void reserve(size_t new_capacity) {
|
||||
if (new_capacity > capacity()) {
|
||||
const size_t old_capacity = capacity();
|
||||
m_mapping.resize(new_capacity);
|
||||
std::fill(data() + old_capacity, data() + new_capacity, osmium::index::empty_value<T>());
|
||||
std::fill(data() + old_capacity, data() + new_capacity, osmium::index::empty_value<value_type>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -81,16 +81,22 @@ namespace osmium {
|
||||
m_vector[id] = value;
|
||||
}
|
||||
|
||||
const TValue get(const TId id) const final {
|
||||
try {
|
||||
const TValue& value = m_vector.at(id);
|
||||
if (value == osmium::index::empty_value<TValue>()) {
|
||||
throw osmium::not_found{id};
|
||||
}
|
||||
return value;
|
||||
} catch (const std::out_of_range&) {
|
||||
TValue get(const TId id) const final {
|
||||
if (id >= m_vector.size()) {
|
||||
throw osmium::not_found{id};
|
||||
}
|
||||
const TValue value = m_vector[id];
|
||||
if (value == osmium::index::empty_value<TValue>()) {
|
||||
throw osmium::not_found{id};
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
TValue get_noexcept(const TId id) const noexcept final {
|
||||
if (id >= m_vector.size()) {
|
||||
return osmium::index::empty_value<TValue>();
|
||||
}
|
||||
return m_vector[id];
|
||||
}
|
||||
|
||||
size_t size() const final {
|
||||
@@ -155,6 +161,16 @@ namespace osmium {
|
||||
|
||||
vector_type m_vector;
|
||||
|
||||
typename vector_type::const_iterator find_id(const TId id) const noexcept {
|
||||
const element_type element {
|
||||
id,
|
||||
osmium::index::empty_value<TValue>()
|
||||
};
|
||||
return std::lower_bound(m_vector.begin(), m_vector.end(), element, [](const element_type& a, const element_type& b) {
|
||||
return a.first < b.first;
|
||||
});
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
VectorBasedSparseMap() :
|
||||
@@ -171,19 +187,22 @@ namespace osmium {
|
||||
m_vector.push_back(element_type(id, value));
|
||||
}
|
||||
|
||||
const TValue get(const TId id) const final {
|
||||
const element_type element {
|
||||
id,
|
||||
osmium::index::empty_value<TValue>()
|
||||
};
|
||||
const auto result = std::lower_bound(m_vector.begin(), m_vector.end(), element, [](const element_type& a, const element_type& b) {
|
||||
return a.first < b.first;
|
||||
});
|
||||
TValue get(const TId id) const final {
|
||||
const auto result = find_id(id);
|
||||
if (result == m_vector.end() || result->first != id) {
|
||||
throw osmium::not_found{id};
|
||||
} else {
|
||||
return result->second;
|
||||
}
|
||||
|
||||
return result->second;
|
||||
}
|
||||
|
||||
TValue get_noexcept(const TId id) const noexcept final {
|
||||
const auto result = find_id(id);
|
||||
if (result == m_vector.end() || result->first != id) {
|
||||
return osmium::index::empty_value<TValue>();
|
||||
}
|
||||
|
||||
return result->second;
|
||||
}
|
||||
|
||||
size_t size() const final {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+20
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -126,8 +126,25 @@ namespace osmium {
|
||||
/// Set the field with id to value.
|
||||
virtual void set(const TId id, const TValue value) = 0;
|
||||
|
||||
/// Retrieve value by id. Does not check for overflow or empty fields.
|
||||
virtual const TValue get(const TId id) const = 0;
|
||||
/**
|
||||
* Retrieve value by id.
|
||||
*
|
||||
* @param id The id to look for.
|
||||
* @returns Value.
|
||||
* @throws osmium::not_found if the id could not be found.
|
||||
*/
|
||||
virtual TValue get(const TId id) const = 0;
|
||||
|
||||
/**
|
||||
* Retrieve value by id.
|
||||
*
|
||||
* @param id The id to look for.
|
||||
* @returns Value or, if not found, the empty value as defined
|
||||
* by osmium::index::empty_value<TValue>() which is
|
||||
* usually the default constructed value of type
|
||||
* TValue.
|
||||
*/
|
||||
virtual TValue get_noexcept(const TId id) const noexcept = 0;
|
||||
|
||||
/**
|
||||
* Get the approximate number of items in the storage. The storage
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -62,10 +62,14 @@ namespace osmium {
|
||||
// intentionally left blank
|
||||
}
|
||||
|
||||
const TValue get(const TId id) const final {
|
||||
TValue get(const TId id) const final {
|
||||
throw osmium::not_found{id};
|
||||
}
|
||||
|
||||
TValue get_noexcept(const TId /*id*/) const noexcept final {
|
||||
return osmium::index::empty_value<TValue>();
|
||||
}
|
||||
|
||||
size_t size() const final {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -76,14 +76,22 @@ namespace osmium {
|
||||
m_elements[id] = value;
|
||||
}
|
||||
|
||||
const TValue get(const TId id) const final {
|
||||
auto it = m_elements.find(id);
|
||||
TValue get(const TId id) const final {
|
||||
const auto it = m_elements.find(id);
|
||||
if (it == m_elements.end()) {
|
||||
throw osmium::not_found{id};
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
TValue get_noexcept(const TId id) const noexcept final {
|
||||
const auto it = m_elements.find(id);
|
||||
if (it == m_elements.end()) {
|
||||
return osmium::index::empty_value<TValue>();
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
size_t size() const noexcept final {
|
||||
return m_elements.size();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -97,13 +97,21 @@ namespace osmium {
|
||||
m_elements[id] = value;
|
||||
}
|
||||
|
||||
const TValue get(const TId id) const final {
|
||||
TValue get(const TId id) const final {
|
||||
if (id >= m_elements.size()) {
|
||||
throw osmium::not_found{id};
|
||||
}
|
||||
if (m_elements[id] == osmium::index::empty_value<TValue>()) {
|
||||
const TValue value = m_elements[id];
|
||||
if (value == osmium::index::empty_value<TValue>()) {
|
||||
throw osmium::not_found{id};
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
TValue get_noexcept(const TId id) const noexcept final {
|
||||
if (id >= m_elements.size()) {
|
||||
return osmium::index::empty_value<TValue>();
|
||||
}
|
||||
return m_elements[id];
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
#ifndef OSMIUM_INDEX_RELATIONS_MAP_HPP
|
||||
#define OSMIUM_INDEX_RELATIONS_MAP_HPP
|
||||
|
||||
/*
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include <osmium/osm/relation.hpp>
|
||||
#include <osmium/osm/types.hpp>
|
||||
|
||||
namespace osmium {
|
||||
|
||||
namespace index {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename TKey, typename TKeyInternal, typename TValue, typename TValueInternal>
|
||||
class flat_map {
|
||||
|
||||
public:
|
||||
|
||||
using key_type = TKey;
|
||||
using value_type = TValue;
|
||||
|
||||
private:
|
||||
|
||||
struct kv_pair {
|
||||
TKeyInternal key;
|
||||
TValueInternal value;
|
||||
|
||||
explicit kv_pair(key_type key_id) :
|
||||
key(static_cast<TKeyInternal>(key_id)),
|
||||
value() {
|
||||
}
|
||||
|
||||
kv_pair(key_type key_id, value_type value_id) :
|
||||
key(static_cast<TKeyInternal>(key_id)),
|
||||
value(static_cast<TValueInternal>(value_id)) {
|
||||
}
|
||||
|
||||
bool operator<(const kv_pair& other) const noexcept {
|
||||
return std::tie(key, value) < std::tie(other.key, other.value);
|
||||
}
|
||||
|
||||
bool operator==(const kv_pair& other) const noexcept {
|
||||
return std::tie(key, value) == std::tie(other.key, other.value);
|
||||
}
|
||||
}; // struct kv_pair
|
||||
|
||||
std::vector<kv_pair> m_map;
|
||||
|
||||
public:
|
||||
|
||||
using const_iterator = typename std::vector<kv_pair>::const_iterator;
|
||||
|
||||
void set(key_type key, value_type value) {
|
||||
m_map.emplace_back(key, value);
|
||||
}
|
||||
|
||||
void sort_unique() {
|
||||
std::sort(m_map.begin(), m_map.end());
|
||||
const auto last = std::unique(m_map.begin(), m_map.end());
|
||||
m_map.erase(last, m_map.end());
|
||||
}
|
||||
|
||||
std::pair<const_iterator, const_iterator> get(key_type key) const noexcept {
|
||||
return std::equal_range(m_map.begin(), m_map.end(), kv_pair{key}, [](const kv_pair& lhs, const kv_pair& rhs) {
|
||||
return lhs.key < rhs.key;
|
||||
});
|
||||
}
|
||||
|
||||
bool empty() const noexcept {
|
||||
return m_map.empty();
|
||||
}
|
||||
|
||||
size_t size() const noexcept {
|
||||
return m_map.size();
|
||||
}
|
||||
|
||||
}; // class flat_map
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* Index for looking up parent relation IDs given a member relation ID.
|
||||
* You can not instantiate such an index yourself, instead you need to
|
||||
* instantiate a RelationsMapStash, fill it and then create an index from
|
||||
* it:
|
||||
*
|
||||
* @code
|
||||
* RelationsMapStash stash;
|
||||
* ...
|
||||
* for_each_relation(const osmium::Relation& relation) {
|
||||
* stash.add_members(relation);
|
||||
* }
|
||||
* ...
|
||||
* const auto index = stash.build_index();
|
||||
* ...
|
||||
* osmium::unsigned_object_id_type member_id = ...;
|
||||
* index.for_each_parent(member_id, [](osmium::unsigned_object_id_type id) {
|
||||
* ...
|
||||
* });
|
||||
* ...
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
class RelationsMapIndex {
|
||||
|
||||
friend class RelationsMapStash;
|
||||
|
||||
using map_type = detail::flat_map<osmium::unsigned_object_id_type, uint32_t,
|
||||
osmium::unsigned_object_id_type, uint32_t>;
|
||||
|
||||
map_type m_map;
|
||||
|
||||
RelationsMapIndex(map_type&& map) :
|
||||
m_map(std::move(map)) {
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
RelationsMapIndex() = delete;
|
||||
|
||||
RelationsMapIndex(const RelationsMapIndex&) = delete;
|
||||
RelationsMapIndex& operator=(const RelationsMapIndex&) = delete;
|
||||
|
||||
RelationsMapIndex(RelationsMapIndex&&) = default;
|
||||
RelationsMapIndex& operator=(RelationsMapIndex&&) = default;
|
||||
|
||||
/**
|
||||
* Find the given relation id in the index and call the given function
|
||||
* with all parent relation ids.
|
||||
*
|
||||
* @code
|
||||
* osmium::unsigned_object_id_type member_id = 17;
|
||||
* index.for_each_parent(member_id, [](osmium::unsigned_object_id_type id) {
|
||||
* ...
|
||||
* });
|
||||
* @endcode
|
||||
*
|
||||
* Complexity: Logarithmic in the number of elements in the index.
|
||||
* (Lookup uses binary search.)
|
||||
*/
|
||||
template <typename Func>
|
||||
void for_each_parent(osmium::unsigned_object_id_type member_id, Func&& func) const {
|
||||
const auto parents = m_map.get(member_id);
|
||||
for (auto it = parents.first; it != parents.second; ++it) {
|
||||
std::forward<Func>(func)(it->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this index empty?
|
||||
*
|
||||
* Complexity: Constant.
|
||||
*/
|
||||
bool empty() const noexcept {
|
||||
return m_map.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* How many entries are in this index?
|
||||
*
|
||||
* Complexity: Constant.
|
||||
*/
|
||||
size_t size() const noexcept {
|
||||
return m_map.size();
|
||||
}
|
||||
|
||||
}; // RelationsMapIndex
|
||||
|
||||
/**
|
||||
* The RelationsMapStash is used to build up the data needed to create
|
||||
* an index of member relation ID to parent relation ID. See the
|
||||
* RelationsMapIndex class for more.
|
||||
*/
|
||||
class RelationsMapStash {
|
||||
|
||||
using map_type = detail::flat_map<osmium::unsigned_object_id_type, uint32_t,
|
||||
osmium::unsigned_object_id_type, uint32_t>;
|
||||
|
||||
map_type m_map;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool m_valid = true;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
RelationsMapStash() = default;
|
||||
|
||||
RelationsMapStash(const RelationsMapStash&) = delete;
|
||||
RelationsMapStash& operator=(const RelationsMapStash&) = delete;
|
||||
|
||||
RelationsMapStash(RelationsMapStash&&) = default;
|
||||
RelationsMapStash& operator=(RelationsMapStash&&) = default;
|
||||
|
||||
/**
|
||||
* Add mapping from member to parent relation in the stash.
|
||||
*/
|
||||
void add(osmium::unsigned_object_id_type member_id, osmium::unsigned_object_id_type relation_id) {
|
||||
assert(m_valid && "You can't use the RelationsMap any more after calling build_index()");
|
||||
m_map.set(member_id, relation_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mapping from all members to given parent relation in the stash.
|
||||
*/
|
||||
void add_members(const osmium::Relation& relation) {
|
||||
assert(m_valid && "You can't use the RelationsMap any more after calling build_index()");
|
||||
for (const auto& member : relation.members()) {
|
||||
if (member.type() == osmium::item_type::relation) {
|
||||
m_map.set(member.positive_ref(), relation.positive_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this stash empty?
|
||||
*
|
||||
* Complexity: Constant.
|
||||
*/
|
||||
bool empty() const noexcept {
|
||||
assert(m_valid && "You can't use the RelationsMap any more after calling build_index()");
|
||||
return m_map.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* How many entries are in this stash?
|
||||
*
|
||||
* Complexity: Constant.
|
||||
*/
|
||||
size_t size() const noexcept {
|
||||
assert(m_valid && "You can't use the RelationsMap any more after calling build_index()");
|
||||
return m_map.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an index with the contents of this stash and return it.
|
||||
*
|
||||
* After you get the index you can not use the stash any more!
|
||||
*/
|
||||
RelationsMapIndex build_index() {
|
||||
assert(m_valid && "You can't use the RelationsMap any more after calling build_index()");
|
||||
m_map.sort_unique();
|
||||
#ifndef NDEBUG
|
||||
m_valid = false;
|
||||
#endif
|
||||
return RelationsMapIndex{std::move(m_map)};
|
||||
}
|
||||
|
||||
}; // class RelationsMapStash
|
||||
|
||||
} // namespace index
|
||||
|
||||
} // namespace osmium
|
||||
|
||||
#endif // OSMIUM_INDEX_RELATIONS_MAP_HPP
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
@@ -33,6 +33,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <exception>
|
||||
#include <future>
|
||||
#include <string>
|
||||
@@ -132,6 +133,7 @@ namespace osmium {
|
||||
if (!m_has_reached_end_of_data) {
|
||||
std::future<T> data_future;
|
||||
m_queue.wait_and_pop(data_future);
|
||||
assert(data_future.valid());
|
||||
data = std::move(data_future.get());
|
||||
if (at_end_of_data(data)) {
|
||||
m_has_reached_end_of_data = true;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
This file is part of Osmium (http://osmcode.org/libosmium).
|
||||
|
||||
Copyright 2013-2016 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
Copyright 2013-2017 Jochen Topf <jochen@topf.org> and others (see README).
|
||||
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user