Commit f9335971 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '6-java-11' into 'master'

Resolve "Java 11"

Closes #6

See merge request !4
parents 0ca9e7de cbcd6987
Pipeline #16191 passed with stage
in 3 minutes and 33 seconds
......@@ -3,7 +3,7 @@ stages:
run tests in branches:
stage: build
image: maven:3-jdk-8
image: maven:3-openjdk-11
script:
- MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" mvn test -B -U
except:
......@@ -12,7 +12,7 @@ run tests in branches:
publish maven snapshot artifacts:
stage: build
image: maven:3-jdk-8
image: maven:3-openjdk-11
before_script:
- echo "${GPG_KEY_SECRET}" | gpg --batch --import
- gpg --list-keys
......@@ -23,7 +23,7 @@ publish maven snapshot artifacts:
publish maven artifacts:
stage: build
image: maven:3-jdk-8
image: maven:3-openjdk-11
before_script:
- echo "${GPG_KEY_SECRET}" | gpg --batch --import
- gpg --list-keys
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>geo-tools</artifactId>
<version>1.1-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
</parent>
<artifactId>genesys-geotools</artifactId>
<name>Genesys Geo Tools library</name>
......@@ -38,10 +38,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.target>1.8</jdk.target>
<jdk.source>1.8</jdk.source>
<jdk.target>11</jdk.target>
<jdk.source>11</jdk.source>
<!-- use the latest snapshot -->
<geotools.version>23.1</geotools.version>
<geotools.version>24.1</geotools.version>
<jar.mainclass>org.genesys.geotools.cli.CLI</jar.mainclass>
</properties>
......@@ -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>
......
......@@ -40,7 +40,7 @@ public interface CountryOfOriginService {
* @param latitude the latitude
* @param origCty the country ISO code
* @return distance to closest point on country border or -1 if not found
* @throws Exception
* @throws Exception the exception
*/
double distanceToBorder(float longitude, float latitude, String origCty) throws Exception;
......
......@@ -37,9 +37,9 @@ public interface LandOrSeaService {
*
* @param longitude the longitude
* @param latitude the latitude
* @param allowedDistanceFromLand the allowed distance from land
* @param allowedDistanceMargin the allowed distance from land
* @return Land, Coastal or Water
* @throws Exception
* @throws Exception the exception
*/
String classifyLocation(float longitude, float latitude, int allowedDistanceMargin) throws Exception;
......
......@@ -51,7 +51,7 @@ public class ShapefileUtils {
/**
* Open shape file.
*
* @param shapeFilePath the shape file path
* @param shapeFile the shape file
* @return the data store
* @throws MalformedURLException the malformed url exception
* @throws IOException Signals that an I/O exception has occurred.
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>geo-tools</artifactId>
<version>1.1-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
</parent>
<artifactId>geotools-cli</artifactId>
<name>Genesys Geo Tools</name>
......@@ -38,10 +38,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.target>1.8</jdk.target>
<jdk.source>1.8</jdk.source>
<!-- use the latest snapshot -->
<geotools.version>15-SNAPSHOT</geotools.version>
<jdk.target>11</jdk.target>
<jdk.source>11</jdk.source>
<jar.mainclass>org.genesys.geotools.cli.CLI</jar.mainclass>
</properties>
......@@ -49,29 +47,24 @@
<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>
<artifactId>genesys-geotools</artifactId>
<version>1.1-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
</dependency>
<!-- <dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency> -->
<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);
}
}
}
......@@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.genesys-pgr</groupId>
<artifactId>geo-tools</artifactId>
<version>1.1-SNAPSHOT</version>
<version>3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Genesys GEO tools</name>
<url>https://gitlab.croptrust.org/genesys-pgr/geo-tools</url>
......@@ -63,8 +63,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.target>1.8</jdk.target>
<jdk.source>1.8</jdk.source>
<jdk.target>11</jdk.target>
<jdk.source>11</jdk.source>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
</properties>
......
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