go-geom icon indicating copy to clipboard operation
go-geom copied to clipboard

Method to check validity of geometries

Open Amogh-Bharadwaj opened this issue 1 year ago • 1 comments

Hey everyone. I was wondering if there is a way to check if an EWKB value was a valid geometry, much like PostGIS' ST_IsValid function

For example, I want to detect if a value I'm getting is a LINESTRING with only one point, or a polygon which is not closed

I am aware of this Unmarshal function:

	geo, err := ewkb.Unmarshal(MustHexDecode("010200000001000000000000000000F03F0000000000000040"))
	if err != nil {
		fmt.Println("invalid geo value. ignoring:", err)
	}

In a way wish there was a geo.IsValid() or some attribute which can be checked to deduce validity. Thanks !

Amogh-Bharadwaj avatar Oct 17 '23 15:10 Amogh-Bharadwaj

There is currently no such function in go-geom. Contributions welcome!

You may also consider github.com/twpayne/go-geos which does have such a function.

twpayne avatar Oct 18 '23 02:10 twpayne