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
Expand Up @@ -204,6 +204,7 @@ public GeoCoding clone() {
clone.inverseMap = inverseMap;
clone.rotator = rotator;
clone.method = method;
clone.datum = datum.clone();

return clone;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,8 @@ public double getDZ() {
}

@Override
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e);
}
public Datum clone() {
return new Datum(name, ellipsoid.clone(), dx, dy, dz);
}

@Override
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ellipsoid inherits from Object, so I doubt that calling super.clone() will have any useful effect.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @deprecated since BEAM 4.7, use {@link org.opengis.referencing.datum.Ellipsoid} instead.
*/
@Deprecated
public class Ellipsoid {
public class Ellipsoid implements Cloneable {

/**
* The standard WGS-72 ellipsoid.
Expand Down Expand Up @@ -66,9 +66,9 @@ public double getSemiMajor() {
}

@Override
public Object clone() {
public Ellipsoid clone() {
try {
return super.clone();
return (Ellipsoid) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.esa.snap.core.datamodel;

import com.bc.ceres.annotation.STTM;
import com.bc.ceres.core.Assert;
import org.esa.snap.core.dataop.maptransf.Datum;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;

/**
* @author Marco Peters
Expand All @@ -32,13 +35,15 @@ public void setUp() throws Exception {

@SuppressWarnings("ConstantConditions")
@Test
@STTM("SNAP-3518")
public void testTransferGeoCoding() {
Scene source = SceneFactory.createScene(new Band("source", ProductData.TYPE_INT8, 10, 10));
Scene target = SceneFactory.createScene(new Band("target", ProductData.TYPE_INT8, 10, 10));

PixelPos pixelPos = gcpGeoCoding.getPixelPos(new GeoPos(4.0, 2.0), null);
assertEquals(5.9, pixelPos.x, 1e-8);
assertEquals(3.2, pixelPos.y, 1e-8);
assertNotNull("getDatum()", gcpGeoCoding.getDatum());

boolean transferred = gcpGeoCoding.transferGeoCoding(source, target, null);

Expand All @@ -48,6 +53,7 @@ public void testTransferGeoCoding() {
pixelPos = geoCoding.getPixelPos(new GeoPos(4.0, 2.0), null);
assertEquals(5.9, pixelPos.x, 1e-8);
assertEquals(3.2, pixelPos.y, 1e-8);
assertNotNull("getDatum()", geoCoding.getDatum());

}

Expand Down Expand Up @@ -144,18 +150,21 @@ public void testCanClone() {
}

@Test
@STTM("SNAP-3518")
public void testClone() {
final PixelPos pixelPos = new PixelPos(6.5, 2.5);

GeoPos geoPos = gcpGeoCoding.getGeoPos(pixelPos, null);
assertEquals(3.3333333333333326, geoPos.lon, 1e-8);
assertEquals(5.555555555555558, geoPos.lat, 1e-8);
assertNotNull("getDatum()", gcpGeoCoding.getDatum());

final GeoCoding clone = gcpGeoCoding.clone();

geoPos = clone.getGeoPos(pixelPos, null);
assertEquals(3.3333333333333326, geoPos.lon, 1e-8);
assertEquals(5.555555555555558, geoPos.lat, 1e-8);
assertNotNull("getDatum()", clone.getDatum());
}

@Test
Expand Down