Documentation ¶
Index ¶
- Constants
- Variables
- func AllRoles() []string
- func AppendPlacetype(pt WOFPlacetype) error
- func AppendPlacetypeSpecification(spec *WOFPlacetypeSpecification) error
- func IsAncestor(a *WOFPlacetype, b *WOFPlacetype) bool
- func IsDescendant(a *WOFPlacetype, b *WOFPlacetype) bool
- func IsValidPlacetype(name string) bool
- func IsValidPlacetypeId(id int64) bool
- func RegisterDefinition(ctx context.Context, scheme string, init_func DefinitionInitializationFunc) error
- func Schemes() []string
- type Definition
- type DefinitionInitializationFunc
- type WOFPlacetype
- func Ancestors(pt *WOFPlacetype) []*WOFPlacetype
- func AncestorsForRoles(pt *WOFPlacetype, roles []string) []*WOFPlacetype
- func Children(pt *WOFPlacetype) []*WOFPlacetype
- func Descendants(pt *WOFPlacetype) []*WOFPlacetype
- func DescendantsForRoles(pt *WOFPlacetype, roles []string) []*WOFPlacetype
- func GetPlacetypeById(id int64) (*WOFPlacetype, error)
- func GetPlacetypeByName(name string) (*WOFPlacetype, error)
- func Placetypes() ([]*WOFPlacetype, error)
- func PlacetypesForRoles(roles []string) ([]*WOFPlacetype, error)
- type WOFPlacetypeAltNames
- type WOFPlacetypeName
- type WOFPlacetypeRecord
- type WOFPlacetypeSpecification
- func (spec *WOFPlacetypeSpecification) Ancestors(pt *WOFPlacetype) []*WOFPlacetype
- func (spec *WOFPlacetypeSpecification) AncestorsForRoles(pt *WOFPlacetype, roles []string) []*WOFPlacetype
- func (spec *WOFPlacetypeSpecification) AppendPlacetype(pt WOFPlacetype) error
- func (spec *WOFPlacetypeSpecification) AppendPlacetypeSpecification(other_spec *WOFPlacetypeSpecification) error
- func (spec *WOFPlacetypeSpecification) Catalog() map[string]WOFPlacetype
- func (spec *WOFPlacetypeSpecification) Children(pt *WOFPlacetype) []*WOFPlacetype
- func (spec *WOFPlacetypeSpecification) Descendants(pt *WOFPlacetype) []*WOFPlacetype
- func (spec *WOFPlacetypeSpecification) DescendantsForRoles(pt *WOFPlacetype, roles []string) []*WOFPlacetype
- func (spec *WOFPlacetypeSpecification) GetPlacetypeById(id int64) (*WOFPlacetype, error)
- func (spec *WOFPlacetypeSpecification) GetPlacetypeByName(name string) (*WOFPlacetype, error)
- func (spec *WOFPlacetypeSpecification) GraphPlacetypes() (graph.Graph[string, *WOFPlacetype], error)
- func (spec *WOFPlacetypeSpecification) IsAncestor(a *WOFPlacetype, b *WOFPlacetype) bool
- func (spec *WOFPlacetypeSpecification) IsDescendant(a *WOFPlacetype, b *WOFPlacetype) bool
- func (spec *WOFPlacetypeSpecification) IsValidPlacetype(name string) bool
- func (spec *WOFPlacetypeSpecification) IsValidPlacetypeId(id int64) bool
- func (spec *WOFPlacetypeSpecification) Placetypes() ([]*WOFPlacetype, error)
- func (spec *WOFPlacetypeSpecification) PlacetypesForRoles(roles []string) ([]*WOFPlacetype, error)
- func (spec *WOFPlacetypeSpecification) PlacetypesToGraphviz(wr io.Writer) error
- type WhosOnFirstDefinition
Constants ¶
const COMMON_COLOUR string = "blue"
COMMON_COLOUR defines the Graphviz edge colour for the "common" placetype role.
const COMMON_OPTIONAL_COLOUR string = "green"
COMMON_OPTIONAL_COLOUR defines the Graphviz edge colour for the "common_optional" placetype role.
const COMMON_OPTIONAL_ROLE string = "common_optional"
COMMON_OPTIONAL_ROLE defines the string label for the "common_optional" placetype role.
const COMMON_ROLE string = "common"
COMMON_ROLE defines the string label for the "common" placetype role.
const CUSTOM_COLOUR string = "black"
CUSTOM_COLOUR defines the Graphviz edge colour for the "custom" placetype role.
const CUSTOM_ROLE string = "custom"
CUSTOM_ROLE defines the string label for the "custom" placetype role.
const OPTIONAL_COLOUR string = "orange"
OPTIONAL_COLOUR defines the Graphviz edge colour for the "optional" placetype role.
const OPTIONAL_ROLE string = "optional"
OPTIONAL_ROLE defines the string label for the "optional" placetype role.
const WHOSONFIRST_DEFINITION_SCHEME string = "whosonfirst"
Variables ¶
var FS embed.FS
Functions ¶
func AllRoles ¶ added in v0.6.0
func AllRoles() []string
AllRoles returns a list of all the known placetype roles.
func AppendPlacetype ¶ added in v0.2.0
func AppendPlacetype(pt WOFPlacetype) error
AppendPlacetype appends 'pt' to the catalog of available placetypes.
func AppendPlacetypeSpecification ¶ added in v0.2.2
func AppendPlacetypeSpecification(spec *WOFPlacetypeSpecification) error
AppendPlacetypeSpecification appends the placetypes defined in 'other_spec' to the catalog of available placetypes in 'spec'.
func IsAncestor ¶ added in v0.4.0
func IsAncestor(a *WOFPlacetype, b *WOFPlacetype) bool
Returns true is 'b' is an ancestor of 'a'.
func IsDescendant ¶ added in v0.4.0
func IsDescendant(a *WOFPlacetype, b *WOFPlacetype) bool
Returns true is 'b' is a descendant of 'a'.
func IsValidPlacetype ¶
IsValidPlacetypeId returns a boolean value indicating whether 'name' is a known and valid placetype name.
func IsValidPlacetypeId ¶
IsValidPlacetypeId returns a boolean value indicating whether 'id' is a known and valid placetype ID.
func RegisterDefinition ¶ added in v0.7.0
func RegisterDefinition(ctx context.Context, scheme string, init_func DefinitionInitializationFunc) error
RegisterDefinition registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Definition` instances by the `NewDefinition` method.
Types ¶
type Definition ¶ added in v0.7.0
type Definition interface { // Specification returns the `WOFPlacetypeSpecification` instance associated with the definition Specification() *WOFPlacetypeSpecification // Property return the relative (base) property name whose values (placetypes) are associated with the definition's placetype specification Property() string // URI() returns the URI used to create the definition URI() string }
type Definition provides an interface for working with "core" and custom placetype specifications and for creating them using a URI-based syntax
func NewDefinition ¶ added in v0.7.0
func NewDefinition(ctx context.Context, uri string) (Definition, error)
NewDefinition returns a new `Definition` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `DefinitionInitializationFunc` function used to instantiate the new `Definition`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterDefinition` method.
func NewWhosOnFirstDefinition ¶ added in v0.7.0
func NewWhosOnFirstDefinition(ctx context.Context, uri string) (Definition, error)
type DefinitionInitializationFunc ¶ added in v0.7.0
type DefinitionInitializationFunc func(ctx context.Context, uri string) (Definition, error)
DefinitionInitializationFunc is a function defined by individual definition package and used to create an instance of that definition
type WOFPlacetype ¶
type WOFPlacetype struct { Id int64 `json:"id"` Name string `json:"name"` Role string `json:"role"` Parent []int64 `json:"parent"` }
Type WOFPlacetype defines an individual placetype encoded in a `WOFPlacetypeSpecification` instance. The choice of naming this "WOFPlacetype" is unfortunate because since it is easily confused with the actual JSON definition files for placetypes. However, we're stuck with it for now in order to preserve backwards compatibility. Womp womp...
This needs to be renamed to "Placetype" or something either at a /v1 or a v2 release. Either way it will be a breaking change. Doing it v2 (even if there is no explicit v1 release) might be "cleaner"...
func Ancestors ¶
func Ancestors(pt *WOFPlacetype) []*WOFPlacetype
Ancestors returns the ancestors of role "common" for 'pt'.
func AncestorsForRoles ¶
func AncestorsForRoles(pt *WOFPlacetype, roles []string) []*WOFPlacetype
AncestorsForRoles returns the ancestors matching any role in 'roles' for 'pt'.
func Children ¶
func Children(pt *WOFPlacetype) []*WOFPlacetype
Children returns the immediate child placetype of 'pt'.
func Descendants ¶
func Descendants(pt *WOFPlacetype) []*WOFPlacetype
Descendants returns the descendants of role "common" for 'pt'.
func DescendantsForRoles ¶
func DescendantsForRoles(pt *WOFPlacetype, roles []string) []*WOFPlacetype
DescendantsForRoles returns the descendants matching any role in 'roles' for 'pt'.
func GetPlacetypeById ¶
func GetPlacetypeById(id int64) (*WOFPlacetype, error)
GetPlacetypesByName returns the `WOFPlacetype` instance associated with 'id'.
func GetPlacetypeByName ¶
func GetPlacetypeByName(name string) (*WOFPlacetype, error)
GetPlacetypesByName returns the `WOFPlacetype` instance associated with 'name'.
func Placetypes ¶ added in v0.1.1
func Placetypes() ([]*WOFPlacetype, error)
Placetypes returns all the known placetypes which are descendants of "planet" for the 'common', 'optional', 'common_optional', and 'custom' roles.
func PlacetypesForRoles ¶ added in v0.1.2
func PlacetypesForRoles(roles []string) ([]*WOFPlacetype, error)
Placetypes returns all the known placetypes which are descendants of "planet" whose role match any of those defined in 'roles'.
func (*WOFPlacetype) IsCorePlacetype ¶ added in v0.6.0
func (pt *WOFPlacetype) IsCorePlacetype() bool
IsCorePlacetype returns a boolean value if 'pt' is one of the "core" Who's On First placetypes.
func (*WOFPlacetype) String ¶ added in v0.6.0
func (pt *WOFPlacetype) String() string
String returns the value of the `Name` property for 'pt'.
type WOFPlacetypeAltNames ¶
type WOFPlacetypeName ¶
type WOFPlacetypeRecord ¶ added in v0.7.0
type WOFPlacetypeRecord struct { Id int64 `json:"wof:id"` Name string `json:"wof:name"` Role string `json:"wof:role"` Parent []string `json:"wof:parent"` Concordances map[string]string `json:"wof:concordances"` }
Type WOFPlacetypeRecord is a struct that maps to the JSON record files for individual placetypes in the `whosonfirst-placetypes` repo. Note that as of this writing it does not account for BCP-47 name: properties.
This needs to be renamed to "Record" either at a /v1 or a v2 release. Either way it will be a breaking change. Doing it v2 (even if there is no explicit v1 release) might be "cleaner"...
type WOFPlacetypeSpecification ¶
type WOFPlacetypeSpecification struct {
// contains filtered or unexported fields
}
This needs to be renamed to "Specification" either at a /v1 or a v2 release. Either way it will be a breaking change. Doing it v2 (even if there is no explicit v1 release) might be "cleaner"...
func DefaultWOFPlacetypeSpecification ¶ added in v0.2.1
func DefaultWOFPlacetypeSpecification() (*WOFPlacetypeSpecification, error)
func NewWOFPlacetypeSpecification ¶ added in v0.2.1
func NewWOFPlacetypeSpecification(body []byte) (*WOFPlacetypeSpecification, error)
NewWOFPlacetypeSpecification returns a `WOFPlacetypeSpecification` derived from 'body'.
func NewWOFPlacetypeSpecificationWithReader ¶ added in v0.2.3
func NewWOFPlacetypeSpecificationWithReader(r io.Reader) (*WOFPlacetypeSpecification, error)
func (*WOFPlacetypeSpecification) Ancestors ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) Ancestors(pt *WOFPlacetype) []*WOFPlacetype
Ancestors returns the ancestors of role "common" for 'pt'.
func (*WOFPlacetypeSpecification) AncestorsForRoles ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) AncestorsForRoles(pt *WOFPlacetype, roles []string) []*WOFPlacetype
AncestorsForRoles returns the ancestors matching any role in 'roles' for 'pt'.
func (*WOFPlacetypeSpecification) AppendPlacetype ¶ added in v0.2.0
func (spec *WOFPlacetypeSpecification) AppendPlacetype(pt WOFPlacetype) error
AppendPlacetype appends 'pt' to the catalog of available placetypes.
func (*WOFPlacetypeSpecification) AppendPlacetypeSpecification ¶ added in v0.2.2
func (spec *WOFPlacetypeSpecification) AppendPlacetypeSpecification(other_spec *WOFPlacetypeSpecification) error
AppendPlacetypeSpecification appends the placetypes defined in 'other_spec' to the catalog of available placetypes in 'spec'.
func (*WOFPlacetypeSpecification) Catalog ¶ added in v0.2.0
func (spec *WOFPlacetypeSpecification) Catalog() map[string]WOFPlacetype
Catalog returns the catalog of placetypes contained by 'spec'.
func (*WOFPlacetypeSpecification) Children ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) Children(pt *WOFPlacetype) []*WOFPlacetype
Children returns the immediate child placetype of 'pt'.
func (*WOFPlacetypeSpecification) Descendants ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) Descendants(pt *WOFPlacetype) []*WOFPlacetype
Descendants returns the descendants of role "common" for 'pt'.
func (*WOFPlacetypeSpecification) DescendantsForRoles ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) DescendantsForRoles(pt *WOFPlacetype, roles []string) []*WOFPlacetype
DescendantsForRoles returns the descendants matching any role in 'roles' for 'pt'.
func (*WOFPlacetypeSpecification) GetPlacetypeById ¶ added in v0.2.0
func (spec *WOFPlacetypeSpecification) GetPlacetypeById(id int64) (*WOFPlacetype, error)
GetPlacetypesByName returns the `WOFPlacetype` instance associated with 'id'.
func (*WOFPlacetypeSpecification) GetPlacetypeByName ¶ added in v0.2.0
func (spec *WOFPlacetypeSpecification) GetPlacetypeByName(name string) (*WOFPlacetype, error)
GetPlacetypesByName returns the `WOFPlacetype` instance associated with 'name'.
func (*WOFPlacetypeSpecification) GraphPlacetypes ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) GraphPlacetypes() (graph.Graph[string, *WOFPlacetype], error)
GraphPlacetypes will generate a directed graph for all the placetypes defined in 'spec'.
func (*WOFPlacetypeSpecification) IsAncestor ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) IsAncestor(a *WOFPlacetype, b *WOFPlacetype) bool
Returns true is 'b' is an ancestor of 'a'.
func (*WOFPlacetypeSpecification) IsDescendant ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) IsDescendant(a *WOFPlacetype, b *WOFPlacetype) bool
Returns true is 'b' is a descendant of 'a'.
func (*WOFPlacetypeSpecification) IsValidPlacetype ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) IsValidPlacetype(name string) bool
IsValidPlacetypeId returns a boolean value indicating whether 'name' is a known and valid placetype name.
func (*WOFPlacetypeSpecification) IsValidPlacetypeId ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) IsValidPlacetypeId(id int64) bool
IsValidPlacetypeId returns a boolean value indicating whether 'id' is a known and valid placetype ID.
func (*WOFPlacetypeSpecification) Placetypes ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) Placetypes() ([]*WOFPlacetype, error)
Placetypes returns all the known placetypes which are descendants of "planet" for the 'common', 'optional', 'common_optional', and 'custom' roles.
func (*WOFPlacetypeSpecification) PlacetypesForRoles ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) PlacetypesForRoles(roles []string) ([]*WOFPlacetype, error)
Placetypes returns all the known placetypes which are descendants of "planet" whose role match any of those defined in 'roles'.
func (*WOFPlacetypeSpecification) PlacetypesToGraphviz ¶ added in v0.6.0
func (spec *WOFPlacetypeSpecification) PlacetypesToGraphviz(wr io.Writer) error
PlacetypesToGraphviz will generate a DOT description for 'spec' and write it to 'wr'.
type WhosOnFirstDefinition ¶ added in v0.7.0
type WhosOnFirstDefinition struct { Definition // contains filtered or unexported fields }
func (*WhosOnFirstDefinition) Property ¶ added in v0.7.0
func (s *WhosOnFirstDefinition) Property() string
func (*WhosOnFirstDefinition) Specification ¶ added in v0.7.0
func (s *WhosOnFirstDefinition) Specification() *WOFPlacetypeSpecification
func (*WhosOnFirstDefinition) URI ¶ added in v0.7.0
func (s *WhosOnFirstDefinition) URI() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package draw provides methods for graphical representations of a placetypes specification
|
Package draw provides methods for graphical representations of a placetypes specification |