writer

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2022 License: BSD-3-Clause Imports: 8 Imported by: 3

README

go-whosonfirst-writer

Common methods for writing Who's On First documents.

Documentation

Go Reference

Examples

Note that error handling has been removed for the sake of brevity.

WriteFeature
import (
	"context"
	"flag"
	"github.com/paulmach/orb/geojson"
	"io"
	wof_writer "github.com/whosonfirst/go-whosonfirst-writer"
	"github.com/whosonfirst/go-writer"			
)

func main() {

	flag.Parse()

	ctx := context.Background()
	wr, _ := writer.NewWriter(ctx, "stdout://")
	
	for _, feature_path := range flag.Args() {
	
		r, _ := os.Open(feature_path)
		body, _ := io.ReadAll(r)		    
		f, _ := geojson.UnmarshalFeature(body)

		wof_writer.WriteFeature(ctx, wr, f)
	}
WriteBytes
import (
	"context"
	"flag"
	"github.com/whosonfirst/go-writer"	
	wof_writer "github.com/whosonfirst/go-whosonfirst-writer"
	"io"
)

func main() {

	flag.Parse()

	ctx := context.Background()
	wr, _ := writer.NewWriter(ctx, "stdout://")
	
	for _, feature_path := range flag.Args() {
	
		fh, _ := os.Open(feature_path)
		body, _ := io.ReadAll(fh)
		
		wof_writer.WriteBytes(ctx, wr, body)
	}

See also

Documentation

Overview

package writer provides common methods for writing Who's On First documents with `whosonfirst/go-writer.Writer` instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteBytes added in v1.0.0

func WriteBytes(ctx context.Context, wr go_writer.Writer, body []byte) error

WriteBytes will write 'body' using 'wr' using a default `whosonfirst/go-whosonfirst-export/v2.Exporter` instance.

func WriteBytesWithExporter added in v1.0.0

func WriteBytesWithExporter(ctx context.Context, wr go_writer.Writer, ex export.Exporter, body []byte) error

WriteBytesWithExporter will write 'body' using 'wr' using a custom `whosonfirst/go-whosonfirst-export/v2.Exporter` instance.

func WriteFeature

func WriteFeature(ctx context.Context, wr go_writer.Writer, f *geojson.Feature) error

WriteFeature will serialize and write 'f' using 'wr' using a default `whosonfirst/go-whosonfirst-export/v2.Exporter` instance.

func WriteFeatureWithExporter added in v1.0.0

func WriteFeatureWithExporter(ctx context.Context, wr go_writer.Writer, ex export.Exporter, f *geojson.Feature) error

WriteFeatureWithExporter will serialize and write 'f' using 'wr' using a custom `whosonfirst/go-whosonfirst-export/v2.Exporter` instance.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL