Documentation
¶
Index ¶
- Constants
- Variables
- func DeduplicateTerms(terms []string) []string
- func ExtractShapesFromBytes(targetShapeBytes []byte, r **bytes.Reader, bufPool *s2.GeoBufferPool) (index.GeoJSON, error)
- func FilterGeoShapesOnRelation(shape index.GeoJSON, targetShapeBytes []byte, relation string, ...) (bool, error)
- func NewGeoCircle(points []float64, radius string) index.GeoJSON
- func NewGeoEnvelope(points [][]float64) index.GeoJSON
- func NewGeoJsonLinestring(points [][]float64) index.GeoJSON
- func NewGeoJsonMultiPoint(v [][]float64) index.GeoJSON
- func NewGeoJsonMultiPolygon(points [][][][]float64) index.GeoJSON
- func NewGeoJsonMultilinestring(points [][][]float64) index.GeoJSON
- func NewGeoJsonPoint(v []float64) index.GeoJSON
- func NewGeoJsonPolygon(points [][][]float64) index.GeoJSON
- func NewGeoJsonShape(coordinates [][][][]float64, typ string) (index.GeoJSON, []byte, error)
- func NewGeometryCollection(shapes []*GeoShape) (index.GeoJSON, []byte, error)
- func ParseDistance(d string) (float64, error)
- func ParseGeoJSONShape(input []byte) (index.GeoJSON, error)
- func StripCoveringTerms(terms []string) []string
- type Circle
- func (c *Circle) BoundingBox() index.GeoJSON
- func (c *Circle) Contains(other index.GeoJSON) (bool, error)
- func (c *Circle) IndexCells() (inner, cross []uint64)
- func (c *Circle) IndexTokens(s *s2.RegionTermIndexer) []string
- func (c *Circle) Intersects(other index.GeoJSON) (bool, error)
- func (c *Circle) Marshal() ([]byte, error)
- func (c *Circle) QueryCells() (inner, cross []uint64)
- func (c *Circle) QueryTokens(s *s2.RegionTermIndexer) []string
- func (c *Circle) Type() string
- func (c *Circle) UnmarshalJSON(data []byte) error
- func (c *Circle) Value() ([]byte, error)
- type Envelope
- func (e *Envelope) BoundingBox() index.GeoJSON
- func (e *Envelope) Contains(other index.GeoJSON) (bool, error)
- func (e *Envelope) IndexCells() (inner, cross []uint64)
- func (e *Envelope) IndexTokens(s *s2.RegionTermIndexer) []string
- func (e *Envelope) Intersects(other index.GeoJSON) (bool, error)
- func (e *Envelope) Marshal() ([]byte, error)
- func (e *Envelope) QueryCells() (inner, cross []uint64)
- func (e *Envelope) QueryTokens(s *s2.RegionTermIndexer) []string
- func (e *Envelope) Type() string
- func (e *Envelope) Value() ([]byte, error)
- type GeoShape
- type GeometryCollection
- func (gc *GeometryCollection) BoundingBox() index.GeoJSON
- func (gc *GeometryCollection) Contains(other index.GeoJSON) (bool, error)
- func (gc *GeometryCollection) IndexCells() (inner, cross []uint64)
- func (gc *GeometryCollection) Intersects(other index.GeoJSON) (bool, error)
- func (gc *GeometryCollection) Marshal() ([]byte, error)
- func (gc *GeometryCollection) Members() []index.GeoJSON
- func (gc *GeometryCollection) QueryCells() (inner, cross []uint64)
- func (gc *GeometryCollection) Type() string
- func (gc *GeometryCollection) UnmarshalJSON(data []byte) error
- func (gc *GeometryCollection) Value() ([]byte, error)
- type LineString
- func (ls *LineString) BoundingBox() index.GeoJSON
- func (ls *LineString) Contains(other index.GeoJSON) (bool, error)
- func (ls *LineString) Coordinates() [][]float64
- func (ls *LineString) IndexCells() (inner, cross []uint64)
- func (ls *LineString) IndexTokens(s *s2.RegionTermIndexer) []string
- func (ls *LineString) Intersects(other index.GeoJSON) (bool, error)
- func (ls *LineString) Marshal() ([]byte, error)
- func (ls *LineString) QueryCells() (inner, cross []uint64)
- func (ls *LineString) QueryTokens(s *s2.RegionTermIndexer) []string
- func (ls *LineString) Type() string
- func (ls *LineString) Value() ([]byte, error)
- type MultiLineString
- func (mls *MultiLineString) BoundingBox() index.GeoJSON
- func (mls *MultiLineString) Contains(other index.GeoJSON) (bool, error)
- func (mls *MultiLineString) Coordinates() [][][]float64
- func (mls *MultiLineString) IndexCells() (inner, cross []uint64)
- func (mls *MultiLineString) IndexTokens(s *s2.RegionTermIndexer) []string
- func (mls *MultiLineString) Intersects(other index.GeoJSON) (bool, error)
- func (mls *MultiLineString) Marshal() ([]byte, error)
- func (mls *MultiLineString) Members() []index.GeoJSON
- func (mls *MultiLineString) QueryCells() (inner, cross []uint64)
- func (mls *MultiLineString) QueryTokens(s *s2.RegionTermIndexer) []string
- func (mls *MultiLineString) Type() string
- func (mls *MultiLineString) Value() ([]byte, error)
- type MultiPoint
- func (mp *MultiPoint) BoundingBox() index.GeoJSON
- func (mp *MultiPoint) Contains(other index.GeoJSON) (bool, error)
- func (mp *MultiPoint) Coordinates() [][]float64
- func (mp *MultiPoint) IndexCells() (inner, cross []uint64)
- func (mp *MultiPoint) IndexTokens(s *s2.RegionTermIndexer) []string
- func (mp *MultiPoint) Intersects(other index.GeoJSON) (bool, error)
- func (mp *MultiPoint) Marshal() ([]byte, error)
- func (mp *MultiPoint) Members() []index.GeoJSON
- func (mp *MultiPoint) QueryCells() (inner, cross []uint64)
- func (mp *MultiPoint) QueryTokens(s *s2.RegionTermIndexer) []string
- func (mp *MultiPoint) Type() string
- func (mp *MultiPoint) Value() ([]byte, error)
- type MultiPolygon
- func (mp *MultiPolygon) BoundingBox() index.GeoJSON
- func (mp *MultiPolygon) Contains(other index.GeoJSON) (bool, error)
- func (mp *MultiPolygon) Coordinates() [][][][]float64
- func (mp *MultiPolygon) IndexCells() (inner, cross []uint64)
- func (mp *MultiPolygon) IndexTokens(s *s2.RegionTermIndexer) []string
- func (mp *MultiPolygon) Intersects(other index.GeoJSON) (bool, error)
- func (mp *MultiPolygon) Marshal() ([]byte, error)
- func (mp *MultiPolygon) Members() []index.GeoJSON
- func (mp *MultiPolygon) QueryCells() (inner, cross []uint64)
- func (mp *MultiPolygon) QueryTokens(s *s2.RegionTermIndexer) []string
- func (mp *MultiPolygon) Type() string
- func (mp *MultiPolygon) Value() ([]byte, error)
- type Point
- func (p *Point) BoundingBox() index.GeoJSON
- func (p *Point) Contains(other index.GeoJSON) (bool, error)
- func (p *Point) Coordinates() []float64
- func (p *Point) IndexCells() (inner, cross []uint64)
- func (p *Point) IndexTokens(s *s2.RegionTermIndexer) []string
- func (p *Point) Intersects(other index.GeoJSON) (bool, error)
- func (p *Point) Marshal() ([]byte, error)
- func (p *Point) QueryCells() (inner, cross []uint64)
- func (p *Point) QueryTokens(s *s2.RegionTermIndexer) []string
- func (p *Point) Type() string
- func (p *Point) Value() ([]byte, error)
- type Polygon
- func (pg *Polygon) BoundingBox() index.GeoJSON
- func (pg *Polygon) Contains(other index.GeoJSON) (bool, error)
- func (pg *Polygon) Coordinates() [][][]float64
- func (pg *Polygon) IndexCells() (inner, cross []uint64)
- func (pg *Polygon) IndexTokens(s *s2.RegionTermIndexer) []string
- func (pg *Polygon) Intersects(other index.GeoJSON) (bool, error)
- func (pg *Polygon) Marshal() ([]byte, error)
- func (pg *Polygon) QueryCells() (inner, cross []uint64)
- func (pg *Polygon) QueryTokens(s *s2.RegionTermIndexer) []string
- func (pg *Polygon) Type() string
- func (pg *Polygon) Value() ([]byte, error)
Constants ¶
const ( PointType = "point" MultiPointType = "multipoint" LineStringType = "linestring" MultiLineStringType = "multilinestring" PolygonType = "polygon" MultiPolygonType = "multipolygon" GeometryCollectionType = "geometrycollection" CircleType = "circle" EnvelopeType = "envelope" )
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 ¶
var GlueBytes = []byte("##")
GlueBytes primarily for quicker filtering of docvalues during the filtering phase.
Functions ¶
func DeduplicateTerms ¶
func ExtractShapesFromBytes ¶ added in v0.2.6
func ExtractShapesFromBytes(targetShapeBytes []byte, r **bytes.Reader, bufPool *s2.GeoBufferPool) ( index.GeoJSON, error)
ExtractShapesFromBytes unmarshal the bytes to retrieve the embedded geojson shape.
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 NewGeoEnvelope ¶
func NewGeoJsonLinestring ¶
NewGeoJsonLinestring instantiates a LineString from the given coordinates.
func NewGeoJsonMultiPoint ¶
func NewGeoJsonMultiPolygon ¶
func NewGeoJsonMultilinestring ¶
NewGeoJsonMultilinestring instantiates a MultiLineString from the given coordinates.
func NewGeoJsonPoint ¶
func NewGeoJsonPolygon ¶
func NewGeoJsonShape ¶
NewGeoJsonShape instantiate a geojson shape/circle or an envelope from the given coordinates and type.
func NewGeometryCollection ¶
NewGeometryCollection instantiate a geometrycollection and prefix the byte contents with certain glue bytes that can be used later while filtering the doc values.
func ParseDistance ¶
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 ¶
ParseGeoJSONShape unmarshals the geojson/circle/envelope shape embedded in the given bytes.
func StripCoveringTerms ¶
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 ¶
NewGeoCircleShape instantiate a circle shape and prefix the byte contents with certain glue bytes that can be used later while filtering the doc values.
func (*Circle) BoundingBox ¶ added in v0.2.6
func (*Circle) IndexCells ¶ added in v0.2.6
IndexCells returns the circle's covering partitioned into inner cells (fully contained in the cap built from the center and radiusInMeters) and cross cells (overlapping the cap's boundary).
func (*Circle) IndexTokens ¶
func (c *Circle) IndexTokens(s *s2.RegionTermIndexer) []string
func (*Circle) QueryCells ¶ added in v0.2.6
QueryCells returns the circle's query-time covering, partitioned the same way as IndexCells.
func (*Circle) QueryTokens ¶
func (c *Circle) QueryTokens(s *s2.RegionTermIndexer) []string
func (*Circle) UnmarshalJSON ¶
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) BoundingBox ¶ added in v0.2.6
func (*Envelope) IndexCells ¶ added in v0.2.6
IndexCells returns the envelope's covering partitioned into inner cells (fully contained in the rectangle) and cross cells (overlapping its boundary).
func (*Envelope) IndexTokens ¶
func (e *Envelope) IndexTokens(s *s2.RegionTermIndexer) []string
func (*Envelope) QueryCells ¶ added in v0.2.6
QueryCells returns the envelope's query-time covering, partitioned the same way as IndexCells.
func (*Envelope) QueryTokens ¶
func (e *Envelope) QueryTokens(s *s2.RegionTermIndexer) []string
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 compositeShape interface.
func (*GeometryCollection) BoundingBox ¶ added in v0.2.6
func (gc *GeometryCollection) BoundingBox() index.GeoJSON
func (*GeometryCollection) Contains ¶
func (gc *GeometryCollection) Contains(other index.GeoJSON) (bool, error)
func (*GeometryCollection) IndexCells ¶ added in v0.2.6
func (gc *GeometryCollection) IndexCells() (inner, cross []uint64)
IndexCells returns the union of the member shapes' coverings, deduplicated and reconciled (see aggregateCells).
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) QueryCells ¶ added in v0.2.6
func (gc *GeometryCollection) QueryCells() (inner, cross []uint64)
QueryCells returns the union of the member shapes' query-time coverings, deduplicated and reconciled (see aggregateCells).
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) BoundingBox ¶ added in v0.2.6
func (ls *LineString) BoundingBox() index.GeoJSON
func (*LineString) Coordinates ¶
func (ls *LineString) Coordinates() [][]float64
func (*LineString) IndexCells ¶ added in v0.2.6
func (ls *LineString) IndexCells() (inner, cross []uint64)
IndexCells returns the linestring's covering: a polyline has no area, so every covering cell is a cross cell and inner is always nil.
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) QueryCells ¶ added in v0.2.6
func (ls *LineString) QueryCells() (inner, cross []uint64)
QueryCells returns the linestring's query-time covering; like IndexCells, it can only contain cross cells.
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 compositeShape interface.
func (*MultiLineString) BoundingBox ¶ added in v0.2.6
func (mls *MultiLineString) BoundingBox() index.GeoJSON
func (*MultiLineString) Contains ¶
func (mls *MultiLineString) Contains(other index.GeoJSON) (bool, error)
func (*MultiLineString) Coordinates ¶
func (mls *MultiLineString) Coordinates() [][][]float64
func (*MultiLineString) IndexCells ¶ added in v0.2.6
func (mls *MultiLineString) IndexCells() (inner, cross []uint64)
IndexCells returns the multilinestring's covering, computed as a single covering of the union of its polylines. Polylines have no area, so every covering cell is a cross cell and inner is always nil.
func (*MultiLineString) IndexTokens ¶
func (mls *MultiLineString) IndexTokens(s *s2.RegionTermIndexer) []string
func (*MultiLineString) Intersects ¶
func (mls *MultiLineString) Intersects(other index.GeoJSON) (bool, error)
func (*MultiLineString) Marshal ¶
func (mls *MultiLineString) Marshal() ([]byte, error)
func (*MultiLineString) Members ¶
func (mls *MultiLineString) Members() []index.GeoJSON
func (*MultiLineString) QueryCells ¶ added in v0.2.6
func (mls *MultiLineString) QueryCells() (inner, cross []uint64)
QueryCells returns the multilinestring's query-time covering; like IndexCells, it can only contain cross cells.
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 compositeShape interface.
func (*MultiPoint) BoundingBox ¶ added in v0.2.6
func (mp *MultiPoint) BoundingBox() index.GeoJSON
func (*MultiPoint) Coordinates ¶
func (mp *MultiPoint) Coordinates() [][]float64
func (*MultiPoint) IndexCells ¶ added in v0.2.6
func (mp *MultiPoint) IndexCells() (inner, cross []uint64)
IndexCells returns the multipoint's covering: points have no area, so the result is one maxCellLevel cross cell per distinct point cell and never any inner cells. Cells are deduplicated, since points can share a cell.
func (*MultiPoint) IndexTokens ¶
func (mp *MultiPoint) IndexTokens(s *s2.RegionTermIndexer) []string
func (*MultiPoint) Intersects ¶
func (mp *MultiPoint) Intersects(other index.GeoJSON) (bool, error)
func (*MultiPoint) Marshal ¶
func (mp *MultiPoint) Marshal() ([]byte, error)
func (*MultiPoint) Members ¶
func (mp *MultiPoint) Members() []index.GeoJSON
func (*MultiPoint) QueryCells ¶ added in v0.2.6
func (mp *MultiPoint) QueryCells() (inner, cross []uint64)
QueryCells delegates to IndexCells: each point maps to exactly one cell, so the query-time coverer would produce the same cross cells as the index-time coverer.
func (*MultiPoint) QueryTokens ¶
func (mp *MultiPoint) QueryTokens(s *s2.RegionTermIndexer) []string
func (*MultiPoint) Type ¶
func (mp *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 compositeShape interface.
func (*MultiPolygon) BoundingBox ¶ added in v0.2.6
func (mp *MultiPolygon) BoundingBox() index.GeoJSON
func (*MultiPolygon) Coordinates ¶
func (mp *MultiPolygon) Coordinates() [][][][]float64
func (*MultiPolygon) IndexCells ¶ added in v0.2.6
func (mp *MultiPolygon) IndexCells() (inner, cross []uint64)
IndexCells returns the multipolygon's covering, computed as a single covering of the union of its polygons and partitioned into inner and cross cells.
func (*MultiPolygon) IndexTokens ¶
func (mp *MultiPolygon) IndexTokens(s *s2.RegionTermIndexer) []string
func (*MultiPolygon) Intersects ¶
func (mp *MultiPolygon) Intersects(other index.GeoJSON) (bool, error)
func (*MultiPolygon) Marshal ¶
func (mp *MultiPolygon) Marshal() ([]byte, error)
func (*MultiPolygon) Members ¶
func (mp *MultiPolygon) Members() []index.GeoJSON
func (*MultiPolygon) QueryCells ¶ added in v0.2.6
func (mp *MultiPolygon) QueryCells() (inner, cross []uint64)
QueryCells returns the multipolygon's query-time covering, partitioned the same way as IndexCells.
func (*MultiPolygon) QueryTokens ¶
func (mp *MultiPolygon) QueryTokens(s *s2.RegionTermIndexer) []string
func (*MultiPolygon) Type ¶
func (mp *MultiPolygon) Type() string
func (*MultiPolygon) Value ¶ added in v0.1.13
func (mp *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) BoundingBox ¶ added in v0.2.6
func (*Point) Coordinates ¶
func (*Point) IndexCells ¶ added in v0.2.6
IndexCells returns the point's covering: a point has no area, so it is a single maxCellLevel cross cell and never an inner cell.
func (*Point) IndexTokens ¶
func (p *Point) IndexTokens(s *s2.RegionTermIndexer) []string
func (*Point) QueryCells ¶ added in v0.2.6
QueryCells delegates to IndexCells: a point maps to exactly one cell, so the query-time coverer would produce the same single cross cell as the index-time coverer.
func (*Point) QueryTokens ¶
func (p *Point) QueryTokens(s *s2.RegionTermIndexer) []string
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) BoundingBox ¶ added in v0.2.6
func (*Polygon) Coordinates ¶
func (*Polygon) IndexCells ¶ added in v0.2.6
IndexCells returns the polygon's covering partitioned into inner cells (fully contained in the polygon, excluding any holes) and cross cells (overlapping the boundary). The hole exclusion relies on the s2 polygon being built from oriented loops, so ContainsCell is false for cells inside interior rings.
func (*Polygon) IndexTokens ¶
func (pg *Polygon) IndexTokens(s *s2.RegionTermIndexer) []string
func (*Polygon) QueryCells ¶ added in v0.2.6
QueryCells returns the polygon's query-time covering, partitioned the same way as IndexCells.
func (*Polygon) QueryTokens ¶
func (pg *Polygon) QueryTokens(s *s2.RegionTermIndexer) []string