ZMHandlersTest.java (geotools-24.0-project) | : | ZMHandlersTest.java (geotools-24.1-project) | ||
---|---|---|---|---|
skipping to change at line 75 | skipping to change at line 75 | |||
ShapefileDataStore store = new ShapefileDataStore(url); | ShapefileDataStore store = new ShapefileDataStore(url); | |||
SimpleFeature feature = DataUtilities.first(store.getFeatureSource().get Features()); | SimpleFeature feature = DataUtilities.first(store.getFeatureSource().get Features()); | |||
Geometry geom = (Geometry) feature.getDefaultGeometry(); | Geometry geom = (Geometry) feature.getDefaultGeometry(); | |||
assertEquals("wrong x", 10, geom.getCoordinate().getX(), 0.00001); | assertEquals("wrong x", 10, geom.getCoordinate().getX(), 0.00001); | |||
assertEquals("wrong y", 5, geom.getCoordinate().getY(), 0.00001); | assertEquals("wrong y", 5, geom.getCoordinate().getY(), 0.00001); | |||
assertEquals("wrong m", 20, geom.getCoordinate().getM(), 0.00001); | assertEquals("wrong m", 20, geom.getCoordinate().getM(), 0.00001); | |||
} | } | |||
@Test | @Test | |||
public void testReadZPoints() throws ShapefileException, IOException { | public void testReadZPoints() throws IOException { | |||
URL url = TestData.url(ShapefileDataStore.class, "mzvalues/zpoints.shp") | // tests that Point with Z and without optional M are correctly parsed | |||
; | URL url = TestData.url(ShapefileDataStore.class, "mzvalues/pointZ.shp"); | |||
ShapefileDataStore store = new ShapefileDataStore(url); | ShapefileDataStore store = new ShapefileDataStore(url); | |||
SimpleFeature feature = DataUtilities.first(store.getFeatureSource().get | Query q = new Query(store.getTypeNames()[0]); | |||
Features()); | q.getHints().put(Hints.FEATURE_2D, Boolean.TRUE); | |||
Geometry geom = (Geometry) feature.getDefaultGeometry(); | FeatureReader<SimpleFeatureType, SimpleFeature> reader = | |||
store.getFeatureReader(q, Transaction.AUTO_COMMIT); | ||||
assertEquals("wrong x", 10, geom.getCoordinate().getX(), 0.00001); | while (reader.hasNext()) { | |||
assertEquals("wrong y", 5, geom.getCoordinate().getY(), 0.00001); | SimpleFeature f = reader.next(); | |||
assertEquals("wrong z", 1, geom.getCoordinate().getZ(), 0.00001); | assertNotNull(f.getDefaultGeometry()); | |||
} | ||||
} | } | |||
@Test | @Test | |||
public void testReadMZMultiPoints() throws ShapefileException, IOException { | public void testReadMZMultiPoints() throws ShapefileException, IOException { | |||
URL url = TestData.url(ShapefileDataStore.class, "mzvalues/zmmultipoints .shp"); | URL url = TestData.url(ShapefileDataStore.class, "mzvalues/zmmultipoints .shp"); | |||
ShapefileDataStore store = new ShapefileDataStore(url); | ShapefileDataStore store = new ShapefileDataStore(url); | |||
SimpleFeature feature = DataUtilities.first(store.getFeatureSource().get Features()); | SimpleFeature feature = DataUtilities.first(store.getFeatureSource().get Features()); | |||
MultiPoint geom = (MultiPoint) feature.getDefaultGeometry(); | MultiPoint geom = (MultiPoint) feature.getDefaultGeometry(); | |||
Coordinate coordinate = geom.getCoordinates()[0]; | Coordinate coordinate = geom.getCoordinates()[0]; | |||
skipping to change at line 383 | skipping to change at line 386 | |||
// System.out.println(geom.getDimension()); | // System.out.println(geom.getDimension()); | |||
// System.out.println(geom.getCoordinate()); | // System.out.println(geom.getCoordinate()); | |||
Geometry geometry = LiteCoordinateSequence.cloneGeometry(geo m); | Geometry geometry = LiteCoordinateSequence.cloneGeometry(geo m); | |||
} | } | |||
} | } | |||
} catch (Exception e) { | } catch (Exception e) { | |||
e.printStackTrace(); | e.printStackTrace(); | |||
fail(); | fail(); | |||
} | } | |||
} | } | |||
@Test | ||||
public void testReadZPointsFalse2D() throws IOException { | ||||
// tests that Point with Z and without optional M and with Feature2D fal | ||||
se are correctly | ||||
// parsed | ||||
URL url = TestData.url(ShapefileDataStore.class, "mzvalues/pointZ.shp"); | ||||
ShapefileDataStore store = new ShapefileDataStore(url); | ||||
Query q = new Query(store.getTypeNames()[0]); | ||||
q.getHints().put(Hints.FEATURE_2D, Boolean.FALSE); | ||||
FeatureReader<SimpleFeatureType, SimpleFeature> reader = | ||||
store.getFeatureReader(q, Transaction.AUTO_COMMIT); | ||||
while (reader.hasNext()) { | ||||
SimpleFeature f = reader.next(); | ||||
assertNotNull(f.getDefaultGeometry()); | ||||
} | ||||
} | ||||
} | } | |||
End of changes. 3 change blocks. | ||||
10 lines changed or deleted | 28 lines changed or added |