feature

package
v0.0.0-...-0cfb223 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Collection = "features"

Collection indicates the MongoDB feature collection

Variables

View Source
var (
	// ErrBadGeometrySemantic indicates that a GeoJSON geometry is semantically invalid
	ErrBadGeometrySemantic = errors.New("bad geometry semantic")

	// ErrUnknownGeometryType indicates that a GeoJSON geometry type is invalid
	ErrUnknownGeometryType = errors.New("unknown geometry type")

	// ErrBadGeometryCoords indicates that GeoJSON geometry coordinates are ivnalid
	ErrBadGeometryCoords = errors.New("bad geometry coordinates")

	// ErrBadGeometryCollection indicates that a GeoJSON geometry collection are invalid
	ErrBadGeometryCollection = errors.New("empty geometry collection")
)

Functions

func Create

func Create(ft *Feature) error

Create creates a new entity

func GetAll

func GetAll(loc string, opts *Options) (*model.Result, error)

GetAll returns a result based on filters

func GetByGroup

func GetByGroup(id, loc string, opts *Options) (*model.Result, error)

GetByGroup returns a result based on feature group

func GetByText

func GetByText(q, loc string, opts *Options) (*model.Result, error)

GetByText returns a result based on given keyword

func Remove

func Remove(id string) error

Remove removes an entity

func Replace

func Replace(id string, ft *Feature) error

Replace replaces the data of an existing entity

Types

type Coordinates

type Coordinates []interface{}

Coordinates ...

type Feature

type Feature struct {
	ID          objectID               `json:"_id" bson:"_id"`
	Name        string                 `json:"name" bson:"name"`
	Description string                 `json:"description" bson:"description"`
	Geometry    Geometry               `json:"geometry" bson:"geometry"`
	Properties  map[string]interface{} `json:"properties" bson:"properties"`
	Group       objectID               `json:"group" bson:"group"`
	Location    objectID               `json:"_location" bson:"_location"`
	Modified    timestamp              `json:"_modified" bson:"_modified"`
}

Feature describes the entity of a feature

func GetByID

func GetByID(id, loc string) (*Feature, error)

GetByID returns the entity of the given ID

func (Feature) Validate

func (f Feature) Validate() error

Validate validates the fields of a feature

type Geometry

type Geometry struct {
	Type        GeometryType `json:"type" bson:"type"`
	Coordinates Coordinates  `json:"coordinates,omitempty" bson:"coordinates,omitempty"`
	Geometries  []Geometry   `json:"geometries,omitempty" bson:"geometries,omitempty"`
}

Geometry describes a GeoJSON geometry object

func (Geometry) Validate

func (g Geometry) Validate() error

Validate validates a GeoJSON geometry object

type GeometryType

type GeometryType int

GeometryType represents an GeoJSON geometry type

const (
	UnknownGeometry GeometryType = iota
	Point
	MultiPoint
	LineString
	MultiLineString
	Polygon
	MultiPolygon
	GeometryCollection
)

Represents the GeoJSON geometry types

func (GeometryType) MarshalBSONValue

func (g GeometryType) MarshalBSONValue() (bsontype.Type, []byte, error)

MarshalBSONValue implements the BSON value marshaler

func (GeometryType) MarshalJSON

func (g GeometryType) MarshalJSON() ([]byte, error)

MarshalJSON implements the JSON marshaler

func (GeometryType) String

func (g GeometryType) String() string

String returns a string representing the GeometryType

func (*GeometryType) UnmarshalBSONValue

func (g *GeometryType) UnmarshalBSONValue(t bsontype.Type, b []byte) error

UnmarshalBSONValue implements the BSON value unmarshaler

func (*GeometryType) UnmarshalJSON

func (g *GeometryType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the JSON unmarshaler

type Options

type Options struct {
	Sort   bson.D
	Limit  int64
	Offset int64
}

Options represents the options for a database operation

Jump to

Keyboard shortcuts

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