Working auth and photo json endpoint
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
ef275f97f4
commit
e4323b6047
2032 changed files with 821464 additions and 52 deletions
70
vendor/github.com/paulmach/go.geojson/feature_collection.go
generated
vendored
Normal file
70
vendor/github.com/paulmach/go.geojson/feature_collection.go
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
Package geojson is a library for encoding and decoding GeoJSON into Go structs.
|
||||
Supports both the json.Marshaler and json.Unmarshaler interfaces as well as helper functions
|
||||
such as `UnmarshalFeatureCollection`, `UnmarshalFeature` and `UnmarshalGeometry`.
|
||||
*/
|
||||
package geojson
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// A FeatureCollection correlates to a GeoJSON feature collection.
|
||||
type FeatureCollection struct {
|
||||
Type string `json:"type"`
|
||||
BoundingBox []float64 `json:"bbox,omitempty"`
|
||||
Features []*Feature `json:"features"`
|
||||
CRS map[string]interface{} `json:"crs,omitempty"` // Coordinate Reference System Objects are not currently supported
|
||||
}
|
||||
|
||||
// NewFeatureCollection creates and initializes a new feature collection.
|
||||
func NewFeatureCollection() *FeatureCollection {
|
||||
return &FeatureCollection{
|
||||
Type: "FeatureCollection",
|
||||
Features: make([]*Feature, 0),
|
||||
}
|
||||
}
|
||||
|
||||
// AddFeature appends a feature to the collection.
|
||||
func (fc *FeatureCollection) AddFeature(feature *Feature) *FeatureCollection {
|
||||
fc.Features = append(fc.Features, feature)
|
||||
return fc
|
||||
}
|
||||
|
||||
// MarshalJSON converts the feature collection object into the proper JSON.
|
||||
// It will handle the encoding of all the child features and geometries.
|
||||
// Alternately one can call json.Marshal(fc) directly for the same result.
|
||||
func (fc FeatureCollection) MarshalJSON() ([]byte, error) {
|
||||
type featureCollection FeatureCollection
|
||||
|
||||
fcol := &featureCollection{
|
||||
Type: "FeatureCollection",
|
||||
}
|
||||
|
||||
if fc.BoundingBox != nil && len(fc.BoundingBox) != 0 {
|
||||
fcol.BoundingBox = fc.BoundingBox
|
||||
}
|
||||
|
||||
fcol.Features = fc.Features
|
||||
if fcol.Features == nil {
|
||||
fcol.Features = make([]*Feature, 0) // GeoJSON requires the feature attribute to be at least []
|
||||
}
|
||||
|
||||
if fc.CRS != nil && len(fc.CRS) != 0 {
|
||||
fcol.CRS = fc.CRS
|
||||
}
|
||||
|
||||
return json.Marshal(fcol)
|
||||
}
|
||||
|
||||
// UnmarshalFeatureCollection decodes the data into a GeoJSON feature collection.
|
||||
// Alternately one can call json.Unmarshal(fc) directly for the same result.
|
||||
func UnmarshalFeatureCollection(data []byte) (*FeatureCollection, error) {
|
||||
fc := &FeatureCollection{}
|
||||
err := json.Unmarshal(data, fc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return fc, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue