geojson

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 20

Documentation

Index

Constants

View Source
const (
	PointType              = "point"
	MultiPointType         = "multipoint"
	LineStringType         = "linestring"
	MultiLineStringType    = "multilinestring"
	PolygonType            = "polygon"
	MultiPolygonType       = "multipolygon"
	GeometryCollectionType = "geometrycollection"
	CircleType             = "circle"
	EnvelopeType           = "envelope"
)
View Source
const (
	PointTypePrefix              = byte(1)
	MultiPointTypePrefix         = byte(2)
	LineStringTypePrefix         = byte(3)
	MultiLineStringTypePrefix    = byte(4)
	PolygonTypePrefix            = byte(5)
	MultiPolygonTypePrefix       = byte(6)
	GeometryCollectionTypePrefix = byte(7)
	CircleTypePrefix             = byte(8)
	EnvelopeTypePrefix           = byte(9)
)

These are the byte prefixes for identifying the shape contained within the doc values byte slice while decoding the contents during the query filtering phase.

Variables

View Source
var GlueBytes = []byte("##")

GlueBytes primarily for quicker filtering of docvalues during the filtering phase.

Functions

func DeduplicateTerms

func DeduplicateTerms(terms []string) []string

func FilterGeoShapesOnRelation

func FilterGeoShapesOnRelation(shape index.GeoJSON, targetShapeBytes []byte,
	relation string, reader **bytes.Reader, bufPool *s2.GeoBufferPool) (bool, error)

FilterGeoShapesOnRelation extracts the shapes in the document, apply the `relation` filter and confirms whether the shape in the document

satisfies the given relation.

func NewGeoCircle

func NewGeoCircle(points []float64,
	radius string) index.GeoJSON

func NewGeoEnvelope

func NewGeoEnvelope(points [][]float64) index.GeoJSON

func NewGeoJsonLinestring

func NewGeoJsonLinestring(points [][]float64) index.GeoJSON

func NewGeoJsonMultiPoint

func NewGeoJsonMultiPoint(v [][]float64) index.GeoJSON

func NewGeoJsonMultiPolygon

func NewGeoJsonMultiPolygon(points [][][][]float64) index.GeoJSON

func NewGeoJsonMultilinestring

func NewGeoJsonMultilinestring(points [][][]float64) index.GeoJSON

func NewGeoJsonPoint

func NewGeoJsonPoint(v []float64) index.GeoJSON

func NewGeoJsonPolygon

func NewGeoJsonPolygon(points [][][]float64) index.GeoJSON

func NewGeoJsonShape

func NewGeoJsonShape(coordinates [][][][]float64, typ string) (
	index.GeoJSON, []byte, error)

NewGeoJsonShape instantiate a geojson shape/circle or an envelope from the given coordinates and type.

func NewGeometryCollection

func NewGeometryCollection(coordinates [][][][][]float64,
	typs []string) (index.GeoJSON, []byte, error)

NewGeometryCollection instantiate a geometrycollection and prefix the byte contents with certain glue bytes that can be used later while filering the doc values.

func ParseDistance

func ParseDistance(d string) (float64, error)

ParseDistance attempts to parse a distance string and return distance in meters. Example formats supported: "5in" "5inch" "7yd" "7yards" "9ft" "9feet" "11km" "11kilometers" "3nm" "3nauticalmiles" "13mm" "13millimeters" "15cm" "15centimeters" "17mi" "17miles" "19m" "19meters" If the unit cannot be determined, the entire string is parsed and the unit of meters is assumed. If the number portion cannot be parsed, 0 and the parse error are returned.

func ParseGeoJSONShape

func ParseGeoJSONShape(input []byte) (index.GeoJSON, error)

ParseGeoJSONShape unmarshals the geojson/circle/envelope shape embedded in the given bytes.

func StripCoveringTerms

func StripCoveringTerms(terms []string) []string

Types

type Circle

type Circle struct {
	Typ      string    `json:"type"`
	Vertices []float64 `json:"coordinates"`
	Radius   string    `json:"radius"`
	// contains filtered or unexported fields
}

-------------------------------------------------------- Circle represents a custom circle type and it implements the index.GeoJSON interface.

func NewGeoCircleShape

func NewGeoCircleShape(cp []float64,
	radius string) (*Circle, []byte, error)

NewGeoCircleShape instantiate a circle shape and prefix the byte contents with certain glue bytes that can be used later while filering the doc values.

func (*Circle) Contains

func (c *Circle) Contains(other index.GeoJSON) (bool, error)

func (*Circle) IndexTokens

func (c *Circle) IndexTokens(s *s2.RegionTermIndexer) []string

func (*Circle) Intersects

func (c *Circle) Intersects(other index.GeoJSON) (bool, error)

func (*Circle) Marshal

func (c *Circle) Marshal() ([]byte, error)

