public CoordinateReferenceSystem getCRS() { return delegate.getCRS(); }
@Test public void testGetBoundsFromCRS() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getDataStoreByName(MockData.LINES.getPrefix())); FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.LINES)); CoordinateReferenceSystem resourceCRS = fti.getCRS(); assertNotNull(resourceCRS); // make sure the srs is as expected, otherwise the rest of the tests don't make sense assertEquals("EPSG:32615", fti.getSRS()); ReferencedEnvelope crsBounds = cb.getBoundsFromCRS(fti); assertNotNull(crsBounds); CoordinateReferenceSystem exptectedCRS = CRS.decode("EPSG:32615"); assertEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds); // if we change the srs when there's no reproject policy, should still be the same bounding // box fti.setSRS("EPSG:4326"); fti.setProjectionPolicy(ProjectionPolicy.NONE); crsBounds = cb.getBoundsFromCRS(fti); assertEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds); // if we use reproject policy, bounds should now be different fti.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED); crsBounds = cb.getBoundsFromCRS(fti); assertNotEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds); // should now be 4326 bounds CoordinateReferenceSystem crs4326 = CRS.decode("EPSG:4326"); assertEquals(new ReferencedEnvelope(CRS.getEnvelope(crs4326)), crsBounds); fti.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED); assertEquals(new ReferencedEnvelope(CRS.getEnvelope(crs4326)), crsBounds); }
@Test public void testLookupSRSDetached() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); DataStoreInfo sf = cat.getDataStoreByName("sf"); FeatureSource fs = sf.getDataStore(null).getFeatureSource(toName(MockData.PRIMITIVEGEOFEATURE)); FeatureTypeInfo ft = cat.getFactory().createFeatureType(); ft.setNativeName("PrimitiveGeoFeature"); assertNull(ft.getSRS()); assertNull(ft.getCRS()); cb.lookupSRS(ft, fs, true); assertNotNull(ft.getSRS()); assertNotNull(ft.getCRS()); }
/** Initializes a feature type object setting any info that has not been set. */ public void initFeatureType(FeatureTypeInfo featureType) throws Exception { if (featureType.getCatalog() == null) { featureType.setCatalog(catalog); } initResourceInfo(featureType); // setup the srs if missing if (featureType.getSRS() == null) { lookupSRS(featureType, true); } if (featureType.getProjectionPolicy() == null) { setupProjectionPolicy(featureType); } // deal with bounding boxes as possible CoordinateReferenceSystem crs = featureType.getCRS(); if (featureType.getLatLonBoundingBox() == null && featureType.getNativeBoundingBox() == null) { // both missing, we compute them setupBounds(featureType); } else if (featureType.getLatLonBoundingBox() == null) { // native available but geographic to be computed setupBounds(featureType); } else if (featureType.getNativeBoundingBox() == null && crs != null) { // we know the geographic and we can reproject back to native ReferencedEnvelope boundsLatLon = featureType.getLatLonBoundingBox(); featureType.setNativeBoundingBox(boundsLatLon.transform(crs, true)); } }
@Test public void testFeatureType() throws Exception { // build a feature type (it's already in the catalog, but we just want to // check it's built as expected // LINES is a feature type with a native SRS, so we want the bounds to be there Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getDataStoreByName(MockData.LINES.getPrefix())); FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.LINES)); // perform basic checks assertEquals("EPSG:32615", fti.getSRS()); assertEquals(CRS.decode("EPSG:32615", true), fti.getCRS()); assertNull(fti.getNativeBoundingBox()); assertNull(fti.getLatLonBoundingBox()); // force bounds computation cb.setupBounds(fti); assertNotNull(fti.getNativeBoundingBox()); assertNotNull(fti.getNativeBoundingBox().getCoordinateReferenceSystem()); assertNotNull(fti.getLatLonBoundingBox()); }
CoordinateReferenceSystem crs = info.getCRS(); if (crs == null) { return mt.doubleValue();
crs = ((GeometryDescriptor) ad).getCoordinateReferenceSystem(); if(crs == null) { crs = ft.getCRS();
catalog.getFeatureTypeByName(fc.getSchema().getName()); if (info != null) { crs = info.getCRS();
/** * Builds a {@link SimpleFeatureType} from the attributes declared in a {@link FeatureTypeInfo} * * @param fti */ protected SimpleFeatureType buildFeatureTypeFromInfo(FeatureTypeInfo fti) { SimpleFeatureType ft; SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.setName(fti.getName()); List<AttributeTypeInfo> attributes = fti.getAttributes(); for (AttributeTypeInfo attr : attributes) { if (Geometry.class.isAssignableFrom(attr.getBinding())) { ftb.add(attr.getName(), attr.getBinding(), fti.getCRS()); } else { ftb.add(attr.getName(), attr.getBinding()); } } ft = ftb.buildFeatureType(); return ft; } }
getCatalog() .getFeatureTypeByName(layer.getPrefix(), layer.getLocalPart()) .getCRS()), is(sourceOrder));
ReferencedEnvelope nativeBounds = cb.getNativeBounds(resource); resource.setNativeBoundingBox(nativeBounds); resource.setLatLonBoundingBox(cb.getLatLonBounds(nativeBounds, resource.getCRS())); getCatalog().save(resource);
resource.setNativeBoundingBox(nativeBounds); resource.setLatLonBoundingBox(cb.getLatLonBounds(nativeBounds, resource.getCRS())); getCatalog().save(resource);
ReferencedEnvelope nativeBounds = cb.getNativeBounds(resource); resource.setNativeBoundingBox(nativeBounds); resource.setLatLonBoundingBox(cb.getLatLonBounds(nativeBounds, resource.getCRS())); getCatalog().save(resource);