Shapely: Crash when calling shapely.geometry.asShape with invalid geometry

Created on 20 Nov 2017  路  4Comments  路  Source: Toblerity/Shapely

Expected behavior and actual behavior.

This code:

import shapely.geometry
x = shapely.geometry.asShape({'coordinates': [[1130.0, 1110.0]], 'type': 'LineString'})
assert x.is_valid
x.wkb

First, is_valid returns True instead of False and I see this log when calling it:

IllegalArgumentException: point array must contain 0 or >1 elements

Then, when asking for the wkb, my python process crashes which is even worse:

python3.5: geos_ts_c.cpp:5240: unsigned char* GEOSWKBWriter_write_r(GEOSContextHandle_t, geos::io::WKBWriter*, const geos::geom::Geometry*, std::size_t*): Assertion `0 != geom' failed.
Aborted (core dumped)

Steps to reproduce the problem.

import shapely.geometry
x = shapely.geometry.asShape({'coordinates': ((1130.0, 1110.0),), 'type': 'LineString'})
assert not x.is_valid
x.wkb

Operating system

Ubuntu Xenial. python 3.5.2.

Shapely version and provenance

1.6.2 from pypi

bug

Most helpful comment

hi, i try with 1.7.0 and nothing. then return to 1.6.3 and its fixed..... its sad

All 4 comments

Thanks for the report @pvalsecc. Looks like it is related to https://github.com/Toblerity/Shapely/issues/509.

Yep, indeed. I'm a bit surprised by how long it's been around, though.

Resolved. The fix will be in 1.6.3.

hi, i try with 1.7.0 and nothing. then return to 1.6.3 and its fixed..... its sad

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikedh picture mikedh  路  6Comments

chivasblue picture chivasblue  路  3Comments

jrobichaud picture jrobichaud  路  3Comments

MarkWieczorek picture MarkWieczorek  路  4Comments

sgillies picture sgillies  路  5Comments