1 /***********************************************************************
2 * Copyright (c) 2013-2024 Commonwealth Computer Research, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Apache License, Version 2.0
5 * which accompanies this distribution and is available at
6 * http://www.opensource.org/licenses/apache2.0.php.
7 ***********************************************************************/
8
9 package org.locationtech.geomesa.index.index
10
11 import org.locationtech.geomesa.curve.{XZ3SFC, Z3SFC}
12 import org.locationtech.geomesa.filter.{Bounds, FilterValues}
13 import org.locationtech.jts.geom.Geometry
14
15 import java.time.ZonedDateTime
16
17 package object z3 {
18
19 /**
20 * Index key for z3 values
21 *
22 * @param bin date epoch
23 * @param z z3 value within the epoch
24 */
25 case class Z3IndexKey(bin: Short, z: Long) extends Ordered[Z3IndexKey] {
26 override def compare(that: Z3IndexKey): Int = {
27 val b = Ordering.Short.compare(bin, that.bin)
28 if (b != 0) { b } else {
29 Ordering.Long.compare(z, that.z)
30 }
31 }
32 }
33
34 /**
35 * Index values extracted from a filter for z3 queries
36 *
37 * @param sfc specific curve being used
38 * @param geometries extracted geometries
39 * @param spatialBounds the spatial bounds from the extracted geometries, as bounding boxes
40 * @param intervals extracted dates
41 * @param temporalBounds the temporal bounds from the extracted dates, as time units (depending on the sfc),
42 * keyed by epoch
43 * @param temporalUnbounded unbounded temporal epochs, i.e. all time values are covered. will be either
44 * `(0, t)`, `(t, Short.MaxValue)` or `(0, Short.MaxValue)` for upper, lower,
45 * and unbounded queries, respectively
46 */
47 case class Z3IndexValues(
48 sfc: Z3SFC,
49 geometries: FilterValues[Geometry],
50 spatialBounds: Seq[(Double, Double, Double, Double)],
51 intervals: FilterValues[Bounds[ZonedDateTime]],
52 temporalBounds: Map[Short, Seq[(Long, Long)]],
53 temporalUnbounded: Seq[(Short, Short)]
54 ) extends TemporalIndexValues with SpatialIndexValues
55
56 /**
57 * Index values extracted from a filter for xz3 queries
58 *
59 * @param sfc specific curve being used
60 * @param geometries extracted geometries
61 * @param spatialBounds the spatial bounds from the extracted geometries, as bounding boxes
62 * @param intervals extracted dates
63 * @param temporalBounds the temporal bounds from the extracted dates, as time units (depending on the sfc),
64 * keyed by epoch
65 * @param temporalUnbounded unbounded temporal epochs, i.e. all time values are covered. will be either
66 * `(0, t)`, `(t, Short.MaxValue)` or `(0, Short.MaxValue)` for upper, lower,
67 * and unbounded queries, respectively
68 */
69 case class XZ3IndexValues(
70 sfc: XZ3SFC,
71 geometries: FilterValues[Geometry],
72 spatialBounds: Seq[(Double, Double, Double, Double)],
73 intervals: FilterValues[Bounds[ZonedDateTime]],
74 temporalBounds: Map[Short, (Double, Double)],
75 temporalUnbounded: Seq[(Short, Short)]
76 ) extends TemporalIndexValues with SpatialIndexValues
77 }