Skip to content

Commit

Permalink
Merge bfe6634 into ca7bb1f
Browse files Browse the repository at this point in the history
  • Loading branch information
fitodic committed Jan 2, 2020
2 parents ca7bb1f + bfe6634 commit e667341
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 13 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ matrix:
env:
- TOXENV=py37-gdal2.3.3
- GDALVERSION=2.3.3
- python: 3.8
stage: test
env:
- TOXENV=py38-gdal2.3.3
- GDALVERSION=2.3.3
- python: 2.7
stage: test
env:
Expand All @@ -73,12 +78,13 @@ matrix:
env:
- TOXENV=py37-gdal2.4.0
- GDALVERSION=2.4.0
- python: 3.8
stage: test
env:
- TOXENV=py38-gdal2.4.0
- GDALVERSION=2.4.0
- python: 3.7
stage: deploy
addons: skip
before_install: skip
script: skip
after_success: skip
deploy:
provider: pypi
user: fitodic
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ install_requires =
where=src

[options.extras_require]
dev = ipdb
dev =
ipdb
tox
gdal =
GDAL>=2.3.3
lint =
Expand Down
3 changes: 1 addition & 2 deletions src/centerline/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,4 @@ def get_ogr_driver(filepath):
if extension == driver_extension or extension in driver_extensions:
return driver

else:
raise UnsupportedVectorType
raise UnsupportedVectorType
223 changes: 218 additions & 5 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_creating_centerline_from_polygon_returns_centerline(simple_polygon):


def test_creating_centerline_from_complex_polygon_returns_centerline(
complex_polygon
complex_polygon,
):
centerline = Centerline(complex_polygon)

Expand All @@ -26,7 +26,7 @@ def test_creating_centerline_from_complex_polygon_returns_centerline(


def test_creating_centerline_from_multipolygon_returns_centerline(
multipolygon
multipolygon,
):
centerline = Centerline(multipolygon)
assert isinstance(centerline, Centerline)
Expand All @@ -49,21 +49,21 @@ def test_creating_centerline_from_linestring_raises_typeerror(linestring):


def test_creating_centerline_from_multilinestring_raises_typeerror(
multilinestring
multilinestring,
):
with pytest.raises(InvalidInputTypeError):
Centerline(multilinestring)


def test_creating_centerline_from_geometry_collection_raises_typeerror(
geometry_collection
geometry_collection,
):
with pytest.raises(InvalidInputTypeError):
Centerline(geometry_collection)


def test_creating_centerline_using_too_large_interp_dist_raises_runtimeerror(
create_polygon
create_polygon,
):
polygon = create_polygon(exterior=[[0, 0], [10, 0], [10, 10], [0, 10]])
with pytest.raises(TooFewRidgesError):
Expand Down Expand Up @@ -114,3 +114,216 @@ def test_centerline_does_not_touch_the_polygons_boundary(complex_polygon):
def test_polygon_contains_the_centerline(complex_polygon):
centerline = Centerline(complex_polygon)
assert complex_polygon.contains(centerline) is True


def test_qhull_error(create_polygon):
# https://github.com/fitodic/centerline/issues/24
polygon = create_polygon(
exterior=[
(107, 189),
(106, 190),
(100, 190),
(99, 191),
(95, 191),
(94, 192),
(92, 192),
(91, 193),
(90, 193),
(89, 194),
(88, 194),
(87, 195),
(86, 195),
(85, 196),
(84, 196),
(82, 198),
(82, 203),
(86, 207),
(87, 207),
(90, 210),
(91, 210),
(92, 211),
(94, 211),
(95, 212),
(98, 212),
(99, 213),
(101, 213),
(102, 214),
(105, 214),
(106, 215),
(108, 215),
(109, 216),
(111, 216),
(112, 217),
(114, 217),
(115, 218),
(117, 218),
(118, 219),
(120, 219),
(121, 220),
(126, 220),
(127, 221),
(133, 221),
(134, 222),
(136, 222),
(137, 223),
(138, 223),
(139, 224),
(139, 227),
(137, 229),
(137, 230),
(136, 231),
(135, 231),
(133, 233),
(132, 233),
(130, 235),
(129, 235),
(126, 238),
(125, 238),
(124, 239),
(123, 239),
(122, 240),
(121, 240),
(120, 241),
(119, 241),
(118, 242),
(116, 242),
(115, 243),
(114, 243),
(113, 244),
(112, 244),
(110, 246),
(109, 246),
(108, 247),
(107, 247),
(106, 248),
(105, 248),
(104, 249),
(102, 249),
(101, 250),
(99, 250),
(98, 251),
(97, 251),
(96, 252),
(94, 252),
(92, 254),
(91, 254),
(90, 255),
(89, 255),
(88, 256),
(87, 256),
(86, 257),
(85, 257),
(84, 258),
(83, 258),
(82, 259),
(80, 259),
(79, 260),
(78, 260),
(70, 268),
(70, 269),
(69, 270),
(69, 272),
(68, 273),
(68, 276),
(71, 279),
(73, 279),
(74, 280),
(83, 280),
(84, 279),
(90, 279),
(91, 278),
(94, 278),
(95, 277),
(97, 277),
(98, 276),
(99, 276),
(100, 275),
(101, 275),
(103, 273),
(105, 273),
(106, 272),
(108, 272),
(109, 271),
(111, 271),
(112, 270),
(113, 270),
(114, 269),
(115, 269),
(116, 268),
(117, 268),
(120, 265),
(121, 265),
(122, 264),
(124, 264),
(125, 263),
(126, 263),
(127, 262),
(128, 262),
(129, 261),
(130, 261),
(132, 259),
(133, 259),
(135, 257),
(136, 257),
(137, 256),
(138, 256),
(139, 255),
(141, 255),
(142, 254),
(143, 254),
(145, 252),
(146, 252),
(149, 249),
(150, 249),
(153, 246),
(154, 246),
(158, 242),
(158, 241),
(164, 235),
(164, 234),
(165, 233),
(165, 232),
(166, 231),
(166, 230),
(167, 229),
(167, 227),
(168, 226),
(168, 223),
(169, 222),
(169, 220),
(170, 219),
(170, 212),
(169, 211),
(169, 210),
(168, 209),
(168, 208),
(167, 207),
(167, 206),
(162, 201),
(161, 201),
(159, 199),
(158, 199),
(157, 198),
(155, 198),
(154, 197),
(153, 197),
(151, 195),
(150, 195),
(149, 194),
(147, 194),
(146, 193),
(144, 193),
(143, 192),
(139, 192),
(138, 191),
(132, 191),
(131, 190),
(122, 190),
(121, 189),
]
)
attributes = {"id": 1, "name": "polygon", "valid": True}
centerline = Centerline(polygon, **attributes)

assert isinstance(centerline, Centerline)
assert isinstance(centerline, geometry.MultiLineString)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
minversion = 3.7
envlist = lint,py{27,36,37}-gdal{2.3.3,2.4.0},docs,manifest,pypi-description
envlist = lint,py{27,36,37,38}-gdal{2.3.3,2.4.0},docs,manifest,pypi-description

[testenv]
description = run the test suite
Expand Down

0 comments on commit e667341

Please sign in to comment.