Commit cbcd6987 authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza
Browse files

Dependency updates

parent 114b475d
Pipeline #16176 passed with stage
in 1 minute and 36 seconds
...@@ -49,12 +49,12 @@ ...@@ -49,12 +49,12 @@
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>1.7.21</version> <version>1.7.30</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.3.2</version> <version>3.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.geotools</groupId> <groupId>org.geotools</groupId>
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>19.0</version> <version>30.1-jre</version>
</dependency> </dependency>
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.13.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version> <version>1.7.30</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
...@@ -57,14 +57,14 @@ ...@@ -57,14 +57,14 @@
<dependency> <dependency>
<groupId>com.opencsv</groupId> <groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId> <artifactId>opencsv</artifactId>
<version>3.6</version> <version>5.3</version>
</dependency> </dependency>
<!-- Test dependencies --> <!-- Test dependencies -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.13.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -16,10 +16,15 @@ ...@@ -16,10 +16,15 @@
package org.genesys.geotools.cli; package org.genesys.geotools.cli;
import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import com.opencsv.CSVParser;
import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader; import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import com.opencsv.exceptions.CsvValidationException;
/** /**
* Generate a KML/KMZ file from CSV data. * Generate a KML/KMZ file from CSV data.
...@@ -40,43 +45,48 @@ public class CSV2KML { ...@@ -40,43 +45,48 @@ public class CSV2KML {
final int columnLongitude = 3; final int columnLongitude = 3;
final int columnOrigCty = 5; 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("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
System.out.println("<kml xmlns=\"http://www.opengis.net/kml/2.2\">"); System.out.println("<kml xmlns=\"http://www.opengis.net/kml/2.2\">");
System.out.println("<Document>"); System.out.println("<Document>");
String[] nextLine; String[] nextLine;
while ((nextLine = reader.readNext()) != null) { try {
try { while ((nextLine = reader.readNext()) != null) {
final String acceNumb = nextLine[columnAcceNumb].trim(); try {
final String remarks = nextLine[nextLine.length - 1].trim(); final String acceNumb = nextLine[columnAcceNumb].trim();
final String origCty = nextLine[columnOrigCty].trim(); final String remarks = nextLine[nextLine.length - 1].trim();
final float latitude = Float.parseFloat(nextLine[columnLatitude].trim()); final String origCty = nextLine[columnOrigCty].trim();
final float longitude = Float.parseFloat(nextLine[columnLongitude].trim()); final float latitude = Float.parseFloat(nextLine[columnLatitude].trim());
final float longitude = Float.parseFloat(nextLine[columnLongitude].trim());
System.out.println("<Placemark>"); System.out.println("<Placemark>");
System.out.print("<name>"); System.out.print("<name>");
System.out.print(nextLine[columnInstCode].trim()); System.out.print(nextLine[columnInstCode].trim());
System.out.print(": "); System.out.print(": ");
System.out.print(acceNumb); System.out.print(acceNumb);
if (origCty != null) if (origCty != null)
System.out.print(" " + origCty); System.out.print(" " + origCty);
System.out.println("</name>"); System.out.println("</name>");
System.out.print("<description>"); System.out.print("<description>");
System.out.print("https://www.genesys-pgr.org/acn/id/" + nextLine[columnGenesysId].trim()); System.out.print("https://www.genesys-pgr.org/acn/id/" + nextLine[columnGenesysId].trim());
if (remarks != null) if (remarks != null)
System.out.print("\n" + remarks); System.out.print("\n" + remarks);
System.out.println("</description>"); System.out.println("</description>");
System.out.println("<Point><coordinates>"); System.out.println("<Point><coordinates>");
System.out.print(longitude); System.out.print(longitude);
System.out.print(","); System.out.print(",");
System.out.print(latitude); System.out.print(latitude);
System.out.println("</coordinates></Point>"); System.out.println("</coordinates></Point>");
System.out.println("</Placemark>"); System.out.println("</Placemark>");
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
System.err.println(e.getMessage()); System.err.println(e.getMessage());
}
} }
} catch (CsvValidationException e) {
throw new IOException(e.getMessage(), e);
} }
System.out.println("</Document>"); System.out.println("</Document>");
System.out.println("</kml>"); System.out.println("</kml>");
......
...@@ -34,6 +34,10 @@ import java.util.concurrent.TimeUnit; ...@@ -34,6 +34,10 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch; import org.apache.commons.lang3.time.StopWatch;
...@@ -99,8 +103,8 @@ public class CountryCLI implements GeoTool { ...@@ -99,8 +103,8 @@ public class CountryCLI implements GeoTool {
public void execute(final InputStream input, final OutputStream output, final char separatorChar, final char quoteChar, public void execute(final InputStream input, final OutputStream output, final char separatorChar, final char quoteChar,
final char escapeChar) throws IOException { final char escapeChar) throws IOException {
try (CSVReader reader = new CSVReader(new BufferedReader(new InputStreamReader(input), 10000), separatorChar, quoteChar, escapeChar, 0, final CSVParser parser = new CSVParserBuilder().withSeparator(separatorChar).withQuoteChar(quoteChar).withEscapeChar(escapeChar).withIgnoreQuotations(false).build();
false)) { try (CSVReader reader = new CSVReaderBuilder(new BufferedReader(new InputStreamReader(input), 10000)).withCSVParser(parser).withSkipLines(0).build()) {
// Scan for headers // Scan for headers
final String[] headers = reader.readNext(); final String[] headers = reader.readNext();
...@@ -249,6 +253,8 @@ public class CountryCLI implements GeoTool { ...@@ -249,6 +253,8 @@ public class CountryCLI implements GeoTool {
countryOfOriginService.printCache(); countryOfOriginService.printCache();
} }
} catch (CsvValidationException e) {
throw new IOException(e.getMessage(), e);
} }
} }
} }
...@@ -29,6 +29,10 @@ import java.util.Map; ...@@ -29,6 +29,10 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.genesys.geotools.service.HeaderUtils; import org.genesys.geotools.service.HeaderUtils;
...@@ -111,8 +115,8 @@ public class LandOrSeaCLI implements GeoTool { ...@@ -111,8 +115,8 @@ public class LandOrSeaCLI implements GeoTool {
public void execute(final InputStream input, final OutputStream output, final char separatorChar, final char quoteChar, public void execute(final InputStream input, final OutputStream output, final char separatorChar, final char quoteChar,
final char escapeChar) throws IOException { final char escapeChar) throws IOException {
try (CSVReader reader = new CSVReader(new BufferedReader(new InputStreamReader(input), 10000), separatorChar, quoteChar, escapeChar, 0, final CSVParser parser = new CSVParserBuilder().withSeparator(separatorChar).withQuoteChar(quoteChar).withEscapeChar(escapeChar).withIgnoreQuotations(false).build();
false)) { try (CSVReader reader = new CSVReaderBuilder(new BufferedReader(new InputStreamReader(input), 10000)).withCSVParser(parser).withSkipLines(0).build()) {
// Scan for headers // Scan for headers
final String[] headers = reader.readNext(); final String[] headers = reader.readNext();
...@@ -181,6 +185,8 @@ public class LandOrSeaCLI implements GeoTool { ...@@ -181,6 +185,8 @@ public class LandOrSeaCLI implements GeoTool {
writer.writeNext(outputLine); writer.writeNext(outputLine);
} }
} }
} catch (CsvValidationException e) {
throw new IOException(e.getMessage(), e);
} }
} }
} }
Markdown is supported
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