Search in sources :

Example 36 with Envelope

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

the class SpaceFillingCurveTest method assertRange.

private static void assertRange(int divisor, long value, HilbertSpaceFillingCurve2D curve, int... index) {
    Envelope range = getTileEnvelope(curve.getRange(), divisor, index);
    String message = Arrays.toString(index) + " should evaluate to " + value;
    assertRange(message, curve, range, value);
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope)

Example 37 with Envelope

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

the class SpaceFillingCurveTest method shouldGet2DHilbertSearchTilesForManyLevels.

@Test
void shouldGet2DHilbertSearchTilesForManyLevels() {
    Envelope envelope = new Envelope(-8, 8, -8, 8);
    for (int level = 1; level <= HilbertSpaceFillingCurve2D.MAX_LEVEL; level++) {
        HilbertSpaceFillingCurve2D curve = new HilbertSpaceFillingCurve2D(envelope, level);
        double halfTile = curve.getTileWidth(0, level) / 2.0;
        long start = System.currentTimeMillis();
        assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(-8, -8 + halfTile, -8, -8 + halfTile)), new SpaceFillingCurve.LongRange(0, 0));
        assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(8 - halfTile, 8, -8, -8 + halfTile)), new SpaceFillingCurve.LongRange(curve.getValueWidth() - 1, curve.getValueWidth() - 1));
        assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(0, halfTile, 0, halfTile)), new SpaceFillingCurve.LongRange(curve.getValueWidth() / 2, curve.getValueWidth() / 2));
    }
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 38 with Envelope

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

the class SpaceFillingCurveTest method shouldCreateSimple2DHilbertCurveAtManyLevels.

@Test
void shouldCreateSimple2DHilbertCurveAtManyLevels() {
    Envelope envelope = new Envelope(new double[] { -8, -8 }, new double[] { 8, 8 });
    for (int level = 1; level <= HilbertSpaceFillingCurve2D.MAX_LEVEL; level++) {
        HilbertSpaceFillingCurve2D curve = new HilbertSpaceFillingCurve2D(envelope, level);
        assertAtLevel(curve, envelope);
        assertRange((int) curve.getWidth(), 0, curve, 0, 0);
        assertRange((int) curve.getWidth(), curve.getValueWidth() - 1, curve, (int) curve.getWidth() - 1, 0);
    }
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 39 with Envelope

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

the class SpaceFillingCurveTest method shouldNotStepMoreThanDistanceOneMoreThan10Percent.

@Test
void shouldNotStepMoreThanDistanceOneMoreThan10Percent() {
    Envelope envelope = new Envelope(new double[] { -8, -8, -8 }, new double[] { 8, 8, 8 });
    for (int level = 1; level < 8; level++) {
        // more than 8 takes way too long
        HilbertSpaceFillingCurve3D curve = new HilbertSpaceFillingCurve3D(envelope, level);
        shouldNeverStepMoreThanDistanceOne(curve, level, 10);
    }
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 40 with Envelope

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

the class SpaceFillingCurveTest method shouldCreateSimple2DZOrderCurveAtLevel24.

@Test
void shouldCreateSimple2DZOrderCurveAtLevel24() {
    Envelope envelope = new Envelope(-8, 8, -8, 8);
    assertAtLevel(new ZOrderSpaceFillingCurve2D(envelope, 24), envelope);
}
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