twpayne / go-geom

Package geom implements efficient geometry types for geospatial applications.
BSD 2-Clause "Simplified" License
839 stars 104 forks source link

add convert method for geom0 #208

Closed 0fv closed 2 years ago

0fv commented 2 years ago

0fv:master https://github.com/twpayne/go-geom/pull/207#issuecomment-1023808120

I create a module for coords conversation

github.com/0fv/coords-convert

twpayne commented 2 years ago

Thank you for your work here. This functionality is already present in the TransformInPlace function. The equivalent to the code in this PR is roughly:

import "github.com/twpayne/go-geom"

func Convert(g geom.T, f func(x, y double) (double, double)) {
    geom.TransformInPlace(g, func(c geom.Coord) {
        c[0], c[1] = f(c[0], c[1])
    })
}