reader

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: BSD-3-Clause Imports: 6 Imported by: 36

README

go-whosonfirst-reader

Common methods for reading Who's On First documents.

Documentation

Go Reference

Examples

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

LoadReadCloser
import (
	"context"
	"github.com/whosonfirst/go-reader"
	wof_reader "github.com/whosonfirst/go-whosonfirst-reader"
	"io"
	"os"
)

func main() {

	ctx := context.Backround()
	wof_id := int64(101736545)

	r_uri := "local:///usr/local/data/whosonfirst-data-admin-ca/data"
	r, _ := reader.NewReader(ctx, r_uri)

	fh, _ := wof_reader.LoadReadCloser(ctx, r, wof_id)
	io.Copy(os.Stdout, fh)
}
LoadBytes
import (
	"context"
	"fmt"
	"github.com/whosonfirst/go-reader"
	wof_reader "github.com/whosonfirst/go-whosonfirst-reader"
)

func main() {

	ctx := context.Backround()
	wof_id := int64(101736545)

	r_uri := "local:///usr/local/data/whosonfirst-data-admin-ca/data"
	r, _ := reader.NewReader(ctx, r_uri)

	body, _ := wof_reader.LoadBytes(ctx, r, wof_id)
	fmt.Printf("%d bytes\n", len(body))
}
LoadFeature
import (
	"context"
	"fmt"
	"github.com/whosonfirst/go-reader"
	wof_reader "github.com/whosonfirst/go-whosonfirst-reader"	
)

func main() {

	ctx := context.Backround()
	wof_id := int64(101736545)

	r_uri := "local:///usr/local/data/whosonfirst-data-admin-ca/data"
	r, _ := reader.NewReader(ctx, r_uri)

	f, _ := wof_reader.LoadFeatureFromID(ctx, r, wof_id)

	props := f.Properties
	name := props.MustString("wof:name")
	fmt.Println(name)
}

See also

Documentation

Overview

package reader provides common logic for whosonfirst/go-reader applications specific to Who's On First documents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadBytes added in v1.0.0

func LoadBytes(ctx context.Context, r go_reader.Reader, id int64) ([]byte, error)

LoadBytes will return an `[]byte` instance from 'r' for the relative path associated with 'id'.

func LoadFeature added in v1.0.0

func LoadFeature(ctx context.Context, r go_reader.Reader, id int64) (*geojson.Feature, error)

LoadBytes will return an `paulmach/orb/geojson.Feature` instance from 'r' for the relative path associated with 'id'.

func LoadReadCloser added in v1.0.0

func LoadReadCloser(ctx context.Context, r go_reader.Reader, id int64) (io.ReadCloser, error)

LoadReadCloser will return an `io.ReadCloser` instance from 'r' for the relative path associated with 'id'.

Types

This section is empty.

Jump to

Keyboard shortcuts

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