uri

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: BSD-3-Clause Imports: 8 Imported by: 159

README

go-whosonfirst-uri

Go package for working with URIs for Who's On First documents

Install

You will need to have both Go and the make programs installed on your computer. Assuming you do just type:

make bin

All of this package's dependencies are bundled with the code in the vendor directory.

Example

Simple
import (
	"github.com/whosonfirst/go-whosonfirst-uri"
)

fname, _ := uri.Id2Fname(101736545)
rel_path, _ := uri.Id2RelPath(101736545)
abs_path, _ := uri.Id2AbsPath("/usr/local/data", 101736545)

Produces:

101736545.geojson
101/736/545/101736545.geojson
/usr/local/data/101/736/545/101736545.geojson
Fancy
import (
	"github.com/whosonfirst/go-whosonfirst-uri"
)

source := "mapzen"
function := "display"
extras := []string{ "1024" }

args := uri.NewAlternateURIArgs(source, function, extras...)

fname, _ := uri.Id2Fname(101736545, args)
rel_path, _ := uri.Id2RelPath(101736545, args)
abs_path, _ := uri.Id2AbsPath("/usr/local/data", 101736545, args)

Produces:

101736545-alt-mapzen-display-1024.geojson
101/736/545/101736545-alt-mapzen-display-1024.geojson
/usr/local/data/101/736/545/101736545-alt-mapzen-display-1024.geojson

The Long Version

Please read this: https://github.com/whosonfirst/whosonfirst-cookbook/blob/master/how_to/creating_alt_geometries.md

Tools

wof-uri-expand

Expand one or more IDs in to their URIs (relative or absolute).

./bin/wof-uri-expand -h
Usage of ./bin/wof-uri-expand:
  -root string
    	An optional (filesystem) root to prepend URIs with
  -stdin
    	Read IDs from STDIN

For example:

./bin/wof-uri-expand 1234556 46632
123/455/6/1234556.geojson
466/32/46632.geojson

Or:

./bin/wof-uri-expand -root /usr/local/data 1234556 46632
/usr/local/data/123/455/6/1234556.geojson
/usr/local/data/466/32/46632.geojson

Or:

cat ./test | ./bin/wof-uri-expand -stdin
487/463/636/453/487463636453.geojson
982/635/344/2/9826353442.geojson

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Id2AbsPath

func Id2AbsPath(root string, id int64, args ...*URIArgs) (string, error)

func Id2Fname

func Id2Fname(id int64, args ...*URIArgs) (string, error)

func Id2Path

func Id2Path(id int64) (string, error)

func Id2RelPath

func Id2RelPath(id int64, args ...*URIArgs) (string, error)

func IdFromPath

func IdFromPath(path string) (int64, error)

func IsAltFile

func IsAltFile(path string) (bool, error)

func IsWOFFile

func IsWOFFile(path string) (bool, error)

func RepoFromPath

func RepoFromPath(path string) (string, error)

Types

type AltGeom

type AltGeom struct {
	Source   string
	Function string
	Extras   []string
}

func AltGeomFromPath

func AltGeomFromPath(path string) (*AltGeom, error)

func (*AltGeom) String

func (a *AltGeom) String() string

type URIArgs

type URIArgs struct {
	// PLEASE UPDATE THIS TO USE/EXPECT AN *AltGeom KTHXBYE (20190501/thisisaaronland)
	Alternate bool
	Source    string
	Function  string
	Extras    []string
	Strict    bool
}

func NewAlternateURIArgs

func NewAlternateURIArgs(source string, function string, extras ...string) *URIArgs

func NewDefaultURIArgs

func NewDefaultURIArgs() *URIArgs

Directories

Path Synopsis
cmd
wof-uri-alt command
wof-uri-expand command

Jump to

Keyboard shortcuts

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