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 update
- Loading branch information
1 parent
b84790c
commit 206fa0d
Showing
6 changed files
with
61 additions
and
7 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
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.
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,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)); | ||
} | ||
|
||
|
||
} |