Documentation ¶
Index ¶
- Constants
- func MapRowsToFeatures(ctx context.Context, rows *sqlx.Rows, fidColumn string, ...) ([]*Feature, *PrevNextFID, error)
- type ContentCrs
- type Cursors
- type DecodedCursor
- type EncodedCursor
- type Feature
- type FeatureCollection
- type FeatureProperties
- func (p *FeatureProperties) Delete(key string)
- func (p *FeatureProperties) Keys() []string
- func (p *FeatureProperties) MarshalJSON() ([]byte, error)
- func (p *FeatureProperties) Set(key string, value any)
- func (p *FeatureProperties) SetRelation(key string, value any, existingKeyPrefix string)
- func (p *FeatureProperties) Value(key string) any
- type JSONFGFeature
- type JSONFGFeatureCollection
- type Link
- type MapGeom
- type MapRelation
- type PrevNextFID
- type Profile
- type ProfileName
- type SRID
Constants ¶
const ( PrevFid = "prevfid" NextFid = "nextfid" )
const ( CrsURIPrefix = "http://www.opengis.net/def/crs/" UndefinedSRID = 0 WGS84SRID = 100000 // We use the SRID for CRS84 (WGS84) as defined in the GeoPackage, instead of EPSG:4326 (due to axis order). In time, we may need to read this value dynamically from the GeoPackage. WGS84CodeOGC = "CRS84" WGS84CrsURI = CrsURIPrefix + "OGC/1.3/" + WGS84CodeOGC )
const (
ConformanceJSONFGCore = "http://www.opengis.net/spec/json-fg-1/0.2/conf/core"
)
Variables ¶
This section is empty.
Functions ¶
func MapRowsToFeatures ¶
func MapRowsToFeatures(ctx context.Context, rows *sqlx.Rows, fidColumn string, externalFidColumn string, geomColumn string, propConfig *config.FeatureProperties, mapGeom MapGeom, mapRel MapRelation) ([]*Feature, *PrevNextFID, error)
MapRowsToFeatures datasource agnostic mapper from SQL rows/result set to Features domain model
Types ¶
type ContentCrs ¶ added in v0.52.2
type ContentCrs string
ContentCrs the coordinate reference system (represented as a URI) of the content/output to return.
func (ContentCrs) IsWGS84 ¶ added in v0.52.2
func (c ContentCrs) IsWGS84() bool
func (ContentCrs) ToLink ¶ added in v0.52.2
func (c ContentCrs) ToLink() string
ToLink returns link target conforming to RFC 8288
type Cursors ¶
type Cursors struct { Prev EncodedCursor Next EncodedCursor HasPrev bool HasNext bool }
Cursors holds next and previous cursor. Note that we use 'cursor-based pagination' as opposed to 'offset-based pagination'
func NewCursors ¶
func NewCursors(fid PrevNextFID, filtersChecksum []byte) Cursors
NewCursors create Cursors based on the prev/next feature ids from the datasource and the provided filters (captured in a hash).
type DecodedCursor ¶
DecodedCursor the cursor values after decoding EncodedCursor
type EncodedCursor ¶
type EncodedCursor string
EncodedCursor is a scrambled string representation of the fields defined in DecodedCursor
func (EncodedCursor) Decode ¶
func (c EncodedCursor) Decode(filtersChecksum []byte) DecodedCursor
Decode turns encoded cursor into DecodedCursor and verifies that the checksum of query params that act as filters hasn't changed
func (EncodedCursor) String ¶
func (c EncodedCursor) String() string
type Feature ¶
type Feature struct { Type featureType `json:"type"` Properties FeatureProperties `json:"properties"` Geometry geom.Geometry `json:"geometry"` // We expect feature ids to be auto-incrementing integers (which is the default in geopackages) // since we use it for cursor-based pagination. ID string `json:"id"` Links []Link `json:"links,omitempty"` }
Feature is a GeoJSON Feature with extras such as links Note: fields in this struct are sorted for optimal memory usage (field alignment)
type FeatureCollection ¶
type FeatureCollection struct { Type featureCollectionType `json:"type"` Timestamp string `json:"timeStamp,omitempty"` Links []Link `json:"links,omitempty"` Features []*Feature `json:"features"` NumberReturned int `json:"numberReturned"` }
FeatureCollection is a GeoJSON FeatureCollection with extras such as links Note: fields in this struct are sorted for optimal memory usage (field alignment)
type FeatureProperties ¶ added in v0.56.0
type FeatureProperties struct {
// contains filtered or unexported fields
}
FeatureProperties the properties of a GeoJSON Feature. Properties are either unordered (default, and has the best performance!) or ordered in a specific way as described in the config.
func NewFeatureProperties ¶ added in v0.56.0
func NewFeatureProperties(order bool) FeatureProperties
func NewFeaturePropertiesWithData ¶ added in v0.56.0
func NewFeaturePropertiesWithData(order bool, data map[string]any) FeatureProperties
func (*FeatureProperties) Delete ¶ added in v0.56.0
func (p *FeatureProperties) Delete(key string)
func (*FeatureProperties) Keys ¶ added in v0.56.0
func (p *FeatureProperties) Keys() []string
Keys of the Feature properties.
Note: In the future we might replace this with Go 1.23 iterators (range-over-func) however at the moment this isn't supported in Go templates: https://github.com/golang/go/pull/68329
func (*FeatureProperties) MarshalJSON ¶ added in v0.56.0
func (p *FeatureProperties) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of either the ordered or unordered properties
func (*FeatureProperties) Set ¶ added in v0.56.0
func (p *FeatureProperties) Set(key string, value any)
func (*FeatureProperties) SetRelation ¶ added in v0.56.0
func (p *FeatureProperties) SetRelation(key string, value any, existingKeyPrefix string)
func (*FeatureProperties) Value ¶ added in v0.56.0
func (p *FeatureProperties) Value(key string) any
type JSONFGFeature ¶
type JSONFGFeature struct { // We expect feature ids to be auto-incrementing integers (which is the default in geopackages) // since we use it for cursor-based pagination. ID string `json:"id"` Type featureType `json:"type"` Time any `json:"time"` // We don't implement the JSON-FG "3D" conformance class. So Place only // supports simple/2D geometries, no 3D geometries like Polyhedron, Prism, etc. Place geom.Geometry `json:"place"` // may only contain non-WGS84 geometries Geometry geom.Geometry `json:"geometry"` // may only contain WGS84 geometries Properties FeatureProperties `json:"properties"` CoordRefSys string `json:"coordRefSys,omitempty"` Links []Link `json:"links,omitempty"` ConformsTo []string `json:"conformsTo,omitempty"` }
JSONFGFeature Feature according to the JSON-FG standard Note: fields in this struct are sorted for optimal memory usage (field alignment)
type JSONFGFeatureCollection ¶
type JSONFGFeatureCollection struct { Type featureCollectionType `json:"type"` Timestamp string `json:"timeStamp,omitempty"` CoordRefSys string `json:"coordRefSys"` Links []Link `json:"links,omitempty"` ConformsTo []string `json:"conformsTo"` Features []*JSONFGFeature `json:"features"` NumberReturned int `json:"numberReturned"` }
JSONFGFeatureCollection FeatureCollection according to the JSON-FG standard Note: fields in this struct are sorted for optimal memory usage (field alignment)
type Link ¶
type Link struct { Rel string `json:"rel"` Title string `json:"title,omitempty"` Type string `json:"type,omitempty"` Href string `json:"href"` Hreflang string `json:"hreflang,omitempty"` Length int64 `json:"length,omitempty"` Templated bool `json:"templated,omitempty"` }
Link according to RFC 8288, https://datatracker.ietf.org/doc/html/rfc8288 Note: fields in this struct are sorted for optimal memory usage (field alignment)
type MapGeom ¶ added in v0.53.0
MapGeom abstract function type to map geometry from bytes to Geometry
type MapRelation ¶ added in v0.53.0
type MapRelation func(columnName string, columnValue any, externalFidColumn string) (newColumnName string, newColumnValue any)
MapRelation abstract function type to map feature relations
type PrevNextFID ¶
PrevNextFID previous and next feature id (fid) to encode in cursor.
func MapRowsToFeatureIDs ¶
func MapRowsToFeatureIDs(ctx context.Context, rows *sqlx.Rows) (featureIDs []int64, prevNextID *PrevNextFID, err error)
MapRowsToFeatureIDs datasource agnostic mapper from SQL rows set feature IDs, including prev/next feature ID
type Profile ¶ added in v0.53.0
type Profile struct {
// contains filtered or unexported fields
}
Profile from OAF Part 5, used to express relations between features
func NewProfile ¶ added in v0.53.0
func NewProfile(profileName ProfileName, baseURL url.URL, collectionNames []string) Profile
type ProfileName ¶ added in v0.53.0
type ProfileName string
const ( RelAsKey ProfileName = "rel-as-key" // RelAsKey a feature reference in the response SHALL be represented by: The featureId RelAsURI ProfileName = "rel-as-uri" // RelAsURI a feature reference in the response SHALL be represented by: an HTTP(S) URI. RelAsLink ProfileName = "rel-as-link" // RelAsLink a feature reference in the response SHALL be represented by: an object with the property "href" and, optionally a "title" )
Profiles from OAF Part 5 as specified in https://docs.ogc.org/DRAFTS/23-058r1.html#rc_profile-parameter
type SRID ¶ added in v0.52.2
type SRID int
SRID Spatial Reference System Identifier: a unique value to unambiguously identify a spatial coordinate system. For example '28992' in https://www.opengis.net/def/crs/EPSG/0/28992