Search in sources :

Example 31 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, ZOrderSpaceFillingCurve2D 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 32 with Envelope

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

the class SpaceFillingCurveTest method shouldCreateSimple2DHilbertCurveAtLevelDefault.

@Test
void shouldCreateSimple2DHilbertCurveAtLevelDefault() {
    Envelope envelope = new Envelope(-8, 8, -8, 8);
    assertAtLevel(new HilbertSpaceFillingCurve2D(envelope), envelope);
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 33 with Envelope

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

the class StandardConfiguration method maxDepth.

/**
 * If the search area is exactly one of the finest grained tiles (tile at maxLevel), then
 * we want the search to traverse to maxLevel, however, for each area that is 4x larger, we would
 * traverse one level shallower. This is achieved by a log (base 4 for 2D, base 8 for 3D) of the ratio of areas.
 * <p>
 * {@inheritDoc}
 */
@Override
public int maxDepth(Envelope referenceEnvelope, Envelope range, int nbrDim, int maxLevel) {
    Envelope paddedEnvelope = referenceEnvelope.withSideRatioNotTooSmall();
    double searchRatio = range.getArea() / paddedEnvelope.getArea();
    if (Double.isInfinite(searchRatio)) {
        return maxLevel;
    }
    // log(2^x) = xlog(2)
    return Math.min(maxLevel, (int) (Math.log(searchRatio) / (nbrDim * LOG_2)) + extraLevels);
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope)

Example 34 with Envelope

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

the class SpaceFillingCurveConfigurationTest method shouldHandleMaxDepthWithEmptySearchArea.

@Test
void shouldHandleMaxDepthWithEmptySearchArea() {
    SpaceFillingCurveConfiguration standardConfiguration = new StandardConfiguration();
    SpaceFillingCurveConfiguration partialOverlapConf = new PartialOverlapConfiguration();
    // search area is a line, thus having a search area = 0
    Envelope search = new Envelope(-180, -180, -90, 90);
    Envelope range = new Envelope(-180, 180, -90, 90);
    // We pad the line to a small area, but we don't expect to go deeper than level 20
    // which would take too long
    int maxLevel = 20;
    assertThat(partialOverlapConf.maxDepth(search, range, 2, 30)).isLessThan(maxLevel);
    assertThat(standardConfiguration.maxDepth(search, range, 2, 30)).isLessThan(maxLevel);
}
Also used : Envelope(org.neo4j.gis.spatial.index.Envelope) Test(org.junit.jupiter.api.Test)

Example 35 with Envelope

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

the class SpaceFillingCurveConfigurationTest method shouldReturnAppropriateDepth.

@Test
void shouldReturnAppropriateDepth() {
    final int maxLevel = 30;
    for (int i = 0; i < maxLevel; i++) {
        SpaceFillingCurveConfiguration standardConfiguration = new StandardConfiguration();
        SpaceFillingCurveConfiguration partialOverlapConf = new PartialOverlapConfiguration();
        // search area is a line, thus having a search area = 0
        Envelope range = new Envelope(0, 1, 0, 1);
        Envelope search = new Envelope(0, Math.pow(2, -i), 0, Math.pow(2, -i));
        assertThat(partialOverlapConf.maxDepth(search, range, 2, maxLevel)).isEqualTo(i + 1);
        assertThat(standardConfiguration.maxDepth(search, range, 2, maxLevel)).isEqualTo(i + 1);
    }
}
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