reader

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: BSD-3-Clause Imports: 7 Imported by: 2

README

go-whosonfirst-iterate-reader

Go package implementing go-whosonfirst-iterate/emitter functionality using whosonfirst/go-reader.Reader instances.

Documentation

Go Reference

Example

import (
	"context"
	"github.com/whosonfirst/go-whosonfirst-iterate/v2/iterator"
	_ "github.com/whosonfirst/go-whosonfirst-iterate-reader"		
	"io"
	"log"
)

func main() {

	ctx := context.Background()
	
	iter_cb := func(ctx context.Context, path string, fh io.ReadSeeker, args ...interface{}) error {
		log.Println(path)	       
		return nil
	}

	iter_uri := "reader://?reader=fs%3A%2F%2F%2Fusr%2Flocal%2Fwhosonfirst%2Fgo-whosonfirst-iterate-reader%2Ffixtures%2Fdata"
	
	iter, _ := iterator.NewIterator(ctx, iter_uri, emitter_cb)

	iter.IterateURIs(ctx, "102/527/513/102527513.geojson")
``

## Tools

### emit

$> go run -mod vendor cmd/emit/main.go
-emitter-uri 'reader://?reader=fs:///usr/local/data/sfomuseum-data-whosonfirst/data' 1 \

| jq '.["properties"]["wof:name"]'

"Null Island"


## See also

* https://github.com/whosonfirst/go-whosonfirst-iterate
* https://github.com/whosonfirst/go-reader 

Documentation

Overview

Package reader implements the `go-whosonfirst-iterate/emitter` interfaces using `whosonfirst/go-reader.Reader` instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReaderEmitter

func NewReaderEmitter(ctx context.Context, uri string) (emitter.Emitter, error)

NewGitEmitter() returns a new `GitEmitter` instance configured by 'uri' in the form of:

reader://?{PARAMETERS}

Where {PATH} is an optional path on disk where a repository will be clone to (default is to clone repository in memory) and {PARAMETERS} may be: * `?include=` Zero or more `aaronland/go-json-query` query strings containing rules that must match for a document to be considered for further processing. * `?exclude=` Zero or more `aaronland/go-json-query` query strings containing rules that if matched will prevent a document from being considered for further processing. * `?include_mode=` A valid `aaronland/go-json-query` query mode string for testing inclusion rules. * `?exclude_mode=` A valid `aaronland/go-json-query` query mode string for testing exclusion rules. * `?reader=` A valid `whosonfirst/go-reader` URI used to create the underlying reader instance.

Types

type ReaderEmitter

type ReaderEmitter struct {
	emitter.Emitter
	// contains filtered or unexported fields
}

GitEmitter implements the `Emitter` interface for crawling records with a `whosonfirst/go-reader.Reader` instance.

func (*ReaderEmitter) WalkURI

func (idx *ReaderEmitter) WalkURI(ctx context.Context, index_cb emitter.EmitterCallbackFunc, path string) error

WalkURI() reads 'path' using the underlying reader (if not excluded by any filters specified when `idx` was created) and invokes 'index_cb'.

Directories

Path Synopsis
cmd
emit command

Jump to

Keyboard shortcuts

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