/** * Sets the projection policy for a resource based on the following rules: * * <ul> * <li>If getSRS() returns a non null value it is set to {@Link * ProjectionPolicy#FORCE_DECLARED} * <li>If getSRS() returns a null value it is set to {@link ProjectionPolicy#NONE} * </ul> * * TODO: make this method smarter, and compare the native crs to figure out if prejection * actually needs to be done, and sync it up with setting proj policy on coverage layers. */ public void setupProjectionPolicy(ResourceInfo rinfo) { if (rinfo.getSRS() != null) { rinfo.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED); } else { rinfo.setProjectionPolicy(ProjectionPolicy.NONE); } }
expect(r.getSRS()).andReturn(srs).anyTimes(); try { expect(r.getNativeCRS()).andReturn(CRS.decode(srs));
/** * @return the resource SRS name or {@code null} if the underlying resource is not a registered * one */ public String getSRS() { if (layerInfo != null) { return layerInfo.getResource().getSRS(); } return 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; }
if (calculate == null || calculate.isEmpty()) { boolean changedProjection = message.getSRS() == null || !message.getSRS().equals(resource.getSRS()); boolean changedProjectionPolicy = message.getProjectionPolicy() == null message.setLatLonBoundingBox( builder.getLatLonBounds( message.getNativeBoundingBox(), resolveCRS(message.getSRS()))); } catch (IOException e) { String errorMessage =
List<String> fieldsToCalculate; if (calculate == null) { boolean changedProjection = message.getSRS() != null; boolean changedProjectionPolicy = message.getProjectionPolicy() != null; boolean changedNativeBounds = message.getNativeBoundingBox() != null; resource.setLatLonBoundingBox(builder.getLatLonBounds( resource.getNativeBoundingBox(), resolveCRS(resource.getSRS()))); } catch (IOException e) { String errorMessage =
@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()); } }
|| ((lyr.getResource().getSRS() == null || lyr.getResource().getLatLonBoundingBox() == null) && WMS.isWmsExposable(lyr))) {
if (srsName == null) { srsName = meta.getSRS();
if (r.getSRS() == null) { task.setState(ImportTask.State.NO_CRS); return false;
if ((covLayer.getResource().getSRS() == null) && (covLayer.getResource().getNativeCRS() != null) && (defaultSRS != null)) { + covLayer.getName()) != null) { status = DUPLICATE; } else if ((covLayer.getResource().getSRS() == null) && (defaultSRS == null)) { if (covLayer.getResource().getNativeCRS() == null) { status = MISSING_NATIVE_CRS;
if (r.getSRS() == null) { task.setState(ImportTask.State.NO_CRS); return false;
ft.setSrs(layer.getResource().getSRS()); ft.setBbox(bboxToString(layer.getResource().getNativeBoundingBox())); ft.setLatLonBbox(bboxToString(layer.getResource().getLatLonBoundingBox()));
CRS.equalsIgnoreMetadata( CRS.decode("EPSG:26713"), l1.getResource().getNativeCRS())); assertEquals("EPSG:26713", l1.getResource().getSRS()); assertTrue( CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), l2.getResource().getNativeCRS())); assertEquals("EPSG:4326", l2.getResource().getSRS()); assertTrue( CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), l2.getResource().getNativeCRS())); assertEquals("EPSG:4326", l2.getResource().getSRS());
assertEquals("Invalid srs", "EPSG:4326", resource.getSRS()); ReferencedEnvelope emptyBounds = new ReferencedEnvelope(); emptyBounds.setToNull();
final String srs = layer.getResource().getSRS(); element("SRS", srs);
handleKeywordList(layer.getResource().getKeywords()); final String crs = layer.getResource().getSRS(); element("CRS", crs);