Go package for exporting Who's On First documents.
go-whosonfirst-export is a Go package for exporting Who's On First documents in Go. It is a port of the py-mapzen-whosonfirst-geojson package and mmmmmmmaybe some or all of the py-mapzen-whosonfirst-export package.
This package is still in flux. It is starting to settle down with the v2
release but it might still change.
Error handling removed for the sake of brevity.
import (
"context"
"github.com/whosonfirst/go-whosonfirst-export/v2"
"io/ioutil"
"os
)
func main() {
ctx := context.Background()
path := "some.geojson"
fh, _ := os.Open(path)
defer fh.Close()
body, _ := ioutil.ReadAll(fh)
opts, _ := export.NewDefaultOptions(ctx)
export.Export(body, opts, os.Stdout)
}
import (
"context"
"github.com/whosonfirst/go-whosonfirst-export/v2"
"io/ioutil"
"os
)
func main() {
ctx := context.Background()
ex, _ := export.NewExporter(ctx, "whosonfirst://")
path := "some.geojson"
fh, _ := os.Open(path)
defer fh.Close()
body, _ := ioutil.ReadAll(fh)
body, _ = ex.Export(ctx, body)
os.Stdout.Write(body)
}
type Exporter interface {
Export(context.Context, []byte) ([]byte, error)
ExportFeature(context.Context, interface{}) ([]byte, error)
}
This package needs to hold hands with the go-whosonfirst-validate
package.