Skip to content

Helper function for finding the center of a polygon? #131

@C-Loftus

Description

@C-Loftus

Thank you very much for your work on this library.

I am trying to get the center of many different geometry types. I wanted to check if there is a function for this already implemented. And if not, if it would be reasonable enhancement. Depending on timeline I could probably look at contributing this upstream. I would probably start with prioritizing geom.Polygon since that is most important to my use case

This is the sort of thing I am looking to accomplish

	geometry, err := wktEncoder.DecodeString(wkt)
	if err != nil {
		return "", err
	}
	switch geometry.(type) {
	case geom.Point:
		point := geometry.(*geom.Point)
		return foo(point.X(), point.Y())
	case geom.Polygon:
		polygon := geometry.(*geom.Polygon)
                // ??
		center := 
        return foo(center.X(), center.Y())
       // so on and so forth for others
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions