Search in sources :

Example 16 with Envelope

use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.

the class SpaceFillingCurveTest method shouldCreateSimple2DZOrderCurveAtLevel2.

@Test
void shouldCreateSimple2DZOrderCurveAtLevel2() {
    Envelope envelope = new Envelope(-8, 8, -8, 8);
    ZOrderSpaceFillingCurve2D curve = new ZOrderSpaceFillingCurve2D(envelope, 2);
    assertAtLevel(curve, envelope);
    assertRange("'00' should evaluate to 0", curve, getTileEnvelope(envelope, 4, 0, 3), 0L);
    assertRange("'10' should evaluate to 1", curve, getTileEnvelope(envelope, 4, 1, 3), 1L);
    assertRange("'11' should evaluate to 2", curve, getTileEnvelope(envelope, 4, 0, 2), 2L);
    assertRange("'01' should evaluate to 3", curve, getTileEnvelope(envelope, 4, 1, 2), 3L);
    assertRange("'02' should evaluate to 4", curve, getTileEnvelope(envelope, 4, 2, 3), 4L);
    assertRange("'03' should evaluate to 5", curve, getTileEnvelope(envelope, 4, 3, 3), 5L);
    assertRange("'13' should evaluate to 6", curve, getTileEnvelope(envelope, 4, 2, 2), 6L);
    assertRange("'12' should evaluate to 7", curve, getTileEnvelope(envelope, 4, 3, 2), 7L);
    assertRange("'22' should evaluate to 8", curve, getTileEnvelope(envelope, 4, 0, 1), 8L);
    assertRange("'23' should evaluate to 9", curve, getTileEnvelope(envelope, 4, 1, 1), 9L);
    assertRange("'33' should evaluate to 10", curve, getTileEnvelope(envelope, 4, 0, 0), 10L);
    assertRange("'32' should evaluate to 11", curve, getTileEnvelope(envelope, 4, 1, 0), 11L);
    assertRange("'31' should evaluate to 12", curve, getTileEnvelope(envelope, 4, 2, 1), 12L);
    assertRange("'21' should evaluate to 13", curve, getTileEnvelope(envelope, 4, 3, 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);
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 17 with Envelope

use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.

the class SpaceFillingCurveTest method shouldCreate3DHilbertCurveWithRectangularEnvelope.

@Test
void shouldCreate3DHilbertCurveWithRectangularEnvelope() {
    Envelope envelope = new Envelope(new double[] { -8, -20, -15 }, new double[] { 8, 0, 15 });
    assertAtLevel(new HilbertSpaceFillingCurve3D(envelope), envelope);
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 18 with Envelope

use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.

the class SpaceFillingCurveTest method shouldGet2DHilbertSearchTilesForLevel1.

@Test
void shouldGet2DHilbertSearchTilesForLevel1() {
    Envelope envelope = new Envelope(-8, 8, -8, 8);
    HilbertSpaceFillingCurve2D curve = new HilbertSpaceFillingCurve2D(envelope, 1);
    assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(-6, -5, -6, -5)), new SpaceFillingCurve.LongRange(0, 0));
    assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(0, 6, -6, -5)), new SpaceFillingCurve.LongRange(3, 3));
    assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(-6, 4, -5, -2)), new SpaceFillingCurve.LongRange(0, 0), new SpaceFillingCurve.LongRange(3, 3));
    assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(-2, -1, -6, 5)), new SpaceFillingCurve.LongRange(0, 1));
    assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(-2, 1, -6, 5)), new SpaceFillingCurve.LongRange(0, 3));
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 19 with Envelope

use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.

the class SpaceFillingCurveTest method shouldStepMoreThanDistanceOneForZOrderOnlyHalfTime.

@Test
void shouldStepMoreThanDistanceOneForZOrderOnlyHalfTime() {
    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
        ZOrderSpaceFillingCurve2D curve = new ZOrderSpaceFillingCurve2D(envelope, level);
        shouldNeverStepMoreThanDistanceOne(curve, level, 50);
    }
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 20 with Envelope

use of org.neo4j.gis.spatial.index.Envelope in project neo4j by neo4j.

the class SpaceFillingCurveTest method shouldCreateSimple3DHilbertCurveAtLevel2.

@Test
void shouldCreateSimple3DHilbertCurveAtLevel2() {
    Envelope envelope = new Envelope(new double[] { -8, -8, -8 }, new double[] { 8, 8, 8 });
    HilbertSpaceFillingCurve3D curve = new HilbertSpaceFillingCurve3D(envelope, 2);
    assertAtLevel(curve, envelope);
    assertRange(4, 0, curve, 0, 0, 0);
    assertRange(4, 1, curve, 0, 0, 1);
    assertRange(4, 2, curve, 1, 0, 1);
    assertRange(4, 3, curve, 1, 0, 0);
    assertRange(4, 4, curve, 1, 1, 0);
    assertRange(4, 5, curve, 1, 1, 1);
    assertRange(4, 6, curve, 0, 1, 1);
    assertRange(4, 7, curve, 0, 1, 0);
    assertRange(4, 8, curve, 0, 2, 0);
    assertRange(4, 9, curve, 1, 2, 0);
    assertRange(4, 10, curve, 1, 3, 0);
    assertRange(4, 11, curve, 0, 3, 0);
    assertRange(4, 12, curve, 0, 3, 1);
    assertRange(4, 13, curve, 1, 3, 1);
    assertRange(4, 14, curve, 1, 2, 1);
    assertRange(4, 15, curve, 0, 2, 1);
    assertRange(4, 63, curve, 3, 0, 0);
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Aggregations

Envelope (org.neo4j.gis.spatial.index.Envelope)55 Test (org.junit.jupiter.api.Test)48 Config (org.neo4j.configuration.Config)1 SpaceFillingCurveSettings (org.neo4j.kernel.impl.index.schema.config.SpaceFillingCurveSettings)1