static GeometryDescriptor findGeometryDescriptor(SimpleFeatureType schema) { GeometryDescriptor gd = schema.getGeometryDescriptor(); if (gd == null) { for (PropertyDescriptor pd : schema.getDescriptors()) { if (pd instanceof GeometryDescriptor) { return (GeometryDescriptor) pd; } } } return gd; }
public Collection<Property> getProperties() { List<Property> result = new ArrayList<Property>(); for (PropertyDescriptor descr : featureTyp.getDescriptors()) { result.add(createProperty(descr.getName().getLocalPart())); } return result; }
/** * Returns a list of properties of a simple feature type, including all properties from a given * list, and all mandatory (minoccurs > 0) added. * * @param type feature type * @param propNames given list of properties * @return list of properties including all mandatory properties * @throws IOException */ public static List<PropertyName> addMandatoryProperties( SimpleFeatureType type, List<PropertyName> oldProps) { Iterator<PropertyDescriptor> ii = type.getDescriptors().iterator(); List<PropertyName> properties = new ArrayList<PropertyName>(); while (ii.hasNext()) { PropertyDescriptor descr = ii.next(); PropertyName propName = ff.property(descr.getName()); if (oldProps != null && oldProps.contains(propName)) { properties.add(propName); } else if (((descr.getMinOccurs() > 0) && (descr.getMaxOccurs() != 0))) { // mandatory, add it properties.add(propName); } } return properties; }
for (PropertyDescriptor ad : featureType.getDescriptors()) { if (ad instanceof GeometryDescriptor) { GeometryDescriptor gd = (GeometryDescriptor) ad;
Collection<PropertyDescriptor> types = featureType.getDescriptors(); StringBuffer buf = new StringBuffer();
/** * Test that properties returned by getAttributeDescriptors() and getDescriptors() are the same * and in the same order. */ public void testConsistentIterationOrder() { SimpleFeatureType type = buildLocationCountType(); assertEquals( "FeatureType and SimpleFeatureType APIs must return the same descriptors in the same order", new ArrayList<PropertyDescriptor>(type.getAttributeDescriptors()), new ArrayList<PropertyDescriptor>(type.getDescriptors())); }
public boolean hasNext() { while (next == null && firstDelegate.hasNext()) { SimpleFeature f = firstDelegate.next(); for (PropertyDescriptor property : fb.getFeatureType().getDescriptors()) { fb.set(property.getName(), f.getAttribute(property.getName())); } next = fb.buildFeature(Integer.toString(iterationIndex)); fb.reset(); iterationIndex++; } while (next == null && secondDelegate.hasNext() && !firstDelegate.hasNext()) { SimpleFeature f = secondDelegate.next(); for (PropertyDescriptor property : fb.getFeatureType().getDescriptors()) { fb.set(property.getName(), f.getAttribute(property.getName())); } next = fb.buildFeature(Integer.toString(iterationIndex)); fb.reset(); iterationIndex++; } return next != null; }
for (PropertyDescriptor descr : featureType.getDescriptors()) { if (descr instanceof GeometryDescriptor) { GeometryDescriptor gd1 = (GeometryDescriptor) descr;
static GeometryDescriptor findGeometryDescriptor(SimpleFeatureType schema) { GeometryDescriptor gd = schema.getGeometryDescriptor(); if (gd == null) { for (PropertyDescriptor pd : schema.getDescriptors()) { if (pd instanceof GeometryDescriptor) { return (GeometryDescriptor) pd; } } } return gd; }
/** * Finds all the non-geographic attributes in the source. */ private List<PropertyDescriptor> getNonGeometryAttributes() { attributes = Lists.newArrayList(); for (PropertyDescriptor descriptor : featureSource.getSchema().getDescriptors()) { if (!(descriptor.getType() instanceof GeometryType)) { attributes.add(descriptor); } } return attributes; }
public Collection<Property> getProperties() { List<Property> result = new ArrayList<Property>(); for (PropertyDescriptor descr : featureTyp.getDescriptors()) { result.add(createProperty(descr.getName().getLocalPart())); } return result; }
/** * Returns a list of properties of a simple feature type, including all properties from a given * list, and all mandatory (minoccurs > 0) added. * * @param type * feature type * @param propNames * given list of properties * @return list of properties including all mandatory properties * @throws IOException */ public static List<PropertyName> addMandatoryProperties(SimpleFeatureType type, List<PropertyName> oldProps) { Iterator<PropertyDescriptor> ii = type.getDescriptors().iterator(); List<PropertyName> properties = new ArrayList<PropertyName>(); while (ii.hasNext()) { PropertyDescriptor descr = ii.next(); PropertyName propName = ff.property(descr.getName()); if (oldProps != null && oldProps.contains(propName)) { properties.add(propName); } else if (((descr.getMinOccurs() > 0) && (descr.getMaxOccurs() != 0))) { // mandatory, add it properties.add(propName); } } return properties; }
SimpleFeature f = it.next(); SimpleFeature g = w.next(); for (PropertyDescriptor pd : collection.getSchema().getDescriptors()) {
@Test public void testDescribeFeatureType() throws Exception { DescribeFeatureType describe = new DescribeFeatureType(); ImmutableSet<PropertyDescriptor> properties = describe.setFeatureType(featureType).call(); for (PropertyDescriptor prop : properties) { assertTrue(pointsType.getDescriptors().contains(prop)); } } }
@Test public void testDescribeFeatureType() throws Exception { DescribeFeatureType describe = new DescribeFeatureType(); ImmutableSet<PropertyDescriptor> properties = describe.setFeatureType(featureType).call(); for (PropertyDescriptor prop : properties) { assertTrue(pointsType.getDescriptors().contains(prop)); } } }
@Test public void testDescribeFeatureType() throws Exception { DescribeFeatureType describe = new DescribeFeatureType(); ImmutableSet<PropertyDescriptor> properties = describe.setFeatureType(featureType).call(); for (PropertyDescriptor prop : properties) { assertTrue(pointsType.getDescriptors().contains(prop)); } } }
public boolean hasNext() { while (next == null && firstDelegate.hasNext()) { SimpleFeature f = firstDelegate.next(); for (PropertyDescriptor property : fb.getFeatureType().getDescriptors()) { fb.set(property.getName(), f.getAttribute(property.getName())); } next = fb.buildFeature(Integer.toString(iterationIndex)); fb.reset(); iterationIndex++; } while (next == null && secondDelegate.hasNext() && !firstDelegate.hasNext()) { SimpleFeature f = secondDelegate.next(); for (PropertyDescriptor property : fb.getFeatureType().getDescriptors()) { fb.set(property.getName(), f.getAttribute(property.getName())); } next = fb.buildFeature(Integer.toString(iterationIndex)); fb.reset(); iterationIndex++; } return next != null; }
@Test public void testFeatureTypeSerialization() throws Exception { RevFeatureType revFeatureType = RevFeatureType.builder().type(featureType).build(); ByteArrayOutputStream output = new ByteArrayOutputStream(); serializer.write(revFeatureType, output); byte[] data = output.toByteArray(); assertTrue(data.length > 0); ByteArrayInputStream input = new ByteArrayInputStream(data); RevFeatureType rft = (RevFeatureType) serializer.read(revFeatureType.getId(), input); assertNotNull(rft); SimpleFeatureType serializedFeatureType = (SimpleFeatureType) rft.type(); assertEquals(serializedFeatureType.getDescriptors().size(), featureType.getDescriptors().size()); for (int i = 0; i < featureType.getDescriptors().size(); i++) { assertEquals(featureType.getDescriptor(i), serializedFeatureType.getDescriptor(i)); } assertEquals(featureType.getGeometryDescriptor(), serializedFeatureType.getGeometryDescriptor()); assertEquals(featureType.getCoordinateReferenceSystem(), serializedFeatureType.getCoordinateReferenceSystem()); }
@Test public void testConstructorAndAccessors() { RevFeatureType featureType = RevFeatureType.build(linesType); assertEquals(RevObject.TYPE.FEATURETYPE, featureType.getType()); assertEquals(linesType, featureType.type()); assertEquals(linesType.getName(), featureType.getName()); ArrayList<PropertyDescriptor> descriptors = Lists.newArrayList(linesType.getDescriptors()); // Collections.sort(descriptors, RevFeatureType.PROPERTY_ORDER); assertEquals(descriptors, featureType.sortedDescriptors()); }
@Test public void testConstructorAndAccessors() { RevFeatureType featureType = RevFeatureTypeBuilder.build(linesType); assertEquals(RevObject.TYPE.FEATURETYPE, featureType.getType()); assertEquals(linesType, featureType.type()); assertEquals(linesType.getName(), featureType.getName()); ArrayList<PropertyDescriptor> descriptors = Lists.newArrayList(linesType.getDescriptors()); // Collections.sort(descriptors, RevFeatureType.PROPERTY_ORDER); assertEquals(descriptors, featureType.descriptors()); }