Refine search
public List<AttributeTypeInfo> loadAttributes(FeatureTypeInfo info) throws IOException { List<AttributeTypeInfo> attributes = new ArrayList(); FeatureType ft = getFeatureType(info); for (PropertyDescriptor pd : ft.getDescriptors()) { AttributeTypeInfo att = catalog.getFactory().createAttribute(); att.setFeatureType(info); att.setName(pd.getName().getLocalPart()); att.setMinOccurs(pd.getMinOccurs()); att.setMaxOccurs(pd.getMaxOccurs()); att.setNillable(pd.isNillable()); att.setBinding(pd.getType().getBinding()); int length = FeatureTypes.getFieldLength(pd); if (length > 0) { att.setLength(length); } attributes.add(att); } return attributes; }
public static boolean isDecendedFrom(FeatureType featureType, FeatureType isParentType) { try { return isDecendedFrom( featureType, new URI(isParentType.getName().getNamespaceURI()), isParentType.getName().getLocalPart()); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
private Query reprojectFilter(Query query) throws IOException { SimpleFeatureType nativeFeatureType = source.getSchema(); final GeometryDescriptor geom = nativeFeatureType.getGeometryDescriptor(); if (srsHandling == ProjectionPolicy.FORCE_DECLARED) { defaultCRS = declaredCRS; nativeFeatureType = FeatureTypes.transform(nativeFeatureType, declaredCRS); } else if (srsHandling == ProjectionPolicy.REPROJECT_TO_DECLARED) { defaultCRS = declaredCRS;
/** Exact equality based on typeNames, namespace, attributes and ancestors */ static boolean equals( SimpleFeatureType typeA, SimpleFeatureType typeB, boolean compareUserMaps) { if (typeA == typeB) return true; if (typeA == null || typeB == null) { return false; } if (!typeA.equals(typeB)) { return false; } if (compareUserMaps) { if (!equals(typeA.getUserData(), typeB.getUserData())) return false; } return equalsId(typeA, typeB) && equals( typeA.getAttributeDescriptors(), typeB.getAttributeDescriptors(), compareUserMaps) && equalsAncestors(typeA, typeB); }
for (int i = 0, ii = featureType.getAttributeCount(); i < ii; i++) { AttributeDescriptor type = featureType.getDescriptor(i); int fieldLen = FeatureTypes.getFieldLength(type); if (fieldLen == FeatureTypes.ANY_LENGTH) fieldLen = 255; if ((colType == Integer.class) || (colType == Short.class) || (colType == Byte.class)) {
public static boolean isFeatureTypeStyleActive(SimpleFeatureType ftype, FeatureTypeStyle fts) { return ((ftype.getTypeName() != null) && (ftype.getTypeName().equalsIgnoreCase(fts.getFeatureTypeName()) || FeatureTypes.isDecendedFrom(ftype, null, fts.getFeatureTypeName()))); }
Level.FINE, "Empty results for " + resultSchema.getName().getLocalPart() + ", skipping read"); goodRecs.close(); ShapefileReader shapeReader = shpManager.openShapeReader(geometryFactory, goodRecs != null); DbaseFileReader dbfReader = null; List<AttributeDescriptor> attributes = readSchema.getAttributeDescriptors(); if (attributes.size() < 1 || (attributes.size() == 1 && readSchema.getGeometryDescriptor() != null)) { LOGGER.fine("The DBF file won't be opened since no attributes will be read from it"); } else { if (!FeatureTypes.equals(readSchema, resultSchema)) { return new ReTypeFeatureReader(reader, resultSchema); } else {
} else { CoordinateReferenceSystem resultCRS = null; GeometryDescriptor gd = fs.getSchema().getGeometryDescriptor(); CoordinateReferenceSystem nativeCRS = gd != null ? gd.getCoordinateReferenceSystem() : null; if (!CRS.equalsIgnoreMetadata(resultCRS, schema.getCoordinateReferenceSystem())) schema = FeatureTypes.transform(schema, resultCRS); } catch (Exception e) { throw new DataSourceException("Problem forcing CRS onto feature type", e);
private SimpleFeatureCollection forceNonNullNamespace(SimpleFeatureCollection features) throws IOException { SimpleFeatureType sourceSchema = features.getSchema(); if (sourceSchema.getName().getNamespaceURI() == null) { try { String targetNs = "http://www.geoserver.org/rest/granules"; AttributeDescriptor[] attributes = sourceSchema .getAttributeDescriptors() .toArray( new AttributeDescriptor [sourceSchema.getAttributeDescriptors().size()]); SimpleFeatureType targetSchema = FeatureTypes.newFeatureType( attributes, sourceSchema.getName().getLocalPart(), new URI(targetNs)); return new RetypingFeatureCollection(features, targetSchema); } catch (Exception e) { throw new IOException( "Failed to retype the granules feature schema, in order to force " + "it having a non null namespace", e); } } else { return features; } }
@Test public void testNoLength() { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName("NoLength"); builder.setCRS(null); builder.add("name", String.class); builder.add("geom", Point.class); SimpleFeatureType ft = builder.buildFeatureType(); assertEquals( FeatureTypes.ANY_LENGTH, FeatureTypes.getFieldLength(ft.getDescriptor("name"))); assertEquals( FeatureTypes.ANY_LENGTH, FeatureTypes.getFieldLength(ft.getDescriptor("geom"))); }
public ReprojectingFeatureCollection( SimpleFeatureCollection delegate, CoordinateReferenceSystem target) throws SchemaException, OperationNotFoundException, FactoryRegistryException, FactoryException { super(delegate); this.target = target; this.schema = FeatureTypes.transform(delegate.getSchema(), target); // create transform cache transformers = new HashMap(); // cache "default" transform CoordinateReferenceSystem source = delegate.getSchema().getCoordinateReferenceSystem(); if (source != null) { MathTransform tx = ReferencingFactoryFinder.getCoordinateOperationFactory(hints) .createOperation(source, target) .getMathTransform(); GeometryCoordinateSequenceTransformer transformer = new GeometryCoordinateSequenceTransformer(); transformer.setMathTransform(tx); transformers.put(source, transformer); } else { throw new RuntimeException( "Source was null in trying to create a reprojected feature collection!"); } }
@Override public void visit(Style style) { super.visit(style); Style copy = (Style) pages.peek(); List<FeatureTypeStyle> filtered = new ArrayList<FeatureTypeStyle>(); for (FeatureTypeStyle fts : copy.featureTypeStyles()) { // do the same filtering as streaming renderer String ftName = fts.getFeatureTypeName(); if (fts.featureTypeNames().isEmpty() || ((schema.getName().getLocalPart() != null) && (schema.getName() .getLocalPart().equalsIgnoreCase(ftName) || FeatureTypes .isDecendedFrom(schema, null, ftName)))) { filtered.add(fts); } } copy.featureTypeStyles().clear(); copy.featureTypeStyles().addAll(filtered); }
/** * Forces the specified CRS on all geometry attributes * * @param schema the original schema * @param crs the forced crs * @return * @throws SchemaException */ public static SimpleFeatureType transform( SimpleFeatureType schema, CoordinateReferenceSystem crs) throws SchemaException { return transform(schema, crs, false); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling <code> * newFeatureType(types,name,ns,false,null)</code>. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, ns, false); }
SimpleFeatureType abstractType2 = tb.buildFeatureType(); assertTrue(abstractType.isAbstract()); assertTrue(abstractType2.isAbstract()); FeatureTypes.isDecendedFrom(abstractType2, abstractType)); assertFalse( "abstractType2 !--|> abstractType", FeatureTypes.isDecendedFrom(abstractType, abstractType2));
/** * Exact equality based on typeNames, namespace, attributes and ancestors, including the user * maps contents */ public static boolean equalsExact(SimpleFeatureType typeA, SimpleFeatureType typeB) { return equals(typeA, typeB, true); }
/** Exact equality based on typeNames, namespace, attributes and ancestors */ public static boolean equals( FeatureType typeA, FeatureType typeB ) { if (typeA == typeB) return true; if (typeA == null || typeB == null) { return false; } return equalsId(typeA, typeB) && equals(typeA.getAttributeTypes(), typeB.getAttributeTypes()) && equalsAncestors( typeA, typeB ); }
/** * This method depends on the correct implementation of FeatureType equals * * <p>We may need to write an implementation that can detect cycles, * * @param typeA * @param typeB */ public static boolean equalsAncestors(SimpleFeatureType typeA, SimpleFeatureType typeB) { return ancestors(typeA).equals(ancestors(typeB)); }
DbaseFileHeader2 header = new DbaseFileHeader2(); final int attributeCount = featureType.getAttributeCount(); writeFlags = new byte[attributeCount]; int dbfFieldCount = 0; for (int index = 0; index < attributeCount; index++) { AttributeDescriptor descriptor = featureType.getDescriptor(index); Class<?> binding = descriptor.getType().getBinding(); String columnName = descriptor.getLocalName(); handler = shapeType.getShapeHandler(new GeometryFactory()); } else { int fieldLen = FeatureTypes.getFieldLength(descriptor); if (fieldLen == FeatureTypes.ANY_LENGTH) { fieldLen = 255;