func (*Circle) QueryTokens

func (c *Circle) QueryTokens(s *s2.RegionTermIndexer) []string

func (*Circle) Type

func (c *Circle) Type() string

func (*Circle) UnmarshalJSON

func (c *Circle) UnmarshalJSON(data []byte) error

func (*Circle) Value added in v0.1.13

func (c *Circle) Value() ([]byte, error)

type Envelope

type Envelope struct {
	Typ      string      `json:"type"`
	Vertices [][]float64 `json:"coordinates"`
	// contains filtered or unexported fields
}

-------------------------------------------------------- Envelope represents the envelope/bounding box type and it implements the index.GeoJSON interface.

func (*Envelope) Contains

func (e *Envelope) Contains(other index.GeoJSON) (bool, error)

func (*Envelope) IndexTokens

func (e *Envelope) IndexTokens(s *s2.RegionTermIndexer) []string

func (*Envelope) Intersects

func (e *Envelope) Intersects(other index.GeoJSON) (bool, error)

func (*Envelope) Marshal

func (e *Envelope) Marshal() ([]byte, error)

func (*Envelope) QueryTokens

func (e *Envelope) QueryTokens(s *s2.RegionTermIndexer) []string

func (*Envelope) Type

func (e *Envelope) Type() string

func (*Envelope) Value added in v0.1.13

func (e *Envelope) Value() ([]byte, error)

type GeometryCollection

type GeometryCollection struct {
	Typ    string          `json:"type"`
	Shapes []index.GeoJSON `json:"geometries"`
}

-------------------------------------------------------- GeometryCollection represents the geoJSON geometryCollection type and it implements the index.GeoJSON interface as well as the compositeShap interface.

func (*GeometryCollection) Contains

func (gc *GeometryCollection) Contains(other index.GeoJSON) (bool, error)

func (*GeometryCollection) Intersects

func (gc *GeometryCollection) Intersects(other index.GeoJSON) (bool, error)

func (*GeometryCollection) Marshal

func (gc *GeometryCollection) Marshal() ([]byte, error)

func (*GeometryCollection) Members

func (gc *GeometryCollection) Members() []index.GeoJSON

func (*GeometryCollection) Type

func (gc *GeometryCollection) Type() string

func (*GeometryCollection) UnmarshalJSON

func (gc *GeometryCollection) UnmarshalJSON(data []byte) error

func (*GeometryCollection) Value added in v0.1.13

func (gc *GeometryCollection) Value() ([]byte, error)

type LineString

type LineString struct {
	Typ      string      `json:"type"`
	Vertices [][]float64 `json:"coordinates"`
	// contains filtered or unexported fields
}

-------------------------------------------------------- LineString represents the geoJSON linestring type and it implements the index.GeoJSON interface.

func (*LineString) Contains

func (ls *LineString) Contains(other index.GeoJSON) (bool, error)

func (*LineString) Coordinates

func (ls *LineString) Coordinates() [][]float64

func (*LineString) IndexTokens

func (ls *LineString) IndexTokens(s *s2.RegionTermIndexer) []string

func (*LineString) Intersects

func (ls *LineString) Intersects(other index.GeoJSON) (bool, error)

func (*LineString) Marshal

func (ls *LineString) Marshal() ([]byte, error)

func (*LineString) QueryTokens

func (ls *LineString) QueryTokens(s *s2.RegionTermIndexer) []string

func (*LineString) Type

func (ls *LineString) Type() string

func (*LineString) Value added in v0.1.13

func (ls *LineString) Value() ([]byte, error)

type MultiLineString

type MultiLineString struct {
	Typ      string        `json:"type"`
	Vertices [][][]float64 `json:"coordinates"`
	// contains filtered or unexported fields
}

-------------------------------------------------------- MultiLineString represents the geoJSON multilinestring type and it implements the index.GeoJSON interface as well as the compositeShap interface.

func (*MultiLineString) Contains

func (p *MultiLineString) Contains(other index.GeoJSON) (bool, error)

func (*MultiLineString) Coordinates

func (p *MultiLineString) Coordinates() [][][]float64

func (*MultiLineString) IndexTokens

func (mls *MultiLineString) IndexTokens(s *s2.RegionTermIndexer) []string

func (*MultiLineString) Intersects

func (p *MultiLineString) Intersects(other index.GeoJSON) (bool, error)

func (*MultiLineString) Marshal

func (mls *MultiLineString) Marshal() ([]byte, error)

func (*MultiLineString) Members

func (p *MultiLineString) Members() []index.GeoJSON

func (*MultiLineString) QueryTokens

func (mls *MultiLineString) QueryTokens(s *s2.RegionTermIndexer) []string

func (*MultiLineString) Type

func (mls *MultiLineString) Type() string

func (*MultiLineString) Value added in v0.1.13

func (mls *MultiLineString) Value() ([]byte, error)

