private void updateFields() { ReferencedEnvelope e = (ReferencedEnvelope) getModelObject(); if(e != null) { this.minX = e.getMinX(); this.minY = e.getMinY(); this.maxX = e.getMaxX(); this.maxY = e.getMaxY(); this.crs = e.getCoordinateReferenceSystem(); } }
private void updateFields() { ReferencedEnvelope e = (ReferencedEnvelope) getModelObject(); if (e != null) { this.minX = e.getMinX(); this.minY = e.getMinY(); this.maxX = e.getMaxX(); this.maxY = e.getMaxY(); this.crs = e.getCoordinateReferenceSystem(); if (is3D()) { if (e instanceof ReferencedEnvelope3D) { this.minZ = ((ReferencedEnvelope3D) e).getMinZ(); this.maxZ = ((ReferencedEnvelope3D) e).getMaxZ(); } else { this.minZ = Double.NaN; this.maxZ = Double.NaN; } } else { this.minZ = Double.NaN; this.maxZ = Double.NaN; } } }
@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); } };
@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); }