Skip to content

Commit ff9aa36

Browse files
authored
Some code smell reduction (#202)
* Missing override * Removed unused parameters * Unused assignment * Boolean literals redundant * Unused import * Catches combined * Return redundant * Missing override * Removed unused parameters * Unused assignment * Boolean literals redundant * Unused import * Catches combined * Return redundant
1 parent 642169f commit ff9aa36

File tree

8 files changed

+9
-20
lines changed

8 files changed

+9
-20
lines changed

src/main/java/org/locationtech/spatial4j/distance/DistanceUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public static double[] vectorBoxCorner(double[] center, double[] result, double
143143
if (result == null || result.length != center.length) {
144144
result = new double[center.length];
145145
}
146-
if (upperRight == false) {
146+
if (!upperRight) {
147147
distance = -distance;
148148
}
149149
//We don't care about the power here,
@@ -269,7 +269,7 @@ public static Rectangle calcBoxByDistFromPtDEG(double lat, double lon, double di
269269
minY = -90;
270270
} else {
271271
//--calc longitude bounds
272-
double lon_delta_deg = calcBoxByDistFromPt_deltaLonDEG(lat, lon, distDEG);
272+
double lon_delta_deg = calcBoxByDistFromPt_deltaLonDEG(lat, distDEG);
273273

274274
minX = normLonDEG(lon - lon_delta_deg);
275275
maxX = normLonDEG(lon + lon_delta_deg);
@@ -287,7 +287,7 @@ public static Rectangle calcBoxByDistFromPtDEG(double lat, double lon, double di
287287
* The delta longitude of a point-distance. In other words, half the width of
288288
* the bounding box of a circle.
289289
*/
290-
public static double calcBoxByDistFromPt_deltaLonDEG(double lat, double lon, double distDEG) {
290+
public static double calcBoxByDistFromPt_deltaLonDEG(double lat, double distDEG) {
291291
//http://gis.stackexchange.com/questions/19221/find-tangent-point-on-circle-furthest-east-or-west
292292
if (distDEG == 0)
293293
return 0;

src/main/java/org/locationtech/spatial4j/io/GeoJSONReader.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public Shape readIfSupported(Object value) throws InvalidShapeException {
6262
}
6363
try {
6464
return read(new StringReader(v));
65-
} catch (IOException ex) {
66-
} catch (ParseException e) {
65+
} catch (IOException | ParseException ex) {
6766
}
6867
return null;
6968
}
@@ -114,7 +113,6 @@ protected void readCoordXYZ(JSONParser parser, ShapeFactory.PointsBuilder points
114113
}
115114
evt = parser.nextEvent();
116115
}
117-
return;
118116
}
119117

120118
protected void readCoordListXYZ(JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder) throws IOException, ParseException {

src/main/java/org/locationtech/spatial4j/io/GeohashUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static String encodeLatLon(double latitude, double longitude, int precisi
8181
int ch = 0;
8282

8383
while (geohash.length() < precision) {
84-
double mid = 0.0;
84+
double mid;
8585
if (isEven) {
8686
mid = (lngInterval[0] + lngInterval[1]) / 2D;
8787
if (longitude > mid) {

src/main/java/org/locationtech/spatial4j/io/PolyshapeReader.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.locationtech.spatial4j.exception.InvalidShapeException;
3131
import org.locationtech.spatial4j.shape.Shape;
3232
import org.locationtech.spatial4j.shape.ShapeFactory;
33-
import org.locationtech.jts.geom.LinearRing;
3433

3534

3635
/**
@@ -62,8 +61,7 @@ public Shape readIfSupported(Object value) throws InvalidShapeException {
6261
if(first >= '0' && first <= '9') {
6362
try {
6463
return read(new StringReader(v));
65-
} catch (ParseException e) {
66-
} catch (IOException e) {
64+
} catch (ParseException | IOException e) {
6765
}
6866
}
6967
return null;

src/main/java/org/locationtech/spatial4j/io/jts/JtsGeoJSONWriter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,24 +101,20 @@ public void write(Writer output, Geometry geom) throws IOException {
101101
output.append("{\"type\":\"Point\",\"coordinates\":");
102102
write(output, nf, v.getCoordinate());
103103
output.append("}");
104-
return;
105104
} else if (geom instanceof Polygon) {
106105
output.append("{\"type\":\"Polygon\",\"coordinates\":");
107106
write(output, nf, (Polygon) geom);
108107
output.append("}");
109-
return;
110108
} else if (geom instanceof LineString) {
111109
LineString v = (LineString) geom;
112110
output.append("{\"type\":\"LineString\",\"coordinates\":");
113111
write(output, nf, v.getCoordinateSequence());
114112
output.append("}");
115-
return;
116113
} else if (geom instanceof MultiPoint) {
117114
MultiPoint v = (MultiPoint) geom;
118115
output.append("{\"type\":\"MultiPoint\",\"coordinates\":");
119116
write(output, nf, v.getCoordinates());
120117
output.append("}");
121-
return;
122118
} else if (geom instanceof MultiLineString) {
123119
MultiLineString v = (MultiLineString) geom;
124120
output.append("{\"type\":\"MultiLineString\",\"coordinates\":[");

src/main/java/org/locationtech/spatial4j/io/jts/JtsPolyshapeWriter.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public JtsPolyshapeWriter(JtsSpatialContext ctx, SpatialContextFactory factory)
4747
// --------------------------------------------------------------
4848

4949
protected void write(Encoder output, CoordinateSequence coordseq) throws IOException {
50-
int dim = coordseq.getDimension();
50+
// int dim = coordseq.getDimension();
5151
// if(dim>2) {
5252
// throw new IllegalArgumentException("only supports 2d geometry now ("+dim+")");
5353
// }
@@ -77,20 +77,16 @@ public void write(Encoder output, Geometry geom) throws IOException {
7777
Point v = (Point) geom;
7878
output.write(PolyshapeWriter.KEY_POINT);
7979
write(output, v.getCoordinateSequence());
80-
return;
8180
} else if (geom instanceof Polygon) {
8281
write(output, (Polygon) geom);
83-
return;
8482
} else if (geom instanceof LineString) {
8583
LineString v = (LineString) geom;
8684
output.write(PolyshapeWriter.KEY_LINE);
8785
write(output, v.getCoordinateSequence());
88-
return;
8986
} else if (geom instanceof MultiPoint) {
9087
MultiPoint v = (MultiPoint) geom;
9188
output.write(PolyshapeWriter.KEY_MULTIPOINT);
9289
write(output, v.getCoordinates());
93-
return;
9490
} else if (geom instanceof GeometryCollection) {
9591
GeometryCollection v = (GeometryCollection) geom;
9692
for (int i = 0; i < v.getNumGeometries(); i++) {

src/main/java/org/locationtech/spatial4j/shape/impl/Range.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public boolean crossesDateline() {
128128
return min > max;
129129
}
130130

131+
@Override
131132
public double getCenter() {
132133
double ctr = super.getCenter();
133134
if (ctr > 180)

src/main/java/org/locationtech/spatial4j/shape/impl/RectangleImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public Rectangle getBuffered(double distance, SpatialContext ctx) {
7474
double latDistance = distance;
7575
double closestToPoleY = Math.abs(maxY) > Math.abs(minY) ? maxY : minY;
7676
double lonDistance = DistanceUtils.calcBoxByDistFromPt_deltaLonDEG(
77-
closestToPoleY, minX, distance);//lat,lon order
77+
closestToPoleY, distance);//lat,lon order
7878
//could still wrap the world though...
7979
if (lonDistance * 2 + getWidth() >= 360)
8080
return ctx.makeRectangle(-180, 180, minY - latDistance, maxY + latDistance);

0 commit comments

Comments
 (0)