Commit cc1029bc authored by Eric Duminil's avatar Eric Duminil
Browse files

Sonarlint: closing files

parent 8f28b8f6
No related merge requests found
Showing with 11 additions and 8 deletions
+11 -8
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
private static final CRSFactory CRS_FACTORY = new CRSFactory(); private static final CRSFactory CRS_FACTORY = new CRSFactory();
public static final CoordinateReferenceSystem WGS84 = CRS_FACTORY.createFromName("EPSG:4326"); public static final CoordinateReferenceSystem WGS84 = CRS_FACTORY.createFromName("EPSG:4326");
private static final Pattern srsNamePattern = Pattern.compile("(?i)(?<=srsName=[\"'])[^\"']+(?=[\"'])"); private static final Pattern srsNamePattern = Pattern.compile("(?i)(?<=srsName=[\"'])[^\"']+(?=[\"'])");
private static final int CITYGML_HEADER_LENGTH = 50;
private RegionChooserUtils() { private RegionChooserUtils() {
// only static use // only static use
...@@ -41,7 +42,7 @@ private RegionChooserUtils() { ...@@ -41,7 +42,7 @@ private RegionChooserUtils() {
* @param srsName * @param srsName
* @return CoordinateReferenceSystem * @return CoordinateReferenceSystem
*/ */
public static CoordinateReferenceSystem crsFromSrsName(String srsName) { private static CoordinateReferenceSystem crsFromSrsName(String srsName) {
// EPSG:31467 // EPSG:31467
Pattern pEPSG = Pattern.compile("^(EPSG:\\d+)$"); Pattern pEPSG = Pattern.compile("^(EPSG:\\d+)$");
Matcher mEPSG = pEPSG.matcher(srsName); Matcher mEPSG = pEPSG.matcher(srsName);
...@@ -116,13 +117,15 @@ public static Polygon changePolygonCRS(Polygon polygonInOriginalCRS, CoordinateR ...@@ -116,13 +117,15 @@ public static Polygon changePolygonCRS(Polygon polygonInOriginalCRS, CoordinateR
* @throws IOException * @throws IOException
*/ */
public static CoordinateReferenceSystem crsFromCityGMLHeader(Path citygmlPath) throws IOException { public static CoordinateReferenceSystem crsFromCityGMLHeader(Path citygmlPath) throws IOException {
Optional<String> line = Files.lines(citygmlPath).limit(50).filter(srsNamePattern.asPredicate()).findFirst(); try (Stream<String> lines = Files.lines(citygmlPath).limit(CITYGML_HEADER_LENGTH)) {
if (line.isPresent()) { Optional<String> line = lines.filter(srsNamePattern.asPredicate()).findFirst();
Matcher matcher = srsNamePattern.matcher(line.get()); if (line.isPresent()) {
matcher.find(); Matcher matcher = srsNamePattern.matcher(line.get());
return crsFromSrsName(matcher.group()); matcher.find();
} else { return crsFromSrsName(matcher.group());
throw new IllegalArgumentException("No srsName found in the header of " + citygmlPath); } else {
throw new IllegalArgumentException("No srsName found in the header of " + citygmlPath);
}
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment