Skip to content

Commit

Permalink
build: GeoTools update
Browse files Browse the repository at this point in the history
Update GeoTools from 21.0 to 29.1
Update gradle from 7.5.1 to 8.4

ING-4083

update
  • Loading branch information
emanuelaepure10 authored and stempler committed Dec 12, 2023
1 parent b84790c commit 206fa0d
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ jobs:
check:
uses: wetransform/gha-workflows/.github/workflows/gradle-library-check.yml@master
with:
java-version: 8
java-version: 17
17 changes: 11 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ dependencies {
implementation 'org.apache.commons:commons-lang3:3.12.0' // Apache 2.0

// GeoTools (LGPL 2.1)
implementation 'org.geotools:geotools:21.0'
implementation 'org.geotools:gt-epsg-hsql:21.0'
implementation 'org.geotools:gt-opengis:21.0'
implementation 'org.geotools:gt-geometry:21.0'
implementation 'org.geotools:gt-referencing:21.0'
implementation 'org.geotools:gt-main:29.1'
implementation 'org.geotools:gt-epsg-hsql:29.1'
implementation 'org.geotools:gt-opengis:29.1'
// implementation 'org.geotools:gt-geometry:24.2'
implementation 'org.geotools:gt-referencing:29.1'

implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'com.sun.xml.bind:jaxb-core:2.3.0.1'
implementation 'com.sun.xml.bind:jaxb-impl:2.3.1'

testImplementation 'junit:junit:4.13'

}

java {
Expand Down Expand Up @@ -70,6 +75,6 @@ publishing {
}

wrapper {
gradleVersion = '7.5.1'
gradleVersion = '8.4'
distributionType = Wrapper.DistributionType.ALL
}
Binary file added data/example.csv
Binary file not shown.
Binary file added data/example.dbf
Binary file not shown.
Binary file added data/example.shp
Binary file not shown.
49 changes: 49 additions & 0 deletions unittest/TestShpToTopojson.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.geotools.referencing.CRS;
import org.junit.Test;

import json.topojson.api.TopojsonApi;


public class TestShpToTopojson {

@Test
public void testShpFromHale() throws IOException {

// Specify the relative path as a string
String relativePathString = "./web/topojson_hale.json";

String crsSpec = "EPSG:4326";

// Decode the text using UTF-8 encoding (or the appropriate encoding)
byte[] crsBytes = crsSpec.getBytes(StandardCharsets.UTF_8);
String decodedCRS = new String(crsBytes, StandardCharsets.UTF_8);

try {
TopojsonApi.shpToTopojsonFile("./data/example.shp", CRS.decode(decodedCRS),
relativePathString,
"Topology",
0,
4,
false);
} catch (Exception e) {
// Handle parsing exceptions, e.g., log or rethrow
e.printStackTrace();
}

// Convert the relative path to an absolute path
Path absolutePath = Paths.get(relativePathString).toAbsolutePath();

// Use Files.exists() to check if the file was created
assertTrue(Files.exists(absolutePath));
}


}

0 comments on commit 206fa0d

Please sign in to comment.