Documentation
¶
Index ¶
- type PointInPolygonHierarchyResolver
- func (t *PointInPolygonHierarchyResolver) PointInPolygon(ctx context.Context, inputs *filter.SPRInputs, body []byte) ([]spr.StandardPlacesResult, error)
- func (t *PointInPolygonHierarchyResolver) PointInPolygonAndUpdate(ctx context.Context, inputs *filter.SPRInputs, ...) (bool, []byte, error)
- func (t *PointInPolygonHierarchyResolver) PointInPolygonCentroid(ctx context.Context, body []byte) (*orb.Point, error)
- func (t *PointInPolygonHierarchyResolver) SetReader(r reader.Reader)
- type PointInPolygonHierarchyResolverOptions
- type PointInPolygonHierarchyResolverUpdateCallback
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 ¶
func (t *PointInPolygonHierarchyResolver) PointInPolygonAndUpdate(ctx context.Context, inputs *filter.SPRInputs, results_cb hierarchy_filter.FilterSPRResultsFunc, update_cb PointInPolygonHierarchyResolverUpdateCallback, body []byte) (bool, []byte, error)
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. If you are using a custom placetypes defintion (see whosonfirst/go-whosonfirst-placetypes)
// and do not enable this flag you will need to manually re-assign the `wof:placetype` property of each record being ingested in to your spatial
// database to take the form of "{CUSTOM_PLACETYPE}#{CUSTOM_PLACETYPE_DEFINITION_URI}". This is necessary because by the time placetype filtering
// occurs the code is working with `whosonfirst/go-whosonfirst-spr.StandardPlacesResult` instances which only have access to a generic `Placetype`
// method. There is no guarantee that changing the default value of the `wof:placetype` property will not have unintended consequences so it might
// be easiest just to enable this flag and deal with placetype filtering in a custom `FilterSPRResultsFunc` callback. 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