Documentation ¶
Overview ¶
Package osmapi provides an interface to the OSM v0.6 API.
Index ¶
- Constants
- Variables
- func Changeset(ctx context.Context, id osm.ChangesetID) (*osm.Changeset, error)
- func ChangesetDownload(ctx context.Context, id osm.ChangesetID) (*osm.Change, error)
- func ChangesetWithDiscussion(ctx context.Context, id osm.ChangesetID) (*osm.Changeset, error)
- func Map(ctx context.Context, bounds *osm.Bounds, opts ...FeatureOption) (*osm.OSM, error)
- func Node(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (*osm.Node, error)
- func NodeHistory(ctx context.Context, id osm.NodeID) (osm.Nodes, error)
- func NodeRelations(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (osm.Relations, error)
- func NodeVersion(ctx context.Context, id osm.NodeID, v int) (*osm.Node, error)
- func NodeWays(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (osm.Ways, error)
- func Nodes(ctx context.Context, ids []osm.NodeID, opts ...FeatureOption) (osm.Nodes, error)
- func Note(ctx context.Context, id osm.NoteID) (*osm.Note, error)
- func Notes(ctx context.Context, bounds *osm.Bounds, opts ...NotesOption) (osm.Notes, error)
- func NotesSearch(ctx context.Context, query string, opts ...NotesOption) (osm.Notes, error)
- func Relation(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (*osm.Relation, error)
- func RelationFull(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (*osm.OSM, error)
- func RelationHistory(ctx context.Context, id osm.RelationID) (osm.Relations, error)
- func RelationRelations(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (osm.Relations, error)
- func RelationVersion(ctx context.Context, id osm.RelationID, v int) (*osm.Relation, error)
- func Relations(ctx context.Context, ids []osm.RelationID, opts ...FeatureOption) (osm.Relations, error)
- func User(ctx context.Context, id osm.UserID) (*osm.User, error)
- func Way(ctx context.Context, id osm.WayID, opts ...FeatureOption) (*osm.Way, error)
- func WayFull(ctx context.Context, id osm.WayID, opts ...FeatureOption) (*osm.OSM, error)
- func WayHistory(ctx context.Context, id osm.WayID) (osm.Ways, error)
- func WayRelations(ctx context.Context, id osm.WayID, opts ...FeatureOption) (osm.Relations, error)
- func WayVersion(ctx context.Context, id osm.WayID, v int) (*osm.Way, error)
- func Ways(ctx context.Context, ids []osm.WayID, opts ...FeatureOption) (osm.Ways, error)
- type Datasource
- func (ds *Datasource) Changeset(ctx context.Context, id osm.ChangesetID) (*osm.Changeset, error)
- func (ds *Datasource) ChangesetDownload(ctx context.Context, id osm.ChangesetID) (*osm.Change, error)
- func (ds *Datasource) ChangesetWithDiscussion(ctx context.Context, id osm.ChangesetID) (*osm.Changeset, error)
- func (ds *Datasource) Map(ctx context.Context, bounds *osm.Bounds, opts ...FeatureOption) (*osm.OSM, error)
- func (ds *Datasource) Node(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (*osm.Node, error)
- func (ds *Datasource) NodeHistory(ctx context.Context, id osm.NodeID) (osm.Nodes, error)
- func (ds *Datasource) NodeRelations(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (osm.Relations, error)
- func (ds *Datasource) NodeVersion(ctx context.Context, id osm.NodeID, v int) (*osm.Node, error)
- func (ds *Datasource) NodeWays(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (osm.Ways, error)
- func (ds *Datasource) Nodes(ctx context.Context, ids []osm.NodeID, opts ...FeatureOption) (osm.Nodes, error)
- func (ds *Datasource) NotFound(err error) bool
- func (ds *Datasource) Note(ctx context.Context, id osm.NoteID) (*osm.Note, error)
- func (ds *Datasource) Notes(ctx context.Context, bounds *osm.Bounds, opts ...NotesOption) (osm.Notes, error)
- func (ds *Datasource) NotesSearch(ctx context.Context, query string, opts ...NotesOption) (osm.Notes, error)
- func (ds *Datasource) Relation(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (*osm.Relation, error)
- func (ds *Datasource) RelationFull(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (*osm.OSM, error)
- func (ds *Datasource) RelationHistory(ctx context.Context, id osm.RelationID) (osm.Relations, error)
- func (ds *Datasource) RelationRelations(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (osm.Relations, error)
- func (ds *Datasource) RelationVersion(ctx context.Context, id osm.RelationID, v int) (*osm.Relation, error)
- func (ds *Datasource) Relations(ctx context.Context, ids []osm.RelationID, opts ...FeatureOption) (osm.Relations, error)
- func (ds *Datasource) User(ctx context.Context, id osm.UserID) (*osm.User, error)
- func (ds *Datasource) Way(ctx context.Context, id osm.WayID, opts ...FeatureOption) (*osm.Way, error)
- func (ds *Datasource) WayFull(ctx context.Context, id osm.WayID, opts ...FeatureOption) (*osm.OSM, error)
- func (ds *Datasource) WayHistory(ctx context.Context, id osm.WayID) (osm.Ways, error)
- func (ds *Datasource) WayRelations(ctx context.Context, id osm.WayID, opts ...FeatureOption) (osm.Relations, error)
- func (ds *Datasource) WayVersion(ctx context.Context, id osm.WayID, v int) (*osm.Way, error)
- func (ds *Datasource) Ways(ctx context.Context, ids []osm.WayID, opts ...FeatureOption) (osm.Ways, error)
- type FeatureOption
- type ForbiddenError
- type GoneError
- type NotFoundError
- type NotesOption
- type RateLimiter
- type RequestURITooLongError
- type UnexpectedStatusCodeError
Constants ¶
const BaseURL = "http://api.openstreetmap.org/api/0.6"
BaseURL defines the api host. This can be change to hit a dev server, for example, http://api06.dev.openstreetmap.org/api/0.6
Variables ¶
var DefaultDatasource = &Datasource{ BaseURL: BaseURL, Client: &http.Client{ Timeout: 6 * time.Minute, }, }
DefaultDatasource is the Datasource used by package level convenience functions.
Functions ¶
func Changeset ¶
Changeset returns a given changeset from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func ChangesetDownload ¶
ChangesetDownload returns the full osmchange for the changeset using the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func ChangesetWithDiscussion ¶
ChangesetWithDiscussion returns a changeset and its discussion from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Map ¶
Map returns the latest elements in the given bounding box. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Node ¶
Node returns the latest version of the node from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func NodeHistory ¶
NodeHistory returns all the versions of the node from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func NodeRelations ¶
func NodeRelations(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (osm.Relations, error)
NodeRelations returns all relations a node is part of. There is no error if the element does not exist. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func NodeVersion ¶
NodeVersion returns the specific version of the node from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func NodeWays ¶
NodeWays returns all ways a node is part of. There is no error if the element does not exist. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Nodes ¶
Nodes returns the latest version of the nodes from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Note ¶
Note returns the note from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Notes ¶
Notes returns the notes in a bounding box. Can provide options to limit the results or change what it means to be "closed". See the options or osm api v0.6 docs for details. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func NotesSearch ¶
NotesSearch returns the notes in a bounding box whose text matches the query. Can provide options to limit the results or change what it means to be "closed". See the options or osm api v0.6 docs for details. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Relation ¶
func Relation(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (*osm.Relation, error)
Relation returns the latest version of the relation from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func RelationFull ¶
func RelationFull(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (*osm.OSM, error)
RelationFull returns the relation and its nodes for the latest version the relation. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func RelationHistory ¶
RelationHistory returns all the versions of the relation from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func RelationRelations ¶
func RelationRelations(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (osm.Relations, error)
RelationRelations returns all relations a relation is part of. There is no error if the element does not exist. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func RelationVersion ¶
RelationVersion returns the specific version of the relation from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Relations ¶
func Relations(ctx context.Context, ids []osm.RelationID, opts ...FeatureOption) (osm.Relations, error)
Relations returns the latest version of the relations from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func User ¶
User returns the user from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Way ¶
Way returns the latest version of the way from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func WayFull ¶
WayFull returns the way and its nodes for the latest version the way. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func WayHistory ¶
WayHistory returns all the versions of the way from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func WayRelations ¶
WayRelations returns all relations a way is part of. There is no error if the element does not exist. Delegates to the DefaultDatasource and uses its http.Client to make the request.
func WayVersion ¶
WayVersion returns the specific version of the way from the osm rest api. Delegates to the DefaultDatasource and uses its http.Client to make the request.
Types ¶
type Datasource ¶
type Datasource struct { // If Limiter is non-nil. The datasource will wait/block until the request // is allowed by the rate limiter. To be a good citizen, it is recommended // to use this when making may concurrent requests against the prod osm api. // See the RateLimiter docs for more information. Limiter RateLimiter BaseURL string Client *http.Client }
Datasource defines context about the http client to use to make requests.
func NewDatasource ¶
func NewDatasource(client *http.Client) *Datasource
NewDatasource creates a Datasource using the given client.
func (*Datasource) Changeset ¶
func (ds *Datasource) Changeset(ctx context.Context, id osm.ChangesetID) (*osm.Changeset, error)
Changeset returns a given changeset from the osm rest api.
func (*Datasource) ChangesetDownload ¶
func (ds *Datasource) ChangesetDownload(ctx context.Context, id osm.ChangesetID) (*osm.Change, error)
ChangesetDownload returns the full osmchange for the changeset using the osm rest api.
func (*Datasource) ChangesetWithDiscussion ¶
func (ds *Datasource) ChangesetWithDiscussion(ctx context.Context, id osm.ChangesetID) (*osm.Changeset, error)
ChangesetWithDiscussion returns a changeset and its discussion from the osm rest api.
func (*Datasource) Map ¶
func (ds *Datasource) Map(ctx context.Context, bounds *osm.Bounds, opts ...FeatureOption) (*osm.OSM, error)
Map returns the latest elements in the given bounding box.
func (*Datasource) Node ¶
func (ds *Datasource) Node(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (*osm.Node, error)
Node returns the latest version of the node from the osm rest api.
func (*Datasource) NodeHistory ¶
NodeHistory returns all the versions of the node from the osm rest api.
func (*Datasource) NodeRelations ¶
func (ds *Datasource) NodeRelations(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (osm.Relations, error)
NodeRelations returns all relations a node is part of. There is no error if the element does not exist.
func (*Datasource) NodeVersion ¶
NodeVersion returns the specific version of the node from the osm rest api.
func (*Datasource) NodeWays ¶
func (ds *Datasource) NodeWays(ctx context.Context, id osm.NodeID, opts ...FeatureOption) (osm.Ways, error)
NodeWays returns all ways a node is part of. There is no error if the element does not exist.
func (*Datasource) Nodes ¶
func (ds *Datasource) Nodes(ctx context.Context, ids []osm.NodeID, opts ...FeatureOption) (osm.Nodes, error)
Nodes returns the latest version of the nodes from the osm rest api. Will return 404 if any node is missing.
func (*Datasource) NotFound ¶
func (ds *Datasource) NotFound(err error) bool
NotFound error will return true if the result is not found.
func (*Datasource) Notes ¶
func (ds *Datasource) Notes(ctx context.Context, bounds *osm.Bounds, opts ...NotesOption) (osm.Notes, error)
Notes returns the notes in a bounding box. Can provide options to limit the results or change what it means to be "closed". See the options or osm api v0.6 docs for details.
func (*Datasource) NotesSearch ¶
func (ds *Datasource) NotesSearch(ctx context.Context, query string, opts ...NotesOption) (osm.Notes, error)
NotesSearch returns the notes whose text matches the query. Can provide options to limit the results or change what it means to be "closed". See the options or osm api v0.6 docs for details.
func (*Datasource) Relation ¶
func (ds *Datasource) Relation(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (*osm.Relation, error)
Relation returns the latest version of the relation from the osm rest api.
func (*Datasource) RelationFull ¶
func (ds *Datasource) RelationFull(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (*osm.OSM, error)
RelationFull returns the relation and its nodes for the latest version the relation.
func (*Datasource) RelationHistory ¶
func (ds *Datasource) RelationHistory(ctx context.Context, id osm.RelationID) (osm.Relations, error)
RelationHistory returns all the versions of the relation from the osm rest api.
func (*Datasource) RelationRelations ¶
func (ds *Datasource) RelationRelations(ctx context.Context, id osm.RelationID, opts ...FeatureOption) (osm.Relations, error)
RelationRelations returns all relations a relation is part of. There is no error if the element does not exist.
func (*Datasource) RelationVersion ¶
func (ds *Datasource) RelationVersion(ctx context.Context, id osm.RelationID, v int) (*osm.Relation, error)
RelationVersion returns the specific version of the relation from the osm rest api.
func (*Datasource) Relations ¶
func (ds *Datasource) Relations(ctx context.Context, ids []osm.RelationID, opts ...FeatureOption) (osm.Relations, error)
Relations returns the latest version of the relations from the osm rest api. Will return 404 if any node is missing.
func (*Datasource) Way ¶
func (ds *Datasource) Way(ctx context.Context, id osm.WayID, opts ...FeatureOption) (*osm.Way, error)
Way returns the latest version of the way from the osm rest api.
func (*Datasource) WayFull ¶
func (ds *Datasource) WayFull(ctx context.Context, id osm.WayID, opts ...FeatureOption) (*osm.OSM, error)
WayFull returns the way and its nodes for the latest version the way.
func (*Datasource) WayHistory ¶
WayHistory returns all the versions of the way from the osm rest api.
func (*Datasource) WayRelations ¶
func (ds *Datasource) WayRelations(ctx context.Context, id osm.WayID, opts ...FeatureOption) (osm.Relations, error)
WayRelations returns all relations a way is part of. There is no error if the element does not exist.
func (*Datasource) WayVersion ¶
WayVersion returns the specific version of the way from the osm rest api.
type FeatureOption ¶
type FeatureOption interface {
// contains filtered or unexported methods
}
FeatureOption can be used when fetching a feature or a set of different features.
func At ¶
func At(t time.Time) FeatureOption
At adds an `at=2006-01-02T15:04:05Z` parameter to the request. The osm.fyi supports requesting features and maps as they were at the given time.
type ForbiddenError ¶
type ForbiddenError struct {
URL string
}
ForbiddenError means 403 from the api. Returned whenever the version of the element is not available (due to redaction).
func (*ForbiddenError) Error ¶
func (e *ForbiddenError) Error() string
Error returns an error message with the url causing the problem.
type GoneError ¶
type GoneError struct {
URL string
}
GoneError is returned for deleted elements that get 410 from the api.
type NotFoundError ¶
type NotFoundError struct {
URL string
}
NotFoundError means 404 from the api.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
Error returns an error message with the url causing the problem.
type NotesOption ¶
type NotesOption interface {
// contains filtered or unexported methods
}
NotesOption defines a valid option for the osmapi.Notes by bounding box api.
func Limit ¶
func Limit(num int) NotesOption
Limit indicates the number of results to return valid values [1,10000]. Default is 100.
func MaxDaysClosed ¶
func MaxDaysClosed(num int) NotesOption
MaxDaysClosed specifies the number of days a note needs to be closed to no longer be returned. 0 will return only open notes, -1 will return all notes. Default is 7.
type RateLimiter ¶
A RateLimiter is something that can wait until its next allowed request. This interface is met by `golang.org/x/time/rate.Limiter` and is meant to be used with it. For example:
// 10 qps osmapi.DefaultDatasource.Limiter = rate.NewLimiter(10, 1)
type RequestURITooLongError ¶
type RequestURITooLongError struct {
URL string
}
RequestURITooLongError is returned when requesting too many ids in a multi id request, ie. Nodes, Ways, Relations functions.
func (*RequestURITooLongError) Error ¶
func (e *RequestURITooLongError) Error() string
Error returns an error message with the url causing the problem.
type UnexpectedStatusCodeError ¶
UnexpectedStatusCodeError is return for a non 200 or 404 status code.
func (*UnexpectedStatusCodeError) Error ¶
func (e *UnexpectedStatusCodeError) Error() string
Error returns an error message with some information.