osmnames

package module
Version: v0.0.0-...-679e898 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 6 Imported by: 0

README

GO OSMNames

Simple wrapper around https://osmnames.org/

How to use

Check sources docs for details:
https://pkg.go.dev/github.com/yuriizinets/go-osmnames

Example usage:


import(
    "fmt"
    osmnames "github.com/yuriizinets/go-osmnames"
)

osmn := &OSMNames{
    Server: "<link to osmnames server>",
    Key: "<provide key, if needed>"
}
res, err := osmn.Query(osmnames.Parameters{
    Query: "Miami, Florida",
    Country: "us",
})
if err != nil {
    panic(err)
}
for _, hit := res.Results {
    fmt.Println(hit.DisplayName)
}

Run tests

$ OSMNAMES_URL=<...> go test
PASS
ok      github.com/yuriizinets/go-osmnames      3.530s
$

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hit

type Hit struct {
	ID          int       `json:"id"`
	Lon         float64   `json:"lon"`
	Lat         float64   `json:"lat"`
	BoundingBox []float64 `json:"bounding_box"`
	Name        string    `json:"name"`
	NameSuffix  string    `json:"name_suffix"`
	DisplayName string    `json:"display_name"`
	Type        string    `json:"type"`
	City        string    `json:"city"`
	County      string    `json:"county"`
	Street      string    `json:"street"`
	State       string    `json:"state"`
}

type OSMNames

type OSMNames struct {
	Server string
	Key    string
}

func (*OSMNames) Query

func (o *OSMNames) Query(p Parameters) (Response, error)

type Parameters

type Parameters struct {
	Query   string
	Country string
}

type Response

type Response struct {
	Count        int   `json:"count"`
	NextIndex    int   `json:"nextIndex"`
	StartIndex   int   `json:"startIndex"`
	TotalResults int   `json:"totalResults"`
	Results      []Hit `json:"results"`
}

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL