[Git][debian-gis-team/pyosmium][buster-backports] 9 commits: New upstream version 2.15.3
Bas Couwenberg
gitlab at salsa.debian.org
Thu Aug 22 05:38:19 BST 2019
Bas Couwenberg pushed to branch buster-backports at Debian GIS Project / pyosmium
Commits:
8c4c3a02 by Bas Couwenberg at 2019-08-17T06:34:05Z
New upstream version 2.15.3
- - - - -
db88a706 by Bas Couwenberg at 2019-08-17T06:34:09Z
Update upstream source from tag 'upstream/2.15.3'
Update to upstream version '2.15.3'
with Debian dir 2307c2f7e9c6cc670a3b4b21449840cc7b2f070d
- - - - -
86088c1d by Bas Couwenberg at 2019-08-17T06:34:23Z
New upstream release.
- - - - -
7d53178e by Bas Couwenberg at 2019-08-17T06:36:28Z
Bump minimum required libosmium2-dev to 2.15.2.
- - - - -
5a2af7f1 by Bas Couwenberg at 2019-08-17T06:38:22Z
Drop obsolete examples file.
- - - - -
5bec3773 by Bas Couwenberg at 2019-08-17T06:58:48Z
Add python3-shapely to (build) dependencies.
- - - - -
b985947e by Bas Couwenberg at 2019-08-17T06:58:48Z
Set distribution to unstable.
- - - - -
18d07c7f by Bas Couwenberg at 2019-08-22T04:01:04Z
Merge tag 'debian/2.15.3-1' into buster-backports
releasing package pyosmium version 2.15.3-1
- - - - -
1520bca1 by Bas Couwenberg at 2019-08-22T04:01:49Z
Rebuild for buster-backports.
- - - - -
28 changed files:
- .travis.yml
- CHANGELOG.md
- CMakeLists.txt
- README.md
- appveyor.yml
- cmake/FindOsmium.cmake
- debian/changelog
- debian/control
- − debian/python-pyosmium.examples
- doc/ref_osmium.rst
- examples/amenity_list.py
- examples/osm_diff_stats.py
- examples/osm_file_stats.py
- examples/pub_names.py
- examples/road_length.py
- lib/osm.cc
- setup.py
- src/osmium/__init__.py
- + src/osmium/helper.py
- src/osmium/replication/server.py
- src/osmium/version.py
- + test/example-test.osc
- + test/example-test.pbf
- test/helpers.py
- + test/test_examples.py
- test/test_osm.py
- test/test_taglist.py
- tools/pyosmium-get-changes
Changes:
=====================================
.travis.yml
=====================================
@@ -45,17 +45,19 @@ addons:
- python-dev
- python-nose
- python-mock
+ - python-shapely
- python3
- python3-dev
- python3-nose
- python3-setuptools
+ - python3-shapely
install:
- git clone --quiet --depth 1 https://github.com/osmcode/libosmium.git contrib/libosmium
- git clone --quiet --depth 1 https://github.com/mapbox/protozero.git contrib/protozero
- git clone --quiet --depth 1 https://github.com/pybind/pybind11.git contrib/pybind11
- if [ "$TRAVIS_OS_NAME" = 'osx' ]; then
- pip${USE_PYTHON_VERSION} install -q nose mock;
+ pip${USE_PYTHON_VERSION} install -q nose mock shapely;
fi
script:
=====================================
CHANGELOG.md
=====================================
@@ -4,6 +4,23 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+## [2.15.3] - 2019-08-16
+
+### Added
+
+- `make_simple_handler()` convenience wrapper
+- iterator for Tag type (for allowing to convert TagLists into python dicts)
+- tests for examples
+- tests for MP building and MergeInputReader
+
+### Changed
+
+- use current libosmium and protozero
+
+### Fixed
+
+- remove spurious 404 error message when downloading OSM diffs
+
## [2.15.2] - 2019-03-09
### Added
=====================================
CMakeLists.txt
=====================================
@@ -3,7 +3,7 @@ project(pyosmium)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-find_package(Osmium 2.14 REQUIRED COMPONENTS io pbf xml)
+find_package(Osmium 2.15 REQUIRED COMPONENTS io pbf xml)
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS} ${PROTOZERO_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
=====================================
README.md
=====================================
@@ -5,7 +5,7 @@ library, a library for working with OpenStreetMap data in a fast and flexible
manner.
[![Travis Build Status](https://api.travis-ci.org/osmcode/pyosmium.svg)](http://travis-ci.org/osmcode/pyosmium)
-[![Appeveyor Build status](https://ci.appveyor.com/api/projects/status/dr69wsw855lwrg8w/branch/master?svg=true)](https://ci.appveyor.com/project/lonvia/pyosmium/branch/master)
+[![Appeveyor Build status](https://ci.appveyor.com/api/projects/status/ch3gwxucycytako4/branch/master?svg=true)](https://ci.appveyor.com/project/lonvia/pyosmium/branch/master)
=====================================
appveyor.yml
=====================================
@@ -3,34 +3,29 @@ environment:
BZIP2_VER: 1.0.6
EXPAT_VER: 2.2.5
ZLIB_VER: 1.2.11
+ SHAPELY_VER: 1.6.4
BOOST_PREFIX: C:\Libraries\boost_1_67_0
matrix:
- - PYTHON: "C:\\Python27-x64"
+ - PYTHON_VER: 2.7
PIPINSTALLS: nose wheel mock
MINICONDA: "C:\\Miniconda-x64"
arch: x64
- - PYTHON: "C:\\Python36-x64"
+ - PYTHON_VER: 3.6
PIPINSTALLS: nose wheel
MINICONDA: "C:\\Miniconda36-x64"
arch: x64
- - PYTHON: "C:\\Python37-x64"
+ - PYTHON_VER: 3.7
PIPINSTALLS: nose wheel
MINICONDA: "C:\\Miniconda37-x64"
arch: x64
-os: Visual Studio 2015
+os: Visual Studio 2017
clone_depth: 1
init:
- git config --global core.autocrlf input
- - if "%arch%"=="x86" (
- set vcvarsall_arg=x86&&
- set build_type=Release)
- - if "%arch%"=="x64" (
- set vcvarsall_arg=amd64&&
- set build_type=Release)
- - '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall" %vcvarsall_arg%'
+ - '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall" amd64'
- set conda_path=%MINICONDA%\Scripts
- set conda_library_path=%MINICONDA%\envs\pyosmium\Library
@@ -38,18 +33,15 @@ install:
- set PATH=%PATH%;%conda_path%
- cd c:\
- conda config --set always_yes yes
- - conda create --name pyosmium
+ - conda create --name pyosmium python=%PYTHON_VER%
- activate pyosmium
- - conda install bzip2=%BZIP2_VER% expat=%EXPAT_VER% zlib=%ZLIB_VER%
- - SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
+ - conda install bzip2=%BZIP2_VER% expat=%EXPAT_VER% zlib=%ZLIB_VER% shapely=%SHAPELY_VER% %PIPINSTALLS%
+ - SET PATH=%MINICONDA%\envs\pyosmium\Scripts;%PATH%
- python --version
- cd c:\dev
- git clone --depth 1 https://github.com/osmcode/libosmium.git pyosmium/contrib/libosmium
- git clone --depth 1 https://github.com/mapbox/protozero.git pyosmium/contrib/protozero
- git clone --depth 1 https://github.com/pybind/pybind11.git pyosmium/contrib/pybind11
- - dir c:\dev
- - cd c:\
- - pip install %PIPINSTALLS%
# clone directory
clone_folder: c:\dev\pyosmium
@@ -66,10 +58,10 @@ test_script:
after_test:
- cd c:\dev\pyosmium
- - copy /y %conda_library_path%\bin\zlib.dll c:\dev\pyosmium\contrib
- - copy /y %conda_library_path%\bin\expat.dll c:\dev\pyosmium\contrib
- - copy /y %conda_library_path%\bin\libbz2.dll c:\dev\pyosmium\contrib
- - "%PYTHON%\\python.exe setup.py bdist_wheel"
+ - copy /y %conda_library_path%\bin\zlib.dll c:\dev\pyosmium\src\osmium
+ - copy /y %conda_library_path%\bin\expat.dll c:\dev\pyosmium\src\osmium
+ - copy /y %conda_library_path%\bin\libbz2.dll c:\dev\pyosmium\src\osmium
+ - python.exe setup.py bdist_wheel
artifacts:
- path: dist\*
=====================================
cmake/FindOsmium.cmake
=====================================
@@ -71,6 +71,9 @@ find_path(OSMIUM_INCLUDE_DIR osmium/version.hpp
# Check libosmium version number
if(Osmium_FIND_VERSION)
+ if(NOT EXISTS "${OSMIUM_INCLUDE_DIR}/osmium/version.hpp")
+ message(FATAL_ERROR "Missing ${OSMIUM_INCLUDE_DIR}/osmium/version.hpp. Either your libosmium version is too old, or libosmium wasn't found in the place you said.")
+ endif()
file(STRINGS "${OSMIUM_INCLUDE_DIR}/osmium/version.hpp" _libosmium_version_define REGEX "#define LIBOSMIUM_VERSION_STRING")
if("${_libosmium_version_define}" MATCHES "#define LIBOSMIUM_VERSION_STRING \"([0-9.]+)\"")
set(_libosmium_version "${CMAKE_MATCH_1}")
@@ -111,7 +114,7 @@ endif()
if(Osmium_USE_PBF)
find_package(ZLIB)
find_package(Threads)
- find_package(Protozero 1.5.1)
+ find_package(Protozero 1.6.3)
list(APPEND OSMIUM_EXTRA_FIND_VARS ZLIB_FOUND Threads_FOUND PROTOZERO_INCLUDE_DIR)
if(ZLIB_FOUND AND Threads_FOUND AND PROTOZERO_FOUND)
@@ -324,7 +327,7 @@ if(MSVC)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
endif()
-if(APPLE)
+if(APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# following only available from cmake 2.8.12:
# add_compile_options(-stdlib=libc++)
# so using this instead:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,18 @@
+pyosmium (2.15.3-1~bpo10+1) buster-backports; urgency=medium
+
+ * Rebuild for buster-backports.
+
+ -- Bas Couwenberg <sebastic at debian.org> Thu, 22 Aug 2019 06:01:10 +0200
+
+pyosmium (2.15.3-1) unstable; urgency=medium
+
+ * New upstream release.
+ * Bump minimum required libosmium2-dev to 2.15.2.
+ * Drop obsolete examples file.
+ * Add python3-shapely to (build) dependencies.
+
+ -- Bas Couwenberg <sebastic at debian.org> Sat, 17 Aug 2019 08:39:20 +0200
+
pyosmium (2.15.2-2~bpo10+1) buster-backports; urgency=medium
* Rebuild for buster-backports.
=====================================
debian/control
=====================================
@@ -11,13 +11,14 @@ Build-Depends: cmake (>= 2.8.12),
libexpat1-dev,
libgdal-dev,
libgeos++-dev,
- libosmium2-dev (>= 2.15.1),
+ libosmium2-dev (>= 2.15.2),
libsparsehash-dev,
pybind11-dev,
python3-all-dev,
python3-setuptools,
python3-mock,
python3-nose,
+ python3-shapely,
python3-sphinx,
python3-sphinxcontrib.autoprogram
Standards-Version: 4.4.0
@@ -49,7 +50,8 @@ Depends: ${python3:Depends},
${shlibs:Depends},
${misc:Depends}
Provides: ${python3:Provides}
-Suggests: pyosmium-doc
+Suggests: python3-shapely,
+ pyosmium-doc
Description: Osmium library bindings for Python 3
The PyOsmium module allows you to access some of the features of the Osmium
library from Python code.
=====================================
debian/python-pyosmium.examples deleted
=====================================
@@ -1 +0,0 @@
-examples/*
=====================================
doc/ref_osmium.rst
=====================================
@@ -45,3 +45,5 @@ Low-level Functions and Classes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: osmium.apply
+
+.. autofunction:: osmium.make_simple_handler
=====================================
examples/amenity_list.py
=====================================
@@ -29,11 +29,17 @@ class AmenityListHandler(o.SimpleHandler):
self.print_amenity(a.tags, centroid.x, centroid.y)
+def main(osmfile):
+
+ handler = AmenityListHandler()
+
+ handler.apply_file(osmfile)
+
+ return 0
+
if __name__ == '__main__':
if len(sys.argv) != 2:
- print("Usage: python amenity_list.py <osmfile>")
+ print("Usage: python %s <osmfile>" % sys.argv[0])
sys.exit(-1)
- handler = AmenityListHandler()
-
- handler.apply_file(sys.argv[1])
+ exit(main(sys.argv[1]))
=====================================
examples/osm_diff_stats.py
=====================================
@@ -1,7 +1,8 @@
"""
Simple example that counts the number of changes in an osm diff file.
-Shows how to detect the different kind of modifications.
+Shows how to detect the different kind of modifications and how to
+use the handler generator function instead of a handler class.
"""
import osmium as o
import sys
@@ -13,7 +14,7 @@ class Stats(object):
self.modified = 0
self.deleted = 0
- def add(self, o):
+ def __call__(self, o):
if o.deleted:
self.deleted += 1
elif o.version == 1:
@@ -27,32 +28,24 @@ class Stats(object):
print("%s deleted: %d" % (prefix, self.deleted))
-class FileStatsHandler(o.SimpleHandler):
- def __init__(self):
- super(FileStatsHandler, self).__init__()
- self.nodes = Stats()
- self.ways = Stats()
- self.rels = Stats()
+def main(osmfile):
+ nodes = Stats()
+ ways = Stats()
+ rels = Stats()
- def node(self, n):
- self.nodes.add(n)
+ h = o.make_simple_handler(node=nodes, way=ways, relation=rels)
- def way(self, w):
- self.ways.add(w)
+ h.apply_file(osmfile)
- def relation(self, r):
- self.rels.add(r)
+ nodes.outstats("Nodes")
+ ways.outstats("Ways")
+ rels.outstats("Relations")
+ return 0
if __name__ == '__main__':
if len(sys.argv) != 2:
- print("Usage: python osm_file_stats.py <osmfile>")
+ print("Usage: python %s <osmfile>" % sys.argv[0])
sys.exit(-1)
- h = FileStatsHandler()
-
- h.apply_file(sys.argv[1])
-
- h.nodes.outstats("Nodes")
- h.ways.outstats("Ways")
- h.rels.outstats("Relations")
+ exit(main(sys.argv[1]))
=====================================
examples/osm_file_stats.py
=====================================
@@ -24,15 +24,20 @@ class FileStatsHandler(o.SimpleHandler):
self.rels += 1
-if __name__ == '__main__':
- if len(sys.argv) != 2:
- print("Usage: python osm_file_stats.py <osmfile>")
- sys.exit(-1)
-
+def main(osmfile):
h = FileStatsHandler()
- h.apply_file(sys.argv[1])
+ h.apply_file(osmfile)
print("Nodes: %d" % h.nodes)
print("Ways: %d" % h.ways)
print("Relations: %d" % h.rels)
+
+ return 0
+
+if __name__ == '__main__':
+ if len(sys.argv) != 2:
+ print("Usage: python %s <osmfile>" % sys.argv[0])
+ sys.exit(-1)
+
+ exit(main(sys.argv[1]))
=====================================
examples/pub_names.py
=====================================
@@ -17,10 +17,14 @@ class NamesHandler(osmium.SimpleHandler):
def way(self, w):
self.output_pubs(w.tags)
+def main(osmfile):
+ NamesHandler().apply_file(osmfile)
+
+ return 0
+
if __name__ == '__main__':
if len(sys.argv) != 2:
- print("Usage: python pub_names.py <osmfile>")
+ print("Usage: python %s <osmfile>" % sys.argv[0])
sys.exit(-1)
- NamesHandler().apply_file(sys.argv[1])
-
+ exit(main(sys.argv[1]))
=====================================
examples/road_length.py
=====================================
@@ -1,7 +1,7 @@
"""
Compute the total length of highways in an osm file.
-Shows how extract the geometry of a way.
+Shows how to extract the geometry of a way.
"""
import osmium as o
import sys
@@ -20,14 +20,19 @@ class RoadLengthHandler(o.SimpleHandler):
# where nodes of ways near the boundary are missing.
print("WARNING: way %d incomplete. Ignoring." % w.id)
-if __name__ == '__main__':
- if len(sys.argv) != 2:
- print("Usage: python road_length.py <osmfile>")
- sys.exit(-1)
-
+def main(osmfile):
h = RoadLengthHandler()
# As we need the geometry, the node locations need to be cached. Therefore
# set 'locations' to true.
- h.apply_file(sys.argv[1], locations=True)
+ h.apply_file(osmfile, locations=True)
print('Total way length: %.2f km' % (h.length/1000))
+
+ return 0
+
+if __name__ == '__main__':
+ if len(sys.argv) != 2:
+ print("Usage: python %s <osmfile>" % sys.argv[0])
+ sys.exit(-1)
+
+ exit(main(sys.argv[1]))
=====================================
lib/osm.cc
=====================================
@@ -7,6 +7,33 @@
namespace py = pybind11;
+class TagIterator
+{
+public:
+ TagIterator(osmium::Tag const &t, py::object r)
+ : tag(t), ref(r)
+ {}
+
+ char const *next()
+ {
+ switch (index) {
+ case 0:
+ ++index;
+ return tag.key();
+ case 1:
+ ++index;
+ return tag.value();
+ };
+
+ throw py::stop_iteration();
+ }
+
+private:
+ osmium::Tag const &tag;
+ py::object ref; // keep a reference
+ size_t index = 0;
+};
+
PYBIND11_MODULE(_osm, m) {
py::enum_<osmium::osm_entity_bits::type>(m, "osm_entity_bits")
@@ -90,12 +117,20 @@ PYBIND11_MODULE(_osm, m) {
"Check if the given location is inside the box.")
;
+ py::class_<TagIterator>(m, "TagIterator")
+ .def("__iter__", [](TagIterator &it) -> TagIterator& { return it; })
+ .def("__next__", &TagIterator::next)
+ .def("__len__", [](TagIterator const &it) { return 2; })
+ ;
+
py::class_<osmium::Tag>(m, "Tag",
"A single OSM tag.")
.def_property_readonly("k", &osmium::Tag::key,
"(read-only) Tag key.")
.def_property_readonly("v", &osmium::Tag::value,
"(read-only) Tag value.")
+ .def("__iter__", [](py::object s)
+ { return TagIterator(s.cast<osmium::Tag const &>(), s); })
;
py::class_<osmium::TagList>(m, "TagList",
=====================================
setup.py
=====================================
@@ -146,6 +146,7 @@ setup(
ext_modules=[CMakeExtension('cmake_example')],
packages = ['osmium', 'osmium/osm', 'osmium/replication'],
package_dir = {'' : 'src'},
+ package_data = { 'osmium' : [ '*.dll' ] },
cmdclass=dict(build_ext=CMakeBuild, sdist=Pyosmium_sdist),
zip_safe=False,
)
=====================================
src/osmium/__init__.py
=====================================
@@ -1,4 +1,5 @@
from osmium._osmium import *
+from osmium.helper import *
import osmium.io
import osmium.osm
import osmium.index
=====================================
src/osmium/helper.py
=====================================
@@ -0,0 +1,22 @@
+from osmium._osmium import SimpleHandler
+
+def make_simple_handler(node=None, way=None, relation=None, area=None):
+ """ Convenience function that creates a `SimpleHandler` from a set of
+ callback functions. Each of the parameters takes an optional callable
+ that must expect a single positional parameter with the object being
+ processed.
+ """
+ class __HandlerWithCallbacks(SimpleHandler):
+ pass
+
+ if node is not None:
+ __HandlerWithCallbacks.node = staticmethod(node)
+ if way is not None:
+ __HandlerWithCallbacks.way = staticmethod(way)
+ if relation is not None:
+ __HandlerWithCallbacks.relation = staticmethod(relation)
+ if area is not None:
+ __HandlerWithCallbacks.area = staticmethod(area)
+
+ return __HandlerWithCallbacks()
+
=====================================
src/osmium/replication/server.py
=====================================
@@ -275,7 +275,6 @@ class ReplicationServer(object):
try:
response = self.open_url(self.get_state_url(seq))
except Exception as err:
- logging.error(err)
return None
ts = None
=====================================
src/osmium/version.py
=====================================
@@ -5,11 +5,11 @@ Version information.
# the major version
pyosmium_major = '2.15'
# current release (Pip version)
-pyosmium_release = '2.15.2'
+pyosmium_release = '2.15.3'
# libosmium version shipped with the Pip release
-libosmium_version = '2.15.1'
+libosmium_version = '2.15.2'
# protozero version shipped with the Pip release
-protozero_version = '1.6.7'
+protozero_version = '1.6.8'
# pybind11 version shipped with the Pip release
-pybind11_version = '2.2.4'
+pybind11_version = '2.3.0'
=====================================
test/example-test.osc
=====================================
The diff for this file was not included because it is too large.
=====================================
test/example-test.pbf
=====================================
Binary files /dev/null and b/test/example-test.pbf differ
=====================================
test/helpers.py
=====================================
@@ -7,6 +7,7 @@ import sys
from textwrap import dedent
import osmium
from datetime import datetime
+from nose.tools import *
if sys.version_info[0] == 3:
from datetime import timezone
@@ -135,7 +136,7 @@ class HandlerTestBase:
apply_locations = False
apply_idx = 'flex_mem'
- def test_func(self):
+ def test_apply_file(self):
if isinstance(self.data, (list, tuple)):
fn = create_osm_file(self.data)
else:
@@ -150,6 +151,34 @@ class HandlerTestBase:
if hasattr(self, "check_result"):
self.check_result()
+ if hasattr(self.handler, "check_result"):
+ self.handler.check_result()
+
+class HandlerTestWithMergeInput(HandlerTestBase):
+
+ def test_merge_input_reader(self):
+ if isinstance(self.data, (list, tuple)):
+ fn = create_osm_file(self.data)
+ else:
+ fn = create_opl_file(self.data)
+
+ try:
+ self.handler = self.Handler()
+ mir = osmium.MergeInputReader()
+ with open(fn, "rb") as f:
+ data = f.read()
+ mir.add_buffer(data, format='osm')
+ mir.add_file(fn)
+ mir.apply(self.handler, idx=self.apply_idx)
+ finally:
+ os.remove(fn)
+
+ if hasattr(self, "check_result"):
+ self.check_result()
+
+ if hasattr(self.handler, "check_result"):
+ self.handler.check_result()
+
class CountingHandler(osmium.SimpleHandler):
@@ -170,6 +199,16 @@ class CountingHandler(osmium.SimpleHandler):
self.counts[3] += 1
+class ExecutedHandler(osmium.SimpleHandler):
+
+ def __init__(self):
+ super(ExecutedHandler, self).__init__()
+ self.has_run = False
+
+ def check_result(self):
+ assert_true(self.has_run)
+
+
class HandlerFunction(osmium.SimpleHandler):
def __init__(self, **kwargs):
=====================================
test/test_examples.py
=====================================
@@ -0,0 +1,86 @@
+"""
+Tests for all examples.
+"""
+from nose.tools import *
+import unittest
+import sys
+from helpers import load_script
+from os import path as osp
+
+TEST_FILE='example-test.pbf'
+TEST_DIFF='example-test.osc'
+
+try:
+ from StringIO import StringIO
+except:
+ from io import StringIO
+
+class Capturing(list):
+ def __enter__(self):
+ self._stdout = sys.stdout
+ sys.stdout = self._stringio = StringIO()
+ return self
+ def __exit__(self, *args):
+ self.extend(self._stringio.getvalue().splitlines())
+ del self._stringio # free up some memory
+ sys.stdout = self._stdout
+
+def load_example(name):
+ return load_script(osp.join(osp.realpath(__file__),
+ "..", "..", "examples", name + ".py"))
+
+def test_amenity_list():
+ script = load_example("amenity_list")
+
+ with Capturing() as output:
+ eq_(0, script['main'](TEST_FILE))
+
+ eq_(835, len(output))
+ eq_('1.535245 42.556681 parking', output[0].strip())
+ eq_('1.570729 42.529562 parking Aparcament Comunal', output[-1].strip())
+
+def test_road_length():
+ script = load_example("road_length")
+
+ with Capturing() as output:
+ eq_(0, script['main'](TEST_FILE))
+
+ eq_(output, ["Total way length: 1590.82 km"])
+
+
+def test_pub_names():
+ script = load_example("pub_names")
+
+ with Capturing() as output:
+ eq_(0, script['main'](TEST_FILE))
+
+ eq_(output, ['Kyu', 'Havana Club', "Mulligan's", 'Bar Broques',
+ 'The Camden - English Pub', 'Aspen', 'el Raval'])
+
+def test_osm_diff_stats():
+ script = load_example("osm_diff_stats")
+
+ with Capturing() as output:
+ eq_(0, script['main'](TEST_DIFF))
+
+ eq_(9, len(output))
+ eq_('Nodes added: 305', output[0])
+ eq_('Nodes modified: 192', output[1])
+ eq_('Nodes deleted: 20', output[2])
+ eq_('Ways added: 31', output[3])
+ eq_('Ways modified: 93', output[4])
+ eq_('Ways deleted: 0', output[5])
+ eq_('Relations added: 0', output[6])
+ eq_('Relations modified: 0', output[7])
+ eq_('Relations deleted: 0', output[8])
+
+def test_osm_file_stats():
+ script = load_example("osm_file_stats")
+
+ with Capturing() as output:
+ eq_(0, script['main'](TEST_FILE))
+
+ eq_(3, len(output))
+ eq_('Nodes: 211100', output[0])
+ eq_('Ways: 10315', output[1])
+ eq_('Relations: 244', output[2])
=====================================
test/test_osm.py
=====================================
@@ -3,7 +3,8 @@ from nose.tools import *
import unittest
import os
import sys
-from helpers import create_osm_file, osmobj, check_repr, HandlerTestBase, mkdate
+from helpers import create_osm_file, osmobj, check_repr, HandlerTestBase,\
+ HandlerTestWithMergeInput, mkdate, ExecutedHandler
import osmium as o
@@ -30,11 +31,11 @@ class TestLocation(unittest.TestCase):
assert_true(check_repr(loc))
-class TestNodeAttributes(HandlerTestBase, unittest.TestCase):
+class TestNodeAttributes(HandlerTestWithMergeInput, unittest.TestCase):
data = [osmobj('N', id=1, version=5, changeset=58674, uid=42,
timestamp='2014-01-31T06:23:35Z', user=u'änonymous')]
- class Handler(o.SimpleHandler):
+ class Handler(ExecutedHandler):
def node(self, n):
assert_equals(n.id, 1)
assert_equals(n.deleted, False)
@@ -47,26 +48,29 @@ class TestNodeAttributes(HandlerTestBase, unittest.TestCase):
assert_equals(n.user, u'änonymous')
assert_equals(n.positive_id(), 1)
assert_true(check_repr(n))
+ self.has_run = True
-class TestNodePositiveId(HandlerTestBase, unittest.TestCase):
+class TestNodePositiveId(HandlerTestWithMergeInput, unittest.TestCase):
data = [osmobj('N', id=-34, version=5, changeset=58674, uid=42,
timestamp='2014-01-31T06:23:35Z', user='anonymous')]
- class Handler(o.SimpleHandler):
+ class Handler(ExecutedHandler):
def node(self, n):
assert_equals(n.positive_id(), 34)
+ self.has_run = True
-class TestNodeLargeId(HandlerTestBase, unittest.TestCase):
+class TestNodeLargeId(HandlerTestWithMergeInput, unittest.TestCase):
data = [osmobj('N', id=17179869418, version=5, changeset=58674, uid=42,
timestamp='2014-01-31T06:23:35Z', user='anonymous')]
- class Handler(o.SimpleHandler):
+ class Handler(ExecutedHandler):
def node(self, n):
assert_equals(n.id, 17179869418)
+ self.has_run = True
-class TestWayAttributes(HandlerTestBase, unittest.TestCase):
+class TestWayAttributes(HandlerTestWithMergeInput, unittest.TestCase):
apply_locations = True
@@ -76,7 +80,7 @@ class TestWayAttributes(HandlerTestBase, unittest.TestCase):
timestamp='2014-01-31T06:23:35Z', user='anonymous',
nodes = [1,2,3])]
- class Handler(o.SimpleHandler):
+ class Handler(ExecutedHandler):
def way(self, n):
assert_equals(n.id, 1)
assert_equals(n.deleted, False)
@@ -93,13 +97,14 @@ class TestWayAttributes(HandlerTestBase, unittest.TestCase):
assert_false(n.ends_have_same_location())
assert_true(check_repr(n))
assert_true(check_repr(n.nodes))
+ self.has_run = True
-class TestRelationAttributes(HandlerTestBase, unittest.TestCase):
+class TestRelationAttributes(HandlerTestWithMergeInput, unittest.TestCase):
data = [osmobj('R', id=1, version=5, changeset=58674, uid=42,
timestamp='2014-01-31T06:23:35Z', user=' anonymous',
members=[('way',1,'')])]
- class Handler(o.SimpleHandler):
+ class Handler(ExecutedHandler):
def relation(self, n):
assert_equals(n.id, 1)
assert_equals(n.deleted, False)
@@ -113,6 +118,7 @@ class TestRelationAttributes(HandlerTestBase, unittest.TestCase):
assert_equals(n.positive_id(), 1)
assert_true(check_repr(n))
assert_true(check_repr(n.members))
+ self.has_run = True
class TestAreaFromWayAttributes(HandlerTestBase, unittest.TestCase):
data = [osmobj('N', id=1, lat=0, lon=0),
@@ -123,7 +129,7 @@ class TestAreaFromWayAttributes(HandlerTestBase, unittest.TestCase):
nodes = [1,2,3,1], tags = { "area" : "yes" }),
]
- class Handler(o.SimpleHandler):
+ class Handler(ExecutedHandler):
def area(self, n):
assert_equals(n.id, 46)
assert_equals(n.deleted, False)
@@ -147,6 +153,88 @@ class TestAreaFromWayAttributes(HandlerTestBase, unittest.TestCase):
assert_true(oring.ends_have_same_id())
assert_true(oring.ends_have_same_location())
assert_equals(len(list(n.inner_rings(oring))), 0)
+ self.has_run = True
+
+class TestAreaFromMultipolygonRelation(HandlerTestBase, unittest.TestCase):
+ data = [osmobj('N', id=1, lat=0, lon=0),
+ osmobj('N', id=2, lat=0, lon=1),
+ osmobj('N', id=3, lat=1, lon=0),
+ osmobj('W', id=23, version=5, changeset=58674, uid=42,
+ timestamp='2014-01-31T06:23:35Z', user='anonymous',
+ nodes = [1, 2, 3], tags = {}),
+ osmobj('W', id=24, version=5, changeset=58674, uid=42,
+ timestamp='2014-01-31T06:23:35Z', user='anonymous',
+ nodes=[3, 1], tags={}),
+ osmobj('R', id=1, version=3, changeset=7654, uid=42, timestamp='2014-01-31T06:23:35Z', user='Anon',
+ members=[('way', 23, 'outer'), ('way', 24, 'outer')], tags={'type': 'multipolygon'}),
+ ]
+
+ class Handler(ExecutedHandler):
+ def area(self, n):
+ assert_equals(n.id, 3)
+ assert_equals(n.deleted, False)
+ assert_equals(n.visible, True)
+ assert_equals(n.version, 3)
+ assert_equals(n.changeset, 7654)
+ assert_equals(n.uid, 42)
+ assert_equals(n.user_is_anonymous(), False)
+ assert_equals(n.timestamp, mkdate(2014, 1, 31, 6, 23, 35))
+ assert_equals(n.user, 'Anon')
+ assert_equals(n.positive_id(), 3)
+ assert_equals(n.orig_id(), 1)
+ assert_equals(n.from_way(), False)
+ assert_equals(n.is_multipolygon(), False)
+ assert_equals(n.num_rings(), (1, 0))
+ assert_equals(len(list(n.outer_rings())), 1)
+ oring = list(n.outer_rings())[0]
+ assert_equals(len(list(oring)), 4)
+ assert_equals(set((1,2,3)), set([x.ref for x in oring]))
+ assert_true(oring.is_closed())
+ assert_true(oring.ends_have_same_id())
+ assert_true(oring.ends_have_same_location())
+ assert_equals(len(list(n.inner_rings(oring))), 0)
+ self.has_run = True
+
+class TestAreaFromBoundaryRelation(HandlerTestBase, unittest.TestCase):
+ data = [osmobj('N', id=1, lat=0, lon=0),
+ osmobj('N', id=2, lat=0, lon=1),
+ osmobj('N', id=3, lat=1, lon=0),
+ osmobj('W', id=23, version=5, changeset=58674, uid=42,
+ timestamp='2014-01-31T06:23:35Z', user='anonymous',
+ nodes=[1, 2, 3], tags = {}),
+ osmobj('W', id=24, version=5, changeset=58674, uid=42,
+ timestamp='2014-01-31T06:23:35Z', user='anonymous',
+ nodes=[3, 1], tags={}),
+ osmobj('R', id=1, version=3, changeset=7654, uid=42, timestamp='2014-01-31T06:23:35Z', user='Anon',
+ members=[('way', 23, 'outer'), ('way', 24, 'outer')], tags={'type': 'boundary'}),
+ ]
+
+ class Handler(ExecutedHandler):
+ def area(self, n):
+ assert_equals(n.id, 3)
+ assert_equals(n.deleted, False)
+ assert_equals(n.visible, True)
+ assert_equals(n.version, 3)
+ assert_equals(n.changeset, 7654)
+ assert_equals(n.uid, 42)
+ assert_equals(n.user_is_anonymous(), False)
+ assert_equals(n.timestamp, mkdate(2014, 1, 31, 6, 23, 35))
+ assert_equals(n.user, 'Anon')
+ assert_equals(n.positive_id(), 3)
+ assert_equals(n.orig_id(), 1)
+ assert_equals(n.from_way(), False)
+ assert_equals(n.is_multipolygon(), False)
+ assert_equals(n.num_rings(), (1, 0))
+ assert_equals(len(list(n.outer_rings())), 1)
+ oring = list(n.outer_rings())[0]
+ assert_equals(len(list(oring)), 4)
+ assert_equals(set((1,2,3)), set([x.ref for x in oring]))
+ assert_true(oring.is_closed())
+ assert_true(oring.ends_have_same_id())
+ assert_true(oring.ends_have_same_location())
+ assert_equals(len(list(n.inner_rings(oring))), 0)
+ self.has_run = True
+
class TestChangesetAttributes(HandlerTestBase, unittest.TestCase):
data = [osmobj('C', id=34, created_at="2005-04-09T19:54:13Z",
@@ -156,7 +244,7 @@ class TestChangesetAttributes(HandlerTestBase, unittest.TestCase):
max_lat=51.5288620, user="Steve", uid="1")
]
- class Handler(o.SimpleHandler):
+ class Handler(ExecutedHandler):
def changeset(self,c):
assert_equals(34, c.id)
assert_equals(1, c.uid)
@@ -172,3 +260,4 @@ class TestChangesetAttributes(HandlerTestBase, unittest.TestCase):
assert_equals(-1465242, c.bounds.bottom_left.x)
assert_equals(515288506, c.bounds.bottom_left.y)
assert_true(check_repr(c))
+ self.has_run = True
=====================================
test/test_taglist.py
=====================================
@@ -101,3 +101,15 @@ class TestTagGet(HandlerTestBase, unittest.TestCase):
eq_("43 fg", n.tags.get("_", "43 fg"))
assert_is_none(n.tags.get("gerger4"))
assert_is_none(n.tags.get("ffleo", None))
+
+class TestTagToDict(HandlerTestBase, unittest.TestCase):
+ data = "n234 Tabba=x,2=vvv,xx=abba"
+
+ class Handler(o.SimpleHandler):
+
+ def node(self, n):
+ d = dict(n.tags)
+ eq_(len(d), 3)
+ eq_(d['abba'], 'x')
+ eq_(d['2'], 'vvv')
+ eq_(d['xx'], 'abba')
=====================================
tools/pyosmium-get-changes
=====================================
@@ -180,7 +180,7 @@ def main(args):
log.error(msgfmt("""
Don't know with which change to start. One of the parameters
-I / -D / -O / -f
- needs to begiven."""))
+ needs to be given."""))
return 1
with open(options.seq_file, 'r') as f:
@@ -206,7 +206,7 @@ def main(args):
svr = rserv.ReplicationServer(url)
if options.cookie is not None:
# According to the documentation, the cookie jar loads the file only if FileCookieJar.load is called.
- cookie_jar = cookiejarlib.MozillaCookieJar(options.cookie, None, cookie_policy)
+ cookie_jar = cookiejarlib.MozillaCookieJar(options.cookie)
cookie_jar.load(options.cookie)
opener = urlrequest.build_opener(urlrequest.HTTPCookieProcessor(cookie_jar))
svr.open_url = opener.open
View it on GitLab: https://salsa.debian.org/debian-gis-team/pyosmium/compare/86a58d52606443bfe28271344772f89d63143b6b...1520bca199d127268a6c15d94f56bb3251097172
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/pyosmium/compare/86a58d52606443bfe28271344772f89d63143b6b...1520bca199d127268a6c15d94f56bb3251097172
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20190822/1f0fc9ba/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list