Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
cc1029bc
Commit
cc1029bc
authored
5 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Sonarlint: closing files
parent
8f28b8f6
master
develop
0.2.2
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/eu/simstadt/geo/RegionChooserUtils.java
+11
-8
src/main/java/eu/simstadt/geo/RegionChooserUtils.java
with
11 additions
and
8 deletions
+11
-8
src/main/java/eu/simstadt/geo/RegionChooserUtils.java
+
11
-
8
View file @
cc1029bc
...
...
@@ -21,6 +21,7 @@
private
static
final
CRSFactory
CRS_FACTORY
=
new
CRSFactory
();
public
static
final
CoordinateReferenceSystem
WGS84
=
CRS_FACTORY
.
createFromName
(
"EPSG:4326"
);
private
static
final
Pattern
srsNamePattern
=
Pattern
.
compile
(
"(?i)(?<=srsName=[\"'])[^\"']+(?=[\"'])"
);
private
static
final
int
CITYGML_HEADER_LENGTH
=
50
;
private
RegionChooserUtils
()
{
// only static use
...
...
@@ -41,7 +42,7 @@ private RegionChooserUtils() {
* @param srsName
* @return CoordinateReferenceSystem
*/
p
ublic
static
CoordinateReferenceSystem
crsFromSrsName
(
String
srsName
)
{
p
rivate
static
CoordinateReferenceSystem
crsFromSrsName
(
String
srsName
)
{
// EPSG:31467
Pattern
pEPSG
=
Pattern
.
compile
(
"^(EPSG:\\d+)$"
);
Matcher
mEPSG
=
pEPSG
.
matcher
(
srsName
);
...
...
@@ -116,13 +117,15 @@ public static Polygon changePolygonCRS(Polygon polygonInOriginalCRS, CoordinateR
* @throws IOException
*/
public
static
CoordinateReferenceSystem
crsFromCityGMLHeader
(
Path
citygmlPath
)
throws
IOException
{
Optional
<
String
>
line
=
Files
.
lines
(
citygmlPath
).
limit
(
50
).
filter
(
srsNamePattern
.
asPredicate
()).
findFirst
();
if
(
line
.
isPresent
())
{
Matcher
matcher
=
srsNamePattern
.
matcher
(
line
.
get
());
matcher
.
find
();
return
crsFromSrsName
(
matcher
.
group
());
}
else
{
throw
new
IllegalArgumentException
(
"No srsName found in the header of "
+
citygmlPath
);
try
(
Stream
<
String
>
lines
=
Files
.
lines
(
citygmlPath
).
limit
(
CITYGML_HEADER_LENGTH
))
{
Optional
<
String
>
line
=
lines
.
filter
(
srsNamePattern
.
asPredicate
()).
findFirst
();
if
(
line
.
isPresent
())
{
Matcher
matcher
=
srsNamePattern
.
matcher
(
line
.
get
());
matcher
.
find
();
return
crsFromSrsName
(
matcher
.
group
());
}
else
{
throw
new
IllegalArgumentException
(
"No srsName found in the header of "
+
citygmlPath
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets