nominatim

package module
v0.0.0-...-5b4c6c9 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 7 Imported by: 0

README

GO Nominatim

Wrapper around Nominatim API

Import

import(
    nm "git.sr.ht/~yuriizinets/go-nominatim"
)

Usage

n := nm.Nominatim{}
results, err := n.Search(nm.SearchParameters{  // Check SearchResult struct for details
    Query:          "Miami, Florida",
    CountryCodes:   []string{"us"},
    IncludeAddress: true,
    IncludeGeoJSON: true,
})
if err != nil {
    log.Panicln(err)
}
log.Println(results[0].DisplayName)
log.Println(results[0].Lat, results[0].Lng)
log.Println(results[0].BoundingBox)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Nominatim

type Nominatim struct {
	BaseURL           string // Use another than default nominatim base url
	FormatHouseNumber bool   // Remove all letters from house number
	UseCache          bool   // Use caching for same requests
	Sync              bool   // Only 1 request at the same time
}

func (*Nominatim) Search

func (n *Nominatim) Search(p SearchParameters) ([]SearchResult, error)

type SearchAddress

type SearchAddress struct {
	HouseNumber   string `json:"house_number"`
	Road          string `json:"road"`
	Building      string `json:"building"`
	City          string `json:"city"`
	Suburb        string `json:"suburb"`
	Neighbourhood string `json:"neighbourhood"`
	County        string `json:"county"`
	State         string `json:"state"`
	PostalCode    string `json:"postcode"`
	Country       string `json:"country"`
	CountryCode   string `json:"country_code"`
}

type SearchParameters

type SearchParameters struct {
	// Search query
	Query string
	// Detailed search, don't combine with Query
	Street     string
	City       string
	County     string
	State      string
	Country    string
	PostalCode string
	// Limit results
	CountryCodes []string
	Limit        int
	Viewbox      []float64 // x1,y1,x2,y2
	// Additional features
	IncludeAddress bool
	IncludeGeoJSON bool
}

type SearchResult

type SearchResult struct {
	PlaceID        int                    `json:"place_id"`
	License        string                 `json:"licence"`
	OSMType        string                 `json:"osm_type"`
	OSMID          int                    `json:"osm_id"`
	BoundingBoxStr []string               `json:"boundingbox"`
	LatStr         string                 `json:"lat"`
	LngStr         string                 `json:"lon"`
	DisplayName    string                 `json:"display_name"`
	Class          string                 `json:"class"`
	Type           string                 `json:"type"`
	Importance     float64                `json:"importance"`
	Icon           string                 `json:"icon"`
	GeoJSON        map[string]interface{} `json:"geojson"`
	Address        SearchAddress          `json:"address"`
	BoundingBox    []float64
	Lat            float64
	Lng            float64
}

Jump to

Keyboard shortcuts

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