public void testRetypeGeometryless() { builder.setName("testGeometryless"); builder.add("geo1", Point.class, DefaultGeographicCRS.WGS84); builder.add("integer", Integer.class); builder.setDefaultGeometry("geo1"); SimpleFeatureType type = builder.buildFeatureType(); // performing an attribute selection, even changing order, should not change // the default geometry, that had a special meaning in the original source SimpleFeatureType retyped = SimpleFeatureTypeBuilder.retype(type, new String[] {"integer"}); assertNotNull(retyped); assertNull(retyped.getGeometryDescriptor()); assertEquals(1, retyped.getAttributeCount()); assertEquals("integer", retyped.getAttributeDescriptors().get(0).getLocalName()); }
public void testCRS() { builder.setName("testName"); builder.setNamespaceURI("testNamespaceURI"); builder.setCRS(DefaultGeographicCRS.WGS84); builder.crs(null).add("point", Point.class); builder.add("point2", Point.class, DefaultGeographicCRS.WGS84); builder.setDefaultGeometry("point"); SimpleFeatureType type = builder.buildFeatureType(); assertEquals(DefaultGeographicCRS.WGS84, type.getCoordinateReferenceSystem()); assertNull(type.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); assertEquals( DefaultGeographicCRS.WGS84, ((GeometryType) type.getType("point2")).getCoordinateReferenceSystem()); }
public void testAttributeDefaultValue() { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName("buggy"); builder.nillable(false).defaultValue(12).add("attrWithDefault", Integer.class); builder.nillable(true).defaultValue(null).add("attrWithoutDefault", Integer.class); SimpleFeatureType featureType = builder.buildFeatureType(); assertFalse(featureType.getDescriptor("attrWithDefault").isNillable()); assertEquals(12, featureType.getDescriptor("attrWithDefault").getDefaultValue()); assertTrue(featureType.getDescriptor("attrWithoutDefault").isNillable()); assertNull(featureType.getDescriptor("attrWithoutDefault").getDefaultValue()); }