[pyosmium] 01/06: Imported Upstream version 2.12.2

Bas Couwenberg sebastic at debian.org
Fri May 5 07:36:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository pyosmium.

commit 6034e86c508c61b6099812882bf353baa382b8dd
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri May 5 08:59:33 2017 +0200

    Imported Upstream version 2.12.2
---
 CHANGELOG.md                                   | 23 ++++++++-
 README.md                                      |  3 +-
 appveyor.yml                                   | 54 +++++++++++++++++++++
 examples/use_nodecache.py                      |  2 +-
 lib/generic_writer.hpp                         |  9 ++--
 lib/index.cc                                   | 12 ++++-
 lib/osm.cc                                     | 15 +++---
 lib/osmium.cc                                  | 14 ++++++
 lib/win_boost_fix.hpp                          | 20 ++++++++
 setup.py                                       | 54 +++++++++++++++++----
 {osmium => src/osmium}/__init__.py             |  0
 {osmium => src/osmium}/osm/__init__.py         |  0
 {osmium => src/osmium}/osm/mutable.py          |  0
 {osmium => src/osmium}/replication/__init__.py |  0
 {osmium => src/osmium}/replication/server.py   |  0
 {osmium => src/osmium}/replication/utils.py    |  0
 {osmium => src/osmium}/version.py              |  4 +-
 test/helpers.py                                |  4 +-
 test/test_index.py                             | 11 +++++
 test/test_memberlist.py                        | 44 +++++++++++++++++
 test/test_nodelist.py                          | 65 ++++++++++++++++++++++++++
 test/test_osm.py                               | 10 +++-
 test/test_writer.py                            |  2 +-
 23 files changed, 317 insertions(+), 29 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index bc98618..0f66df3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,25 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 
 ### Fixed
 
+## [2.12.2] - 2017-05-04
+
+### Added
+
+- build support for Windows
+- various tests
+
+### Changed
+
+- python sources moved into src/ directory
+- use current libosmium
+- area.inner_rings() now takes an outer ring as parameter and returns an iterator
+
+### Fixed
+
+- force use of C++ compiler
+- output type of index.map_types() function
+- write buffers growing unbound
+
 ## [2.12.1] - 2017-04-11
 
 ### Added
@@ -158,7 +177,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 
 - Exception not caught in test.
 
-[unreleased]: https://github.com/osmcode/pyosmium/compare/v2.12.0...HEAD
+[unreleased]: https://github.com/osmcode/pyosmium/compare/v2.12.2...HEAD
+[2.12.2]: https://github.com/osmcode/pyosmium/compare/v2.12.1...v2.12.2
+[2.12.1]: https://github.com/osmcode/pyosmium/compare/v2.12.0...v2.12.1
 [2.12.0]: https://github.com/osmcode/pyosmium/compare/v2.11.0...v2.12.0
 [2.11.0]: https://github.com/osmcode/pyosmium/compare/v2.10.2...v2.11.0
 [2.10.2]: https://github.com/osmcode/pyosmium/compare/v2.9.0...v2.10.2
diff --git a/README.md b/README.md
index 740c191..892ccda 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,8 @@ Provides Python bindings for the [Libosmium](https://github.com/osmcode/libosmiu
 library, a library for working with OpenStreetMap data in a fast and flexible
 manner.
 
-[![Build Status](https://secure.travis-ci.org/osmcode/pyosmium.png)](http://travis-ci.org/osmcode/pyosmium)
+[![Travis Build Status](https://api.travis-ci.org/osmcode/pyosmium.svg)](http://travis-ci.org/osmcode/pyosmium)
+[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/osmcode/pyosmium?svg=true)](https://ci.appveyor.com/project/Mapbox/pyosmium)
 
 
 ## Dependencies
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..8ce1bfa
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,54 @@
+environment:
+
+  matrix:
+    - PYTHON: "C:\\Python27-x64"
+      DEVPACK: pyosmium_libs27-b63.7z
+    - PYTHON: "C:\\Python36-x64"
+      DEVPACK: pyosmium_libs36-b63.7z
+
+os: Visual Studio 2015
+
+install:
+  - SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
+  - SET VS90COMNTOOLS=%VS140COMNTOOLS%
+  - cd "c:\Users\appveyor\AppData\Local\Programs\Common\Microsoft\"
+  - ren "Visual C++ for Python" "Visual C++ for Python Do Not Use"
+  - cd "C:\Program Files (x86)\"
+  - ren "Microsoft Visual Studio 9.0" "Microsoft Visual Studio 9.0 Do Not Use"
+  - python --version
+  - cd c:\dev 
+  - git clone --depth 10 https://github.com/osmcode/libosmium.git
+  - dir c:\dev
+  - IF NOT EXIST pyosmium_libs_Release.7z ECHO downloading dependencies pack... && powershell Invoke-WebRequest https://github.com/alex85k/pyosmium_libs/releases/download/0.3/%DEVPACK% -OutFile %DEVPACK%
+  - cd c:\
+  - 7z x c:\dev\%DEVPACK%
+  - dir c:\libs\include
+  - dir c:\libs\lib
+  - pip install nose wheel
+
+# scripts that are called at very beginning, before repo cloning
+init:
+  - git config --global core.autocrlf input
+
+# clone directory
+clone_folder: c:\dev\pyosmium
+
+build_script:
+  - cd c:\dev\pyosmium
+  - SET BOOST_PREFIX=c:/libs
+  - SET BOOST_VERSION=1_63
+  - python setup.py build
+  - python setup.py install --user
+
+test_script:
+  - set PATH=%BOOST_PREFIX:/=\%\lib;%PATH%
+  - cd test
+  - python run_tests.py
+
+after_test:
+  - cd c:\dev\pyosmium
+  - copy c:\libs\lib\*.dll c:\dev\pyosmium\src\osmium
+  - "%PYTHON%\\python.exe setup.py bdist_wheel"
+
+artifacts:
+  - path: dist\*
diff --git a/examples/use_nodecache.py b/examples/use_nodecache.py
index 7e2fa90..02d0382 100644
--- a/examples/use_nodecache.py
+++ b/examples/use_nodecache.py
@@ -4,7 +4,7 @@ import sys
 class WayHandler(o.SimpleHandler):
 
     def __init__(self, idx):
-        super(WayHandler).__init__()
+        super(WayHandler, self).__init__()
         self.idx = idx
 
     def way(self, w):
diff --git a/lib/generic_writer.hpp b/lib/generic_writer.hpp
index 1dc7c4f..5840283 100644
--- a/lib/generic_writer.hpp
+++ b/lib/generic_writer.hpp
@@ -16,7 +16,9 @@ class SimpleWriterWrap {
 public:
     SimpleWriterWrap(const char* filename, size_t bufsz=4096*1024)
     : writer(filename),
-      buffer(bufsz < 2*BUFFER_WRAP ? 2*BUFFER_WRAP : bufsz, osmium::memory::Buffer::auto_grow::yes)
+      buffer(bufsz < 2 * BUFFER_WRAP ? 2 * BUFFER_WRAP : bufsz,
+             osmium::memory::Buffer::auto_grow::yes),
+      buffer_size(buffer.capacity()) // same rounding to BUFFER_WRAP
     {}
 
     virtual ~SimpleWriterWrap()
@@ -261,8 +263,8 @@ private:
     void flush_buffer() {
         buffer.commit();
 
-        if (buffer.committed() > buffer.capacity() - BUFFER_WRAP) {
-            osmium::memory::Buffer new_buffer(buffer.capacity(), osmium::memory::Buffer::auto_grow::yes);
+        if (buffer.committed() > buffer_size - BUFFER_WRAP) {
+            osmium::memory::Buffer new_buffer(buffer_size, osmium::memory::Buffer::auto_grow::yes);
             using std::swap;
             swap(buffer, new_buffer);
             writer(std::move(new_buffer));
@@ -271,6 +273,7 @@ private:
 
     osmium::io::Writer writer;
     osmium::memory::Buffer buffer;
+    size_t buffer_size;
 };
 
 #endif // PYOSMIUM_GENERIC_WRITER_HPP
diff --git a/lib/index.cc b/lib/index.cc
index 02352e7..57b036e 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -2,6 +2,9 @@
 
 #include <osmium/osm.hpp>
 #include <osmium/index/map/all.hpp>
+#include <osmium/index/node_locations_map.hpp>
+
+#include "win_boost_fix.hpp"
 
 using namespace boost::python;
 
@@ -12,9 +15,14 @@ LocationTable *create_map(const std::string& config_string) {
     return map_factory.create_map(config_string).release();
 }
 
-std::vector<std::string> map_types() {
+PyObject *map_types() {
     const auto& map_factory = osmium::index::MapFactory<osmium::unsigned_object_id_type, osmium::Location>::instance();
-    return map_factory.map_types();
+
+    boost::python::list* l = new boost::python::list();
+    for (auto const &e : map_factory.map_types())
+        (*l).append(e);
+
+    return l->ptr();
 }
 
 BOOST_PYTHON_MODULE(index)
diff --git a/lib/osm.cc b/lib/osm.cc
index 74bd212..3491237 100644
--- a/lib/osm.cc
+++ b/lib/osm.cc
@@ -61,9 +61,7 @@ BOOST_PYTHON_MODULE(_osm)
     docstring_options doc_options(true, true, false);
 
     to_python_converter<osmium::Timestamp, Timestamp_to_python>();
-    std_pair_to_python_converter<int, int>();
-    std_pair_to_python_converter<unsigned int, unsigned int>();
-    std_pair_to_python_converter<unsigned long, unsigned long>();
+    std_pair_to_python_converter<size_t, size_t>();
 
     enum_<osmium::osm_entity_bits::type>("osm_entity_bits")
         .value("NOTHING", osmium::osm_entity_bits::nothing)
@@ -284,6 +282,11 @@ BOOST_PYTHON_MODULE(_osm)
                       "(read-only) Ordered list of relation members. "
                       "See :py:class:`osmium.osm.RelationMemberList`")
     ;
+    class_<osmium::memory::ItemIteratorRange<osmium::InnerRing const> >("InnerRingIterator",
+            "Iterator over inner rings.",
+            no_init)
+        .def("__iter__", iterator<osmium::memory::ItemIteratorRange<osmium::InnerRing const>, return_internal_reference<> >())
+    ;
     class_<osmium::Area, bases<osmium::OSMObject>, boost::noncopyable>("Area",
             "Areas are a special kind of meta-object representing a polygon. "
             "They can either be derived from closed ways or from relations "
@@ -309,10 +312,8 @@ BOOST_PYTHON_MODULE(_osm)
                 &osmium::Area::cbegin<osmium::OuterRing>,
                 &osmium::Area::cend<osmium::OuterRing>),
              "Return an iterator over all outer rings of the multipolygon.")
-        .def("inner_rings", 
-              range<return_internal_reference<> >(
-                &osmium::Area::cbegin<osmium::InnerRing>,
-                &osmium::Area::cend<osmium::InnerRing>),
+        .def("inner_rings", &osmium::Area::inner_rings,
+                (arg("self"), arg("outer_ring")),
              "Return an iterator over all inner rings of the multipolygon.")
     ;
     class_<osmium::Changeset, boost::noncopyable>("Changeset",
diff --git a/lib/osmium.cc b/lib/osmium.cc
index f4a2b94..73e0da9 100644
--- a/lib/osmium.cc
+++ b/lib/osmium.cc
@@ -8,6 +8,20 @@
 #include "generic_handler.hpp"
 #include "merged_input.hpp"
 #include "write_handler.hpp"
+#include "win_boost_fix.hpp"
+
+// workaround for Visual Studio 2015 Update 3
+// https://connect.microsoft.com/VisualStudio/Feedback/Details/2852624
+#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190023918)
+namespace boost {
+    template<>
+    const volatile SimpleHandlerWrap*
+    get_pointer(const volatile SimpleHandlerWrap* p)
+    {
+        return p;
+    }
+}
+#endif
 
 template <typename T>
 void apply_reader_simple(osmium::io::Reader &rd, T &h) {
diff --git a/lib/win_boost_fix.hpp b/lib/win_boost_fix.hpp
new file mode 100644
index 0000000..9a70f76
--- /dev/null
+++ b/lib/win_boost_fix.hpp
@@ -0,0 +1,20 @@
+#ifndef PYOSMIUM_WIN_BOOST_FIX_HPP
+#define PYOSMIUM_WIN_BOOST_FIX_HPP
+
+// workarodund for Visual Studio 2015 Update 3
+// https://connect.microsoft.com/VisualStudio/Feedback/Details/2852624
+#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190023918)
+namespace boost {
+
+    template <>
+    const volatile osmium::index::map::Map<unsigned __int64,class osmium::Location>*
+    get_pointer(const volatile osmium::index::map::Map<unsigned __int64,
+                class osmium::Location> *c)
+    {
+       return c;
+    }
+}
+#endif
+
+
+#endif
diff --git a/setup.py b/setup.py
index 89dab74..3a07fd6 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,6 @@
 from setuptools import setup, Extension
 from setuptools.command.sdist import sdist as orig_sdist
+from distutils.command import build_ext as setuptools_build_ext
 from subprocess import call
 from sys import version_info as pyversion, platform as osplatform
 from ctypes.util import find_library
@@ -24,7 +25,7 @@ def get_versions():
         The file cannot be directly imported because it is not installed
         yet.
     """
-    version_py = os.path.join(os.path.split(__file__)[0], "osmium/version.py")
+    version_py = os.path.join(os.path.split(__file__)[0], "src/osmium/version.py")
     v = {}
     with open(version_py) as version_file:
         # Execute the code in version.py.
@@ -35,11 +36,20 @@ def get_versions():
 pyosmium_release, libosmium_version = get_versions()
 
 ## boost dependencies
-includes.append(os.path.join(os.environ.get('BOOST_PREFIX', '/usr'), 'include'))
-if 'BOOST_PREFIX' in os.environ:
-    libdirs.append(os.path.join(os.environ['BOOST_PREFIX'], 'lib'))
+boost_prefix = os.environ.get('BOOST_PREFIX',
+                              'c:/libs' if osplatform == "win32" else '/usr')
+
+includes.append(os.path.join(boost_prefix, 'include'))
+if 'BOOST_VERSION' in os.environ:
+    includes.append(os.path.join(boost_prefix, 'include',
+                                 "boost-%s" %os.environ['BOOST_VERSION']))
+
+if 'BOOST_VERSION' in os.environ:
+    libdirs.append(os.path.join(boost_prefix, 'lib'))
 elif osplatform in ["linux", "linux2"]:
     libdirs.append('/usr/lib/x86_64-linux-gnu/')
+else:
+    libdirs.append(os.path.join(boost_prefix, 'lib'))
 
 # try to find the boost library matching the python version
 suffixes = [ # Debian naming convention for version installed in parallel
@@ -59,7 +69,28 @@ for suf in suffixes:
         libs.append("boost_python%s" % suf)
         break
 else:
-    raise Exception("Cannot find boost_python library")
+    # Visual C++ supports auto-linking, no library needed
+    if osplatform != "win32":
+        raise Exception("Cannot find boost_python library")
+
+if osplatform != "win32":
+    orig_compiler = setuptools_build_ext.customize_compiler
+
+    def cpp_compiler(compiler):
+        retval = orig_compiler(compiler)
+        # force C++ compiler
+        # Note that we only exchange the compiler as we want to keep the
+        # original Python cflags.
+        if len(compiler.compiler_cxx) > 0:
+            compiler.compiler_so[0] = compiler.compiler_cxx[0]
+        # remove warning that does not make sense for C++
+        try:
+            compiler.compiler_so.remove('-Wstrict-prototypes')
+        except (ValueError, AttributeError):
+            pass
+        return retval
+
+    setuptools_build_ext.customize_compiler = cpp_compiler
 
 ### osmium dependencies
 osmium_prefixes = [ 'libosmium-' + libosmium_version, '../libosmium' ]
@@ -79,11 +110,16 @@ else:
     else:
         print("Using global libosmium.")
 
-osmium_libs = ('expat', 'pthread', 'z', 'bz2')
+if osplatform == "win32" :
+    osmium_libs = ('expat', 'zlib', 'bzip2', 'ws2_32')
+    extra_compile_args = [ '-DWIN32_LEAN_AND_MEAN', '-D_CRT_SECURE_NO_WARNINGS', '-DNOMINMAX', '/wd4996', '/EHsc' ]
+else:
+    osmium_libs = ('expat', 'pthread', 'z', 'bz2')
+    extra_compile_args = [ '-std=c++11', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS' ]
+
 libs.extend(osmium_libs)
 
 extensions = []
-extra_compile_args = [ '-std=c++11', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS' ]
 
 extensions.append(Extension('osmium._osmium',
        sources = ['lib/osmium.cc'],
@@ -148,7 +184,9 @@ setup (name = 'osmium',
        scripts=['tools/pyosmium-get-changes', 'tools/pyosmium-up-to-date'],
        classifiers=classifiers,
        packages = packages,
-       cmdclass={'sdist' : My_sdist },
+       package_dir = {'' : 'src'},
+       package_data = { 'osmium' : [ '*.dll' ] },
+       cmdclass={'sdist' : My_sdist},
        ext_modules = extensions)
 
 
diff --git a/osmium/__init__.py b/src/osmium/__init__.py
similarity index 100%
rename from osmium/__init__.py
rename to src/osmium/__init__.py
diff --git a/osmium/osm/__init__.py b/src/osmium/osm/__init__.py
similarity index 100%
rename from osmium/osm/__init__.py
rename to src/osmium/osm/__init__.py
diff --git a/osmium/osm/mutable.py b/src/osmium/osm/mutable.py
similarity index 100%
rename from osmium/osm/mutable.py
rename to src/osmium/osm/mutable.py
diff --git a/osmium/replication/__init__.py b/src/osmium/replication/__init__.py
similarity index 100%
rename from osmium/replication/__init__.py
rename to src/osmium/replication/__init__.py
diff --git a/osmium/replication/server.py b/src/osmium/replication/server.py
similarity index 100%
rename from osmium/replication/server.py
rename to src/osmium/replication/server.py
diff --git a/osmium/replication/utils.py b/src/osmium/replication/utils.py
similarity index 100%
rename from osmium/replication/utils.py
rename to src/osmium/replication/utils.py
diff --git a/osmium/version.py b/src/osmium/version.py
similarity index 73%
rename from osmium/version.py
rename to src/osmium/version.py
index c3ee027..34ed1a8 100644
--- a/osmium/version.py
+++ b/src/osmium/version.py
@@ -5,7 +5,7 @@ Version information.
 # the major version
 pyosmium_major = '2.12'
 # current release (Pip version)
-pyosmium_release = '2.12.1'
+pyosmium_release = '2.12.2'
 
 # libosmium version shipped with the Pip release
-libosmium_version = '2.12.1'
+libosmium_version = '2.12.2'
diff --git a/test/helpers.py b/test/helpers.py
index 03084bb..df0862d 100644
--- a/test/helpers.py
+++ b/test/helpers.py
@@ -75,7 +75,7 @@ def create_osm_file(data):
        the memberlist.
     """
     data.sort(key=lambda x:('NWR'.find(x['type']), x['id']))
-    with tempfile.NamedTemporaryFile(dir='/tmp', suffix='.osm', delete=False) as fd:
+    with tempfile.NamedTemporaryFile(dir=tempfile.gettempdir(), suffix='.osm', delete=False) as fd:
         fname = fd.name
         fd.write("<?xml version='1.0' encoding='UTF-8'?>\n".encode('utf-8'))
         fd.write('<osm version="0.6" generator="test-pyosmium" timestamp="2014-08-26T20:22:02Z">\n'.encode('utf-8'))
@@ -89,7 +89,7 @@ def create_osm_file(data):
     return fname
 
 def create_opl_file(data):
-    with tempfile.NamedTemporaryFile(dir='/tmp', suffix='.opl', delete=False) as fd:
+    with tempfile.NamedTemporaryFile(dir=tempfile.gettempdir(), suffix='.opl', delete=False) as fd:
         fname = fd.name
         fd.write(dedent(data).encode('utf-8'))
         fd.write(b'\n')
diff --git a/test/test_index.py b/test/test_index.py
new file mode 100644
index 0000000..9895b43
--- /dev/null
+++ b/test/test_index.py
@@ -0,0 +1,11 @@
+from nose.tools import *
+import unittest
+
+import osmium as o
+
+class TestIndexMapTypes(unittest.TestCase):
+
+    def runTest(self):
+        ml = o.index.map_types()
+        assert_true(isinstance(ml, list))
+        assert_greater(len(ml), 0)
diff --git a/test/test_memberlist.py b/test/test_memberlist.py
new file mode 100644
index 0000000..917a1cd
--- /dev/null
+++ b/test/test_memberlist.py
@@ -0,0 +1,44 @@
+
+from nose.tools import *
+import unittest
+import os
+import sys
+from datetime import datetime
+
+from helpers import create_osm_file, osmobj, HandlerTestBase
+
+import osmium as o
+
+class TestLength(HandlerTestBase, unittest.TestCase):
+    data = """\
+           r2 Mn3@
+           r4
+           r45 Mw1 at fo,r45 at 4,r45 at 5
+           """
+
+    class Handler(o.SimpleHandler):
+        expected_length = { 2 : 1, 4 : 0, 45 : 3 }
+
+        def relation(self, r):
+            assert_equals(self.expected_length[r.id], len(r.members))
+
+class TestMembers(HandlerTestBase, unittest.TestCase):
+    data = """r34 Mn23@,n12 at foo,w5 at .,r34359737784@()"""
+
+    class Handler(o.SimpleHandler):
+
+        def relation(self, r):
+            m = list(r.members)
+            eq_(4, len(m))
+            eq_(23, m[0].ref)
+            eq_('n', m[0].type)
+            eq_('', m[0].role)
+            eq_(12, m[1].ref)
+            eq_('n', m[1].type)
+            eq_('foo', m[1].role)
+            eq_(5, m[2].ref)
+            eq_('w', m[2].type)
+            eq_('.', m[2].role)
+            eq_(34359737784, m[3].ref)
+            eq_('r', m[3].type)
+            eq_('()', m[3].role)
diff --git a/test/test_nodelist.py b/test/test_nodelist.py
new file mode 100644
index 0000000..46937a2
--- /dev/null
+++ b/test/test_nodelist.py
@@ -0,0 +1,65 @@
+from nose.tools import *
+import unittest
+import os
+import sys
+from datetime import datetime
+
+from helpers import create_osm_file, osmobj, HandlerTestBase
+
+import osmium as o
+
+class TestLength(HandlerTestBase, unittest.TestCase):
+    data = """\
+           w593
+           w4 Nn1,n2,n-34
+           w8 Nn12,n12,n12,n0
+           """
+
+    class Handler(o.SimpleHandler):
+        expected_length = { 593 : 0, 4 : 3, 8 : 4 }
+
+        def way(self, w):
+            assert_equals(self.expected_length[w.id], len(w.nodes))
+
+class TestNodeIds(HandlerTestBase, unittest.TestCase):
+    data = """w4 Nn1,n1,n34359737784,n-34,n0"""
+
+    class Handler(o.SimpleHandler):
+
+        def way(self, w):
+            eq_(1, w.nodes[0].ref)
+            eq_(1, w.nodes[1].ref)
+            eq_(34359737784, w.nodes[2].ref)
+            eq_(-34, w.nodes[3].ref)
+            eq_(0, w.nodes[4].ref)
+
+class TestMissingRef(HandlerTestBase, unittest.TestCase):
+    data = """\
+           n1 x0.5 y10.0
+           w4 Nn1
+           """
+
+    class Handler(o.SimpleHandler):
+
+        def way(self, w):
+            eq_(1, w.nodes[0].ref)
+            assert_false(w.nodes[0].location.valid())
+            with assert_raises(o.InvalidLocationError):
+                w.nodes[0].location.lat
+            with assert_raises(o.InvalidLocationError):
+                w.nodes[0].location.lon
+
+class TestValidRefs(HandlerTestBase, unittest.TestCase):
+    data = """\
+           n1 x0.5 y10.0
+           w4 Nn1
+           """
+    apply_locations = True
+
+    class Handler(o.SimpleHandler):
+
+        def way(self, w):
+            eq_(1, w.nodes[0].ref)
+            assert_true(w.nodes[0].location.valid())
+            assert_almost_equal(w.nodes[0].location.lat, 10.0)
+            assert_almost_equal(w.nodes[0].location.lon, 0.5)
diff --git a/test/test_osm.py b/test/test_osm.py
index 86821db..ea5c2c6 100644
--- a/test/test_osm.py
+++ b/test/test_osm.py
@@ -57,6 +57,14 @@ class TestNodePositiveId(HandlerTestBase, unittest.TestCase):
         def node(self, n):
             assert_equals(n.positive_id(), 34)
 
+class TestNodeLargeId(HandlerTestBase, 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):
+        def node(self, n):
+            assert_equals(n.id, 17179869418)
+
 
 class TestWayAttributes(HandlerTestBase, unittest.TestCase):
 
@@ -134,7 +142,7 @@ class TestAreaFromWayAttributes(HandlerTestBase, unittest.TestCase):
             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())), 0)
+            assert_equals(len(list(n.inner_rings(oring))), 0)
 
 class TestChangesetAttributes(HandlerTestBase, unittest.TestCase):
     data = [osmobj('C', id=34, created_at="2005-04-09T19:54:13Z",
diff --git a/test/test_writer.py b/test/test_writer.py
index 3e6de40..d6caa8e 100644
--- a/test/test_writer.py
+++ b/test/test_writer.py
@@ -23,7 +23,7 @@ else:
 
 @contextmanager
 def WriteExpect(expected):
-    fname = tempfile.mktemp(dir='/tmp', suffix='.opl')
+    fname = tempfile.mktemp(dir=tempfile.gettempdir(), suffix='.opl')
     writer = o.SimpleWriter(fname, 1024*1024)
     try:
         yield writer

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pyosmium.git



More information about the Pkg-grass-devel mailing list