Documentation ¶
Index ¶
Constants ¶
const ( DEFAULT_PGSQL_OPEN_STR = "user=postgres dbname=points sslmode=disable" DEFAULT_MYSQL_OPEN_STR = "points/root/" DEFAULT_TEST_OPEN_STR = "" )
const (
EARTH_RADIUS = 6371 // Earth's radius ~= 6,371km, according to wikipedia
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 ¶
type GoogleGeocoder struct{}
func (*GoogleGeocoder) Geocode ¶
func (g *GoogleGeocoder) Geocode(query 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 URL-encoded entities. Returns an array of byes as a result, or any error incurred along the way
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 { }
A Geocoder that makes use of open street map's geocoding service
func (*MapQuestGeocoder) Geocode ¶
func (g *MapQuestGeocoder) Geocode(query string) (*Point, error)
Use MapQuest's open service for geocoding @param [String] str. The query in which to geocode.
func (*MapQuestGeocoder) ReverseGeocode ¶
func (g *MapQuestGeocoder) ReverseGeocode(p *Point) (string, error)
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 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) GreatCircleDistance ¶
Calculates the Haversine distance between two points. 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 of transposing the origin point the distance (in meters) supplied by the compass bearing (in degrees) supplied. Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html
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.
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 the config.yml file 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 (*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.