hierarchy

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: BSD-3-Clause Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PointInPolygonHierarchyResolver

type PointInPolygonHierarchyResolver struct {
	// Database is the `database.SpatialDatabase` instance used to perform point-in-polygon requests.
	Database database.SpatialDatabase
	// Mapshaper is an optional `mapshaper.Client` instance used to derive centroids used in point-in-polygon requests.
	Mapshaper *mapshaper.Client
	// PlacetypesDefinition is an optional `go-whosonfirst-placetypes.Definition` instance used to resolve custom or bespoke placetypes.
	PlacetypesDefinition placetypes.Definition
	// contains filtered or unexported fields
}

PointInPolygonHierarchyResolver provides methods for constructing a hierarchy of ancestors for a given point, following rules established by the Who's On First project.

func NewPointInPolygonHierarchyResolver

func NewPointInPolygonHierarchyResolver(ctx context.Context, opts *PointInPolygonHierarchyResolverOptions) (*PointInPolygonHierarchyResolver, error)

NewPointInPolygonHierarchyResolver returns a `PointInPolygonHierarchyResolver` instance for 'spatial_db' and 'ms_client'. The former is used to perform point in polygon operations and the latter is used to determine a "reverse geocoding" centroid to use for point-in-polygon operations.

func (*PointInPolygonHierarchyResolver) PointInPolygon

func (t *PointInPolygonHierarchyResolver) PointInPolygon(ctx context.Context, inputs *filter.SPRInputs, body []byte) ([]spr.StandardPlacesResult, error)

PointInPolygon will perform a point-in-polygon (reverse geocoding) operation for 'body' using zero or more 'inputs' as query filters. This is known to not work as expected if the `wof:placetype` property is "common". There needs to be a way to a) retrieve placetypes using a custom WOFPlacetypeSpecification (go-whosonfirst-placetypes v0.6.0+) and b) specify an alternate property to retrieve placetypes from if `wof:placetype=custom`.

func (*PointInPolygonHierarchyResolver) PointInPolygonAndUpdate

PointInPolygonAndUpdate will ...

func (*PointInPolygonHierarchyResolver) PointInPolygonCentroid

func (t *PointInPolygonHierarchyResolver) PointInPolygonCentroid(ctx context.Context, body []byte) (*orb.Point, error)

PointInPolygonCentroid derives an *orb.Point (or "centroid") to use for point-in-polygon operations.

func (*PointInPolygonHierarchyResolver) SetReader

func (t *PointInPolygonHierarchyResolver) SetReader(r reader.Reader)

SetReader assigns 'r' as the internal `reader.Reader` instance used to retrieve ancestor records when resolving a hierarchy.

type PointInPolygonHierarchyResolverOptions

type PointInPolygonHierarchyResolverOptions struct {
	// Database is the `database.SpatialDatabase` instance used to perform point-in-polygon requests.
	Database database.SpatialDatabase
	// Mapshaper is an optional `mapshaper.Client` instance used to derive centroids used in point-in-polygon requests.
	Mapshaper *mapshaper.Client
	// PlacetypesDefinition is an optional `go-whosonfirst-placetypes.Definition` instance used to resolve custom or bespoke placetypes.
	PlacetypesDefinition placetypes.Definition
	// SkipPlacetypeFilter is an optional boolean flag to signal whether or not point-in-polygon operations should be performed using
	// the list of known ancestors for a given placetype. Default is false.
	SkipPlacetypeFilter bool
	// Roles is an optional list of Who's On First placetype roles used to derive ancestors during point-in-polygon operations.
	// If missing (or zero length) then all possible roles will be assumed.
	Roles []string
}

type PointInPolygonHierarchyResolverUpdateCallback

type PointInPolygonHierarchyResolverUpdateCallback func(context.Context, reader.Reader, spr.StandardPlacesResult) (map[string]interface{}, error)

PointInPolygonHierarchyResolverUpdateCallback is a function definition for a custom callback to convert 'spr' in to a dictionary of properties containining hierarchy information. Records in 'spr' are expected to be able to be read from 'r'.

func DefaultPointInPolygonHierarchyResolverUpdateCallback

func DefaultPointInPolygonHierarchyResolverUpdateCallback() PointInPolygonHierarchyResolverUpdateCallback

DefaultPointInPolygonHierarchyResolverUpdateCallback returns a `PointInPolygonHierarchyResolverUpdateCallback` function that will return a dictionary containing the following properties: wof:parent_id, wof:country, wof:hierarchy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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