Skip to content

Commit

Permalink
Minor code cleanups (intellij inspections).
Browse files Browse the repository at this point in the history
  • Loading branch information
sabi0 authored Dec 30, 2023
1 parent 346f4ff commit 67d866c
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static Object parse(String wkt) throws IOException, ParseException {
public static Object parseExpectedType(String wkt, final ShapeType shapeType)
throws IOException, ParseException {
try (StringReader reader = new StringReader(wkt)) {
// setup the tokenizer; configured to read words w/o numbers
// set up the tokenizer; configured to read words w/o numbers
StreamTokenizer tokenizer = new StreamTokenizer(reader);
tokenizer.resetSyntax();
tokenizer.wordChars('a', 'z');
Expand Down Expand Up @@ -110,7 +110,7 @@ private static double[] parsePoint(StreamTokenizer stream) throws IOException, P
return null;
}
double[] pt = new double[] {nextNumber(stream), nextNumber(stream)};
if (isNumberNext(stream) == true) {
if (isNumberNext(stream)) {
nextNumber(stream);
}
nextCloser(stream);
Expand Down Expand Up @@ -195,7 +195,7 @@ private static Line[] parseMultiLine(StreamTokenizer stream) throws IOException,
while (nextCloserOrComma(stream).equals(COMMA)) {
lines.add(parseLine(stream));
}
return lines.toArray(new Line[lines.size()]);
return lines.toArray(new Line[0]);
}

/** parses the hole of a polygon */
Expand Down Expand Up @@ -226,7 +226,7 @@ private static Polygon parsePolygon(StreamTokenizer stream) throws IOException,
return new Polygon(
lats.stream().mapToDouble(i -> i).toArray(),
lons.stream().mapToDouble(i -> i).toArray(),
holes.toArray(new Polygon[holes.size()]));
holes.toArray(new Polygon[0]));
}
return new Polygon(
lats.stream().mapToDouble(i -> i).toArray(), lons.stream().mapToDouble(i -> i).toArray());
Expand All @@ -244,7 +244,7 @@ private static Polygon[] parseMultiPolygon(StreamTokenizer stream)
while (nextCloserOrComma(stream).equals(COMMA)) {
polygons.add(parsePolygon(stream));
}
return polygons.toArray(new Polygon[polygons.size()]);
return polygons.toArray(new Polygon[0]);
}

/** parses an ENVELOPE */
Expand Down Expand Up @@ -274,7 +274,7 @@ private static Object[] parseGeometryCollection(StreamTokenizer stream)
while (nextCloserOrComma(stream).equals(COMMA)) {
geometries.add(parseGeometry(stream, null));
}
return geometries.toArray(new Object[geometries.size()]);
return geometries.toArray(new Object[0]);
}

/** next word in the stream */
Expand Down Expand Up @@ -355,7 +355,7 @@ private static String nextCloser(StreamTokenizer stream) throws IOException, Par

/** expects a comma as next token */
private static String nextComma(StreamTokenizer stream) throws IOException, ParseException {
if (nextWord(stream).equals(COMMA) == true) {
if (nextWord(stream).equals(COMMA)) {
return COMMA;
}
throw new ParseException(
Expand Down Expand Up @@ -404,7 +404,7 @@ public enum ShapeType {
ENVELOPE("envelope"); // not part of the actual WKB spec

private final String shapeName;
private static Map<String, ShapeType> shapeTypeMap = new HashMap<>();
private static final Map<String, ShapeType> shapeTypeMap = new HashMap<>();
private static final String BBOX = "BBOX";

static {
Expand All @@ -429,10 +429,9 @@ public String wktName() {

public static ShapeType forName(String shapename) {
String typename = shapename.toLowerCase(Locale.ROOT);
for (ShapeType type : values()) {
if (type.shapeName.equals(typename)) {
return type;
}
ShapeType type = shapeTypeMap.get(typename);
if (type != null) {
return type;
}
throw new IllegalArgumentException("unknown geo_shape [" + shapename + "]");
}
Expand Down

0 comments on commit 67d866c

Please sign in to comment.