From 68ca821450e297fed03f2b33936259d6e1857e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louise=20S=C3=B6derstr=C3=B6m?= Date: Mon, 18 Dec 2017 15:00:40 +0100 Subject: [PATCH] Improve check-style to align with neo4j codebase --- .../index/curves/HilbertSpaceFillingCurve2D.java | 4 ++-- .../index/curves/HilbertSpaceFillingCurve3D.java | 2 +- .../spatial/index/curves/SpaceFillingCurve.java | 14 +++++++++++--- .../index/curves/SpaceFillingCurveTest.java | 8 +++++--- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/neo4j/gis/spatial/index/curves/HilbertSpaceFillingCurve2D.java b/src/main/java/org/neo4j/gis/spatial/index/curves/HilbertSpaceFillingCurve2D.java index be1458a18..44049728b 100644 --- a/src/main/java/org/neo4j/gis/spatial/index/curves/HilbertSpaceFillingCurve2D.java +++ b/src/main/java/org/neo4j/gis/spatial/index/curves/HilbertSpaceFillingCurve2D.java @@ -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 ) { @@ -78,7 +78,7 @@ public CurveRule childAt( int npoint ) private static HashMap curves = new LinkedHashMap<>(); - private static void addCurveRule(int... npointValues ) + private static void addCurveRule( int... npointValues ) { HilbertCurve2D curve = new HilbertCurve2D( npointValues ); String name = curve.name(); diff --git a/src/main/java/org/neo4j/gis/spatial/index/curves/HilbertSpaceFillingCurve3D.java b/src/main/java/org/neo4j/gis/spatial/index/curves/HilbertSpaceFillingCurve3D.java index bd7f3f36d..716828655 100644 --- a/src/main/java/org/neo4j/gis/spatial/index/curves/HilbertSpaceFillingCurve3D.java +++ b/src/main/java/org/neo4j/gis/spatial/index/curves/HilbertSpaceFillingCurve3D.java @@ -60,7 +60,7 @@ static int rotateYZ( int value ) */ static class HilbertCurve3D extends CurveRule { - CurveRule[] children = null; + CurveRule[] children; private HilbertCurve3D( int... npointValues ) { diff --git a/src/main/java/org/neo4j/gis/spatial/index/curves/SpaceFillingCurve.java b/src/main/java/org/neo4j/gis/spatial/index/curves/SpaceFillingCurve.java index 8f626b6c6..ad1ea0d7a 100644 --- a/src/main/java/org/neo4j/gis/spatial/index/curves/SpaceFillingCurve.java +++ b/src/main/java/org/neo4j/gis/spatial/index/curves/SpaceFillingCurve.java @@ -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; @@ -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 ); @@ -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 + ")"; @@ -403,8 +411,8 @@ public String toString() */ private class SearchEnvelope { - long min[]; - long max[]; + long[] min; + long[] max; int nbrDim; private SearchEnvelope( Envelope referenceEnvelope ) diff --git a/src/test/java/org/neo4j/gis/spatial/index/curves/SpaceFillingCurveTest.java b/src/test/java/org/neo4j/gis/spatial/index/curves/SpaceFillingCurveTest.java index cfdbae64d..e1ef141c2 100644 --- a/src/test/java/org/neo4j/gis/spatial/index/curves/SpaceFillingCurveTest.java +++ b/src/test/java/org/neo4j/gis/spatial/index/curves/SpaceFillingCurveTest.java @@ -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] ); @@ -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" ); } } @@ -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; }