domain

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConformanceJSONFGCore = "http://www.opengis.net/spec/json-fg-1/0.2/conf/core"
)

Variables

This section is empty.

Functions

func MapRowsToFeatures

func MapRowsToFeatures(rows *sqlx.Rows, fidColumn string, geomColumn string,
	geomMapper func([]byte) (geom.Geometry, error)) ([]*Feature, *PrevNextFID, error)

MapRowsToFeatures datasource agnostic mapper from SQL rows/result set to Features domain model

Types

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

type DecodedCursor struct {
	FiltersChecksum []byte
	FID             int64
}

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 the 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 {
	geojson.Feature
	Links []Link `json:"links,omitempty"`

	// we overwrite ID since we want to make it a required attribute. We also expect feature ids to be
	// auto-incrementing integers (which is the default in geopackages) since we use it for cursor-based pagination.
	ID int64 `json:"id"`
}

Feature is a GeoJSON Feature with extras such as links

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

type JSONFGFeature

type JSONFGFeature struct {
	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  map[string]any `json:"properties"`
	CoordRefSys string         `json:"coordRefSys,omitempty"`
	Links       []Link         `json:"links,omitempty"`
	ConformsTo  []string       `json:"conformsTo,omitempty"`
	// We expect feature ids to be auto-incrementing integers (which is the default in geopackages)
	// since we use it for cursor-based pagination.
	ID int64 `json:"id"`
}

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"`
}
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

type PrevNextFID

type PrevNextFID struct {
	Prev int64
	Next int64
}

PrevNextFID previous and next feature id (fid) to encode in cursor.

func MapRowsToFeatureIDs

func MapRowsToFeatureIDs(rows *sqlx.Rows) (featureIDs []int64, prevNextID *PrevNextFID, err error)

MapRowsToFeatureIDs datasource agnostic mapper from SQL rows set feature IDs, including prev/next feature ID

Jump to

Keyboard shortcuts

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