fc = new ForceCoordinateSystemFeatureResults(fc, declaredCRS); nativeCRS = declaredCRS; fc = new ForceCoordinateSystemFeatureResults(fc, declaredCRS); nativeCRS = declaredCRS; } else if (srsHandling == ProjectionPolicy.REPROJECT_TO_DECLARED
private void assertOptimalVisit(FeatureVisitor visitor) throws IOException, SchemaException { SimpleFeatureCollection retypedCollection = new ForceCoordinateSystemFeatureResults(visitorCollection, utm32n); retypedCollection.accepts(visitor, null); assertSame(lastVisitor, visitor); }
return new ForceCoordinateSystemFeatureResults( (SimpleFeatureCollection) features, sourceCrs); } catch (Exception ee) {
if (cCs != null) results = new ForceCoordinateSystemFeatureResults(results, cCs); results = new ReprojectFeatureResults(results, cCsr); if (qCs != null) results = new ForceCoordinateSystemFeatureResults(results, qCs); results = new ReprojectFeatureResults(results, qCsr); } else if (qCs != null && cCsr != null) { results = new ForceCoordinateSystemFeatureResults(results, cCs); results = new ReprojectFeatureResults(source.getFeatures(mergedQuery), cCsr); results = new ForceCoordinateSystemFeatureResults(results, qCs); } catch (SchemaException e) { throw new DataSourceException("This should not happen", e); results = new ForceCoordinateSystemFeatureResults(results, forcedCS); if (reprojectCS != null) results = new ReprojectFeatureResults(results, reprojectCS);
public void testBoundsNotOptimized() throws IOException, SchemaException { BoundsVisitor boundsVisitor = new BoundsVisitor(); SimpleFeatureCollection retypedCollection = new ForceCoordinateSystemFeatureResults(visitorCollection, utm32n); retypedCollection.accepts(boundsVisitor, null); // not optimized assertNull(lastVisitor); } }
features = new ForceCoordinateSystemFeatureResults(features, forcedCRS, false);
public void testBounds() throws Exception { SimpleFeatureCollection original = featureCollection; assertFalse(original.getBounds().isEmpty()); SimpleFeatureCollection forced = new ForceCoordinateSystemFeatureResults(original, utm32n); assertEquals(new ReferencedEnvelope(10, 10, 10, 10, utm32n), forced.getBounds()); }
/** * Reads a feature collection from GeoJSON. * * <p>Warning that this method will load the entire feature collection into memory. For large * feature collections {@link #streamFeatureCollection(Object)} should be used. * * @param input The input. See {@link GeoJSONUtil#toReader(Object)} for details. * @return The feature collection. * @throws IOException In the event of a parsing error or if the input json is invalid. */ public FeatureCollection readFeatureCollection(Object input) throws IOException { DefaultFeatureCollection features = new DefaultFeatureCollection(null, null); FeatureCollectionIterator it = (FeatureCollectionIterator) streamFeatureCollection(input); while (it.hasNext()) { features.add(it.next()); } // check for the case of a crs specified post features in the json if (features.getSchema() != null && features.getSchema().getCoordinateReferenceSystem() == null && it.getHandler().getCRS() != null) { try { return new ForceCoordinateSystemFeatureResults(features, it.getHandler().getCRS()); } catch (SchemaException e) { throw (IOException) new IOException().initCause(e); } } return features; }
public void testSchema() throws Exception { SimpleFeatureCollection original = featureCollection; assertEquals(wgs84, original.getSchema().getCoordinateReferenceSystem()); SimpleFeatureCollection forced = new ForceCoordinateSystemFeatureResults(original, utm32n); assertEquals(utm32n, forced.getSchema().getCoordinateReferenceSystem()); }
resultFc = new ForceCoordinateSystemFeatureResults(inputFeatures, forcedCRS, false); } catch (IOException e) { LOGGER.log(Level.FINER, e.getMessage(), e);
/** * Helper method that tries to force a CRS to be defined. If no CRS is defined buf if all the * feature collection geometries use the same CRS that CRS will be forced. This only work for * simple features. */ private FeatureCollection forceCrs(FeatureCollection featureCollection) { if (featureCollection.getSchema().getCoordinateReferenceSystem() != null) { // a CRS is already defined return featureCollection; } // try to extract a CRS from the feature collection features CoordinateReferenceSystem crs = LayerIdentifierUtils.getCrs(featureCollection); if (crs == null) { // there is nothing more we can do return featureCollection; } try { // force the CRS return new ForceCoordinateSystemFeatureResults(featureCollection, crs); } catch (Exception exception) { throw new RuntimeException( String.format( "Error forcing feature collection to use SRS '%s'.", CRS.toSRS(crs)), exception); } }
return new ForceCoordinateSystemFeatureResults( features, sourceCrs ); } catch (Exception ee) { LOGGER.log(Level.WARNING, ee.getLocalizedMessage(), ee);
return new ForceCoordinateSystemFeatureResults( (SimpleFeatureCollection) features, sourceCrs); } catch (Exception ee) { LOGGER.log(Level.WARNING, ee.getLocalizedMessage(), ee);
if (qCsr != null && cCsr != null) { if (cCs != null) results = new ForceCoordinateSystemFeatureResults(results, cCs); results = new ReprojectFeatureResults(results, cCsr); if (qCs != null) results = new ForceCoordinateSystemFeatureResults(results, qCs); results = new ReprojectFeatureResults(results, qCsr); } else if (qCs != null && cCsr != null) { results = new ForceCoordinateSystemFeatureResults(results, cCs); results = new ReprojectFeatureResults(source.getFeatures(mergedQuery), cCsr); results = new ForceCoordinateSystemFeatureResults(results, qCs); } catch (SchemaException e) { throw new DataSourceException("This should not happen", e); results = new ForceCoordinateSystemFeatureResults(results, forcedCS); if (reprojectCS != null) results = new ReprojectFeatureResults(results, reprojectCS);
if (qCsr != null && cCsr != null) { if (cCs != null) results = new ForceCoordinateSystemFeatureResults(results, cCs); results = new ReprojectFeatureResults(results, cCsr); if (qCs != null) results = new ForceCoordinateSystemFeatureResults(results, qCs); results = new ReprojectFeatureResults(results, qCsr); } else if (qCs != null && cCsr != null) { results = new ForceCoordinateSystemFeatureResults(results, cCs); results = new ReprojectFeatureResults(source.getFeatures(mergedQuery), cCsr); results = new ForceCoordinateSystemFeatureResults(results, qCs); } catch (SchemaException e) { throw new DataSourceException("This should not happen", e); results = new ForceCoordinateSystemFeatureResults(results, forcedCS); if (reprojectCS != null) results = new ReprojectFeatureResults(results, reprojectCS);
@DescribeResult(name = "result", description = "Input feature collection") public SimpleFeatureCollection execute( @DescribeParameter(name = "features", description = "The feature collection that will be reprojected") SimpleFeatureCollection features, @DescribeParameter(name = "forcedCRS", min = 0, description = "Coordinate reference system to use for input feature collection (overrides native one)") CoordinateReferenceSystem forcedCRS, @DescribeParameter(name = "targetCRS", min = 0, description = "Target coordinate reference system to use for reprojection") CoordinateReferenceSystem targetCRS) throws Exception { if (forcedCRS != null) { features = new ForceCoordinateSystemFeatureResults(features, forcedCRS, false); } if (targetCRS != null) { // note, using ReprojectFeatureResults would work. However that would // just work by accident... see GEOS-4072 features = new ReprojectingFeatureCollection(features, targetCRS); } return features; }
/** * Reads a feature collection from GeoJSON. * <p> * Warning that this method will load the entire feature collection into memory. For large * feature collections {@link #streamFeatureCollection(Object)} should be used. * </p> * * @param input The input. See {@link GeoJSONUtil#toReader(Object)} for details. * @return The feature collection. * * @throws IOException In the event of a parsing error or if the input json is invalid. */ public FeatureCollection readFeatureCollection(Object input) throws IOException { FeatureCollection features = new DefaultFeatureCollection(null, null); FeatureCollectionIterator it = (FeatureCollectionIterator) streamFeatureCollection(input); while(it.hasNext()) { features.add(it.next()); } //check for the case of a crs specified post features in the json if (features.getSchema().getCoordinateReferenceSystem() == null && it.getHandler().getCRS() != null ) { try { features = new ForceCoordinateSystemFeatureResults(features, it.getHandler().getCRS()); } catch (SchemaException e) { throw (IOException) new IOException().initCause(e); } } return features; }
if (nativeCrs == null) { fc = new ForceCoordinateSystemFeatureResults(fc, crs, false);
if(nativeCrs == null) { fc = new ForceCoordinateSystemFeatureResults(fc, crs, false);
/** * Try to re-import buildings as another layer (different name, different projection) */ public void testImportBuildings() throws Exception { FeatureTypeInfo ti = getCatalog().getFeatureTypeByName(getLayerId(MockData.BUILDINGS)); SimpleFeatureCollection rawSource = (SimpleFeatureCollection) ti.getFeatureSource(null, null).getFeatures(); ForceCoordinateSystemFeatureResults forced = new ForceCoordinateSystemFeatureResults( rawSource, CRS.decode("EPSG:4326")); ImportProcess importer = new ImportProcess(getCatalog()); String result = importer.execute(forced, MockData.CITE_PREFIX, MockData.CITE_PREFIX, "Buildings2", null, null, null); checkBuildings2(result); }