Documentation ¶
Index ¶
- func ConvertTo3waImpl(geo *Geocoder, coords *Coordinates) (interface{}, error)
- func ConvertToCoordsImpl(geo *Geocoder, words string) (interface{}, error)
- func GridSectionImpl(geo *Geocoder, box *Box) (interface{}, error)
- func IsWhat3WordsAddress(address string) bool
- func PackageVersion() string
- type AutoSuggestRequest
- func (ar *AutoSuggestRequest) InputTypeIsText() bool
- func (ar *AutoSuggestRequest) SetClipToBoundingBox(box *Box)
- func (ar *AutoSuggestRequest) SetClipToCircle(circle *Circle)
- func (ar *AutoSuggestRequest) SetClipToCountry(countries []string)
- func (ar *AutoSuggestRequest) SetClipToPolyGon(polygon *PolyGon)
- func (ar *AutoSuggestRequest) SetFocus(focus *Coordinates)
- func (ar *AutoSuggestRequest) SetInputType(input string) error
- func (ar *AutoSuggestRequest) SetNFocusResults(number int) error
- func (ar *AutoSuggestRequest) SetNResults(number int) error
- func (ar *AutoSuggestRequest) SetPreferLand(land bool)
- type AutoSuggestRequestInterface
- type AutoSuggestResponse
- type Box
- type Circle
- type ConvertTo3waResponse
- type ConvertToCoordsResponse
- type Coordinates
- type CoordinatesInterface
- type ErrorDetails
- type Geocoder
- func (geocoder *Geocoder) APIKey() string
- func (geocoder *Geocoder) AutoSuggest(request *AutoSuggestRequest) (*AutoSuggestResponse, error)
- func (geocoder *Geocoder) AvailableLanguages() (*LanguagesResponse, error)
- func (geocoder *Geocoder) BaseURL() *url.URL
- func (geocoder *Geocoder) ConvertTo3wa(coord *Coordinates) (*ConvertTo3waResponse, error)
- func (geocoder *Geocoder) ConvertTo3waGeoJSON(coord *Coordinates) (*geojson.FeatureCollection, error)
- func (geocoder *Geocoder) ConvertToCoords(words string) (*ConvertToCoordsResponse, error)
- func (geocoder *Geocoder) ConvertToCoordsGeoJSON(words string) (*geojson.FeatureCollection, error)
- func (geocoder *Geocoder) Format() string
- func (geocoder *Geocoder) GridSection(box *Box) (*GridSectionResponse, error)
- func (geocoder *Geocoder) GridSectionGeoJSON(box *Box) (*geojson.FeatureCollection, error)
- func (geocoder *Geocoder) IsFormatGeoJSON() bool
- func (geocoder *Geocoder) IsFormatJSON() bool
- func (geocoder *Geocoder) Language() string
- func (geocoder *Geocoder) SetAPIKey(apiKey string)
- func (geocoder *Geocoder) SetBaseURL(urlString string) error
- func (geocoder *Geocoder) SetFormat(format string) error
- func (geocoder *Geocoder) SetFormatGeoJSON()
- func (geocoder *Geocoder) SetFormatJSON()
- func (geocoder *Geocoder) SetLanguage(language string)
- func (geocoder *Geocoder) Version() string
- type GeocoderInterface
- type GridSectionResponse
- type Language
- type LanguagesResponse
- type Line
- type PolyGon
- type Response
- type ResponseError
- type ResponseErrorInterface
- type ShapeInterface
- type Suggestion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertTo3waImpl ¶
func ConvertTo3waImpl(geo *Geocoder, coords *Coordinates) (interface{}, error)
ConvertTo3waImpl perform REST API request over HTTP.
func ConvertToCoordsImpl ¶
ConvertToCoordsImpl perform REST API request over HPTTP.
func GridSectionImpl ¶ added in v0.1.0
GridSectionImpl perform REST API request over HTTP.
func IsWhat3WordsAddress ¶ added in v0.3.5
func PackageVersion ¶ added in v0.3.0
func PackageVersion() string
PackageVersion returns Git version tag of current package
Types ¶
type AutoSuggestRequest ¶ added in v0.1.0
type AutoSuggestRequest struct { Input string NResults int Focus *Coordinates NFocusResults int ClipToCountry []string ClipToBoundingBox *Box ClipToCircle *Circle ClipToPolyGon *PolyGon InputType string PreferLand bool }
AutoSuggestRequest response from REST API. Tags are used to map from the JSON response.
func NewAutoSuggestRequest ¶ added in v0.1.0
func NewAutoSuggestRequest(input string) *AutoSuggestRequest
NewAutoSuggestRequest instantiate a AutoSuggestRequest object.
func (*AutoSuggestRequest) InputTypeIsText ¶ added in v0.2.0
func (ar *AutoSuggestRequest) InputTypeIsText() bool
InputTypeIsText sets the Input type.
func (*AutoSuggestRequest) SetClipToBoundingBox ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetClipToBoundingBox(box *Box)
SetClipToBoundingBox sets the cliping box.
func (*AutoSuggestRequest) SetClipToCircle ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetClipToCircle(circle *Circle)
SetClipToCircle sets the clipping circle.
func (*AutoSuggestRequest) SetClipToCountry ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetClipToCountry(countries []string)
SetClipToCountry sets the list of countries.
func (*AutoSuggestRequest) SetClipToPolyGon ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetClipToPolyGon(polygon *PolyGon)
SetClipToPolyGon sets the clipping circle.
func (*AutoSuggestRequest) SetFocus ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetFocus(focus *Coordinates)
SetFocus sets the focus point.
func (*AutoSuggestRequest) SetInputType ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetInputType(input string) error
SetInputType sets the Input type.
func (*AutoSuggestRequest) SetNFocusResults ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetNFocusResults(number int) error
SetNFocusResults sets the Number of focus results parameter.
func (*AutoSuggestRequest) SetNResults ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetNResults(number int) error
SetNResults sets the Number of results parameter.
func (*AutoSuggestRequest) SetPreferLand ¶ added in v0.1.0
func (ar *AutoSuggestRequest) SetPreferLand(land bool)
SetPreferLand sets the PeferLand type.
type AutoSuggestRequestInterface ¶ added in v0.3.0
type AutoSuggestRequestInterface interface { SetNResults(number int) error SetFocus(focus *Coordinates) SetNFocusResults(number int) error SetClipToCountry(countries []string) SetClipToBoundingBox(box *Box) SetClipToCircle(circle *Circle) SetClipToPolyGon(polygon *PolyGon) SetInputType(input string) error InputTypeIsText() bool SetPreferLand(land bool) }
AutoSuggestRequestInterface interface definiton
type AutoSuggestResponse ¶ added in v0.1.0
type AutoSuggestResponse struct {
Suggestions []*Suggestion `json:"suggestions"`
}
AutoSuggestResponse response from REST API. Tags are used to map from the JSON response.
func AutoSuggestImpl ¶ added in v0.1.0
func AutoSuggestImpl(geo *Geocoder, areq *AutoSuggestRequest) (*AutoSuggestResponse, error)
AutoSuggestImpl perform REST API request over HTTP.
func NewAutoSuggestResponse ¶ added in v0.1.0
func NewAutoSuggestResponse() *AutoSuggestResponse
NewAutoSuggestResponse instantiate a AutoSuggestResponse object.
type Box ¶ added in v0.1.0
type Box struct { SouthWest *Coordinates `json:"southwest"` NorthEast *Coordinates `json:"northeast"` }
Box defines an area bounded by two coordinates. South West and North East points of the Box define its extent. // Tags are used to map from the JSON response.
func NewBox ¶ added in v0.1.0
func NewBox(sw *Coordinates, ne *Coordinates) (*Box, error)
NewBox returns a Box region
type Circle ¶ added in v0.1.0
type Circle struct { Centre *Coordinates `json:"centre"` Radius float64 `json:"radius"` }
Circle defines an area bounded by a coordinate and a radius. Tags are used to map from the JSON response.
type ConvertTo3waResponse ¶
type ConvertTo3waResponse struct {
Response
}
ConvertTo3waResponse response from REST API. Tags are used to map from the JSON response.
func NewConvertTo3waResponse ¶
func NewConvertTo3waResponse() *ConvertTo3waResponse
NewConvertTo3waResponse instantiate a ConvertTo3waResponse object.
type ConvertToCoordsResponse ¶
type ConvertToCoordsResponse struct {
Response
}
ConvertToCoordsResponse response from REST API. Tags are used to map from the JSON response.
func NewConvertToCoordsResponse ¶
func NewConvertToCoordsResponse() *ConvertToCoordsResponse
NewConvertToCoordsResponse instantiate a ConvertToCoordsResponse object.
type Coordinates ¶
Coordinates struct with latitude and longitude. Tags are used to map from the JSON response.
func NewCoordinates ¶
func NewCoordinates(lat float64, lon float64) (*Coordinates, error)
NewCoordinates return a new Coordinates object. constructed from latitude and longitude values. It verifies range of latitude and longitude are correct.
func (*Coordinates) SetLat ¶
func (coord *Coordinates) SetLat(lat float64) error
SetLat sets the Latitude in a Coordinates object. verifying range of latitude is correct.
func (*Coordinates) SetLon ¶
func (coord *Coordinates) SetLon(lon float64) error
SetLon sets the Longitude in a Coordinates object. verifying range of longitude is correct.
func (*Coordinates) String ¶ added in v0.1.0
func (coord *Coordinates) String() string
String returns a string suitable for a URL parameter.
type CoordinatesInterface ¶ added in v0.3.0
type CoordinatesInterface interface { SetLat(lat float64) error SetLon(lon float64) error String() string }
CoordinatesInterface interface definition
type ErrorDetails ¶
ErrorDetails response from REST API. Tags are used to map from the JSON response.
type Geocoder ¶
type Geocoder struct {
// contains filtered or unexported fields
}
Geocoder struct with information needed to make HTTP API calls.
func NewGeocoder ¶
NewGeocoder return a new Geocoder. Default values ensure W3W API V3 is used, json is returned and English is the default language.
func (*Geocoder) AutoSuggest ¶ added in v0.1.0
func (geocoder *Geocoder) AutoSuggest(request *AutoSuggestRequest) (*AutoSuggestResponse, error)
AutoSuggest suggests a list of 3 word addresses from an imprecise input.
func (*Geocoder) AvailableLanguages ¶ added in v0.1.0
func (geocoder *Geocoder) AvailableLanguages() (*LanguagesResponse, error)
AvailableLanguages returns a list of available languages.
func (*Geocoder) ConvertTo3wa ¶
func (geocoder *Geocoder) ConvertTo3wa(coord *Coordinates) (*ConvertTo3waResponse, error)
ConvertTo3wa converts a set of coordinates to a 3 word address.
func (*Geocoder) ConvertTo3waGeoJSON ¶ added in v0.1.2
func (geocoder *Geocoder) ConvertTo3waGeoJSON(coord *Coordinates) (*geojson.FeatureCollection, error)
ConvertTo3waGeoJSON converts a set of coordinates to a 3 word address.
func (*Geocoder) ConvertToCoords ¶
func (geocoder *Geocoder) ConvertToCoords(words string) (*ConvertToCoordsResponse, error)
ConvertToCoords converts a 3 word address to coordinates.
func (*Geocoder) ConvertToCoordsGeoJSON ¶ added in v0.1.2
func (geocoder *Geocoder) ConvertToCoordsGeoJSON(words string) (*geojson.FeatureCollection, error)
ConvertToCoordsGeoJSON converts a 3 word address to coordinates.
func (*Geocoder) GridSection ¶ added in v0.1.0
func (geocoder *Geocoder) GridSection(box *Box) (*GridSectionResponse, error)
GridSection returns a list of lines from a box.
func (*Geocoder) GridSectionGeoJSON ¶ added in v0.1.2
func (geocoder *Geocoder) GridSectionGeoJSON(box *Box) (*geojson.FeatureCollection, error)
GridSectionGeoJSON returns a list of lines from a box.
func (*Geocoder) IsFormatGeoJSON ¶ added in v0.1.2
IsFormatGeoJSON test the Format for a Geocoder.
func (*Geocoder) IsFormatJSON ¶ added in v0.1.2
IsFormatJSON test the Format for a Geocoder.
func (*Geocoder) SetBaseURL ¶ added in v0.2.2
SetBaseURL set the base URL for a Geocoder.
func (*Geocoder) SetFormatGeoJSON ¶ added in v0.1.2
func (geocoder *Geocoder) SetFormatGeoJSON()
SetFormatGeoJSON set format as GeoJSON
func (*Geocoder) SetFormatJSON ¶ added in v0.1.2
func (geocoder *Geocoder) SetFormatJSON()
SetFormatJSON set format as JSON
func (*Geocoder) SetLanguage ¶
SetLanguage set the language in a Geocoder.
type GeocoderInterface ¶ added in v0.3.0
type GeocoderInterface interface { SetAPIKey(apiKey string) APIKey() string BaseURL() *url.URL SetBaseURL(urlString string) error Format() string SetFormat(format string) error SetFormatJSON() SetFormatGeoJSON() IsFormatJSON() bool IsFormatGeoJSON() bool Language() string SetLanguage(language string) Version() string ConvertTo3wa(coord *Coordinates) (*ConvertTo3waResponse, error) ConvertTo3waGeoJSON(coord *Coordinates) (*geojson.FeatureCollection, error) ConvertToCoords(words string) (*ConvertToCoordsResponse, error) ConvertToCoordsGeoJSON(words string) (*geojson.FeatureCollection, error) AutoSuggest(request *AutoSuggestRequest) (*AutoSuggestResponse, error) GridSection(box *Box) (*GridSectionResponse, error) GridSectionGeoJSON(box *Box) (*geojson.FeatureCollection, error) AvailableLanguages() (*LanguagesResponse, error) }
GeocoderInterface interface to object
type GridSectionResponse ¶ added in v0.1.0
type GridSectionResponse struct {
Lines []*Line `json:"lines"`
}
GridSectionResponse response from REST API. Tags are used to map from the JSON response.
func NewGridSectionResponse ¶ added in v0.1.0
func NewGridSectionResponse() *GridSectionResponse
NewGridSectionResponse instantiate a GridSectionResponse object.
type Language ¶ added in v0.1.0
type Language struct { NativeName string `json:"nativeName"` Code string `json:"code"` Name string `json:"name"` }
Language response from REST API Tags are used to map from the JSON response.
type LanguagesResponse ¶ added in v0.1.0
type LanguagesResponse struct {
Languages []Language `json:"languages"`
}
LanguagesResponse response from REST API. Tags are used to map from the JSON response.
func AvailableLanguagesImpl ¶ added in v0.1.0
func AvailableLanguagesImpl(geo *Geocoder) (*LanguagesResponse, error)
AvailableLanguagesImpl perform REST API request over HTTP.
func NewLanguagesResponse ¶ added in v0.1.0
func NewLanguagesResponse() *LanguagesResponse
NewLanguagesResponse instantiate a LanguagesResponse object.
type Line ¶ added in v0.1.0
type Line struct { Start *Coordinates `json:"start"` End *Coordinates `json:"end"` }
Line object. Tags are used to map from the JSON response.
type PolyGon ¶ added in v0.1.0
type PolyGon struct {
Path []*Coordinates `json:"path"`
}
PolyGon defines an area bounded by a slice of coordinates. Tags are used to map from the JSON response.
func NewPolyGon ¶ added in v0.1.0
func NewPolyGon(path []*Coordinates) *PolyGon
NewPolyGon returns a polygon region
type Response ¶ added in v0.1.0
type Response struct { Country string `json:"country"` Square *Box `json:"square"` NearestPlace string `json:"nearestPlace"` Coordinates *Coordinates `json:"coordinates"` Words string `json:"words"` Language string `json:"language"` Map string `json:"map"` }
Response generic response from REST API. Tags are used to map from the JSON response.
type ResponseError ¶
type ResponseError struct {
Error ErrorDetails `json:"error"`
}
ResponseError response from REST API. Tags are used to map from the JSON response.
func NewResponseError ¶
func NewResponseError() *ResponseError
NewResponseError instantiate a ResponseError object.
func (*ResponseError) AsError ¶ added in v0.1.0
func (respErr *ResponseError) AsError() error
AsError renders ResponseError in error form.
func (*ResponseError) Message ¶
func (respErr *ResponseError) Message() string
Message of error message.
func (*ResponseError) String ¶ added in v0.1.0
func (respErr *ResponseError) String() string
String renders ResponseError in string form.
type ResponseErrorInterface ¶ added in v0.3.0
type ResponseErrorInterface interface { Code() string Message() string String() string AsError() error }
ResponseErrorInterface interface definition
type ShapeInterface ¶ added in v0.3.0
type ShapeInterface interface {
String() string
}
ShapeInterface common operations on shapes
type Suggestion ¶ added in v0.1.0
type Suggestion struct { Country string `json:"country"` NearestPlace string `json:"nearestPlace"` Words string `json:"words"` DistanceToFocusKm float64 `json:"distanceToFocusKm"` Rank int `json:"rank"` Language string `json:"language"` }
Suggestion response from REST API. Tags are used to map from the JSON response.