use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.
the class HashKeyIndexStrategyTest method testDistribution.
@Test
public void testDistribution() {
final Map<ByteArray, Long> counts = new HashMap<>();
int total = 0;
for (double x = 90; x < 180; x += 0.05) {
for (double y = 50; y < 90; y += 0.5) {
final NumericRange dimension1Range = new NumericRange(x, x + 0.002);
final NumericRange dimension2Range = new NumericRange(y - 0.002, y);
final MultiDimensionalNumericData sfcIndexedRange = new BasicNumericDataset(new NumericData[] { dimension1Range, dimension2Range });
for (final byte[] id : hashIdexStrategy.getInsertionPartitionKeys(sfcIndexedRange)) {
final Long count = counts.get(new ByteArray(id));
final long nextcount = count == null ? 1 : count + 1;
counts.put(new ByteArray(id), nextcount);
total++;
}
}
}
final double mean = total / counts.size();
double diff = 0.0;
for (final Long count : counts.values()) {
diff += Math.pow(mean - count, 2);
}
final double sd = Math.sqrt(diff / counts.size());
assertTrue(sd < (mean * 0.18));
}
use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.
the class NumericFieldConstraints method generateNumericData.
private static void generateNumericData(final List<MultiDimensionalIndexData<Double>> results, final int currentDimension, final List<DimensionConstraints<Double>> dimensions, final NumericData[] current) {
if (currentDimension == dimensions.size()) {
results.add(new BasicNumericDataset(current));
return;
}
final DimensionConstraints<Double> dimension = dimensions.get(currentDimension);
final List<FilterRange<Double>> ranges = dimension.getRanges();
for (int i = 0; i < ranges.size(); i++) {
final NumericData[] copy = Arrays.copyOf(current, current.length + 1);
final FilterRange<Double> range = ranges.get(i);
final Double start = toStartRangeValue(range.getStart());
final Double end = toEndRangeValue(range.getEnd());
if (start.equals(end) && range.isStartInclusive() && range.isEndInclusive()) {
copy[copy.length - 1] = new NumericValue(start);
} else {
copy[copy.length - 1] = new NumericRange(toStartRangeValue(range.getStart()), toEndRangeValue(range.getEnd()), range.isStartInclusive(), range.isEndInclusive());
}
generateNumericData(results, currentDimension + 1, dimensions, copy);
}
}
use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.
the class SpatialQueryFilter method stripGeometry.
private static StrippedGeometry stripGeometry(final MultiDimensionalNumericData query, final NumericDimensionField<?>[] orderedConstrainedDimensionDefinitions, final NumericDimensionField<?>[] unconstrainedDimensionDefinitions) {
final Set<String> geometryFieldNames = new HashSet<>();
final List<NumericData> numericDataPerDimension = new ArrayList<>();
final List<NumericDimensionField<?>> fields = new ArrayList<>();
final NumericData[] data = query.getDataPerDimension();
for (int d = 0; d < orderedConstrainedDimensionDefinitions.length; d++) {
// the field ID for later filtering
if (isSpatial(orderedConstrainedDimensionDefinitions[d])) {
geometryFieldNames.add(orderedConstrainedDimensionDefinitions[d].getFieldName());
} else {
numericDataPerDimension.add(data[d]);
fields.add(orderedConstrainedDimensionDefinitions[d]);
}
}
// results)
for (int d = 0; d < unconstrainedDimensionDefinitions.length; d++) {
if (isSpatial(unconstrainedDimensionDefinitions[d])) {
geometryFieldNames.add(unconstrainedDimensionDefinitions[d].getFieldName());
}
}
return new StrippedGeometry(new BasicNumericDataset(numericDataPerDimension.toArray(new NumericData[numericDataPerDimension.size()])), fields.toArray(new NumericDimensionField<?>[fields.size()]), geometryFieldNames);
}
use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.
the class HilbertSFCTest method testDecomposeQuery_2DSpatialOneIndexFilter.
@Test
public void testDecomposeQuery_2DSpatialOneIndexFilter() {
final int LATITUDE_BITS = 31;
final int LONGITUDE_BITS = 31;
final SFCDimensionDefinition[] SPATIAL_DIMENSIONS = new SFCDimensionDefinition[] { new SFCDimensionDefinition(new LongitudeDefinition(), LONGITUDE_BITS), new SFCDimensionDefinition(new LatitudeDefinition(), LATITUDE_BITS) };
final SpaceFillingCurve hilbertSFC = SFCFactory.createSpaceFillingCurve(SPATIAL_DIMENSIONS, SFCType.HILBERT);
// Create a IndexRange object using the x axis
final NumericRange rangeX = new NumericRange(55, 57);
// Create a IndexRange object using the y axis
final NumericRange rangeY = new NumericRange(25, 27);
final BasicNumericDataset spatialQuery = new BasicNumericDataset(new NumericData[] { rangeX, rangeY });
final RangeDecomposition rangeDecomposition = hilbertSFC.decomposeRange(spatialQuery, true, 1);
Assert.assertEquals(1, rangeDecomposition.getRanges().length);
}
use of org.locationtech.geowave.core.index.numeric.BasicNumericDataset in project geowave by locationtech.
the class HilbertSFCTest method testDecomposeQuery_2DSpatialTwentyIndexFilters.
@Test
public void testDecomposeQuery_2DSpatialTwentyIndexFilters() {
final int LATITUDE_BITS = 31;
final int LONGITUDE_BITS = 31;
final SFCDimensionDefinition[] SPATIAL_DIMENSIONS = new SFCDimensionDefinition[] { new SFCDimensionDefinition(new LongitudeDefinition(), LONGITUDE_BITS), new SFCDimensionDefinition(new LatitudeDefinition(), LATITUDE_BITS) };
final SpaceFillingCurve hilbertSFC = SFCFactory.createSpaceFillingCurve(SPATIAL_DIMENSIONS, SFCType.HILBERT);
// Create a IndexRange object using the x axis
final NumericRange rangeX = new NumericRange(10, 57);
// Create a IndexRange object using the y axis
final NumericRange rangeY = new NumericRange(25, 50);
final BasicNumericDataset spatialQuery = new BasicNumericDataset(new NumericData[] { rangeX, rangeY });
final RangeDecomposition rangeDecomposition = hilbertSFC.decomposeRange(spatialQuery, true, 20);
Assert.assertEquals(20, rangeDecomposition.getRanges().length);
}
Aggregations