void doSetupBounds(ResourceInfo rinfo, Object data) throws IOException { // setup the native bbox if needed if (rinfo.getNativeBoundingBox() == null) { ReferencedEnvelope bounds = getNativeBounds(rinfo, data); rinfo.setNativeBoundingBox(bounds); } // setup the geographic bbox if missing and we have enough info rinfo.setLatLonBoundingBox(getLatLonBounds(rinfo.getNativeBoundingBox(), rinfo.getCRS())); }
boolean computeLatLonBoundingBox(ImportTask task, boolean force) throws Exception { ResourceInfo r = task.getLayer().getResource(); if (force || r.getLatLonBoundingBox() == null && r.getNativeBoundingBox() != null) { CoordinateReferenceSystem nativeCRS = CRS.decode(r.getSRS()); ReferencedEnvelope nativeBbox = new ReferencedEnvelope(r.getNativeBoundingBox(), nativeCRS); r.setLatLonBoundingBox(nativeBbox.transform(CRS.decode("EPSG:4326"), true)); return true; } return false; }
boolean computeLatLonBoundingBox(ImportTask task, boolean force) throws Exception { ResourceInfo r = task.getLayer().getResource(); if (force || r.getLatLonBoundingBox() == null && r.getNativeBoundingBox() != null) { CoordinateReferenceSystem nativeCRS = CRS.decode(r.getSRS()); ReferencedEnvelope nativeBbox = new ReferencedEnvelope(r.getNativeBoundingBox(), nativeCRS); r.setLatLonBoundingBox(nativeBbox.transform(CRS.decode("EPSG:4326"), true)); return true; } return false; }
CatalogBuilder builder = new CatalogBuilder(catalog); try { resource.setLatLonBoundingBox(builder.getLatLonBounds( resource.getNativeBoundingBox(), resolveCRS(resource.getSRS())));
@Override protected void onSetUp(SystemTestData testData) throws Exception { // insert extra metadata ResourceInfo forestInfo = getCatalog().getLayerByName("Forests").getResource(); forestInfo.getMetadata().put("date", "09/10/2012"); forestInfo.setLatLonBoundingBox(new ReferencedEnvelope(-200, -180, -100, -90, CRS .decode("EPSG:4326"))); getCatalog().save(forestInfo); }
CatalogBuilder builder = new CatalogBuilder(catalog); try { message.setLatLonBoundingBox( builder.getLatLonBounds( message.getNativeBoundingBox(), resolveCRS(message.getSRS())));
@Override protected void onSetUp(SystemTestData testData) throws Exception { // insert extra metadata ResourceInfo forestInfo = getCatalog().getLayerByName("Forests").getResource(); forestInfo.getMetadata().put("date", "09/10/2012"); forestInfo.setLatLonBoundingBox(new ReferencedEnvelope(-200, -180, -100, -90, CRS .decode("EPSG:4326"))); forestInfo.getKeywords().add(new Keyword ("CustomKeyWord-1")); forestInfo.getKeywords().add(new Keyword ("CustomKeyWord-2")); forestInfo.setDescription("Land with lots of trees on."); forestInfo.getAlias().add("Bush"); forestInfo.getAlias().add("Woods"); getCatalog().save(forestInfo); }
@Override public void apply(ImportTask task, ImportData data) throws Exception { // let the transform run super.apply(task, data); // see if we need to update the layer definition, we just changed the CRS after all LayerInfo layer = task.getLayer(); ResourceInfo resource = layer.getResource(); String originalSRS = resource.getSRS(); // do so only if it's a direct import if (layer.getId() != null || resource == null || resource.getCatalog() == null) { return; } DataFormat format = DataFormat.lookup(((FileData) data).getFile()); List<ImportTask> tasks = format.list(data, resource.getCatalog(), new ProgressMonitor()); if (tasks == null || tasks.isEmpty()) { return; } LayerInfo updatedLayer = tasks.get(0).getLayer(); ResourceInfo updatedResource = updatedLayer.getResource(); String updatedSRS = updatedResource.getSRS(); // check if the layer srs is incompatible with the one we just reprojected to, update if // necessary if (originalSRS == null || (!originalSRS.equals(updatedSRS) && updatedSRS != null)) { resource.setSRS(updatedSRS); resource.setNativeCRS(updatedResource.getNativeCRS()); resource.setNativeBoundingBox(updatedResource.getNativeBoundingBox()); resource.setLatLonBoundingBox(updatedResource.getLatLonBoundingBox()); } }
resource.setNativeCRS(KML_CRS); resource.setNativeBoundingBox(EMPTY_BOUNDS); resource.setLatLonBoundingBox(EMPTY_BOUNDS); resource.getMetadata().put("recalculate-bounds", Boolean.TRUE);
resource.setNativeCRS(KML_CRS); resource.setNativeBoundingBox(EMPTY_BOUNDS); resource.setLatLonBoundingBox(EMPTY_BOUNDS); resource.getMetadata().put("recalculate-bounds", Boolean.TRUE);
ReferencedEnvelope nativeBounds = cb.getNativeBounds(resourceInfo); resourceInfo.setNativeBoundingBox(nativeBounds); resourceInfo.setLatLonBoundingBox( cb.getLatLonBounds(nativeBounds, resourceInfo.getCRS()));
resource.setLatLonBoundingBox(EMPTY_BOUNDS); resource.getMetadata().put("recalculate-bounds", Boolean.TRUE);