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
  • Loading branch information
emanuelaepure10 committed Dec 7, 2023
1 parent b84790c commit 1d17351
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 deletions.
19 changes: 13 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ 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:geotools: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'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

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

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

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

import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.geotools.referencing.CRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import json.topojson.api.TopojsonApi;


public class TestShpToTopojson {

@Test
public void testFileCreation() throws IOException {

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

// Specify the WKT representation of the coordinate reference system
String wkt = "PROJCS[\"WGS 84 / UTM zone 33N\", GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", ...]]]";

try {
// Parse the WKT and obtain a CoordinateReferenceSystem
CoordinateReferenceSystem crs = CRS.parseWKT(wkt);

TopojsonApi.shpToTopojsonFile("./data/example.shp", crs,
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 exists
boolean fileExists = Files.exists(absolutePath);
if (fileExists) {
System.out.println("File '" + absolutePath + "' exists.");
} else {
System.out.println("File '" + absolutePath + "' does not exist.");
// You might choose to throw an exception, log an error, or take other actions.
}

assertTrue(!fileExists, "File should exist after creation");
// Use Files.exists() to check if the file was created
// assertTrue(Files.exists(absolutePath), "File should exist after creation");
}


}

0 comments on commit 1d17351

Please sign in to comment.