Skip to content

Commit

Permalink
Merge pull request #62 from ebocher/fix/gridspath
Browse files Browse the repository at this point in the history
Fix grid reader This PR solved the grid loading with the IGNF projections
  • Loading branch information
nicolas-f committed Mar 21, 2014
2 parents 4497807 + 0f998ac commit f9a7cd0
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* compatible RGF93.<p> It is a geocentric translation which parameters are
* interpolated on a geographic grid.
*
* @author Michaël Michaud, Jules Party
* @author Michaël Michaud, Jules Party, Erwan Bocher
*/
public class FrenchGeocentricNTF2RGF extends AbstractCoordinateOperation {

Expand All @@ -71,10 +71,6 @@ public class FrenchGeocentricNTF2RGF extends AbstractCoordinateOperation {
* The GeographicGrid that define this transformation.
*/
private IGNGeographicGrid GRID3D;
/**
* The grid path to acces the grid used by this transformation.
*/
private String gridPath;

/**
* Geocentric translation with parameters interpolated in a grid.<p> The
Expand All @@ -88,18 +84,14 @@ public FrenchGeocentricNTF2RGF(String gridPath) throws Exception {
super(opId);
this.precision = 0.01;
try {
InputStream is;

is = FrenchGeocentricNTF2RGF.class.getClassLoader().getResourceAsStream("org/cts/op/transformation/grids/gr3df97a.txt");
InputStream is = FrenchGeocentricNTF2RGF.class.getResourceAsStream("grids/gr3df97a.txt");
if (is == null) {
this.gridPath = gridPath;
GRID3D = new IGNGeographicGrid(new FileInputStream(gridPath + "gr3df97a.txt"), false);
GRID3D = new IGNGeographicGrid(new FileInputStream(gridPath + "gr3df97a.txt"));
} else {
this.gridPath = "org/cts/op/transformation/grids/";
GRID3D = new IGNGeographicGrid(is, false);
GRID3D = new IGNGeographicGrid(is);
}
} catch (Exception e) {
throw new Exception(e.getMessage() + "\nThis problem occured when trying to load the gr3df97a.txt grid file, using this path : " + gridPath);
throw new Exception( "\nThis problem occured when trying to load the gr3df97a.txt grid file", e);
}
}

Expand All @@ -110,15 +102,12 @@ public FrenchGeocentricNTF2RGF(String gridPath) throws Exception {
*/
public FrenchGeocentricNTF2RGF() throws Exception {
super(opId);
this.gridPath = "org/cts/op/transformation/grids/";
this.precision = 0.01;
try {
InputStream is;

is = FrenchGeocentricNTF2RGF.class.getClassLoader().getResourceAsStream("org/cts/op/transformation/grids/gr3df97a.txt");
GRID3D = new IGNGeographicGrid(is, false);
InputStream is = FrenchGeocentricNTF2RGF.class.getResourceAsStream("grids/gr3df97a.txt");
GRID3D = new IGNGeographicGrid(is);
} catch (Exception e) {
throw new Exception(e.getMessage() + "\nThis problem occured when trying to load the gr3df97a.txt grid file, using this path : " + gridPath);
throw new Exception("\nThis problem occured when trying to load the gr3df97a.txt grid file", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@ public double[][][] getValues() {
* @param longitude the longitude
* @return the interpolated value as a double
*/
// Bug corrigé le 15/11/03 : les indices de grille i+1 ou j+1 provoquent des
// IndexOutOfBoundsException --> remplacé par
// i\<nbL-1?i+1:i<br>
// j\<nbC-1?j+1:j
public double[] bilinearInterpolation(double latitude, double longitude)
throws OutOfExtentException {
if (!extent.isInside(latitude, longitude)) {
Expand Down
Loading

0 comments on commit f9a7cd0

Please sign in to comment.