Skip to content
Open
Show file tree
Hide file tree
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
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

import org.esa.snap.core.dataio.geocoding.forward.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

import org.esa.snap.core.dataio.ProductSubsetDef;
Expand All @@ -7,7 +25,6 @@
import org.esa.snap.core.util.SystemUtils;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import java.io.IOException;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -150,6 +167,7 @@ public boolean transferGeoCoding(Scene srcScene, Scene destScene, ProductSubsetD
SystemUtils.LOG.warning("error loading geolocation data: " + e.getMessage());
return false;
}

ForwardCoding forwardCoding = null;
if (this.forwardCoding != null) {
forwardCoding = ComponentFactory.getForward(this.forwardCoding.getKey());
Expand Down Expand Up @@ -239,7 +257,7 @@ public void dispose() {
@Override
@Deprecated
public Datum getDatum() {
throw new NotImplementedException();
throw new IllegalStateException("Method not implemented!");
}

@Override
Expand All @@ -258,6 +276,7 @@ public GeoCoding clone() {
final ComponentGeoCoding clone = new ComponentGeoCoding(geoRaster, cloneForward, cloneInverse, geoChecks);

clone.isInitialized = this.isInitialized;
clone.isCrossingAntiMeridian = this.isCrossingAntiMeridian;

return clone;
}
Expand Down Expand Up @@ -334,6 +353,8 @@ private GeoRaster calculateGeoRaster(Scene destScene, ProductSubsetDef subsetDef
subsamplingX = lonTPG.getSubSamplingX();
subsamplingY = lonTPG.getSubSamplingY();
} else {
// this is based on already subsetted geo-location data, we take
// the subset in full resolution of the subset here tb 2021-05-12
gridWidth = lonRaster.getRasterWidth();
gridHeight = lonRaster.getRasterHeight();

Expand All @@ -348,7 +369,8 @@ private GeoRaster calculateGeoRaster(Scene destScene, ProductSubsetDef subsetDef

geoRaster = new GeoRaster(longitudes, latitudes, lonVariableName, latVariableName,
gridWidth, gridHeight, destScene.getRasterWidth(), destScene.getRasterHeight(),
this.geoRaster.getRasterResolutionInKm() * subsetDef.getSubSamplingX(),
// @todo 1 tb/tb this should also take the subsampling in y direction into account
this.geoRaster.getRasterResolutionInKm() * subsamplingY,
offsetX, offsetY, subsamplingX, subsamplingY);
return geoRaster;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

import org.esa.snap.core.dataio.dimap.spi.DimapPersistable;
import org.esa.snap.core.dataio.geocoding.forward.PixelForward;
import org.esa.snap.core.dataio.geocoding.forward.PixelInterpolatingForward;
import org.esa.snap.core.dataio.geocoding.inverse.PixelGeoIndexInverse;
import org.esa.snap.core.dataio.geocoding.inverse.PixelQuadTreeInverse;
import org.esa.snap.core.dataio.geocoding.util.RasterUtils;
import org.esa.snap.core.datamodel.Product;
import org.esa.snap.core.datamodel.RasterDataNode;
import org.esa.snap.core.datamodel.TiePointGrid;
import org.esa.snap.core.util.SystemUtils;
import org.esa.snap.runtime.Config;
import org.geotools.referencing.CRS;
import org.jdom.Element;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

import java.awt.*;
import java.io.IOException;
import java.awt.Dimension;
import java.util.prefs.Preferences;
import java.util.stream.IntStream;

/**
* @deprecated dont further use this class. Now it is wrapped by {@link ComponentGeoCodingPersistenceConverter}
*/
@Deprecated
public class ComponentGeoCodingPersistable implements DimapPersistable {

public static final String TAG_COMPONENT_GEO_CODING = "ComponentGeoCoding";
Expand Down Expand Up @@ -107,15 +132,15 @@ public Object createObjectFromXml(Element element, Product product, Dimension re
}

if (forwardInvalid
|| inverseInvalid
|| geoChecksInvalid
|| lonVarNameInvalid
|| latVarNameInvalid
|| resolutionKmInvalid
|| resolutionInKm == null
|| geoChecksName == null
|| invalidValueGeoChecks
|| geoCRS == null) {
|| inverseInvalid
|| geoChecksInvalid
|| lonVarNameInvalid
|| latVarNameInvalid
|| resolutionKmInvalid
|| resolutionInKm == null
|| geoChecksName == null
|| invalidValueGeoChecks
|| geoCRS == null) {
SystemUtils.LOG.warning("Unable to create " + TAG_COMPONENT_GEO_CODING + ".");
return null;
}
Expand Down Expand Up @@ -176,14 +201,18 @@ public Object createObjectFromXml(Element element, Product product, Dimension re
resolutionInKm);
}

// TODO preliminary location to overwrite non-interpolating spec of input product e.g. for binning with supersampling, mb, 2021-03-31
// Tom, please find a better solution.
if (Boolean.getBoolean(ComponentGeoCoding.SYSPROP_SNAP_PIXEL_CODING_FRACTION_ACCURACY) && PixelForward.KEY.equals(forwardKey)) {
forwardKey = PixelInterpolatingForward.KEY;
final Preferences snapPreferences = Config.instance("snap").preferences();
final boolean isFractionalEnabled = snapPreferences.getBoolean(ComponentGeoCoding.SYSPROP_SNAP_PIXEL_CODING_FRACTION_ACCURACY, false);
if (isFractionalEnabled && PixelForward.KEY.equals(forwardKey)) {
forwardKey = PixelInterpolatingForward.KEY;
}
if (isFractionalEnabled && PixelQuadTreeInverse.KEY.equals(inverseKey)) {
inverseKey = PixelQuadTreeInverse.KEY_INTERPOLATING;
}
if (Boolean.getBoolean(ComponentGeoCoding.SYSPROP_SNAP_PIXEL_CODING_FRACTION_ACCURACY) && PixelQuadTreeInverse.KEY.equals(inverseKey)) {
inverseKey = PixelQuadTreeInverse.KEY_INTERPOLATING;
if (isFractionalEnabled && PixelGeoIndexInverse.KEY.equals(inverseKey)) {
inverseKey = PixelGeoIndexInverse.KEY_INTERPOLATING;
}

final ForwardCoding forwardCoding = ComponentFactory.getForward(forwardKey);
final InverseCoding inverseCoding = ComponentFactory.getInverse(inverseKey);
final ComponentGeoCoding geoCoding = new ComponentGeoCoding(geoRaster, forwardCoding, inverseCoding, GeoChecks.valueOf(geoChecksName), geoCRS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

import org.esa.snap.core.dataio.dimap.spi.DimapPersistable;
Expand All @@ -6,6 +24,10 @@

import static org.esa.snap.core.dataio.geocoding.ComponentGeoCodingPersistable.TAG_COMPONENT_GEO_CODING;

/**
* @deprecated use {@link ComponentGeoCodingPersistenceSpi} instead
*/
@Deprecated
public class ComponentGeoCodingPersistableSpi implements DimapPersistableSpi {
@Override
public boolean canDecode(Element element) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

public enum Discontinuity {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

import org.esa.snap.core.datamodel.GeoPos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

public enum GeoChecks {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

public class GeoRaster {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding;

import org.esa.snap.core.datamodel.GeoPos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding.forward;

import org.esa.snap.core.dataio.geocoding.ForwardCoding;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
*
* Copyright (C) 2020 Brockmann Consult GmbH ([email protected])
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see http://www.gnu.org/licenses/
*
*/

package org.esa.snap.core.dataio.geocoding.forward;

import org.esa.snap.core.dataio.geocoding.ForwardCoding;
Expand Down
Loading