mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-06-30 07:01:16 +02:00
Added naive BigMin interleaved implementation for interleaved spatial query.
This commit is contained in:
@ -21,6 +21,10 @@ type (
|
||||
X, Y, Z int16
|
||||
}
|
||||
|
||||
Cuboid struct {
|
||||
P1, P2 Coord
|
||||
}
|
||||
|
||||
KeyTransformer func(int64) int64
|
||||
KeyEncoder func(int64) ([]byte, error)
|
||||
KeyDecoder func([]byte) (int64, error)
|
||||
@ -29,6 +33,12 @@ type (
|
||||
KeyJoiner func(Coord) int64
|
||||
)
|
||||
|
||||
func (cub Cuboid) Contains(c Coord) bool {
|
||||
return c.X >= cub.P1.X && c.X <= cub.P2.X &&
|
||||
c.Y >= cub.P1.Y && c.Y <= cub.P2.Y &&
|
||||
c.Z >= cub.P1.Z && c.Z <= cub.P2.Z
|
||||
}
|
||||
|
||||
func (c Coord) String() string {
|
||||
return fmt.Sprintf("(%d, %d, %d)", c.X, c.Y, c.Z)
|
||||
}
|
||||
@ -204,3 +214,23 @@ func TranscodeInterleavedToPlain(key []byte) ([]byte, error) {
|
||||
return EncodeStringToBytes(TransformInterleavedToPlain(pos))
|
||||
}
|
||||
}
|
||||
|
||||
// For correctness checks only.
|
||||
func NaiveBigMin(minz, maxz, zcode int64) int64 {
|
||||
c1, c2 := InterleavedToCoord(minz), InterleavedToCoord(maxz)
|
||||
|
||||
cand := minz
|
||||
|
||||
for x := c1.X; x <= c2.X; x++ {
|
||||
for y := c1.Y; y <= c2.Y; y++ {
|
||||
for z := c1.Z; z <= c2.Z; z++ {
|
||||
z := CoordToInterleaved(Coord{X: x, Y: y, Z: z})
|
||||
if z > zcode && z < cand {
|
||||
cand = z
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cand
|
||||
}
|
||||
|
Reference in New Issue
Block a user