forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshape_token.go
33 lines (26 loc) · 1.07 KB
/
shape_token.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
package ravendb
import "strings"
var _ queryToken = &shapeToken{}
type shapeToken struct {
shape string
}
func shapeTokenCircle(radiusParameterName string, latitudeParameterName string, longitudeParameterName string, radiusUnits SpatialUnits) *shapeToken {
if radiusUnits == "" {
shape := "spatial.circle($" + radiusParameterName + ", $" + latitudeParameterName + ", $" + longitudeParameterName + ")"
return &shapeToken{shape: shape}
}
if radiusUnits == SpatialUnitsKilometers {
shape := "spatial.circle($" + radiusParameterName + ", $" + latitudeParameterName + ", $" + longitudeParameterName + ", 'Kilometers')"
return &shapeToken{shape: shape}
}
shape := "spatial.circle($" + radiusParameterName + ", $" + latitudeParameterName + ", $" + longitudeParameterName + ", 'Miles')"
return &shapeToken{shape: shape}
}
func shapeTokenWkt(shapeWktParameterName string) *shapeToken {
shape := "spatial.wkt($" + shapeWktParameterName + ")"
return &shapeToken{shape: shape}
}
func (t *shapeToken) writeTo(writer *strings.Builder) error {
writer.WriteString(t.shape)
return nil
}