Commit 4ce60a80 authored by Torben Barsbsballe's avatar Torben Barsbsballe
Browse files

Fixed UNKNOWN crs for layer group

parent 5f84c5f6
......@@ -156,9 +156,9 @@ public class LayerGroupHelper {
}
LayerInfo l = layers.get(0);
ReferencedEnvelope bounds = transform(l.getResource().getLatLonBoundingBox(), crs);
for (int i = 1; i < layers.size(); i++) {
ReferencedEnvelope bounds = new ReferencedEnvelope(crs);
for (int i = 0; i < layers.size(); i++) {
l = layers.get(i);
bounds.expandToInclude(transform(l.getResource().getLatLonBoundingBox(), crs));
}
......
......@@ -29,8 +29,13 @@ import org.geoserver.test.GeoServerSystemTestSupport;
import org.geoserver.test.SystemTest;
import org.geoserver.test.TestSetup;
import org.geoserver.test.TestSetupFrequency;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
@Category(SystemTest.class)
@TestSetup(run=TestSetupFrequency.REPEAT)
......@@ -259,4 +264,31 @@ public class CatalogIntegrationTest extends GeoServerSystemTestSupport {
assertNull(catalog.getStyleByName(style.getName()));
assertNull(catalog.getLayerGroupByName(lg.getName()));
}
@Test
public void testReprojectLayerGroup()
throws NoSuchAuthorityCodeException, FactoryException, Exception {
Catalog catalog = getCatalog();
CatalogBuilder cb = new CatalogBuilder(catalog);
LayerGroupInfo lg = catalog.getFactory().createLayerGroup();
LayerInfo l = catalog.getLayerByName(getLayerId(MockData.ROAD_SEGMENTS));
lg.getLayers().add(l);
lg.setName("test-reproject");
//Give our layer a CRS without the EPSG code defined
CoordinateReferenceSystem lCrs = DefaultGeographicCRS.WGS84;
((FeatureTypeInfo)l.getResource()).setSRS(null);
((FeatureTypeInfo)l.getResource()).setNativeCRS(lCrs);
assertNull(CRS.lookupEpsgCode(lCrs, false));
//EPSG:4326 should have an EPSG code
CoordinateReferenceSystem lgCrs = CRS.decode("EPSG:4326");
assertNotNull(CRS.lookupEpsgCode(lgCrs, false));
//Reproject our layer group to EPSG:4326. We expect it to have an EPSG code.
cb.calculateLayerGroupBounds(lg, lgCrs);
assertNotNull(CRS.lookupEpsgCode(lg.getBounds().getCoordinateReferenceSystem(), false));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment