Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (5)
New upstream version 2.15.2
· 7e5a8d74
Bas Couwenberg
authored
Mar 10, 2019
7e5a8d74
Merge tag 'upstream/2.15.2'
· 2d10c533
Bas Couwenberg
authored
Mar 10, 2019
Upstream version 2.15.2
2d10c533
New upstream release.
· 25d2b0c3
Bas Couwenberg
authored
Mar 10, 2019
25d2b0c3
Bump minimum required libosmium2-dev to 2.15.1.
· 2dcd3486
Bas Couwenberg
authored
Mar 10, 2019
2dcd3486
Set distribution to experimental.
· 4fa31644
Bas Couwenberg
authored
Mar 10, 2019
4fa31644
Show whitespace changes
Inline
Side-by-side
.travis.yml
View file @
4fa31644
...
...
@@ -6,7 +6,7 @@
language
:
cpp
dist
:
trusty
dist
:
xenial
matrix
:
include
:
...
...
@@ -41,9 +41,7 @@ addons:
sources
:
-
boost-latest
packages
:
-
g++-4.8
-
gcc-4.8
-
libboost1.55-dev
-
libboost1.58-dev
-
python-dev
-
python-nose
-
python-mock
...
...
@@ -61,10 +59,6 @@ install:
fi
script
:
-
if [ "${CXX}" = 'g++' ]; then
CXX=g++-4.8;
CC=gcc-4.8;
fi
-
if [ "$TRAVIS_OS_NAME" = 'osx' ]; then
PYTHON=python${USE_PYTHON_VERSION};
else
...
...
CHANGELOG.md
View file @
4fa31644
...
...
@@ -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.2] - 2019-03-09
### Added
-
NodeLocationsForWays (accidentally removed in 2.15.0)
-
more tests
### Changed
-
GIL lock now released while apply() is in C++ code
### Fixed
-
unicode output of tag str() representation for python 2
-
handling of tempfile in test for pyosmium_get_changes
-
documentation for ends_have_same_location()
## [2.15.1] - 2019-01-24
### Added
...
...
README.md
View file @
4fa31644
...
...
@@ -5,7 +5,9 @@ library, a library for working with OpenStreetMap data in a fast and flexible
manner.
[

](http://travis-ci.org/osmcode/pyosmium)
[

](https://ci.appveyor.com/project/Mapbox/pyosmium)
[

](https://ci.appveyor.com/project/lonvia/pyosmium/branch/master)
## Dependencies
...
...
appveyor.yml
View file @
4fa31644
...
...
@@ -7,9 +7,15 @@ environment:
matrix
:
-
PYTHON
:
"
C:
\\
Python27-x64"
PIPINSTALLS
:
nose wheel mock
MINICONDA
:
"
C:
\\
Miniconda-x64"
arch
:
x64
-
PYTHON
:
"
C:
\\
Python36-x64"
PIPINSTALLS
:
nose wheel
MINICONDA
:
"
C:
\\
Miniconda36-x64"
arch
:
x64
-
PYTHON
:
"
C:
\\
Python37-x64"
PIPINSTALLS
:
nose wheel
MINICONDA
:
"
C:
\\
Miniconda37-x64"
arch
:
x64
os
:
Visual Studio
2015
...
...
@@ -20,15 +26,13 @@ init:
-
git config --global core.autocrlf input
-
if "%arch%"=="x86" (
set vcvarsall_arg=x86&&
set conda_path=C:\Miniconda36\Scripts&&
set conda_library_path=C:\Miniconda36\envs\pyosmium\Library&&
set build_type=Release)
-
if "%arch%"=="x64" (
set vcvarsall_arg=amd64&&
set conda_path=C:\Miniconda36-x64\Scripts&&
set conda_library_path=C:\Miniconda36-x64\envs\pyosmium\Library&&
set build_type=Release)
-
'
"C:\Program
Files
(x86)\Microsoft
Visual
Studio
14.0\VC\vcvarsall"
%vcvarsall_arg%'
-
set conda_path=%MINICONDA%\Scripts
-
set conda_library_path=%MINICONDA%\envs\pyosmium\Library
install
:
-
set PATH=%PATH%;%conda_path%
...
...
@@ -40,9 +44,9 @@ install:
-
SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
-
python --version
-
cd c:\dev
-
git clone --depth 1
0
https://github.com/osmcode/libosmium.git pyosmium/contrib/libosmium
-
git clone --depth 1
0
https://github.com/mapbox/protozero.git pyosmium/contrib/protozero
-
git clone --depth 1
0
https://github.com/pybind/pybind11.git pyosmium/contrib/pybind11
-
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%
...
...
debian/changelog
View file @
4fa31644
pyosmium (2.15.2-1~exp1) experimental; urgency=medium
* New upstream release.
* Bump minimum required libosmium2-dev to 2.15.1.
-- Bas Couwenberg <sebastic@debian.org> Sun, 10 Mar 2019 07:54:56 +0100
pyosmium (2.15.1-1) unstable; urgency=medium
* New upstream release.
...
...
debian/control
View file @
4fa31644
...
...
@@ -11,7 +11,7 @@ Build-Depends: cmake (>= 2.8.12),
libexpat1-dev,
libgdal-dev,
libgeos++-dev,
libosmium2-dev (>= 2.15.
0
),
libosmium2-dev (>= 2.15.
1
),
libsparsehash-dev,
pybind11-dev,
python-all-dev,
...
...
lib/osm.cc
View file @
4fa31644
...
...
@@ -31,9 +31,13 @@ PYBIND11_MODULE(_osm, m) {
.
def_property_readonly
(
"y"
,
&
osmium
::
Location
::
y
,
"(read-only) Y coordinate (latitude) as a fixed-point integer."
)
.
def_property_readonly
(
"lon"
,
&
osmium
::
Location
::
lon
,
"(read-only) Longitude (x coordinate) as floating point number."
)
"(read-only) Longitude (x coordinate) as floating point number."
"Raises an :py:class:`osmium.InvalidLocationError` when the "
"location is invalid."
)
.
def_property_readonly
(
"lat"
,
&
osmium
::
Location
::
lat
,
"(read-only) Latitude (y coordinate) as floating point number."
)
"(read-only) Latitude (y coordinate) as floating point number."
"Raises an :py:class:`osmium.InvalidLocationError` when the "
"location is invalid."
)
.
def
(
"valid"
,
&
osmium
::
Location
::
valid
,
"Check that the location is a valid WGS84 coordinate, i.e. "
"that it is within the usual bounds."
)
...
...
@@ -191,7 +195,10 @@ PYBIND11_MODULE(_osm, m) {
"True if the start and end node are exactly the same."
)
.
def
(
"ends_have_same_location"
,
&
osmium
::
NodeRefList
::
ends_have_same_location
,
"True if the start and end node of the way are at the same location. "
"Throws an exception if the location of one of the nodes is missing."
)
"Expects that the coordinates of the way nodes have been loaded "
"(see :py:func:`osmium.SimpleHandler.apply_buffer` and "
":py:func:`osmium.SimpleHandler.apply_file`). "
"If the locations are not present then the function returns always true."
)
;
py
::
class_
<
osmium
::
WayNodeList
,
osmium
::
NodeRefList
>
(
m
,
"WayNodeList"
,
...
...
@@ -280,7 +287,10 @@ PYBIND11_MODULE(_osm, m) {
"True if the start and end node are exactly the same."
)
.
def
(
"ends_have_same_location"
,
&
osmium
::
Way
::
ends_have_same_location
,
"True if the start and end node of the way are at the same location."
"Throws an exception if the location of one of the nodes is missing."
)
"Expects that the coordinates of the way nodes have been loaded "
"(see :py:func:`osmium.SimpleHandler.apply_buffer` and "
":py:func:`osmium.SimpleHandler.apply_file`). "
"If the locations are not present then the function returns always true."
)
;
py
::
class_
<
osmium
::
Relation
,
osmium
::
OSMObject
>
(
m
,
"Relation"
,
...
...
lib/osmium.cc
View file @
4fa31644
...
...
@@ -25,17 +25,23 @@ PYBIND11_MODULE(_osmium, m) {
}
});
py
::
class_
<
osmium
::
handler
::
NodeLocationsForWays
<
LocationTable
>>
(
m
,
"NodeLocationsForWays"
)
.
def
(
py
::
init
<
LocationTable
&>
())
.
def
(
"ignore_errors"
,
&
osmium
::
handler
::
NodeLocationsForWays
<
LocationTable
>::
ignore_errors
)
;
m
.
def
(
"apply"
,
[](
osmium
::
io
::
Reader
&
rd
,
BaseHandler
&
h
)
{
osmium
::
apply
(
rd
,
h
);
},
{
py
::
gil_scoped_release
release
;
osmium
::
apply
(
rd
,
h
);
},
py
::
arg
(
"reader"
),
py
::
arg
(
"handler"
),
"Apply a chain of handlers."
);
m
.
def
(
"apply"
,
[](
osmium
::
io
::
Reader
&
rd
,
NodeLocationHandler
&
h
)
{
osmium
::
apply
(
rd
,
h
);
},
{
py
::
gil_scoped_release
release
;
osmium
::
apply
(
rd
,
h
);
},
py
::
arg
(
"reader"
),
py
::
arg
(
"handler"
),
"Apply a chain of handlers."
);
m
.
def
(
"apply"
,
[](
osmium
::
io
::
Reader
&
rd
,
NodeLocationHandler
&
l
,
BaseHandler
&
h
)
{
osmium
::
apply
(
rd
,
l
,
h
);
},
{
py
::
gil_scoped_release
release
;
osmium
::
apply
(
rd
,
l
,
h
);
},
py
::
arg
(
"reader"
),
py
::
arg
(
"node_handler"
),
py
::
arg
(
"handler"
),
"Apply a chain of handlers."
);
...
...
lib/simple_handler.h
View file @
4fa31644
...
...
@@ -58,6 +58,7 @@ private:
if
(
callbacks
&
osmium
::
osm_entity_bits
::
changeset
)
entities
|=
osmium
::
osm_entity_bits
::
changeset
;
pybind11
::
gil_scoped_release
release
;
apply
(
file
,
entities
,
handler
,
idx
);
}
};
...
...
@@ -86,19 +87,34 @@ public:
// handler functions
void
node
(
osmium
::
Node
const
*
n
)
override
{
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
node
,
n
);
}
{
pybind11
::
gil_scoped_acquire
acquire
;
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
node
,
n
);
}
void
way
(
osmium
::
Way
const
*
w
)
override
{
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
way
,
w
);
}
{
pybind11
::
gil_scoped_acquire
acquire
;
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
way
,
w
);
}
void
relation
(
osmium
::
Relation
const
*
r
)
override
{
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
relation
,
r
);
}
{
pybind11
::
gil_scoped_acquire
acquire
;
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
relation
,
r
);
}
void
changeset
(
osmium
::
Changeset
const
*
c
)
override
{
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
changeset
,
c
);
}
{
pybind11
::
gil_scoped_acquire
acquire
;
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
changeset
,
c
);
}
void
area
(
osmium
::
Area
const
*
a
)
override
{
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
area
,
a
);
}
{
pybind11
::
gil_scoped_acquire
acquire
;
PYBIND11_OVERLOAD
(
void
,
SimpleHandler
,
area
,
a
);
}
private
:
bool
hasfunc
(
char
const
*
name
)
...
...
src/osmium/osm/__init__.py
View file @
4fa31644
from
._osm
import
*
import
osmium.osm.mutable
from
sys
import
version_info
as
python_version
def
create_mutable_node
(
node
,
**
args
):
"""
Create a mutable node replacing the properties given in the
...
...
@@ -36,8 +37,12 @@ Box.__repr__ = lambda b : 'osmium.osm.Box(bottom_left=%r, top_right=%r)' \
%
(
b
.
bottom_left
,
b
.
top_right
)
Box
.
__str__
=
lambda
b
:
'
(%s %s)
'
%
(
b
.
bottom_left
,
b
.
top_right
)
Tag
.
__repr__
=
lambda
t
:
'
osmium.osm.Tag(k=%s, v=%s)
'
%
(
t
.
k
,
t
.
v
)
Tag
.
__repr__
=
lambda
t
:
'
osmium.osm.Tag(k=%r, v=%r)
'
%
(
t
.
k
,
t
.
v
)
if
python_version
>=
(
3
,
0
):
Tag
.
__str__
=
lambda
t
:
'
%s=%s
'
%
(
t
.
k
,
t
.
v
)
else
:
Tag
.
__str__
=
lambda
t
:
'
%s=%s
'
%
(
t
.
k
.
encode
(
'
utf-8
'
),
t
.
v
.
encode
(
'
utf-8
'
))
TagList
.
__repr__
=
lambda
t
:
"
osmium.osm.TagList({%s})
"
\
%
"
,
"
.
join
([
"
%r=%r
"
%
(
i
.
k
,
i
.
v
)
for
i
in
t
])
...
...
src/osmium/version.py
View file @
4fa31644
...
...
@@ -5,11 +5,11 @@ Version information.
# the major version
pyosmium_major
=
'
2.15
'
# current release (Pip version)
pyosmium_release
=
'
2.15.
1
'
pyosmium_release
=
'
2.15.
2
'
# libosmium version shipped with the Pip release
libosmium_version
=
'
2.15.
0
'
libosmium_version
=
'
2.15.
1
'
# protozero version shipped with the Pip release
protozero_version
=
'
1.6.
4
'
protozero_version
=
'
1.6.
7
'
# pybind11 version shipped with the Pip release
pybind11_version
=
'
2.2.4
'
test/test_memberlist.py
View file @
4fa31644
# vim: set fileencoding=utf-8 :
from
nose.tools
import
*
import
unittest
import
os
import
sys
from
datetime
import
datetime
from
helpers
import
create_osm_file
,
osmobj
,
HandlerTestBase
from
helpers
import
create_osm_file
,
osmobj
,
HandlerTestBase
,
check_repr
import
osmium
as
o
...
...
@@ -23,7 +23,7 @@ class TestLength(HandlerTestBase, unittest.TestCase):
assert_equals
(
self
.
expected_length
[
r
.
id
],
len
(
r
.
members
))
class
TestMembers
(
HandlerTestBase
,
unittest
.
TestCase
):
data
=
"""
r34 Mn23@,n12@foo,w5@.,r34359737784@()
"""
data
=
u
"""
r34 Mn23@,n12@foo,w5@.,r34359737784@(
ü
)
"""
class
Handler
(
o
.
SimpleHandler
):
...
...
@@ -41,4 +41,5 @@ class TestMembers(HandlerTestBase, unittest.TestCase):
eq_
(
'
.
'
,
m
[
2
].
role
)
eq_
(
34359737784
,
m
[
3
].
ref
)
eq_
(
'
r
'
,
m
[
3
].
type
)
eq_
(
'
()
'
,
m
[
3
].
role
)
eq_
(
u
'
(ü)
'
,
m
[
3
].
role
)
assert_true
(
check_repr
(
m
))
test/test_osm.py
View file @
4fa31644
# vim: set fileencoding=utf-8 :
from
nose.tools
import
*
import
unittest
import
os
...
...
@@ -12,6 +13,13 @@ class TestLocation(unittest.TestCase):
loc
=
o
.
osm
.
Location
()
assert_false
(
loc
.
valid
())
assert_true
(
check_repr
(
loc
))
with
assert_raises
(
o
.
InvalidLocationError
):
lat
=
loc
.
lat
with
assert_raises
(
o
.
InvalidLocationError
):
lon
=
loc
.
lon
# these two don't raise an exception
lat
=
loc
.
lat_without_check
()
lon
=
loc
.
lon_without_check
()
def
test_valid_location
(
self
):
loc
=
o
.
osm
.
Location
(
1
,
10
)
...
...
@@ -24,7 +32,7 @@ class TestLocation(unittest.TestCase):
class
TestNodeAttributes
(
HandlerTestBase
,
unittest
.
TestCase
):
data
=
[
osmobj
(
'
N
'
,
id
=
1
,
version
=
5
,
changeset
=
58674
,
uid
=
42
,
timestamp
=
'
2014-01-31T06:23:35Z
'
,
user
=
'
a
nonymous
'
)]
timestamp
=
'
2014-01-31T06:23:35Z
'
,
user
=
u
'
ä
nonymous
'
)]
class
Handler
(
o
.
SimpleHandler
):
def
node
(
self
,
n
):
...
...
@@ -36,7 +44,7 @@ class TestNodeAttributes(HandlerTestBase, unittest.TestCase):
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
,
'
a
nonymous
'
)
assert_equals
(
n
.
user
,
u
'
ä
nonymous
'
)
assert_equals
(
n
.
positive_id
(),
1
)
assert_true
(
check_repr
(
n
))
...
...
test/test_pyosmium_get_changes.py
View file @
4fa31644
...
...
@@ -9,6 +9,7 @@ from os import path as osp
from
textwrap
import
dedent
import
sys
import
tempfile
from
os
import
unlink
try
:
from
cStringIO
import
StringIO
...
...
@@ -76,17 +77,26 @@ class TestPyosmiumGetChanges(unittest.TestCase):
assert_equals
(
'
1
'
,
self
.
stdout
[
0
])
def
test_init_to_file
(
self
):
with
tempfile
.
NamedTemporaryFile
(
dir
=
tempfile
.
gettempdir
(),
suffix
=
'
.seq
'
)
as
fd
:
fd
=
tempfile
.
NamedTemporaryFile
(
dir
=
tempfile
.
gettempdir
(),
suffix
=
'
.seq
'
,
delete
=
False
)
fname
=
fd
.
name
fd
.
close
()
assert_equals
(
0
,
self
.
main
(
'
-I
'
,
'
453
'
,
'
-f
'
,
fd
.
name
))
fd
=
open
(
fname
,
'
r
'
)
content
=
fd
.
read
()
assert_equals
(
'
454
'
,
content
.
decode
(
'
utf-8
'
))
try
:
assert_equals
(
'
454
'
,
content
)
fd
.
close
()
finally
:
unlink
(
fname
)
def
test_init_from_seq_file
(
self
):
with
tempfile
.
NamedTemporaryFile
(
dir
=
tempfile
.
gettempdir
(),
suffix
=
'
.seq
'
)
as
fd
:
with
tempfile
.
NamedTemporaryFile
(
dir
=
tempfile
.
gettempdir
(),
suffix
=
'
.seq
'
,
delete
=
False
)
as
fd
:
fd
.
write
(
'
453
'
.
encode
(
'
utf-8
'
))
fd
.
flush
()
assert_equals
(
0
,
self
.
main
(
'
-f
'
,
fd
.
name
))
fd
.
seek
(
0
)
fname
=
fd
.
name
assert_equals
(
0
,
self
.
main
(
'
-f
'
,
fname
))
fd
=
open
(
fname
,
'
r
'
)
content
=
fd
.
read
()
assert_equals
(
'
454
'
,
content
.
decode
(
'
utf-8
'
)
)
assert_equals
(
'
454
'
,
content
)
test/test_taglist.py
View file @
4fa31644
# vim: set fileencoding=utf-8 :
from
nose.tools
import
*
import
unittest
import
os
...
...
@@ -47,10 +48,10 @@ class TestTagEmptyTagListIndexOp(HandlerTestBase, unittest.TestCase):
n
.
tags
[
None
]
class
TestTagListLen
(
HandlerTestBase
,
unittest
.
TestCase
):
data
=
"""
\
data
=
u
"""
\
n1 x0 y0 Ta=a
n2 Tkey=value
n3 Tfoo=1,bar=2,foobar=33
n2 Tkey
ñ
=value
n3 Tfoo=1
ß
,bar=2,foobar=33
"""
class
Handler
(
o
.
SimpleHandler
):
...
...
@@ -59,6 +60,7 @@ class TestTagListLen(HandlerTestBase, unittest.TestCase):
def
node
(
self
,
n
):
assert_true
(
n
.
tags
)
assert_equals
(
self
.
expected_len
[
n
.
id
],
len
(
n
.
tags
))
assert_true
(
check_repr
(
n
.
tags
))
class
TestTagContains
(
HandlerTestBase
,
unittest
.
TestCase
):
data
=
"
n234 Tabba=x,2=vvv,xx=abba
"
...
...
test/test_threaded.py
0 → 100644
View file @
4fa31644
from
nose.tools
import
*
import
unittest
import
os
import
threading
from
helpers
import
create_osm_file
,
osmobj
,
HandlerTestBase
,
CountingHandler
import
osmium
as
o
def
import_data
(
function_complete
):
data
=
[
osmobj
(
'
N
'
,
id
=
1
,
lat
=
28.0
,
lon
=-
23.3
)]
fn
=
create_osm_file
(
data
)
c
=
CountingHandler
()
try
:
c
.
apply_file
(
fn
)
finally
:
os
.
remove
(
fn
)
function_complete
.
set
()
def
test_threaded_processing
():
"""
Process a file in a different thread nad make sure that processing
completes.
"""
function_complete
=
threading
.
Event
()
t
=
threading
.
Thread
(
target
=
import_data
,
args
=
(
function_complete
,))
t
.
start
()
function_complete
.
wait
(
timeout
=
2
)
assert_true
(
function_complete
.
is_set
());