Documentation
¶
Overview ¶
package hierarchy provides methods for deriving hierarchies from and associated with Who's On First records.
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 // Logger is a `log.Logger` instance for logging feedback. The default logger sends all messages to `io.Discard`. Logger *log.Logger // 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 ¶ added in v0.4.0
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 ¶ added in v0.5.0
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 // Logger is an optional `log.Logger` instance for logging feedback. Logger *log.Logger // 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