Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Geo Tools
Commits
cbcd6987
Commit
cbcd6987
authored
Jan 08, 2021
by
Maxym Borodenko
Committed by
Matija Obreza
Jan 11, 2021
Browse files
Dependency updates
parent
114b475d
Changes
5
Hide whitespace changes
Inline
Side-by-side
genesys-geotools/pom.xml
View file @
cbcd6987
...
...
@@ -49,12 +49,12 @@
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
1.7.
21
</version>
<version>
1.7.
30
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.
3.2
</version>
<version>
3.
11
</version>
</dependency>
<dependency>
<groupId>
org.geotools
</groupId>
...
...
@@ -74,7 +74,7 @@
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
19.0
</version>
<version>
30.1-jre
</version>
</dependency>
...
...
@@ -82,7 +82,7 @@
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.1
2
</version>
<version>
4.1
3.1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
...
...
geotools-cli/pom.xml
View file @
cbcd6987
...
...
@@ -47,7 +47,7 @@
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
<version>
1.7.
21
</version>
<version>
1.7.
30
</version>
</dependency>
<dependency>
<groupId>
org.genesys-pgr
</groupId>
...
...
@@ -57,14 +57,14 @@
<dependency>
<groupId>
com.opencsv
</groupId>
<artifactId>
opencsv
</artifactId>
<version>
3.6
</version>
<version>
5.3
</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.1
2
</version>
<version>
4.1
3.1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
...
...
geotools-cli/src/main/java/org/genesys/geotools/cli/CSV2KML.java
View file @
cbcd6987
...
...
@@ -16,10 +16,15 @@
package
org.genesys.geotools.cli
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
com.opencsv.CSVParser
;
import
com.opencsv.CSVParserBuilder
;
import
com.opencsv.CSVReader
;
import
com.opencsv.CSVReaderBuilder
;
import
com.opencsv.exceptions.CsvValidationException
;
/**
* Generate a KML/KMZ file from CSV data.
...
...
@@ -40,43 +45,48 @@ public class CSV2KML {
final
int
columnLongitude
=
3
;
final
int
columnOrigCty
=
5
;
final
CSVReader
reader
=
new
CSVReader
(
new
InputStreamReader
(
System
.
in
),
','
,
'"'
,
'\\'
,
0
,
false
);
final
CSVParser
parser
=
new
CSVParserBuilder
().
withSeparator
(
','
).
withQuoteChar
(
'"'
).
withEscapeChar
(
'\\'
).
withIgnoreQuotations
(
false
).
build
();
final
CSVReader
reader
=
new
CSVReaderBuilder
(
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
))).
withCSVParser
(
parser
).
withSkipLines
(
0
).
build
();
System
.
out
.
println
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
);
System
.
out
.
println
(
"<kml xmlns=\"http://www.opengis.net/kml/2.2\">"
);
System
.
out
.
println
(
"<Document>"
);
String
[]
nextLine
;
while
((
nextLine
=
reader
.
readNext
())
!=
null
)
{
try
{
final
String
acceNumb
=
nextLine
[
columnAcceNumb
].
trim
();
final
String
remarks
=
nextLine
[
nextLine
.
length
-
1
].
trim
();
final
String
origCty
=
nextLine
[
columnOrigCty
].
trim
();
final
float
latitude
=
Float
.
parseFloat
(
nextLine
[
columnLatitude
].
trim
());
final
float
longitude
=
Float
.
parseFloat
(
nextLine
[
columnLongitude
].
trim
());
try
{
while
((
nextLine
=
reader
.
readNext
())
!=
null
)
{
try
{
final
String
acceNumb
=
nextLine
[
columnAcceNumb
].
trim
();
final
String
remarks
=
nextLine
[
nextLine
.
length
-
1
].
trim
();
final
String
origCty
=
nextLine
[
columnOrigCty
].
trim
();
final
float
latitude
=
Float
.
parseFloat
(
nextLine
[
columnLatitude
].
trim
());
final
float
longitude
=
Float
.
parseFloat
(
nextLine
[
columnLongitude
].
trim
());
System
.
out
.
println
(
"<Placemark>"
);
System
.
out
.
print
(
"<name>"
);
System
.
out
.
print
(
nextLine
[
columnInstCode
].
trim
());
System
.
out
.
print
(
": "
);
System
.
out
.
print
(
acceNumb
);
if
(
origCty
!=
null
)
System
.
out
.
print
(
" "
+
origCty
);
System
.
out
.
println
(
"</name>"
);
System
.
out
.
print
(
"<description>"
);
System
.
out
.
print
(
"https://www.genesys-pgr.org/acn/id/"
+
nextLine
[
columnGenesysId
].
trim
());
if
(
remarks
!=
null
)
System
.
out
.
print
(
"\n"
+
remarks
);
System
.
out
.
println
(
"</description>"
);
System
.
out
.
println
(
"<Point><coordinates>"
);
System
.
out
.
print
(
longitude
);
System
.
out
.
print
(
","
);
System
.
out
.
print
(
latitude
);
System
.
out
.
println
(
"</coordinates></Point>"
);
System
.
out
.
println
(
"</Placemark>"
);
}
catch
(
final
NumberFormatException
e
)
{
System
.
err
.
println
(
e
.
getMessage
());
System
.
out
.
println
(
"<Placemark>"
);
System
.
out
.
print
(
"<name>"
);
System
.
out
.
print
(
nextLine
[
columnInstCode
].
trim
());
System
.
out
.
print
(
": "
);
System
.
out
.
print
(
acceNumb
);
if
(
origCty
!=
null
)
System
.
out
.
print
(
" "
+
origCty
);
System
.
out
.
println
(
"</name>"
);
System
.
out
.
print
(
"<description>"
);
System
.
out
.
print
(
"https://www.genesys-pgr.org/acn/id/"
+
nextLine
[
columnGenesysId
].
trim
());
if
(
remarks
!=
null
)
System
.
out
.
print
(
"\n"
+
remarks
);
System
.
out
.
println
(
"</description>"
);
System
.
out
.
println
(
"<Point><coordinates>"
);
System
.
out
.
print
(
longitude
);
System
.
out
.
print
(
","
);
System
.
out
.
print
(
latitude
);
System
.
out
.
println
(
"</coordinates></Point>"
);
System
.
out
.
println
(
"</Placemark>"
);
}
catch
(
final
NumberFormatException
e
)
{
System
.
err
.
println
(
e
.
getMessage
());
}
}
}
catch
(
CsvValidationException
e
)
{
throw
new
IOException
(
e
.
getMessage
(),
e
);
}
System
.
out
.
println
(
"</Document>"
);
System
.
out
.
println
(
"</kml>"
);
...
...
geotools-cli/src/main/java/org/genesys/geotools/cli/CountryCLI.java
View file @
cbcd6987
...
...
@@ -34,6 +34,10 @@ import java.util.concurrent.TimeUnit;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
com.opencsv.CSVParser
;
import
com.opencsv.CSVParserBuilder
;
import
com.opencsv.CSVReaderBuilder
;
import
com.opencsv.exceptions.CsvValidationException
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.StopWatch
;
...
...
@@ -99,8 +103,8 @@ public class CountryCLI implements GeoTool {
public
void
execute
(
final
InputStream
input
,
final
OutputStream
output
,
final
char
separatorChar
,
final
char
quoteChar
,
final
char
escapeChar
)
throws
IOException
{
try
(
CSVReader
reader
=
new
CSVReader
(
new
BufferedReader
(
new
InputStreamReader
(
input
),
10000
),
separatorChar
,
quoteChar
,
escapeChar
,
0
,
false
))
{
final
CSVParser
parser
=
new
CSVParserBuilder
().
withSeparator
(
separatorChar
).
withQuoteChar
(
quoteChar
).
withEscapeChar
(
escapeChar
).
withIgnoreQuotations
(
false
).
build
();
try
(
CSVReader
reader
=
new
CSVReaderBuilder
(
new
BufferedReader
(
new
InputStreamReader
(
input
),
10000
)).
withCSVParser
(
parser
).
withSkipLines
(
0
).
build
(
))
{
// Scan for headers
final
String
[]
headers
=
reader
.
readNext
();
...
...
@@ -249,6 +253,8 @@ public class CountryCLI implements GeoTool {
countryOfOriginService
.
printCache
();
}
}
catch
(
CsvValidationException
e
)
{
throw
new
IOException
(
e
.
getMessage
(),
e
);
}
}
}
geotools-cli/src/main/java/org/genesys/geotools/cli/LandOrSeaCLI.java
View file @
cbcd6987
...
...
@@ -29,6 +29,10 @@ import java.util.Map;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
com.opencsv.CSVParser
;
import
com.opencsv.CSVParserBuilder
;
import
com.opencsv.CSVReaderBuilder
;
import
com.opencsv.exceptions.CsvValidationException
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.genesys.geotools.service.HeaderUtils
;
...
...
@@ -111,8 +115,8 @@ public class LandOrSeaCLI implements GeoTool {
public
void
execute
(
final
InputStream
input
,
final
OutputStream
output
,
final
char
separatorChar
,
final
char
quoteChar
,
final
char
escapeChar
)
throws
IOException
{
try
(
CSVReader
reader
=
new
CSVReader
(
new
BufferedReader
(
new
InputStreamReader
(
input
),
10000
),
separatorChar
,
quoteChar
,
escapeChar
,
0
,
false
))
{
final
CSVParser
parser
=
new
CSVParserBuilder
().
withSeparator
(
separatorChar
).
withQuoteChar
(
quoteChar
).
withEscapeChar
(
escapeChar
).
withIgnoreQuotations
(
false
).
build
();
try
(
CSVReader
reader
=
new
CSVReaderBuilder
(
new
BufferedReader
(
new
InputStreamReader
(
input
),
10000
)).
withCSVParser
(
parser
).
withSkipLines
(
0
).
build
(
))
{
// Scan for headers
final
String
[]
headers
=
reader
.
readNext
();
...
...
@@ -181,6 +185,8 @@ public class LandOrSeaCLI implements GeoTool {
writer
.
writeNext
(
outputLine
);
}
}
}
catch
(
CsvValidationException
e
)
{
throw
new
IOException
(
e
.
getMessage
(),
e
);
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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