Opened 14 years ago

Closed 14 years ago

#14318 closed (fixed)

Add GEOSGeometry.valid_reason

Reported by: Robert Coup Owned by: jbronn
Component: GIS Version: dev
Severity: Keywords: geos
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When you're messing with geometries it's handy to find out the reason why they're invalid. GEOS >= v3.1 supports GEOSisValidReason() for that purpose - returning a string about why a geometry is invalid. The attached patch adds support to the GeoDjango GEOS bindings as GEOSGeometry.valid_reason.

Tests, docs, and error-chucking for GEOS <v3.1 are included.

Attachments (2)

geos_validreason.1.diff (4.3 KB ) - added by Robert Coup 14 years ago.
Patch against r13683 (without the random test_sqlite change this time)
geos_validreason.2.diff (4.6 KB ) - added by jbronn 14 years ago.

Download all attachments as: .zip

Change History (5)

by Robert Coup, 14 years ago

Attachment: geos_validreason.1.diff added

Patch against r13683 (without the random test_sqlite change this time)

by jbronn, 14 years ago

Attachment: geos_validreason.2.diff added

comment:1 by jbronn, 14 years ago

Owner: changed from nobody to jbronn
Status: newassigned

Updated the patch to make sure 3.1 is available before making prototype for GEOSisValidReason (else there'd be an AttributeError when trying to get function from C library). 99% ready for check-in, only thing that's bugging me is whether we should rename property invalid_reason, because users are only checking when geometries are invalid.

comment:2 by Robert Coup, 14 years ago

only thing that's bugging me is whether we should rename property invalid_reason

Yeah, I was in two minds as well. You do get a "Valid Geometry" message. TBH i would have preferred None or "" but I didn't want to forcibly change the return value. +0

comment:3 by jbronn, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [14447]) Fixed #14318 -- Added GEOSGeometry.valid_reason property. Thanks, Rob Coup.

Note: See TracTickets for help on using tickets.
Back to Top