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())); }
@Test public void testLatLonBounds() throws Exception { ReferencedEnvelope nativeBounds = new ReferencedEnvelope(700000, 800000, 4000000, 4100000, null); CoordinateReferenceSystem crs = CRS.decode("EPSG:32632", true); CatalogBuilder cb = new CatalogBuilder(getCatalog()); ReferencedEnvelope re = cb.getLatLonBounds(nativeBounds, crs); assertEquals(DefaultGeographicCRS.WGS84, re.getCoordinateReferenceSystem()); assertEquals(11.22, re.getMinX(), 0.01); assertEquals(36.1, re.getMinY(), 0.01); }
@Test public void testWgs84BoundsFromCompoundCRS() throws Exception { try { MapProjection.SKIP_SANITY_CHECKS = true; CatalogBuilder cb = new CatalogBuilder(getCatalog()); ReferencedEnvelope3D bounds = new ReferencedEnvelope3D( 142892, 470783, 16, 142900, 470790, 20, CRS.decode("EPSG:7415")); // used to throw an exception here ReferencedEnvelope latLonBounds = cb.getLatLonBounds(bounds, bounds.getCoordinateReferenceSystem()); assertTrue( CRS.equalsIgnoreMetadata( CRS.decode("EPSG:4326"), latLonBounds.getCoordinateReferenceSystem())); // System.out.println(latLonBounds); } finally { MapProjection.SKIP_SANITY_CHECKS = false; } }
CatalogBuilder builder = new CatalogBuilder(catalog); try { resource.setLatLonBoundingBox(builder.getLatLonBounds( resource.getNativeBoundingBox(), resolveCRS(resource.getSRS())));
try { message.setLatLonBoundingBox( builder.getLatLonBounds( message.getNativeBoundingBox(), resolveCRS(message.getSRS()))); } catch (IOException e) {
@Override protected void onClick(AjaxRequestTarget target, Form form) { // perform manual processing of the required fields nativeBBox.processInput(); declaredCRS.processInput(); ReferencedEnvelope nativeBounds = (ReferencedEnvelope) nativeBBox.getModelObject(); try { // if the native bounds are not around compute them if(nativeBounds == null) { ResourceInfo resource = (ResourceInfo) BasicResourceConfig.this.getDefaultModelObject(); CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog()); nativeBounds = cb.getNativeBounds(resource); resource.setNativeBoundingBox(nativeBounds); nativeBBox.setModelObject(nativeBounds); target.addComponent(nativeBBox); } CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog()); latLonPanel.setModelObject(cb.getLatLonBounds(nativeBounds, declaredCRS.getCRS())); } catch(IOException e) { LOGGER.log(Level.SEVERE, "Error computing the geographic BBOX", e); error("Error computing the geographic bounds:" + e.getMessage()); } target.addComponent(latLonPanel); } };
resourceInfo.setNativeBoundingBox(nativeBounds); resourceInfo.setLatLonBoundingBox( cb.getLatLonBounds(nativeBounds, resourceInfo.getCRS()));
@Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { // perform manual processing of the required fields form.process(null); form.visitFormComponents(new FeedbackMessageCleaner<>(FeedbackMessage.UNDEFINED)); ReferencedEnvelope nativeBounds = (ReferencedEnvelope) nativeBBox.getModelObject(); try { // if the native bounds are not around compute them if (nativeBounds == null) { ResourceInfo resource = (ResourceInfo) BasicResourceConfig.this.getDefaultModelObject(); CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog()); nativeBounds = cb.getNativeBounds(resource); resource.setNativeBoundingBox(nativeBounds); nativeBBox.setModelObject(nativeBounds); target.add(nativeBBox); } CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog()); latLonPanel.setModelObject( cb.getLatLonBounds(nativeBounds, declaredCRS.getCRS())); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Error computing the geographic BBOX", e); error("Error computing the geographic bounds:" + e.getMessage()); } target.add(latLonPanel); }
ReferencedEnvelope nativeBounds = cb.getNativeBounds(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);
ReferencedEnvelope nativeBounds = cb.getNativeBounds(resource); resource.setNativeBoundingBox(nativeBounds); resource.setLatLonBoundingBox(cb.getLatLonBounds(nativeBounds, resource.getCRS())); getCatalog().save(resource);