type MultiPoint

type MultiPoint struct {
	Typ      string      `json:"type"`
	Vertices [][]float64 `json:"coordinates"`
	// contains filtered or unexported fields
}

-------------------------------------------------------- MultiPoint represents the geoJSON multipoint type and it implements the index.GeoJSON interface as well as the compositeShap interface.

func (*MultiPoint) Contains

func (p *MultiPoint) Contains(other index.GeoJSON) (bool, error)

func (*MultiPoint) Coordinates

func (p *MultiPoint) Coordinates() [][]float64

func (*MultiPoint) IndexTokens

func (mp *MultiPoint) IndexTokens(s *s2.RegionTermIndexer) []string

func (*MultiPoint) Intersects

func (p *MultiPoint) Intersects(other index.GeoJSON) (bool, error)

func (*MultiPoint) Marshal

func (p *MultiPoint) Marshal() ([]byte, error)

func (*MultiPoint) Members

func (p *MultiPoint) Members() []index.GeoJSON

func (*MultiPoint) QueryTokens

func (mp *MultiPoint) QueryTokens(s *s2.RegionTermIndexer) []string

func (*MultiPoint) Type

func (p *MultiPoint) Type() string

func (*MultiPoint) Value added in v0.1.13

func (mp *MultiPoint) Value() ([]byte, error)

type MultiPolygon

type MultiPolygon struct {
	Typ      string          `json:"type"`
	Vertices [][][][]float64 `json:"coordinates"`
	// contains filtered or unexported fields
}

-------------------------------------------------------- MultiPolygon represents the geoJSON multipolygon type and it implements the index.GeoJSON interface as well as the compositeShap interface.

func (*MultiPolygon) Contains

func (p *MultiPolygon) Contains(other index.GeoJSON) (bool, error)

func (*MultiPolygon) Coordinates

func (p *MultiPolygon) Coordinates() [][][][]float64

func (*MultiPolygon) IndexTokens

func (mp *MultiPolygon) IndexTokens(s *s2.RegionTermIndexer) []string

func (*MultiPolygon) Intersects

func (p *MultiPolygon) Intersects(other index.GeoJSON) (bool, error)

func (*MultiPolygon) Marshal

func (p *MultiPolygon) Marshal() ([]byte, error)

func (*MultiPolygon) Members

func (p *MultiPolygon) Members() []index.GeoJSON

func (*MultiPolygon) QueryTokens

func (mp *MultiPolygon) QueryTokens(s *s2.RegionTermIndexer) []string

func (*MultiPolygon) Type

func (p *MultiPolygon) Type() string

func (*MultiPolygon) Value added in v0.1.13

func (p *MultiPolygon) Value() ([]byte, error)

type Point

type Point struct {
	Typ      string    `json:"type"`
	Vertices []float64 `json:"coordinates"`
	// contains filtered or unexported fields
}

-------------------------------------------------------- Point represents the geoJSON point type and it implements the index.GeoJSON interface.

func (*Point) Contains

func (p *Point) Contains(other index.GeoJSON) (bool, error)

func (*Point) Coordinates

func (p *Point) Coordinates() []float64

func (*Point) IndexTokens

func (p *Point) IndexTokens(s *s2.RegionTermIndexer) []string

func (*Point) Intersects

func (p *Point) Intersects(other index.GeoJSON) (bool, error)

func (*Point) Marshal

func (p *Point) Marshal() ([]byte, error)

func (*Point) QueryTokens

func (p *Point) QueryTokens(s *s2.RegionTermIndexer) []string

func (*Point) Type

func (p *Point) Type() string

func (*Point) Value added in v0.1.13

func (p *Point) Value() ([]byte, error)

type Polygon

type Polygon struct {
	Typ      string        `json:"type"`
	Vertices [][][]float64 `json:"coordinates"`
	// contains filtered or unexported fields
}

-------------------------------------------------------- Polygon represents the geoJSON polygon type and it implements the index.GeoJSON interface.

func (*Polygon) Contains

func (p *Polygon) Contains(other index.GeoJSON) (bool, error)

func (*Polygon) Coordinates

func (p *Polygon) Coordinates() [][][]float64

func (*Polygon) IndexTokens

func (pgn *Polygon) IndexTokens(s *s2.RegionTermIndexer) []string

func (*Polygon) Intersects

func (p *Polygon) Intersects(other index.GeoJSON) (bool, error)

func (*Polygon) Marshal

func (p *Polygon) Marshal() ([]byte, error)

func (*Polygon) QueryTokens

func (pgn *Polygon) QueryTokens(s *s2.RegionTermIndexer) []string

func (*Polygon) Type

func (p *Polygon) Type() string

func (*Polygon) Value added in v0.1.13

func (p *Polygon) Value() ([]byte, error)

Jump to

Keyboard shortcuts

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