Skip to content

Commit

Permalink
Add top level query redirects for GeoShape queries (#1841)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavdangeti authored Jul 12, 2023
1 parent b9d9c3b commit 0cf7316
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,28 @@ func NewGeoDistanceQuery(lon, lat float64, distance string) *query.GeoDistanceQu
func NewIPRangeQuery(cidr string) *query.IPRangeQuery {
return query.NewIPRangeQuery(cidr)
}

// NewGeoShapeQuery creates a new Query for matching the given geo shape.
// This method can be used for creating geoshape queries for shape types
// like: point, linestring, polygon, multipoint, multilinestring,
// multipolygon and envelope.
func NewGeoShapeQuery(coordinates [][][][]float64, typ, relation string) (*query.GeoShapeQuery, error) {
return query.NewGeoShapeQuery(coordinates, typ, relation)
}

// NewGeoShapeCircleQuery creates a new query for a geoshape that is a
// circle given center point and the radius. Radius 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.
func NewGeoShapeCircleQuery(coordinates []float64, radius, relation string) (*query.GeoShapeQuery, error) {
return query.NewGeoShapeCircleQuery(coordinates, radius, relation)
}

// NewGeometryCollectionQuery creates a new query for the provided
// geometrycollection coordinates and types, which could contain
// multiple geo shapes.
func NewGeometryCollectionQuery(coordinates [][][][][]float64, types []string, relation string) (*query.GeoShapeQuery, error) {
return query.NewGeometryCollectionQuery(coordinates, types, relation)
}
2 changes: 1 addition & 1 deletion search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ func TestGeoShapePolygonContainsPoint(t *testing.T) {
coordinates: []float64{1.5, 48.2},
},
} {
q, err := query.NewGeoShapeQuery(
q, err := NewGeoShapeQuery(
[][][][]float64{{{test.coordinates}}},
geo.PointType,
"contains",
Expand Down

0 comments on commit 0cf7316

Please sign in to comment.