/** * Looks up and sets the SRS based on the feature type info native {@link * CoordinateReferenceSystem} * * @param ftinfo * @param extensive if true an extenstive lookup will be performed (more accurate, but might * take various seconds) * @throws IOException */ public void lookupSRS(FeatureTypeInfo ftinfo, boolean extensive) throws IOException { lookupSRS(ftinfo, null, extensive); }
lookupSRS(ftinfo, false); } catch (Exception e) { LOGGER.log(Level.WARNING, "SRS lookup failed", e);
/** 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 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()); }
@Test public void testSetupBoundsDetached() 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.getNativeBoundingBox()); assertNull(ft.getLatLonBoundingBox()); cb.lookupSRS(ft, fs, true); cb.setupBounds(ft, fs); assertNotNull(ft.getNativeBoundingBox()); assertNotNull(ft.getLatLonBoundingBox()); }
builder.lookupSRS(ftinfo, true); builder.setupBounds(ftinfo);
builder.lookupSRS(ftinfo, true); builder.setupBounds(ftinfo);
builder.lookupSRS(featureType, true); try