go-spatial / geom

Geometry interfaces to help drive interoperability within the Go geospatial community
MIT License
173 stars 38 forks source link

Helper function for retrieving the underlying type of geom.Geometry #106

Closed ARolek closed 4 years ago

ARolek commented 4 years ago

A helper function that would accept the geom.Geometry container type and then return either a string or a GeomType. This is useful when writing an error message like:

fmt.Printf("expected %t, got %t", geom.LineString{}, goem.Type(geom.Geometry))

Potential function signature

func geom.Type(geom.Geometry) GeomType {
  // switch on the type and return it
}
gdey commented 4 years ago

Are you sure this is needed? https://play.golang.org/p/uQtcbPQjwdy This seems to print the base type when you use '%T"

ARolek commented 4 years ago

@gdey indeed it does. I learned something new today.