"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/plugin/geopkg/src/test/java/org/geotools/geopkg/GeoPackageTest.java" between
geotools-24.0-project.zip and geotools-24.1-project.zip

About: GeoTools (The Open Source Java GIS Toolkit) is a Java code library which provides standards compliant methods for the manipulation of geospatial data.

GeoPackageTest.java  (geotools-24.0-project):GeoPackageTest.java  (geotools-24.1-project)
skipping to change at line 473 skipping to change at line 473
FeatureEntry entry = new FeatureEntry(); FeatureEntry entry = new FeatureEntry();
entry.setBounds(coll.getBounds()); entry.setBounds(coll.getBounds());
try { try {
geopkg.add(entry, coll); geopkg.add(entry, coll);
} catch (Exception e) { } catch (Exception e) {
fail(e.getMessage()); fail(e.getMessage());
} }
} }
@Test @Test
public void testDoubleFloatPrecision() throws Exception {
double pi = 3.1415926535897932;
SimpleFeatureType featureType =
createFeatureTypeWithAttribute("double-pi", "pie", Double.class)
;
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureTy
pe);
SimpleFeature simpleFeature = createSimpleFeatureWithValue(featureBuilde
r, pi);
SimpleFeatureCollection collection = DataUtilities.collection(simpleFeat
ure);
FeatureEntry entry = new FeatureEntry();
geopkg.add(entry, collection);
FeatureEntry readFeature = geopkg.features().get(0);
try (SimpleFeatureReader reader = geopkg.reader(readFeature, null, null)
) {
Object attribute = reader.next().getAttribute("pie");
assertTrue(attribute instanceof Double);
Double readValue = (Double) attribute;
assertEquals(pi, readValue, 1e-10);
}
}
@Test
public void testSingleFloatPrecision() throws Exception {
float pi = 3.14159265f;
SimpleFeatureType featureType =
createFeatureTypeWithAttribute("single-pi", "pie", Float.class);
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureTy
pe);
SimpleFeature simpleFeature = createSimpleFeatureWithValue(featureBuilde
r, pi);
SimpleFeatureCollection collection = DataUtilities.collection(simpleFeat
ure);
FeatureEntry entry = new FeatureEntry();
geopkg.add(entry, collection);
FeatureEntry readFeature = geopkg.features().get(0);
try (SimpleFeatureReader reader = geopkg.reader(readFeature, null, null)
) {
Object attribute = reader.next().getAttribute("pie");
assertTrue(attribute instanceof Double);
Double attributeValue = (Double) attribute;
assertEquals(pi, attributeValue, 1e-5);
}
}
private SimpleFeatureType createFeatureTypeWithAttribute(
String featureName, String attributeName, Class<?> attributeClazz) {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName(featureName);
builder.setCRS(DefaultGeographicCRS.WGS84);
builder.add("the_geom", LineString.class);
builder.add(attributeName, attributeClazz);
return builder.buildFeatureType();
}
private SimpleFeature createSimpleFeatureWithValue(
SimpleFeatureBuilder featureBuilder, Object value) {
featureBuilder.add(createGeometry());
featureBuilder.add(value);
return featureBuilder.buildFeature(null);
}
@Test
public void testFunctionsNoEnvelope() throws Exception { public void testFunctionsNoEnvelope() throws Exception {
ShapefileDataStore shp = new ShapefileDataStore(setUpShapefile()); ShapefileDataStore shp = new ShapefileDataStore(setUpShapefile());
SimpleFeatureReader re = Features.simple(shp.getFeatureReader()); SimpleFeatureReader re = Features.simple(shp.getFeatureReader());
FeatureEntry entry = new FeatureEntry(); FeatureEntry entry = new FeatureEntry();
geopkg.getWriterConfiguration().setWriteEnvelope(false); geopkg.getWriterConfiguration().setWriteEnvelope(false);
geopkg.add(entry, shp.getFeatureSource(), null); geopkg.add(entry, shp.getFeatureSource(), null);
Connection cx = geopkg.getDataSource().getConnection(); Connection cx = geopkg.getDataSource().getConnection();
 End of changes. 1 change blocks. 
0 lines changed or deleted 66 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)