/** @param crs */ public void calculateBounds(CoordinateReferenceSystem crs) throws Exception { List<LayerInfo> layers = allLayers(); if (layers.isEmpty()) { return; } LayerInfo l = layers.get(0); ReferencedEnvelope bounds = new ReferencedEnvelope(crs); for (int i = 0; i < layers.size(); i++) { l = layers.get(i); bounds.expandToInclude(transform(l.getResource().getLatLonBoundingBox(), crs)); } group.setBounds(bounds); }
boolean latlon = false; if (bounds == null) { bounds = l.getResource().getLatLonBoundingBox(); latlon = true; ResourceInfo resource = l.getResource(); if (latlon) { re = resource.getLatLonBoundingBox(); } else { re = resource.boundingBox(); if (re == null) { re = resource.getLatLonBoundingBox();
} else if (!keywords.equals(other.getKeywords())) return false; if (latLonBoundingBox == null) { if (other.getLatLonBoundingBox() != null) return false; } else if (!latLonBoundingBox.equals(other.getLatLonBoundingBox())) return false; if (metadataLinks == null) { if (other.getMetadataLinks() != null) return false;
expect(r.isAdvertised()).andReturn(true).anyTimes(); expect(r.getProjectionPolicy()).andReturn(projPolicy).anyTimes(); expect(r.getLatLonBoundingBox()).andReturn(latLonEnvelope).anyTimes();
@Test public void testSingleStyleGroup() throws Exception { Catalog catalog = getCatalog(); LayerGroupInfo lg = catalog.getFactory().createLayerGroup(); StyleInfo s = catalog.getStyleByName("singleStyleGroup"); lg.setWorkspace(null); lg.setName("singleStyleLayerGroup"); lg.getLayers().add(null); lg.getStyles().add(s); catalog.add(lg); LayerGroupInfo resolved = catalog.getLayerGroupByName("singleStyleLayerGroup"); assertEquals(1, resolved.layers().size()); assertEquals(1, resolved.styles().size()); assertEquals(s.getStyle(), resolved.styles().get(0).getStyle()); // Test bounds calculation new LayerGroupHelper(lg).calculateBounds(); assertEquals( catalog.getLayerByName((getLayerId(MockData.STREAMS))) .getResource() .getLatLonBoundingBox(), lg.getBounds()); }
/** * Get the bounding box in latitude and longitude for this layer. * * @return Envelope the feature source bounds. * @throws IOException when an error occurs */ public ReferencedEnvelope getLatLongBoundingBox() throws IOException { if (layerInfo != null) { ResourceInfo resource = layerInfo.getResource(); return resource.getLatLonBoundingBox(); } throw new UnsupportedOperationException( "getLatLongBoundingBox not " + "implemented for remote sources"); }
/** * Called by <code>handleLayers()</code>, iterates over the available featuretypes and * coverages to summarize their LatLonBBox'es and write the aggregated bounds for the root * layer. * * @param ftypes the collection of FeatureTypeInfo and CoverageInfo objects to traverse */ private void handleRootBbox(Collection<LayerInfo> layers) { Envelope latlonBbox = new Envelope(); Envelope layerBbox = null; LOGGER.finer("Collecting summarized latlonbbox and common SRS..."); for (LayerInfo layer : layers) { ResourceInfo resource = layer.getResource(); layerBbox = resource.getLatLonBoundingBox(); if (layerBbox != null) latlonBbox.expandToInclude(layerBbox); } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Summarized LatLonBBox is " + latlonBbox); } handleLatLonBBox(latlonBbox); handleAdditionalBBox( new ReferencedEnvelope(latlonBbox, DefaultGeographicCRS.WGS84), null, null); }
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; }
latLongBbox = resourceInfo.getLatLonBoundingBox(); if (null == latLongBbox) { latLongBbox = new ReferencedEnvelope(wgs84LonFirst);
latLongBbox = resourceInfo.getLatLonBoundingBox(); if (null == latLongBbox) { latLongBbox = new ReferencedEnvelope(wgs84LonFirst);
.equals(resource.getNativeBoundingBox()); boolean changedLatLonBounds = message.getLatLonBoundingBox() == null || !message.getLatLonBoundingBox() .equals(resource.getLatLonBoundingBox()); boolean changedNativeInterpretation = changedProjectionPolicy || changedProjection; fieldsToCalculate = new ArrayList<>();
world, latlonBbox, layer.getResource().getLatLonBoundingBox())) {
boolean changedProjectionPolicy = message.getProjectionPolicy() != null; boolean changedNativeBounds = message.getNativeBoundingBox() != null; boolean changedLatLonBounds = message.getLatLonBoundingBox() != null; boolean changedNativeInterpretation = changedProjectionPolicy || changedProjection; fieldsToCalculate = new ArrayList<String>();
|| lyr.getResource().getLatLonBoundingBox() == null) && WMS.isWmsExposable(lyr))) { throw new RuntimeException("Layer's resource is not fully configured");
@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()); } }
public void testGetGridSubsets() throws Exception { layerInfoTileLayer = new GeoServerTileLayer(layerInfo, defaults, gridSetBroker); Set<String> gridSubsets = layerInfoTileLayer.getGridSubsets(); assertNotNull(gridSubsets); assertEquals(2, gridSubsets.size()); Set<XMLGridSubset> subsets = layerInfoTileLayer.getInfo().getGridSubsets(); subsets.clear(); XMLGridSubset xmlGridSubset = new XMLGridSubset(); xmlGridSubset.setGridSetName("EPSG:900913"); subsets.add(xmlGridSubset); LegacyTileLayerInfoLoader.save(layerInfoTileLayer.getInfo(), layerInfo.getMetadata()); layerInfoTileLayer = new GeoServerTileLayer(layerInfo, defaults, gridSetBroker); gridSubsets = layerInfoTileLayer.getGridSubsets(); assertNotNull(gridSubsets); assertEquals(1, gridSubsets.size()); layerGroup.setBounds(layerInfo.getResource().getLatLonBoundingBox()); layerGroupInfoTileLayer = new GeoServerTileLayer(layerGroup, defaults, gridSetBroker); gridSubsets = layerGroupInfoTileLayer.getGridSubsets(); assertNotNull(gridSubsets); assertEquals(2, gridSubsets.size()); }
if (resource.getLatLonBoundingBox() == null)
ft.setSrs(layer.getResource().getSRS()); ft.setBbox(bboxToString(layer.getResource().getNativeBoundingBox())); ft.setLatLonBbox(bboxToString(layer.getResource().getLatLonBoundingBox())); ft.setGeometryCoords(bboxToJSON(layer.getResource().getLatLonBoundingBox()));
@Test public void testImportNoCrsLatLonBoundingBox() throws Exception { File dir = unpack("shape/archsites_no_crs.zip"); ImportContext context = importer.createContext(new Directory(dir)); assertEquals(1, context.getTasks().size()); ImportTask task = context.getTasks().get(0); assertEquals(ImportTask.State.NO_CRS, task.getState()); task.getLayer().getResource().setSRS("EPSG:26713"); importer.changed(task); assertEquals(ImportTask.State.READY, task.getState()); ResourceInfo r = task.getLayer().getResource(); assertNotNull(r.getLatLonBoundingBox()); assertNotNull(r.boundingBox()); assertNotNull(r.boundingBox().getCoordinateReferenceSystem()); assertEquals("EPSG:26713", CRS.toSRS(r.boundingBox().getCoordinateReferenceSystem())); // Do the import, verify the changed CRS is preserved when the bounds are calculated importer.doDirectImport(task); assertEquals(ImportTask.State.COMPLETE, task.getState()); r = task.getLayer().getResource(); assertNotNull(r.getLatLonBoundingBox()); assertNotEquals(VectorFormat.EMPTY_BOUNDS, r.getLatLonBoundingBox()); assertNotNull(r.boundingBox()); assertNotEquals(VectorFormat.EMPTY_BOUNDS, r.boundingBox()); assertNotNull(r.boundingBox().getCoordinateReferenceSystem()); assertEquals("EPSG:26713", CRS.toSRS(r.boundingBox().getCoordinateReferenceSystem())); }