pip

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: BSD-3-Clause Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

wof

wof pip

$> ./bin/wof pip -h
Perform point-in-polygon and wof:hierarchy update operations on one or more Who's On First records.
Usage:
	 ./bin/wof path(N) path(N)
  -export
    	"Export-ify" each record after point-in-polygon operations are complete.
  -mapshaper-client-uri string
    	Optional URI to a sfomuseum/go-sfomuseum-mapshaper server instance used to derive point-in-polygon centroids. If absent then the centroid used to perform point-in-polygon operations will be determined using internal heuristics.
  -placetype string
    	Assign this value as the "wof:placetype" property before performing point-in-polygon operations.
  -spatial-database-uri string
    	A valid whosonfirst/go-whosonfirst-spatial/database URI. By default 'pmtiles://' and 'sqlite://' spatial database URIs are supported.
  -stdout
    	Boolean flag signaling that updated records should be written to STDOUT. (default true)
Examples

For example, imagine a shell script like this (in order to account for boring URL-escaping issues):

#!/bin/sh

TILES_URI=file:///usr/local/data
TILES_DATABASE=architecture
TILES_ZOOM=12
TILES_LAYER=architecture

ENC_TILES_URI=`urlescape ${TILES_URI}`

./bin/wof pip \
    -spatial-database-uri "pmtiles://?tiles=${ENC_TILES_URI}&database=${TILES_DATABASE}&zoom=${TILES_ZOOM}&layer=${TILES_LAYER}&enable-cache=true" \
    -mapshaper-client-uri http://localhost:8080 \
    -placetype venue \
    test.geojson 
	 

Running this command would yield something like this:

2024/05/20 15:34:27 INFO fetching architecture 0-16384
2024/05/20 15:34:27 INFO fetched architecture 0-16384
2024/05/20 15:34:27 INFO fetching architecture 127-89
2024/05/20 15:34:27 INFO fetched architecture 127-89
2024/05/20 15:34:27 INFO Time to create database path=/architecture/12/655/1585.mvt "spatial database uri"="sqlite://?dsn=modernc://mem" "count features"=628 time=183.835708ms
{
  "id": 6102,
  "type": "Feature",
  "properties": {
    "USAGE": "STAIR"
  ,"wof:placetype":"venue","wof:parent_id":102527513,"wof:country":"US","wof:hierarchy":[{"campus_id":102527513,"continent_id":102191575,"country_id":85633793,"county_id":102087579,"locality_id":85922583,"postalcode_id":554784711,"region_id":85688637},{"campus_id":102527513,"continent_id":102191575,"country_id":85633793,"county_id":102085387,"region_id":85688637}]},
  "bbox": null,
  "geometry": {"coordinates":[[[-122.39515729496134,37.62304022215619,40],[-122.39511251529856,37.62305107289922,40],[-122.39508811697748,37.623056984354164,40],[-122.39509251970546,37.62306848116357,40],[-122.39510034575342,37.62308891418595,40],[-122.39516943471905,37.62307271147819,40],[-122.39515729496134,37.62304022215619,40]]],"type":"Polygon"}
}

There are a few things to note:

  • The -placetype flag is a convenience to facilitate point-in-polygon operations without having to first update an input record.
  • By default the pip command neither "formats" or "exports" results. Although there is an -export flag to enable both it is your responsibility to ensure that input documents have all the necessary properties (for example "wof:name").
  • The pip command does NOT yet implement the logic of the py-mapzen-whosonfirst-hierarchy library. There is an open issue for this.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultFlagSet

func DefaultFlagSet() *flag.FlagSet

func NewPointInPolygonCommand

func NewPointInPolygonCommand(ctx context.Context, cmd string) (wof.Command, error)

func RunWithOptions

func RunWithOptions(ctx context.Context, opts *RunOptions) error

Types

type PointInPolygonCommand

type PointInPolygonCommand struct {
	wof.Command
}

func (*PointInPolygonCommand) Run

func (c *PointInPolygonCommand) Run(ctx context.Context, args []string) error

type RunOptions

type RunOptions struct {
	// A list of URIs to perform point-in-polygon operations on.
	URIs []string
	// Write output to STDOUT
	Stdout bool
	// ...
	Export bool
	// ...
	Exporter export.Exporter
	// ...
	Placetype string
	// Resolver is a `PointInPolygonHierarchyResolver` instance which is what manages all the point-in-polygon operations and related decision making.
	Resolver *hierarchy.PointInPolygonHierarchyResolver
	// ResultsFunc is function used to derive a single `spr.StandardPlacesResult` from a list of `spr.StandardPlacesResult` instances (point-in-polygon candidates).
	ResultsFunc hierarchy_filter.FilterSPRResultsFunc
	// InputFilters are filterd used to limits the point-in-polygon candidates to consider.
	InputFilters *filter.SPRInputs
	// UpdateCallback is a function definition for a custom callback to convert point-in-polygon candidates in to a dictionary of properties containining hierarchy information
	UpdateCallback hierarchy.PointInPolygonHierarchyResolverUpdateCallback
}

Jump to

Keyboard shortcuts

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