mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-07-02 16:10:49 +02:00
Added some spatial query for plain sql backend.
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user