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!"); } }
public SimpleFeatureCollection subCollection(Filter filter) { // reproject the filter to the delegate native crs CoordinateReferenceSystem crs = getSchema().getCoordinateReferenceSystem(); CoordinateReferenceSystem crsDelegate = delegate.getSchema().getCoordinateReferenceSystem(); if (crs != null) { DefaultCRSFilterVisitor defaulter = new DefaultCRSFilterVisitor(FF, crs); filter = (Filter) filter.accept(defaulter, null); if (crsDelegate != null && !CRS.equalsIgnoreMetadata(crs, crsDelegate)) { ReprojectingFilterVisitor reprojector = new ReprojectingFilterVisitor(FF, delegate.getSchema()); filter = (Filter) filter.accept(reprojector, null); } } SimpleFeatureCollection sub = delegate.subCollection(filter); if (sub != null) { try { ReprojectingFeatureCollection wrapper = new ReprojectingFeatureCollection(sub, target); wrapper.setDefaultSource(defaultSource); return wrapper; } catch (Exception e) { throw new RuntimeException(e); } } return null; }
public void testComposeOne() { CompositeFeatureCollection fc = new CompositeFeatureCollection( Arrays.asList(DataUtilities.collection(riverFeatures[0]))); assertEquals(1, fc.size()); assertEquals( new ReferencedEnvelope(5, 13, 3, 7, riverType.getCoordinateReferenceSystem()), fc.getBounds()); assertEquals(riverFeatures[0], DataUtilities.first(fc)); }
public void testComposeMany() { SimpleFeatureCollection roads = DataUtilities.collection(roadFeatures); SimpleFeatureCollection rivers = DataUtilities.collection(riverFeatures); SimpleFeatureCollection lakes = DataUtilities.collection(lakeFeatures); CompositeFeatureCollection fc = new CompositeFeatureCollection(Arrays.asList(roads, rivers, lakes)); // 3 roads, 2 rivers, 1 lake assertEquals(6, fc.size()); assertEquals( new ReferencedEnvelope(1, 16, 0, 10, riverType.getCoordinateReferenceSystem()), fc.getBounds()); assertEquals(roadFeatures[0], DataUtilities.first(fc)); } }
if (ul.getInlineFeatureType().getCoordinateReferenceSystem() == null) { LOGGER.warning( "No CRS set on inline features default geometry. Assuming the requestor has their inlinefeatures in the boundingbox CRS.");
/** @see org.geotools.data.ResourceInfo#getCRS() */ public CoordinateReferenceSystem getCRS() { return info.getFeatureType().getCoordinateReferenceSystem(); }
public CoordinateReferenceSystem getCRS() { return DefaultView.this.getSchema().getCoordinateReferenceSystem(); }
public CoordinateReferenceSystem getCRS() { return ContentFeatureSource.this.getSchema().getCoordinateReferenceSystem(); }
public ReferencedEnvelope getBounds() { CoordinateReferenceSystem crs = schema.getCoordinateReferenceSystem(); Envelope bounds = (Envelope) index.getRoot().getBounds(); return new ReferencedEnvelope(bounds, crs); }
/** @see org.geotools.data.FeatureResults#getBounds() */ public ReferencedEnvelope getBounds() { ReferencedEnvelope env = results.getBounds(); if (env == null) { return null; } env = new ReferencedEnvelope(env, getSchema().getCoordinateReferenceSystem()); return env; }
/** @see org.geotools.data.ResourceInfo#getBounds() */ public synchronized ReferencedEnvelope getBounds() { ReferencedEnvelope bounds; try { bounds = source.getBounds(); } catch (IOException e) { CoordinateReferenceSystem crs = info.getFeatureType().getCoordinateReferenceSystem(); bounds = new ReferencedEnvelope(crs); } return bounds; }
if (!CRS.equalsIgnoreMetadata(resultCRS, schema.getCoordinateReferenceSystem())) schema = FeatureTypes.transform(schema, resultCRS); } catch (Exception e) {
public BoundingBox getBounds() { Object obj = getDefaultGeometry(); if (obj instanceof Geometry) { Geometry geometry = (Geometry) obj; return ReferencedEnvelope.create( geometry.getEnvelopeInternal(), featureType.getCoordinateReferenceSystem()); } return ReferencedEnvelope.create(featureType.getCoordinateReferenceSystem()); }
public ReprojectFeatureIterator( FeatureIterator<SimpleFeature> reader, SimpleFeatureType schema, MathTransform transform) { this.reader = reader; this.schema = schema; transformer.setMathTransform(transform); // set hte target coordinate system transformer.setCoordinateReferenceSystem(schema.getCoordinateReferenceSystem()); }
@Override public BoundingBox getBounds() { ReferencedEnvelope bounds = new ReferencedEnvelope(featureType.getCoordinateReferenceSystem()); Object value = getAttribute(index); if (value instanceof Geometry) { bounds.init(((Geometry) value).getEnvelopeInternal()); } return bounds; }
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; }
@Override public BoundingBox getBounds() { Object o = getDefaultGeometry(); if (o instanceof Geometry) { CoordinateReferenceSystem crs = featureType.getCoordinateReferenceSystem(); if (crs == null) { crs = DefaultGeographicCRS.WGS84; } Envelope bounds = ReferencedEnvelope.create(crs); bounds.init(JTS.bounds((Geometry) o, crs)); return (BoundingBox) bounds; } return null; }
public void testSchema() throws Exception { SimpleFeatureCollection original = featureCollection; assertEquals(wgs84, original.getSchema().getCoordinateReferenceSystem()); SimpleFeatureCollection forced = new ForceCoordinateSystemFeatureResults(original, utm32n); assertEquals(utm32n, forced.getSchema().getCoordinateReferenceSystem()); }
public void testSchema() throws Exception { SimpleFeatureType schema = featureSource.getSchema(); assertEquals(tname("ft1"), schema.getTypeName()); assertEquals(dataStore.getNamespaceURI(), schema.getName().getNamespaceURI()); assertTrue(areCRSEqual(CRS.decode("EPSG:4326"), schema.getCoordinateReferenceSystem())); assertEquals(5, schema.getAttributeCount()); assertNotNull(schema.getDescriptor(aname("id"))); assertNotNull(schema.getDescriptor(aname("geometry"))); assertNotNull(schema.getDescriptor(aname("intProperty"))); assertNotNull(schema.getDescriptor(aname("stringProperty"))); assertNotNull(schema.getDescriptor(aname("doubleProperty"))); } }
public void testSchema() throws Exception { SimpleFeatureType schema = featureSource.getSchema(); assertEquals(tname("ft1"), schema.getTypeName()); assertEquals(dataStore.getNamespaceURI(), schema.getName().getNamespaceURI()); assertTrue(areCRSEqual(getWGS84(), schema.getCoordinateReferenceSystem())); assertEquals(4, schema.getAttributeCount()); assertNotNull(schema.getDescriptor(aname("geometry"))); assertNotNull(schema.getDescriptor(aname("intProperty"))); assertNotNull(schema.getDescriptor(aname("stringProperty"))); assertNotNull(schema.getDescriptor(aname("doubleProperty"))); }