osm

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2018 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Changeset

type Changeset struct {
	XMLName      xml.Name  `xml:"changeset"`
	ID           int64     `xml:"id,attr,omitempty"`
	User         string    `xml:"user,attr,omitempty"`
	UID          int64     `xml:"uid,attr,omitempty"`
	CreatedAt    time.Time `xml:"created_at,attr,omitempty"`
	ClosedAt     time.Time `xml:"closed_at,attr,omitempty"`
	Open         bool      `xml:"open,attr,omitempty"`
	MinLat       float64   `xml:"min_lat,attr,omitempty"`
	MinLon       float64   `xml:"min_lon,attr,omitempty"`
	MaxLat       float64   `xml:"max_lat,attr,omitempty"`
	MaxLon       float64   `xml:"max_lon,attr,omitempty"`
	CommentCount int64     `xml:"comments_count,attr,omitempty"`

	Tags []Tag `xml:"tag"`
}

Changeset contains information about a changeset in the API. You need to create a changeset before submitting any changes to the API.

type Client

type Client struct {
	APIBaseURL  string
	HTTPClient  *http.Client
	CurrentUser *User

	DebugHTTPRequests bool
	// contains filtered or unexported fields
}

Client represents an OSM client which is capable of RW operations on the OpenStreetMap

func New

func New(username, password string, useDevServer bool) (*Client, error)

New instantiates a new client and retrieves information about the current user. Set useDevServer to true to change the API URL to the api06.dev.openstreetmap.org server.

func NewWithAPIEndpoint added in v0.3.0

func NewWithAPIEndpoint(username, password, apiEndpoint string) (*Client, error)

NewWithAPIEndpoint instantiates a new client and retrieves information about the current user. Set apiEndpoint to your desired API endpoint (e.g. https://api06.dev.openstreetmap.org/api/0.6)

func (*Client) CreateChangeset

func (c *Client) CreateChangeset() (*Changeset, error)

CreateChangeset creates a new changeset

func (*Client) GetMyChangesets

func (c *Client) GetMyChangesets(onlyOpen bool) ([]*Changeset, error)

GetMyChangesets retrieves a list of (open) changesets from the API

func (*Client) RetrieveMapObjects

func (c *Client) RetrieveMapObjects(minLat, minLon, maxLat, maxLon float64) (*Wrap, error)

RetrieveMapObjects queries all objects within the passed bounds. You need to ensure the min values are below the max values.

func (*Client) SaveChangeset

func (c *Client) SaveChangeset(cs *Changeset) error

SaveChangeset updates or creates a changeset

func (*Client) SaveNode

func (c *Client) SaveNode(n *Node, cs *Changeset) error

SaveNode creates or updates a node with an association to the passed changeset which needs to be open and known to the API.

type Node

type Node struct {
	XMLName   xml.Name `xml:"node"`
	ID        int64    `xml:"id,attr,omitempty"`
	Version   int64    `xml:"version,attr,omitempty"`
	Changeset int64    `xml:"changeset,attr,omitempty"`
	User      string   `xml:"user,attr,omitempty"`
	UID       int64    `xml:"uid,attr,omitempty"`
	Latitude  float64  `xml:"lat,attr"`
	Longitude float64  `xml:"lon,attr"`

	Tags []Tag `xml:"tag"`
}

Node represents one node in the OpenStreetMap

type Tag

type Tag struct {
	XMLName xml.Name `xml:"tag"`
	Key     string   `xml:"k,attr"`
	Value   string   `xml:"v,attr"`
}

Tag represents a key-value pair used in all objects inside OpenStreetMap

type User

type User struct {
	XMLName        xml.Name  `xml:"user"`
	ID             int64     `xml:"id,attr"`
	DisplayName    string    `xml:"display_name,attr"`
	AccountCreated time.Time `xml:"account_created,attr"`

	Description string `xml:"description"`
}

User contains information about an User in the OpenStreetMap

type Wrap

type Wrap struct {
	XMLName    xml.Name     `xml:"osm"`
	User       *User        `xml:"user,omitempty"`
	Changesets []*Changeset `xml:"changeset,omitempty"`
	Nodes      []*Node      `xml:"node,omitempty"`
}

Wrap is a mostly internal used struct which holds requests to / responses from the API. You will get a Wrap object when querying map objects from the API

Jump to

Keyboard shortcuts

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