forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspatial_criteria.go
42 lines (35 loc) · 1.36 KB
/
spatial_criteria.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package ravendb
type SpatialCriteria interface {
GetShapeToken(addQueryParameter func(interface{}) string) *shapeToken
ToQueryToken(fieldName string, addQueryParameter func(interface{}) string) queryToken
}
type SpatialCriteriaCommon struct {
_relation SpatialRelation
_distanceErrorPct float64
}
func NewSpatialCriteria(relation SpatialRelation, distanceErrorPct float64) SpatialCriteriaCommon {
return SpatialCriteriaCommon{
_relation: relation,
_distanceErrorPct: distanceErrorPct,
}
}
// Note: hacky way to emulate Java's inheritance
func (c *SpatialCriteriaCommon) toQueryTokenCommon(sc SpatialCriteria, fieldName string, addQueryParameter func(interface{}) string) queryToken {
shapeToken := sc.GetShapeToken(addQueryParameter)
var whereOperator whereOperator
switch c._relation {
case SpatialRelationWithin:
whereOperator = whereOperatorSpatialWithin
case SpatialRelationContains:
whereOperator = whereOperatorSpatialContains
case SpatialRelationDisjoin:
whereOperator = whereOperatorSpatialDisjoint
case SpatialRelationIntersects:
whereOperator = whereOperatorSpatialIntersects
default:
//throw new IllegalArgumentError();
panicIf(true, "Unknown relation '%s'", c._relation)
}
opts := newWhereOptionsWithTokenAndDistance(shapeToken, c._distanceErrorPct)
return createWhereTokenWithOptions(whereOperator, fieldName, "", opts)
}