github.com/PDOK/gokoala@v0.50.6/internal/ogc/features/domain/geojson.go (about) 1 package domain 2 3 import ( 4 "github.com/go-spatial/geom/encoding/geojson" 5 ) 6 7 // featureCollectionType allows the GeoJSON type to be automatically set during json marshalling 8 type featureCollectionType struct{} 9 10 func (fc *featureCollectionType) MarshalJSON() ([]byte, error) { 11 return []byte(`"FeatureCollection"`), nil 12 } 13 14 // FeatureCollection is a GeoJSON FeatureCollection with extras such as links 15 type FeatureCollection struct { 16 Type featureCollectionType `json:"type"` 17 Timestamp string `json:"timeStamp,omitempty"` 18 Links []Link `json:"links,omitempty"` 19 20 Features []*Feature `json:"features"` 21 22 NumberReturned int `json:"numberReturned"` 23 } 24 25 // Feature is a GeoJSON Feature with extras such as links 26 type Feature struct { 27 geojson.Feature 28 Links []Link `json:"links,omitempty"` 29 30 // we overwrite ID since we want to make it a required attribute. We also expect feature ids to be 31 // auto-incrementing integers (which is the default in geopackages) since we use it for cursor-based pagination. 32 ID int64 `json:"id"` 33 } 34 35 // Link according to RFC 8288, https://datatracker.ietf.org/doc/html/rfc8288 36 type Link struct { 37 Rel string `json:"rel"` 38 Title string `json:"title,omitempty"` 39 Type string `json:"type,omitempty"` 40 Href string `json:"href"` 41 Hreflang string `json:"hreflang,omitempty"` 42 Length int64 `json:"length,omitempty"` 43 Templated bool `json:"templated,omitempty"` 44 }