Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import org.hortonmachine.gears.utils.RegionMap;
import org.hortonmachine.gears.utils.crs.CrsUtilities;
import org.hortonmachine.gears.utils.geometry.GeometryUtilities;
import org.hortonmachine.gears.utils.crs.HMCrsRegistry;
import org.hortonmachine.gears.utils.crs.HMCrsTransformer;

import org.integratedmodelling.klab.Authentication;
import org.integratedmodelling.klab.Observables;
import org.integratedmodelling.klab.api.data.IGeometry;
Expand Down Expand Up @@ -375,20 +378,18 @@ public boolean test(HMStacAsset asset) { // Assuming for now that "eo:bands" wou
}
HMRaster outRaster = collection.readRasterBandOnRegion(regionTransformed, predicate, items, true,
MergeMode.SUBSTITUTE, lpm);
CoordinateReferenceSystem targetCRS = HMCrsRegistry.INSTANCE.getCrs("4326");
if (!HMCrsRegistry.crsEquals(outRaster.getCrs(),targetCRS)) {
var transformer = new HMCrsTransformer(outRaster.getCrs(), targetCRS);
transformer.setAcceptLenientDatumShift(true);
outRaster = transformer.transform(outRaster);
}

coverage = outRaster.buildCoverage();
}
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
if (bandIndex != null) { // Which means theat it's a Multi Band COG
coverage = (GridCoverage2D) Operations.DEFAULT.selectSampleDimension(coverage, new int[]{bandIndex});
}
if (!CRS.equalsIgnoreMetadata(
coverage.getCoordinateReferenceSystem(),
targetCRS)) {

coverage = (GridCoverage2D) Operations.DEFAULT.resample(
coverage,
targetCRS);
}
} catch (Exception e) {
throw new KlabResourceAccessException(
"Cannot build output for static collection " + collectionId + ". Reason: " + e.getLocalizedMessage());
Expand All @@ -413,7 +414,7 @@ public boolean test(HMStacAsset asset) { // Assuming for now that "eo:bands" wou
throw new KlabResourceAccessException("Cannot access to STAC collection " + collectionUrl); // Fail
// fast
}

IObservable targetSemantics = scope.getTargetArtifact() instanceof Observation
? ((Observation) scope.getTargetArtifact()).getObservable()
: null;
Expand Down Expand Up @@ -505,21 +506,20 @@ public boolean test(HMStacAsset asset) { // Assuming for now that "eo:bands" wou
scope.getMonitor().error("No STAC assets were found. Please check the spatial/temporal coverage of the resource");
throw new KlabIllegalStateException("No STAC assets were found. Please check the spatial/temporal coverage of the resource");
}
CoordinateReferenceSystem targetCRS = HMCrsRegistry.INSTANCE.getCrs("4326");
if (!HMCrsRegistry.crsEquals(outRaster.getCrs(),targetCRS)) {
var transformer = new HMCrsTransformer(outRaster.getCrs(), targetCRS);
transformer.setAcceptLenientDatumShift(true);
outRaster = transformer.transform(outRaster);
}

coverage = outRaster.buildCoverage();
if (bandIndex != null) { // Which means theat it's a Multi Band COG
coverage = (GridCoverage2D) Operations.DEFAULT.selectSampleDimension(coverage, new int[]{bandIndex});
}
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");

manager.close();
encoder = new RasterEncoder();
if (!CRS.equalsIgnoreMetadata(
coverage.getCoordinateReferenceSystem(),
targetCRS)) {

coverage = (GridCoverage2D) Operations.DEFAULT.resample(
coverage,
targetCRS);
}
((RasterEncoder) encoder).encodeFromCoverage(resource, urnParameters, coverage, geometry, builder, scope);
} catch (Exception e) {
e.printStackTrace();
Expand Down
Loading