github.com/seeker-insurance/kit@v0.0.13/geojson/geojson.go (about)

     1  //Package geojson contains an interface and various structs for 2d and 3d geometry that correspond to the [geojson](http://geojson.org/) format.
     2  package geojson
     3  
     4  import (
     5  	"fmt"
     6  
     7  	"gopkg.in/mgo.v2/bson"
     8  )
     9  
    10  const (
    11  	PointType   = "Point"
    12  	PolygonType = "Polygon"
    13  )
    14  
    15  type Geometry interface {
    16  	bson.Getter
    17  	Type() string
    18  	Coordinates() string
    19  	GeoJSON() []byte
    20  }
    21  
    22  func geoJSON(geo Geometry) []byte {
    23  	return []byte(fmt.Sprintf(`{"type": %s, "coordinates": %s}`, geo.Type(), geo.Coordinates()))
    24  }