Added some spatial query for plain sql backend.

This commit is contained in:
Sascha L. Teichmann
2014-09-01 12:42:57 +02:00
parent caf2cbbcfe
commit 0021854000
2 changed files with 120 additions and 1 deletions

View File

@ -37,6 +37,34 @@ func (c Coord) Equals(o Coord) bool {
return c.X == o.X && c.Y == o.Y && c.Z == o.Z
}
func minComponent(a, b int16) int16 {
if a < b {
return a
}
return b
}
func maxComponent(a, b int16) int16 {
if a > b {
return a
}
return b
}
func MinCoord(a, b Coord) Coord {
return Coord{
X: minComponent(a.X, b.X),
Y: minComponent(a.Y, b.Y),
Z: minComponent(a.Z, b.Z)}
}
func MaxCoord(a, b Coord) Coord {
return Coord{
X: maxComponent(a.X, b.X),
Y: maxComponent(a.Y, b.Y),
Z: maxComponent(a.Z, b.Z)}
}
// Constructs a database key out of byte slice.
func DecodeStringFromBytes(key []byte) (pos int64, err error) {
return strconv.ParseInt(string(key), 10, 64)