use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.
the class SpaceFillingCurveTest method shouldCreateSimple2DHilbertCurveAtLevel2.
@Test
void shouldCreateSimple2DHilbertCurveAtLevel2() {
Envelope envelope = new Envelope(-8, 8, -8, 8);
HilbertSpaceFillingCurve2D curve = new HilbertSpaceFillingCurve2D(envelope, 2);
assertAtLevel(curve, envelope);
assertRange("'00' should evaluate to 0", curve, getTileEnvelope(envelope, 4, 0, 0), 0L);
assertRange("'10' should evaluate to 1", curve, getTileEnvelope(envelope, 4, 1, 0), 1L);
assertRange("'11' should evaluate to 2", curve, getTileEnvelope(envelope, 4, 1, 1), 2L);
assertRange("'01' should evaluate to 3", curve, getTileEnvelope(envelope, 4, 0, 1), 3L);
assertRange("'02' should evaluate to 4", curve, getTileEnvelope(envelope, 4, 0, 2), 4L);
assertRange("'03' should evaluate to 5", curve, getTileEnvelope(envelope, 4, 0, 3), 5L);
assertRange("'13' should evaluate to 6", curve, getTileEnvelope(envelope, 4, 1, 3), 6L);
assertRange("'12' should evaluate to 7", curve, getTileEnvelope(envelope, 4, 1, 2), 7L);
assertRange("'22' should evaluate to 8", curve, getTileEnvelope(envelope, 4, 2, 2), 8L);
assertRange("'23' should evaluate to 9", curve, getTileEnvelope(envelope, 4, 2, 3), 9L);
assertRange("'33' should evaluate to 10", curve, getTileEnvelope(envelope, 4, 3, 3), 10L);
assertRange("'32' should evaluate to 11", curve, getTileEnvelope(envelope, 4, 3, 2), 11L);
assertRange("'31' should evaluate to 12", curve, getTileEnvelope(envelope, 4, 3, 1), 12L);
assertRange("'21' should evaluate to 13", curve, getTileEnvelope(envelope, 4, 2, 1), 13L);
assertRange("'20' should evaluate to 14", curve, getTileEnvelope(envelope, 4, 2, 0), 14L);
assertRange("'30' should evaluate to 15", curve, getTileEnvelope(envelope, 4, 3, 0), 15L);
}
use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.
the class SpaceFillingCurveTest method shouldGet3DSearchTilesForLevel1.
@Test
void shouldGet3DSearchTilesForLevel1() {
Envelope envelope = new Envelope(new double[] { -8, -8, -8 }, new double[] { 8, 8, 8 });
HilbertSpaceFillingCurve3D curve = new HilbertSpaceFillingCurve3D(envelope, 1);
assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(new double[] { -6, -6, -6 }, new double[] { -5, -5, -5 })), new SpaceFillingCurve.LongRange(0, 0));
assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(new double[] { 0, -6, -6 }, new double[] { 6, -5, -5 })), new SpaceFillingCurve.LongRange(7, 7));
assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(new double[] { -6, -5, -5 }, new double[] { 4, -2, -2 })), new SpaceFillingCurve.LongRange(0, 0), new SpaceFillingCurve.LongRange(7, 7));
assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(new double[] { -2, -6, -2 }, new double[] { -1, 5, -1 })), new SpaceFillingCurve.LongRange(0, 1));
assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(new double[] { -2, -1, -1 }, new double[] { -1, 1, 1 })), new SpaceFillingCurve.LongRange(0, 3));
assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(new double[] { -1, -1, -1 }, new double[] { 1, 1, 1 })), new SpaceFillingCurve.LongRange(0, 7));
}
use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.
the class SpaceFillingCurveTest method shouldWorkWithNormalGPSCoordinatesZOrder.
@Test
void shouldWorkWithNormalGPSCoordinatesZOrder() {
Envelope envelope = new Envelope(-180, 180, -90, 90);
ZOrderSpaceFillingCurve2D curve = new ZOrderSpaceFillingCurve2D(envelope);
assertAtLevel(curve, envelope);
}
use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.
the class SpaceFillingCurveTest method shouldNeverStepMoreThanDistanceOneForHilbert2D.
@Test
void shouldNeverStepMoreThanDistanceOneForHilbert2D() {
Envelope envelope = new Envelope(new double[] { -8, -8 }, new double[] { 8, 8 });
for (int level = 1; level < 8; level++) {
// more than 8 takes way too long
HilbertSpaceFillingCurve2D curve = new HilbertSpaceFillingCurve2D(envelope, level);
shouldNeverStepMoreThanDistanceOne(curve, level, 0);
}
}
use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.
the class SpaceFillingCurveTest method shouldCreateSimple2DHilbertCurveAtLevel1.
//
// Set of tests for 2D HilbertCurve at various levels
//
@Test
void shouldCreateSimple2DHilbertCurveAtLevel1() {
Envelope envelope = new Envelope(-8, 8, -8, 8);
HilbertSpaceFillingCurve2D curve = new HilbertSpaceFillingCurve2D(envelope, 1);
assertAtLevel(curve, envelope);
assertRange("Bottom-left should evaluate to zero", curve, getTileEnvelope(envelope, 2, 0, 0), 0L);
assertRange("Top-left should evaluate to one", curve, getTileEnvelope(envelope, 2, 0, 1), 1L);
assertRange("Top-right should evaluate to two", curve, getTileEnvelope(envelope, 2, 1, 1), 2L);
assertRange("Bottom-right should evaluate to three", curve, getTileEnvelope(envelope, 2, 1, 0), 3L);
}
Aggregations