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

Sonarlint: closing files

parent 8f28b8f6
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,7 +117,8 @@ public static Polygon changePolygonCRS(Polygon polygonInOriginalCRS, CoordinateR ...@@ -116,7 +117,8 @@ 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)) {
Optional<String> line = lines.filter(srsNamePattern.asPredicate()).findFirst();
if (line.isPresent()) { if (line.isPresent()) {
Matcher matcher = srsNamePattern.matcher(line.get()); Matcher matcher = srsNamePattern.matcher(line.get());
matcher.find(); matcher.find();
...@@ -125,6 +127,7 @@ public static CoordinateReferenceSystem crsFromCityGMLHeader(Path citygmlPath) t ...@@ -125,6 +127,7 @@ public static CoordinateReferenceSystem crsFromCityGMLHeader(Path citygmlPath) t
throw new IllegalArgumentException("No srsName found in the header of " + citygmlPath); throw new IllegalArgumentException("No srsName found in the header of " + citygmlPath);
} }
} }
}
/** /**
* Finds every CityGML in every .proj folder in a repository. * Finds every CityGML in every .proj folder in a repository.
......
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