geotools

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

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

Go to latest
Published: Mar 16, 2016 License: MIT Imports: 8 Imported by: 1

README

GeoTools

GeoTools is a library and Web service written in Go that creates a singular interface to geo-location data via the Google Maps/Location APIs.

Part 1

Geo data comes in many forms:

  • Strings, "Toronto" (a city), "Eiffel Tower" (a place)
  • Geo-point, [10,20] (lng,lat)

In order to query or convert between structures, the data must be in a normalized form.

Geoy should transform between:

  1. Point (lat,lng) -> Place, City or Address

  2. Place, City, or Address -> Point (lat, lng)

..and I wonder where point + radius fits in?

Social data

Pressly also queries a lot of social data from specifically, Twitter, Instagram and Facebook. Each of these networks return a different geo-type or locality (radius).

Check out the Twitter and Instagram APIs with their sample consoles, and lets make sure for a tweet or a post, we can map the geo-data that they return to the same form we need so we can find all the tweets that match "food" in "Liberty Village" (a place, which is a neighbourhood in Toronto).

Part 2

Pressly hubs, posts, and users can all be geo-spaced.

For example:

  • User, "Peter" is from "Toronto"
  • User, "Peter" was in "Liberty Village" on Thursday Dec 10th at 9am
  • Hub, "TechCommunity" is set a point <10,20> (random lat/lng) in "Liberty Village"
  • Post, "How we all fell in love with Go" is a post at point <15,20> made in the "TechCommunity" hub

.. all of those are optional, where a hub can have a beacon point with radius 5km(?), or perhaps city / place bound, and the posts made to the hub don't require a geo-point. But, the post would show up if a user in the hub's beacon was exploring the area, or searching for a matching tag in the post.

The point of a hub is to anchor a community and allow the posts or users to be discovered that would like it, but still create connections among the things around us.

 --------            --------            -------
|  Hub   |---------*| Post   |*---------| User  |
 --------            --------            -------

NOTES

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAPIKey

func SetAPIKey(key string) (err error)

SetAPIKey sets the Google Maps API key.

Types

type AddressComponent

type AddressComponent struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

AddressComponent represents a part of an address.

type Envelope

type Envelope struct {
	Type        string      `json:"type"`
	Coordinates [][]float64 `json:"coordinates"`
}

Envelope is a GeoJSON like shape where coordinates contains [[left, top], [right, bottom]]

func NewEnvelope

func NewEnvelope(left, top, right, bottom float64) *Envelope

NewEnvelope creates an envelope.

func (Envelope) MarshalDB

func (e Envelope) MarshalDB() (interface{}, error)

MarshalDB implements db.Marshaler

func (Envelope) String

func (e Envelope) String() string

Implements fmt.Stringer

func (Envelope) WKT

func (e Envelope) WKT() string

WKT implements Geometry.

type FacebookLocation

type FacebookLocation InstagramLocation

FacebookLocation is an object representing the location information returned by the Facebook API

type Geometry

type Geometry interface {
	WKT() string
}

Geometry defines WKT, which provides a text representation of a vector.

type InstagramLocation

type InstagramLocation struct {
	Latitude  float64
	Longitude float64
	ID        string
	Name      string
}

InstagramLocation is an object representing the location information returned by the Instagram API

func (InstagramLocation) LatLng

func (l InstagramLocation) LatLng() []float64

LatLng implements LatLnger

type LatLng

type LatLng maps.LatLng

LatLng implements LatLnger

func LatLngFromPoint

func LatLngFromPoint(p Point) *LatLng

LatLngFromPoint converts a Point to a LatLng.

func (LatLng) LatLng

func (l LatLng) LatLng() []float64

LatLng returns an array of [lat, lon]

type LatLnger

type LatLnger interface {
	LatLng() []float64
}

LatLnger defines a struct that can convert itself to cartesian coordinates.

type Place

type Place struct {
	PlaceID           string             `json:"place_id"`
	Name              string             `json:"name"`
	AddressComponents []AddressComponent `json:"address_components"`
	AddressString     string             `json:"address_string"`
	Location          *Point             `json:"location"`
	BoundingBox       *Envelope          `json:"bounding_box"`
}

Place represents a physical location.

func LookupCoordinates

func LookupCoordinates(ctx context.Context, p LatLnger) ([]*Place, error)

LookupCoordinates lookups a coordinate and returns all its associated places.

func LookupName

func LookupName(ctx context.Context, s string) ([]*Place, error)

LookupName converts a string place name/address into

func PlaceDetails

func PlaceDetails(ctx context.Context, placeID string) (*Place, error)

PlaceDetails returns the details of a place given its placeID.

func (Place) String

func (p Place) String() string

type Point

type Point struct {
	Type        string    `json:"type"`
	Coordinates []float64 `json:"coordinates"`
}

Point is a standard GeoJSON 2d Point with x,y coordinates

func NewPoint

func NewPoint(x, y float64) *Point

NewPoint creates a GeoJSON 2d point.

func NewPointFromLatLng

func NewPointFromLatLng(lat, lng float64) *Point

NewPointFromLatLng creates a cartesian point that represents the given geographic coordinates.

func PointFromLatLng

func PointFromLatLng(latlon LatLnger) *Point

PointFromLatLng converts a latLng to a cartesian Point.

func (Point) LatLng

func (p Point) LatLng() []float64

LatLng implements LatLngr.

func (Point) MarshalDB

func (p Point) MarshalDB() (interface{}, error)

MarshalDB prepares the point to be stored.

func (Point) String

func (p Point) String() string

String returns a text representation of the point.

func (*Point) UnmarshalDB

func (p *Point) UnmarshalDB(v interface{}) error

UnmarshalDB converts an stored point into a Point struct.

func (Point) WKT

func (p Point) WKT() string

WKT implements Geometry.

type TwitterLocation

type TwitterLocation Point

TwitterLocation is an object representing the location information returned by the Twitter API (a GeoJSON Point)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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