Documentation ¶
Index ¶
- Constants
- Variables
- func SetGoogleAPIKey(newAPIKey string)
- func SetGoogleGeocodeURL(newGeocodeURL string)
- func SetMapquestAPIKey(newAPIKey string)
- func SetMapquestGeocodeURL(newGeocodeURL string)
- func SetOpenCageAPIKey(newAPIKey string)
- func SetOpenCageGeocodeURL(newGeocodeURL string)
- type Geocoder
- type GoogleGeocoder
- type MapQuestGeocoder
- type Mapper
- type OpenCageGeocoder
- type Point
- func (p *Point) BearingTo(p2 *Point) float64
- func (p *Point) GreatCircleDistance(p2 *Point) float64
- func (p *Point) Lat() float64
- func (p *Point) Lng() float64
- func (p *Point) MarshalBinary() ([]byte, error)
- func (p *Point) MarshalJSON() ([]byte, error)
- func (p *Point) MidpointTo(p2 *Point) *Point
- func (p *Point) PointAtDistanceAndBearing(dist float64, bearing float64) *Point
- func (p *Point) UnmarshalBinary(data []byte) error
- func (p *Point) UnmarshalJSON(data []byte) error
- type Polygon
- type SQLConf
- type SQLMapper
Constants ¶
const ( DEFAULT_PGSQL_OPEN_STR = "user=postgres dbname=points sslmode=disable" DEFAULT_MYSQL_OPEN_STR = "points/root/" DEFAULT_TEST_OPEN_STR = "\"\"" )
const (
// According to Wikipedia, the Earth's radius is about 6,371km
EARTH_RADIUS = 6371
)
Variables ¶
var GoogleAPIKey = ""
var MapquestAPIKey = ""
var OpenCageAPIKey = ""
Functions ¶
func SetGoogleAPIKey ¶ added in v0.6.1
func SetGoogleAPIKey(newAPIKey string)
func SetGoogleGeocodeURL ¶
func SetGoogleGeocodeURL(newGeocodeURL string)
Note: In the next major revision (1.0.0), it is planned
That Geocoders should adhere to the `geo.Geocoder` interface and provide versioning of APIs accordingly.
Sets the base URL for the Google Geocoding API.
func SetMapquestAPIKey ¶ added in v0.6.1
func SetMapquestAPIKey(newAPIKey string)
func SetMapquestGeocodeURL ¶
func SetMapquestGeocodeURL(newGeocodeURL string)
Note: In the next major revision (1.0.0), it is planned
That Geocoders should adhere to the `geo.Geocoder` interface and provide versioning of APIs accordingly.
Sets the base URL for the MapQuest Geocoding API.
func SetOpenCageAPIKey ¶ added in v0.6.1
func SetOpenCageAPIKey(newAPIKey string)
func SetOpenCageGeocodeURL ¶
func SetOpenCageGeocodeURL(newGeocodeURL string)
Note: In the next major revision (1.0.0), it is planned
That Geocoders should adhere to the `geo.Geocoder` interface and provide versioning of APIs accordingly.
Sets the base URL for the OpenCage Geocoding API.
Types ¶
type Geocoder ¶
type Geocoder interface { Geocode(query string) (*Point, error) ReverseGeocode(p *Point) (string, error) }
This interface describes a Geocoder, which provides the ability to Geocode and Reverse Geocode geographic points of interest. Geocoding should accept a string that represents a street address, and returns a pointer to a Point that most closely identifies it. Reverse geocoding should accept a pointer to a Point, and return the street address that most closely represents it.
type GoogleGeocoder ¶
This struct contains all the funcitonality of interacting with the Google Maps Geocoding Service
func (*GoogleGeocoder) Geocode ¶
func (g *GoogleGeocoder) Geocode(address string) (*Point, error)
Geocodes the passed in query string and returns a pointer to a new Point struct. Returns an error if the underlying request cannot complete.
func (*GoogleGeocoder) Request ¶
func (g *GoogleGeocoder) Request(params string) ([]byte, error)
Issues a request to the google geocoding service and forwards the passed in params string as a URL-encoded entity. Returns an array of byes as a result, or an error if one occurs during the process. Note: Since this is an arbitrary request, you are responsible for passing in your API key if you want one.
func (*GoogleGeocoder) ReverseGeocode ¶
func (g *GoogleGeocoder) ReverseGeocode(p *Point) (string, error)
Reverse geocodes the pointer to a Point struct and returns the first address that matches or returns an error if the underlying request cannot complete.
type MapQuestGeocoder ¶
type MapQuestGeocoder struct{}
This struct contains all the funcitonality of interacting with the MapQuest Geocoding Service
func (*MapQuestGeocoder) Geocode ¶
func (g *MapQuestGeocoder) Geocode(address string) (*Point, error)
Returns the first point returned by MapQuest's geocoding service or an error if one occurs during the geocoding request.
func (*MapQuestGeocoder) Request ¶
func (g *MapQuestGeocoder) Request(url string) ([]byte, error)
Issues a request to the open mapquest api geocoding services using the passed in url query. Returns an array of bytes as the result of the api call or an error if one occurs during the process. Note: Since this is an arbitrary request, you are responsible for passing in your API key if you want one.
func (*MapQuestGeocoder) ReverseGeocode ¶
func (g *MapQuestGeocoder) ReverseGeocode(p *Point) (string, error)
Returns the first most available address that corresponds to the passed in point. It may also return an error if one occurs during execution.
type Mapper ¶
This interface describes a Mapper, which should be a data storage mechanism that can execute interesting queries. Currently, mappers should be able to find points within a radius of an origin point.
type OpenCageGeocoder ¶
type OpenCageGeocoder struct{}
This struct contains all the funcitonality of interacting with the OpenCage Geocoding Service
func (*OpenCageGeocoder) Geocode ¶
func (g *OpenCageGeocoder) Geocode(address string) (*Point, error)
Returns the first point returned by OpenCage's geocoding service or an error if one occurs during the geocoding request.
func (*OpenCageGeocoder) Request ¶
func (g *OpenCageGeocoder) Request(url string) ([]byte, error)
Issues a request to the open OpenCage API geocoding services using the passed in url query. Returns an array of bytes as the result of the api call or an error if one occurs during the process. Note: Since this is an arbitrary request, you are responsible for passing in your API key if you want one.
func (*OpenCageGeocoder) ReverseGeocode ¶
func (g *OpenCageGeocoder) ReverseGeocode(p *Point) (string, error)
Returns the first most available address that corresponds to the passed in point. It may also return an error if one occurs during execution.
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Represents a Physical Point in geographic notation [lat, lng].
func NewPoint ¶
Returns a new Point populated by the passed in latitude (lat) and longitude (lng) values.
func (*Point) BearingTo ¶
Calculates the initial bearing (sometimes referred to as forward azimuth) Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html
func (*Point) GreatCircleDistance ¶
Calculates the Haversine distance between two points in kilometers. Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html
func (*Point) MarshalBinary ¶ added in v0.7.0
Renders the current point to a byte slice. Implements the encoding.BinaryMarshaler Interface.
func (*Point) MarshalJSON ¶
Renders the current Point to valid JSON. Implements the json.Marshaller Interface.
func (*Point) MidpointTo ¶ added in v0.6.1
Calculates the midpoint between 'this' point and the supplied point. Original implementation from http://www.movable-type.co.uk/scripts/latlong.html
func (*Point) PointAtDistanceAndBearing ¶
Returns a Point populated with the lat and lng coordinates by transposing the origin point the passed in distance (in kilometers) by the passed in compass bearing (in degrees). Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html
func (*Point) UnmarshalBinary ¶ added in v0.7.0
func (*Point) UnmarshalJSON ¶
Decodes the current Point from a JSON body. Throws an error if the body of the point cannot be interpreted by the JSON body
type Polygon ¶
type Polygon struct {
// contains filtered or unexported fields
}
A Polygon is carved out of a 2D plane by a set of (possibly disjoint) contours. It can thus contain holes, and can be self-intersecting.
func NewPolygon ¶
Creates and returns a new pointer to a Polygon composed of the passed in points. Points are considered to be in order such that the last point forms an edge with the first point.
type SQLConf ¶
type SQLConf struct {
// contains filtered or unexported fields
}
Provides a set of configuration variables that describe how to interact with a SQL database.
func GetSQLConf ¶
Attempts to read config/geo.yml, and creates a SQLConf as described therein. Returns the DefaultSQLConf if no config/geo.yml is found, or an error if one arises during the process of parsing the configuration file.
func GetSQLConfFromFile ¶
Attempts to read from the passed in filename and creates a SQLconf as described therin. Retruns the DefaultSQLConf if the file cannot be found, or an error if one arises during the process of parsing the configuration file.
type SQLMapper ¶
type SQLMapper struct {
// contains filtered or unexported fields
}
A Mapper that uses Standard SQL Syntax to perform mapping functions and queries
func HandleWithSQL ¶
Retrieves the SQL configuration specified in config.yml that resides at the root level of the project. Returns a pointer to a SQLMapper if successful, or an error if there is an issue opening a database connection.
func NewSQLMapper ¶
Creates and returns a pointer to a new geo.SQLMapper.
func (*SQLMapper) PointsWithinRadius ¶
Uses SQL to retrieve all points within the radius (in meters) passed in from the origin point passed in. Original implemenation from : http://www.movable-type.co.uk/scripts/latlong-db.html Returns a pointer to a sql.Rows as a result, or an error if one occurs during the query.