Skip to content

Commit

Permalink
Some code smell reduction (#202)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
matteobaccan committed Apr 27, 2021
1 parent 642169f commit ff9aa36
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static double[] vectorBoxCorner(double[] center, double[] result, double
if (result == null || result.length != center.length) {
result = new double[center.length];
}
if (upperRight == false) {
if (!upperRight) {
distance = -distance;
}
//We don't care about the power here,
Expand Down Expand Up @@ -269,7 +269,7 @@ public static Rectangle calcBoxByDistFromPtDEG(double lat, double lon, double di
minY = -90;
} else {
//--calc longitude bounds
double lon_delta_deg = calcBoxByDistFromPt_deltaLonDEG(lat, lon, distDEG);
double lon_delta_deg = calcBoxByDistFromPt_deltaLonDEG(lat, distDEG);

minX = normLonDEG(lon - lon_delta_deg);
maxX = normLonDEG(lon + lon_delta_deg);
Expand All @@ -287,7 +287,7 @@ public static Rectangle calcBoxByDistFromPtDEG(double lat, double lon, double di
* The delta longitude of a point-distance. In other words, half the width of
* the bounding box of a circle.
*/
public static double calcBoxByDistFromPt_deltaLonDEG(double lat, double lon, double distDEG) {
public static double calcBoxByDistFromPt_deltaLonDEG(double lat, double distDEG) {
//http://gis.stackexchange.com/questions/19221/find-tangent-point-on-circle-furthest-east-or-west
if (distDEG == 0)
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public Shape readIfSupported(Object value) throws InvalidShapeException {
}
try {
return read(new StringReader(v));
} catch (IOException ex) {
} catch (ParseException e) {
} catch (IOException | ParseException ex) {
}
return null;
}
Expand Down Expand Up @@ -114,7 +113,6 @@ protected void readCoordXYZ(JSONParser parser, ShapeFactory.PointsBuilder points
}
evt = parser.nextEvent();
}
return;
}

protected void readCoordListXYZ(JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder) throws IOException, ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static String encodeLatLon(double latitude, double longitude, int precisi
int ch = 0;

while (geohash.length() < precision) {
double mid = 0.0;
double mid;
if (isEven) {
mid = (lngInterval[0] + lngInterval[1]) / 2D;
if (longitude > mid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.locationtech.spatial4j.exception.InvalidShapeException;
import org.locationtech.spatial4j.shape.Shape;
import org.locationtech.spatial4j.shape.ShapeFactory;
import org.locationtech.jts.geom.LinearRing;


/**
Expand Down Expand Up @@ -62,8 +61,7 @@ public Shape readIfSupported(Object value) throws InvalidShapeException {
if(first >= '0' && first <= '9') {
try {
return read(new StringReader(v));
} catch (ParseException e) {
} catch (IOException e) {
} catch (ParseException | IOException e) {
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,20 @@ public void write(Writer output, Geometry geom) throws IOException {
output.append("{\"type\":\"Point\",\"coordinates\":");
write(output, nf, v.getCoordinate());
output.append("}");
return;
} else if (geom instanceof Polygon) {
output.append("{\"type\":\"Polygon\",\"coordinates\":");
write(output, nf, (Polygon) geom);
output.append("}");
return;
} else if (geom instanceof LineString) {
LineString v = (LineString) geom;
output.append("{\"type\":\"LineString\",\"coordinates\":");
write(output, nf, v.getCoordinateSequence());
output.append("}");
return;
} else if (geom instanceof MultiPoint) {
MultiPoint v = (MultiPoint) geom;
output.append("{\"type\":\"MultiPoint\",\"coordinates\":");
write(output, nf, v.getCoordinates());
output.append("}");
return;
} else if (geom instanceof MultiLineString) {
MultiLineString v = (MultiLineString) geom;
output.append("{\"type\":\"MultiLineString\",\"coordinates\":[");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public JtsPolyshapeWriter(JtsSpatialContext ctx, SpatialContextFactory factory)
// --------------------------------------------------------------

protected void write(Encoder output, CoordinateSequence coordseq) throws IOException {
int dim = coordseq.getDimension();
// int dim = coordseq.getDimension();
// if(dim>2) {
// throw new IllegalArgumentException("only supports 2d geometry now ("+dim+")");
// }
Expand Down Expand Up @@ -77,20 +77,16 @@ public void write(Encoder output, Geometry geom) throws IOException {
Point v = (Point) geom;
output.write(PolyshapeWriter.KEY_POINT);
write(output, v.getCoordinateSequence());
return;
} else if (geom instanceof Polygon) {
write(output, (Polygon) geom);
return;
} else if (geom instanceof LineString) {
LineString v = (LineString) geom;
output.write(PolyshapeWriter.KEY_LINE);
write(output, v.getCoordinateSequence());
return;
} else if (geom instanceof MultiPoint) {
MultiPoint v = (MultiPoint) geom;
output.write(PolyshapeWriter.KEY_MULTIPOINT);
write(output, v.getCoordinates());
return;
} else if (geom instanceof GeometryCollection) {
GeometryCollection v = (GeometryCollection) geom;
for (int i = 0; i < v.getNumGeometries(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public boolean crossesDateline() {
return min > max;
}

@Override
public double getCenter() {
double ctr = super.getCenter();
if (ctr > 180)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Rectangle getBuffered(double distance, SpatialContext ctx) {
double latDistance = distance;
double closestToPoleY = Math.abs(maxY) > Math.abs(minY) ? maxY : minY;
double lonDistance = DistanceUtils.calcBoxByDistFromPt_deltaLonDEG(
closestToPoleY, minX, distance);//lat,lon order
closestToPoleY, distance);//lat,lon order
//could still wrap the world though...
if (lonDistance * 2 + getWidth() >= 360)
return ctx.makeRectangle(-180, 180, minY - latDistance, maxY + latDistance);
Expand Down

0 comments on commit ff9aa36

Please sign in to comment.