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 @@
<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.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -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.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -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>");
......
......@@ -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);
}
}
}
......@@ -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);
}
}
}
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