rtree

package module
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause Imports: 25 Imported by: 3

README

go-whosonfirst-spatial-rtree

In-memory implementation of the go-whosonfirst-spatial interfaces.

Important

This is work in progress. Documentation remains incomplete.

Interfaces

This package implements the following go-whosonfirst-spatial interfaces.

spatial.SpatialDatabase
import (
	"github.com/whosonfirst/go-whosonfirst-spatial/database"
	_ "github.com/whosonfirst/go-whosonfirst-spatial-rtree"       
)

db, err := database.NewSpatialDatabase(ctx, "rtree://")
Database URIs

The go-whosonfirst-spatial-rtree package is instantiated using a URI in the form of:

rtree://?{PARAMETERS}

Valid parameters include:

Parameters
Name Value Required Notes
strict bool N
index_alt_files bool N

Tools

$> make cli
query
$> ./bin/query -h
  -alternate-geometry value
    	One or more alternate geometry labels (wof:alt_label) values to filter results by.
  -cessation-date string
    	A valid EDTF date string.
  -custom-placetypes string
    	A JSON-encoded string containing custom placetypes defined using the syntax described in the whosonfirst/go-whosonfirst-placetypes repository.
  -enable-custom-placetypes
    	Enable wof:placetype values that are not explicitly defined in the whosonfirst/go-whosonfirst-placetypes repository.
  -geometries string
    	Valid options are: all, alt, default. (default "all")
  -inception-date string
    	A valid EDTF date string.
  -is-ceased value
    	One or more existential flags (-1, 0, 1) to filter results by.
  -is-current value
    	One or more existential flags (-1, 0, 1) to filter results by.
  -is-deprecated value
    	One or more existential flags (-1, 0, 1) to filter results by.
  -is-superseded value
    	One or more existential flags (-1, 0, 1) to filter results by.
  -is-superseding value
    	One or more existential flags (-1, 0, 1) to filter results by.
  -is-wof
    	Input data is WOF-flavoured GeoJSON. (Pass a value of '0' or 'false' if you need to index non-WOF documents. (default true)
  -iterator-uri string
    	A valid whosonfirst/go-whosonfirst-iterate/emitter URI. Supported schemes are: directory://, featurecollection://, file://, filelist://, geojsonl://, repo://. (default "repo://")
  -latitude float
    	A valid latitude.
  -longitude float
    	A valid longitude.
  -placetype value
    	One or more place types to filter results by.
  -properties-reader-uri string
    	A valid whosonfirst/go-reader.Reader URI. Available options are: [file:// fs:// null://]
  -property value
    	One or more Who's On First properties to append to each result.
  -spatial-database-uri string
    	A valid whosonfirst/go-whosonfirst-spatial/data.SpatialDatabase URI. options are: [rtree://]
  -verbose
    	Be chatty.
Example
$> ./bin/query \
	-iterator-uri 'repo://?include=properties.mz:is_current=1' \
	-latitude 37.613490350845794 \
	-longitude -122.38882533303682 \
	/usr/local/data/sfomuseum-data-architecture/

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

"Boarding Area A"
"SFO Terminal Complex"
"International Terminal"

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRTreeSpatialDatabase

func NewRTreeSpatialDatabase(ctx context.Context, uri string) (database.SpatialDatabase, error)

Types

type RTreeCache

type RTreeCache struct {
	Geometry *geojson.Geometry        `json:"geometry"`
	SPR      spr.StandardPlacesResult `json:"properties"`
}

type RTreeResults

type RTreeResults struct {
	spr.StandardPlacesResults `json:",omitempty"`
	Places                    []spr.StandardPlacesResult `json:"places"`
}

func (*RTreeResults) Results

func (r *RTreeResults) Results() []spr.StandardPlacesResult

type RTreeSpatialDatabase

type RTreeSpatialDatabase struct {
	database.SpatialDatabase
	Logger *log.Logger
	// contains filtered or unexported fields
}

func (*RTreeSpatialDatabase) Close

func (r *RTreeSpatialDatabase) Close(ctx context.Context) error

func (*RTreeSpatialDatabase) Flush added in v0.2.2

func (r *RTreeSpatialDatabase) Flush(ctx context.Context) error

func (*RTreeSpatialDatabase) IndexFeature

func (r *RTreeSpatialDatabase) IndexFeature(ctx context.Context, body []byte) error

func (*RTreeSpatialDatabase) PointInPolygon

func (r *RTreeSpatialDatabase) PointInPolygon(ctx context.Context, coord *orb.Point, filters ...spatial.Filter) (spr.StandardPlacesResults, error)

func (*RTreeSpatialDatabase) PointInPolygonCandidates

func (r *RTreeSpatialDatabase) PointInPolygonCandidates(ctx context.Context, coord *orb.Point, filters ...spatial.Filter) ([]*spatial.PointInPolygonCandidate, error)

func (*RTreeSpatialDatabase) PointInPolygonCandidatesWithChannels

func (r *RTreeSpatialDatabase) PointInPolygonCandidatesWithChannels(ctx context.Context, rsp_ch chan *spatial.PointInPolygonCandidate, err_ch chan error, done_ch chan bool, coord *orb.Point, filters ...spatial.Filter)

func (*RTreeSpatialDatabase) PointInPolygonWithChannels

func (r *RTreeSpatialDatabase) PointInPolygonWithChannels(ctx context.Context, rsp_ch chan spr.StandardPlacesResult, err_ch chan error, done_ch chan bool, coord *orb.Point, filters ...spatial.Filter)

func (*RTreeSpatialDatabase) Read added in v0.0.8

func (*RTreeSpatialDatabase) ReaderURI added in v0.0.8

func (r *RTreeSpatialDatabase) ReaderURI(ctx context.Context, str_uri string) string

func (*RTreeSpatialDatabase) RemoveFeature added in v0.1.0

func (r *RTreeSpatialDatabase) RemoveFeature(ctx context.Context, id string) error

func (*RTreeSpatialDatabase) SetLogger added in v0.2.2

func (r *RTreeSpatialDatabase) SetLogger(ctx context.Context, logger *log.Logger) error

func (*RTreeSpatialDatabase) Write added in v0.0.8

func (r *RTreeSpatialDatabase) Write(ctx context.Context, key string, fh io.ReadSeeker) (int64, error)

func (*RTreeSpatialDatabase) WriterURI added in v0.0.8

func (r *RTreeSpatialDatabase) WriterURI(ctx context.Context, str_uri string) string

type RTreeSpatialIndex

type RTreeSpatialIndex struct {
	Rect      *rtreego.Rect
	Id        string
	FeatureId string
	IsAlt     bool
	AltLabel  string
}

func (*RTreeSpatialIndex) Bounds

func (i *RTreeSpatialIndex) Bounds() rtreego.Rect

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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