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; }
fc.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem();
if (old.getCoordinateReferenceSystem() == null) {
crs = featureType.getGeometryDescriptor().getCoordinateReferenceSystem();
CoordinateReferenceSystem nativeCRS = geom.getCoordinateReferenceSystem(); if (srsHandling == ProjectionPolicy.FORCE_DECLARED) { defaultCRS = declaredCRS;
@Override public Object visit(PropertyName expression, Object extraData) { AttributeDescriptor ad = expression.evaluate(schema, AttributeDescriptor.class); if (ad == null) { throw new IllegalArgumentException( "Original feature type does not have a property named " + expression.getPropertyName()); } else if (ad instanceof GeometryDescriptor) { return ((GeometryDescriptor) ad).getCoordinateReferenceSystem(); } return null; }
private static SimpleFeatureType forceType( SimpleFeatureType startingType, CoordinateReferenceSystem forcedCS) throws SchemaException { if (forcedCS == null) { throw new NullPointerException("CoordinateSystem required"); } CoordinateReferenceSystem originalCs = startingType.getGeometryDescriptor().getCoordinateReferenceSystem(); if (forcedCS.equals(originalCs)) { return startingType; } else { return FeatureTypes.transform(startingType, forcedCS); } }
GeometryDescriptor gd = fs.getSchema().getGeometryDescriptor(); CoordinateReferenceSystem nativeCRS = gd != null ? gd.getCoordinateReferenceSystem() : null;
public ReprojectingFeatureCollection( SimpleFeatureCollection delegate, CoordinateReferenceSystem target) { this( delegate, delegate.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem(), target); }
private CoordinateReferenceSystem getCRS() { GeometryDescriptor defaultGeometry = this.featureSource.getSchema().getGeometryDescriptor(); return defaultGeometry == null ? null : defaultGeometry.getCoordinateReferenceSystem(); }
private static SimpleFeatureType forceType( SimpleFeatureType startingType, CoordinateReferenceSystem forcedCS, boolean forceOnlyMissing) throws SchemaException { if (forcedCS == null) { throw new NullPointerException("CoordinateSystem required"); } CoordinateReferenceSystem originalCs = startingType.getGeometryDescriptor() != null ? startingType.getGeometryDescriptor().getCoordinateReferenceSystem() : null; if (forcedCS.equals(originalCs)) { return startingType; } else { return FeatureTypes.transform(startingType, forcedCS, forceOnlyMissing); } }
static Integer findSRID(SimpleFeatureType schema) throws Exception { CoordinateReferenceSystem crs = schema.getCoordinateReferenceSystem(); if (crs == null) { GeometryDescriptor gd = findGeometryDescriptor(schema); crs = gd.getCoordinateReferenceSystem(); } return crs != null ? CRS.lookupEpsgCode(crs, true) : null; }
/** * Builds a new ForceCoordinateSystemFeatureReader * * @param reader * @param cs * @throws SchemaException * @throws NullPointerException DOCUMENT ME! * @throws IllegalArgumentException DOCUMENT ME! */ public ForceCoordinateSystemIterator( FeatureIterator<SimpleFeature> reader, SimpleFeatureType type, CoordinateReferenceSystem cs) throws SchemaException { if (cs == null) { throw new NullPointerException("CoordinateSystem required"); } CoordinateReferenceSystem originalCs = type.getGeometryDescriptor().getCoordinateReferenceSystem(); if (!cs.equals(originalCs)) { type = FeatureTypes.transform(type, cs); } builder = new SimpleFeatureBuilder(type); this.reader = reader; }
@Override public Object visit(PropertyName expression, Object extraData) { AttributeDescriptor result = expression.evaluate(schema, AttributeDescriptor.class); if (result == null) { throw new IllegalArgumentException( "Original feature type does not have a property named " + expression.getPropertyName()); } if (result instanceof GeometryDescriptor) { this.crs = ((GeometryDescriptor) result).getCoordinateReferenceSystem(); } return result.getType().getBinding(); }
/** * Constructor that will generate schema and mathTransform for the results. * * @param reader original reader * @param cs Target coordinate reference system; will be used to create the target FeatureType * and MathTransform used to transform the data */ public ReprojectFeatureReader( FeatureReader<SimpleFeatureType, SimpleFeature> reader, CoordinateReferenceSystem cs) throws SchemaException, OperationNotFoundException, NoSuchElementException, FactoryException { if (cs == null) { throw new NullPointerException("CoordinateSystem required"); } SimpleFeatureType type = reader.getFeatureType(); CoordinateReferenceSystem original = type.getGeometryDescriptor().getCoordinateReferenceSystem(); if (cs.equals(original)) { throw new IllegalArgumentException( "CoordinateSystem " + cs + " already used (check before using wrapper)"); } this.schema = FeatureTypes.transform(type, cs); this.reader = reader; transformer.setMathTransform(CRS.findMathTransform(original, cs, true)); }
/** * Sets all the attribute specific state from a single descriptor. * * <p>This method is convenience for: <code> * builder.minOccurs( descriptor.getMinOccurs() ).maxOccurs( descriptor.getMaxOccurs() ) * .nillable( descriptor.isNillable() )... * </code> */ public SimpleFeatureTypeBuilder descriptor(AttributeDescriptor descriptor) { minOccurs(descriptor.getMinOccurs()); maxOccurs(descriptor.getMaxOccurs()); nillable(descriptor.isNillable()); // namespaceURI( descriptor.getName().getNamespaceURI() ); defaultValue(descriptor.getDefaultValue()); if (descriptor instanceof GeometryDescriptor) { crs(((GeometryDescriptor) descriptor).getCoordinateReferenceSystem()); } return this; }
public void testSchema() throws Exception { SimpleFeatureType schema = dataStore.getSchema(tname(getLine3d())); CoordinateReferenceSystem crs = schema.getGeometryDescriptor().getCoordinateReferenceSystem(); assertEquals(Integer.valueOf(getEpsgCode()), CRS.lookupEpsgCode(crs, false)); assertEquals( getNativeSRID(), schema.getGeometryDescriptor().getUserData().get(JDBCDataStore.JDBC_NATIVE_SRID)); assertEquals( 3, schema.getGeometryDescriptor().getUserData().get(Hints.COORDINATE_DIMENSION)); }
@Override protected SimpleFeatureType buildTargetFeatureType() { SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); for (AttributeDescriptor ad : delegate.getSchema().getAttributeDescriptors()) { if (ad instanceof GeometryDescriptor) { GeometryDescriptor gd = (GeometryDescriptor) ad; Class<?> binding = ad.getType().getBinding(); if (Point.class.isAssignableFrom(binding)) { tb.add(ad); } else { tb.minOccurs(ad.getMinOccurs()); tb.maxOccurs(ad.getMaxOccurs()); tb.nillable(ad.isNillable()); tb.add(ad.getLocalName(), Point.class, gd.getCoordinateReferenceSystem()); } } else { tb.add(ad); } } tb.setName(delegate.getSchema().getName()); return tb.buildFeatureType(); }
@Override protected SimpleFeatureType buildFeatureType() throws IOException { final WFSDataStore dataStore = getDataStore(); final Name localTypeName = getEntry().getName(); final QName remoteTypeName = dataStore.getRemoteTypeName(localTypeName); final SimpleFeatureType remoteSimpleFeatureType; remoteSimpleFeatureType = dataStore.getRemoteSimpleFeatureType(remoteTypeName); // adapt the feature type name SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.init(remoteSimpleFeatureType); builder.setName(localTypeName); String namespaceOverride = entry.getName().getNamespaceURI(); if (namespaceOverride != null) { builder.setNamespaceURI(namespaceOverride); } GeometryDescriptor defaultGeometry = remoteSimpleFeatureType.getGeometryDescriptor(); if (defaultGeometry != null) { builder.setDefaultGeometry(defaultGeometry.getLocalName()); builder.setCRS(defaultGeometry.getCoordinateReferenceSystem()); } final SimpleFeatureType adaptedFeatureType = builder.buildFeatureType(); return adaptedFeatureType; }
public void testSchema() throws Exception { if (!isGeographySupportAvailable()) { return; } SimpleFeatureType ft = dataStore.getFeatureSource(tname("geopoint")).getSchema(); assertNotNull(ft); assertTrue(ft.getDescriptor(aname("geo")) instanceof GeometryDescriptor); assertEquals(Point.class, ft.getDescriptor("geo").getType().getBinding()); int epsg = CRS.lookupEpsgCode( ((GeometryDescriptor) ft.getDescriptor(aname("geo"))) .getCoordinateReferenceSystem(), false); assertEquals(4326, epsg); }