forked from bouviervj/topojson-j
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GeoTools from 21.0 to 29.1 Update gradle from 7.5.1 to 8.4 ING-4083
- Loading branch information
1 parent
b84790c
commit 1d17351
Showing
4 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
|
||
|
||
} |