private Map<String, Object> buildDummyFeatureTypeInfo(ComplexAttribute f) { Map<String, Object> dummy = new HashMap<String, Object>(); dummy.put("name", f.getType().getName().getLocalPart()); dummy.put("namespace", getNamespace(f.getType().getName())); dummy.put("prefix", getPrefix(f.getType().getName())); dummy.put("title", "Layer: " + f.getType().getName().getLocalPart()); dummy.put("abstract", "[No Abstract Provided]"); dummy.put("description", "[No Description Provided]"); dummy.put("keywords", new ArrayList<String>()); dummy.put("metadataLinks", new ArrayList<String>()); dummy.put("SRS", "[SRS]"); if (f instanceof Feature) { final GeometryDescriptor gd = ((Feature) f).getType().getGeometryDescriptor(); if (gd != null) { dummy.put("nativeCRS", gd.getCoordinateReferenceSystem()); } } return dummy; }
public Set entrySet() { if (entrySet == null) { entrySet = new LinkedHashSet<MapEntry>(); final Collection<PropertyDescriptor> types = feature.getType().getDescriptors(); Name attName; Map attributesMap; for (Iterator<PropertyDescriptor> iterator = types.iterator(); iterator.hasNext(); ) { attName = iterator.next().getName(); attributesMap = new AttributeMap(attName, feature); entrySet.add( new MapEntry<Object, Object>(attName.getLocalPart(), attributesMap)); } } return entrySet; } }
@Override public void accepts(FeatureVisitor visitor, ProgressListener progress) { SimpleFeatureIterator it = features(); try { while (it.hasNext()) { visitor.visit(it.next()); } } finally { it.close(); } }
if (entrySet == null) { entrySet = new LinkedHashSet<MapEntry>(); final ComplexType featureType = feature.getType(); PropertyDescriptor attributeDescr = featureType.getDescriptor(attributeName); Property property = feature.getProperty(attributeName); List<AttributeDescriptor> substitutionGroup = (List<AttributeDescriptor>) attributeDescr.getUserData().get("substitutionGroup"); if (substitutionGroup != null) { Iterator<AttributeDescriptor> it = substitutionGroup.iterator(); while (property == null && it.hasNext()) { property = feature.getProperty(it.next().getName()); attributeDescr = property.getDescriptor(); value = buildComplex((ComplexAttribute) property); } else if (property != null) { value = property.getValue(); entrySet.add(new MapEntry<Object, Object>("name", attributeName.getLocalPart())); entrySet.add( new MapEntry<Object, Object>("namespace", getNamespace(attributeName))); entrySet.add(new MapEntry<Object, Object>("prefix", getPrefix(attributeName))); if (attributeDescr.getType() instanceof ComplexType) { entrySet.add( new MapEntry<Object, Object>( "type", buildType((ComplexType) attributeDescr.getType())));
for (Property p : protoFt.getProperties()) { propertyFields.add(p.getName().toString()); while (it.hasNext()) { SimpleFeature feature = it.next(); Geometry geom = (Geometry) feature.getDefaultGeometry(); ft.setId(Integer.toString(i)); } else { ft.setId(feature.getProperty(originIDField).getValue().toString()); for(Property prop : feature.getProperties() ){ String propName = prop.getName().toString(); if (propertyFields.contains(propName)) { Object binding = prop.getType().getBinding(); val = (Integer)prop.getValue(); } else if(binding.equals(Long.class)){ val = ((Long)prop.getValue()).intValue(); } else if(binding.equals(String.class)){ try{ val = Integer.parseInt((String)prop.getValue()); } catch (NumberFormatException ex ){ continue; LOG.debug("Property {} of feature {} could not be interpreted as int, skipping", prop.getName().toString(), ft.getId()); continue;
info = cat.getResourceByName( att.getType().getName().getNamespaceURI(), att.getType().getName().getLocalPart(), FeatureTypeInfo.class); if (att.getIdentifier() != null) { map.put("fid", att.getIdentifier().getID()); } else { map.put("fid", ""); map.put("typeName", att.getType().getName().getLocalPart());
@Test public void testWithRename() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName("MyPoints"); assertEquals("EPSG:4326", fti.getSRS()); assertEquals(ProjectionPolicy.REPROJECT_TO_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4326"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that geometry was reprojected Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertFalse(g.equalsExact(WKT.read("POINT(500050 500050)"))); fi.close(); assertEquals(CRS.decode("EPSG:4326"), f.getType().getCoordinateReferenceSystem()); }
@Test public void testDefaultGeometry() throws IOException { FeatureTypeInfo featureType = getCatalog().getResourceByName("cdf", "Nulls", FeatureTypeInfo.class); GeometryDescriptor schemaDefaultGeometry = featureType.getFeatureType().getGeometryDescriptor(); FeatureIterator i = featureType.getFeatureSource(null, null).getFeatures().features(); GeometryDescriptor featureDefaultGeometry = i.next().getDefaultGeometryProperty().getDescriptor(); assertNotNull(schemaDefaultGeometry); assertNotNull(featureDefaultGeometry); assertEquals("pointProperty", schemaDefaultGeometry.getLocalName()); assertEquals(schemaDefaultGeometry, featureDefaultGeometry); } }
public void setValue(Collection<Property> value) { int i = 0; for (Property p : value) { this.values[i] = p.getValue(); } }
@Test public void testForce() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.BASIC_POLYGONS.getLocalPart()); assertEquals("EPSG:4269", fti.getSRS()); assertEquals(ProjectionPolicy.FORCE_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4269"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); fi.close(); assertEquals(CRS.decode("EPSG:4269"), f.getType().getCoordinateReferenceSystem()); }
b.add(new WKTReader().read("POINT(1 1)")); SimpleFeature f = b.buildFeature(null); f.getUserData().put("foo", "bar"); assertEquals("bar", it.next().getUserData().get("foo")); } finally { it.close(); assertEquals("bar", it.next().getUserData().get("foo")); } finally { it.close();
public Object get(Object object, String xpath, Class target) throws IllegalArgumentException { if (object instanceof Attribute) return ((Attribute) object).getValue(); else return object; }
public void set(Object object, String xpath, Object value, Class target) { throw new org.opengis.feature.IllegalAttributeException( null, value, "feature id is immutable"); } }
public void set(Object object, String xpath, Object value, Class target) throws IllegalArgumentException { ((Property) object).setValue(value); } }
public Object evaluate(Object obj) { if (obj instanceof Attribute) { Attribute att = (Attribute) obj; return att.getIdentifier(); } return null; } }
public void validate() { delegate.validate(); } }
@Test public void testLeaveNative() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.LINES.getLocalPart()); assertEquals("EPSG:3004", fti.getSRS()); assertEquals(ProjectionPolicy.NONE, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:32615"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that the geometry was left in tact Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertTrue(g.equalsExact(WKT.read("LINESTRING(500125 500025,500175 500075)"))); fi.close(); assertEquals(CRS.decode("EPSG:32615"), f.getType().getCoordinateReferenceSystem()); }
public void setValue(Collection<Property> values) { int i = 0; for (Property p : values) { this.values[i++] = p.getValue(); } }
@Test public void testReproject() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.POLYGONS.getLocalPart()); assertEquals("EPSG:4326", fti.getSRS()); assertEquals(ProjectionPolicy.REPROJECT_TO_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4326"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that geometry was actually reprojected Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertFalse( g.equalsExact( WKT.read( "POLYGON((500225 500025,500225 500075,500275 500050,500275 500025,500225 500025))"))); fi.close(); assertEquals(CRS.decode("EPSG:4326"), f.getType().getCoordinateReferenceSystem()); }
public Attribute set(int index, Property element) { values[index] = element.getValue(); return null; }