Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.0-hilbert-index' into 0.25-neo…
Browse files Browse the repository at this point in the history
…4j-3.0B
  • Loading branch information
Lojjs committed Dec 18, 2017
2 parents df19820 + 68ca821 commit 5b026ea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Expand Up @@ -32,7 +32,7 @@ public class HilbertSpaceFillingCurve2D extends SpaceFillingCurve
*/
static class HilbertCurve2D extends CurveRule
{
private CurveRule[] children = null;
private CurveRule[] children;

private HilbertCurve2D( int... npointValues )
{
Expand Down Expand Up @@ -78,7 +78,7 @@ public CurveRule childAt( int npoint )

private static HashMap<String,HilbertCurve2D> curves = new LinkedHashMap<>();

private static void addCurveRule(int... npointValues )
private static void addCurveRule( int... npointValues )
{
HilbertCurve2D curve = new HilbertCurve2D( npointValues );
String name = curve.name();
Expand Down
Expand Up @@ -60,7 +60,7 @@ static int rotateYZ( int value )
*/
static class HilbertCurve3D extends CurveRule
{
CurveRule[] children = null;
CurveRule[] children;

private HilbertCurve3D( int... npointValues )
{
Expand Down
Expand Up @@ -30,7 +30,7 @@ public abstract class SpaceFillingCurve
/**
* Description of the space filling curve structure
*/
static abstract class CurveRule
abstract static class CurveRule
{
final int dimension;
final int[] npointValues;
Expand Down Expand Up @@ -382,6 +382,7 @@ void expandToMax( long other )
this.max = other;
}

@Override
public boolean equals( Object other )
{
return (other instanceof LongRange) && this.equals( (LongRange) other );
Expand All @@ -392,6 +393,13 @@ public boolean equals( LongRange other )
return this.min == other.min && this.max == other.max;
}

@Override
public int hashCode()
{
return (int) (this.min << 16 + this.max);
}

@Override
public String toString()
{
return "LongRange(" + min + "," + max + ")";
Expand All @@ -403,8 +411,8 @@ public String toString()
*/
private class SearchEnvelope
{
long min[];
long max[];
long[] min;
long[] max;
int nbrDim;

private SearchEnvelope( Envelope referenceEnvelope )
Expand Down
Expand Up @@ -509,7 +509,7 @@ public void shouldGet3DSearchTilesForLevel2()
Envelope envelope = new Envelope( new double[]{-8, -8, -8}, new double[]{8, 8, 8} );
HilbertSpaceFillingCurve3D curve = new HilbertSpaceFillingCurve3D( envelope, 2 );
int[] mid = new int[]{5, 14, 17, 28, 35, 46, 49, 58};
SpaceFillingCurve.LongRange midRanges[] = new SpaceFillingCurve.LongRange[mid.length];
SpaceFillingCurve.LongRange[] midRanges = new SpaceFillingCurve.LongRange[mid.length];
for ( int i = 0; i < mid.length; i++ )
{
midRanges[i] = new SpaceFillingCurve.LongRange( mid[i], mid[i] );
Expand Down Expand Up @@ -558,7 +558,8 @@ public void shouldGet3DSearchTilesForManyLevels()
new SpaceFillingCurve.LongRange( curve.getValueWidth() - 1, curve.getValueWidth() - 1 ) );
//TODO: There is a performance issue building the full range when the search envelope hits a very wide part of the extent
// Suggestion to fix this with shallower traversals
//assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(new double[]{-8, -8, -8}, new double[]{8, 8, 8})), new HilbertSpaceFillingCurve.LongRange(0, curve.getValueWidth() - 1));
//assertTiles(curve.getTilesIntersectingEnvelope(new Envelope(new double[]{-8, -8, -8}, new double[]{8, 8, 8})),
// new HilbertSpaceFillingCurve.LongRange(0, curve.getValueWidth() - 1));
System.out.println( ", took " + (System.currentTimeMillis() - start) + "ms" );
}
}
Expand Down Expand Up @@ -625,7 +626,8 @@ private void shouldNeverStepMoreThanDistanceOne( SpaceFillingCurve curve, int le
{
badCount++;
}
// assertThat("Distance at level:" + level + " between " + strOf(derivedValue, point) + " and " + strOf(derivedValue - 1, previous) + " should be 1.0", distance, equalTo(1.0D));
// assertThat("Distance at level:" + level + " between " + strOf(derivedValue, point) + " and " + strOf(derivedValue - 1, previous)
// + " should be 1.0", distance, equalTo(1.0D));
}
previous = point;
}
Expand Down

0 comments on commit 5b026ea

Please sign in to comment.