Read shapefiles in UTF-8 mode (#137)

pull/139/head
Oliver Wipfli 2022-03-17 13:26:13 +01:00 zatwierdzone przez GitHub
rodzic 332e631507
commit 1cfcca2e20
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -125,7 +125,9 @@ public class ShapefileReader extends SimpleReader implements Closeable {
} else {
throw new IllegalArgumentException("Invalid shapefile input: " + path + " must be zip or shp");
}
return new ShapefileDataStore(uri.toURL());
var store = new ShapefileDataStore(uri.toURL());
store.setTryCPGFile(true);
return store;
} catch (IOException e) {
throw new IllegalArgumentException(e);
}

Wyświetl plik

@ -41,6 +41,7 @@ public class ShapefileReaderTest {
public void testReadShapefile() {
for (int i = 1; i <= 2; i++) {
List<Geometry> points = new ArrayList<>();
List<String> names = new ArrayList<>();
WorkerPipeline.start("test", Stats.inMemory())
.fromGenerator("shapefile", reader.read())
.addBuffer("reader_queue", 100, 1)
@ -49,8 +50,10 @@ public class ShapefileReaderTest {
assertEquals("test", elem.getSource());
assertNull(elem.getSourceLayer());
points.add(elem.latLonGeometry());
names.add(elem.getTag("name").toString());
}).await();
assertEquals(86, points.size());
assertTrue(names.contains("Van Dörn Street"));
var gc = GeoUtils.JTS_FACTORY.createGeometryCollection(points.toArray(new Geometry[0]));
var centroid = gc.getCentroid();
assertEquals(-77.0297995, centroid.getX(), 5, "iter " + i);

Plik binarny nie jest wyświetlany.