From d4c5b3dff3a942e2f0afba560edf45bd0ebe3b69 Mon Sep 17 00:00:00 2001 From: Erwan Bocher Date: Wed, 19 Mar 2014 07:06:08 +0100 Subject: [PATCH 1/5] Clean up --- .../FrenchGeocentricNTF2RGF.java | 21 +++++-------------- .../transformation/grids/GeographicGrid.java | 4 ---- .../grids/IGNGeographicGrid.java | 4 ++-- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/cts/op/transformation/FrenchGeocentricNTF2RGF.java b/src/main/java/org/cts/op/transformation/FrenchGeocentricNTF2RGF.java index 53f6f70d..a4c1d019 100644 --- a/src/main/java/org/cts/op/transformation/FrenchGeocentricNTF2RGF.java +++ b/src/main/java/org/cts/op/transformation/FrenchGeocentricNTF2RGF.java @@ -53,7 +53,7 @@ * compatible RGF93.

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 { @@ -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.

The @@ -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); } else { - this.gridPath = "org/cts/op/transformation/grids/"; GRID3D = new IGNGeographicGrid(is, false); } } 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); } } @@ -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"); + InputStream is = FrenchGeocentricNTF2RGF.class.getResourceAsStream("grids/gr3df97a.txt"); GRID3D = new IGNGeographicGrid(is, false); } 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); } } diff --git a/src/main/java/org/cts/op/transformation/grids/GeographicGrid.java b/src/main/java/org/cts/op/transformation/grids/GeographicGrid.java index c0458e7c..4c58e1af 100644 --- a/src/main/java/org/cts/op/transformation/grids/GeographicGrid.java +++ b/src/main/java/org/cts/op/transformation/grids/GeographicGrid.java @@ -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\ - // j\ Date: Thu, 20 Mar 2014 08:16:26 +0100 Subject: [PATCH 2/5] Use logger instead of throw exception to warn a message when the grid reader fails Remove zip option because it's never used Clean the grid file --- .../FrenchGeocentricNTF2RGF.java | 6 +- .../grids/IGNGeographicGrid.java | 61 +++++-------------- .../cts/op/transformation/grids/gr3df97a.txt | 2 +- 3 files changed, 20 insertions(+), 49 deletions(-) diff --git a/src/main/java/org/cts/op/transformation/FrenchGeocentricNTF2RGF.java b/src/main/java/org/cts/op/transformation/FrenchGeocentricNTF2RGF.java index a4c1d019..004fa2d9 100644 --- a/src/main/java/org/cts/op/transformation/FrenchGeocentricNTF2RGF.java +++ b/src/main/java/org/cts/op/transformation/FrenchGeocentricNTF2RGF.java @@ -86,9 +86,9 @@ public FrenchGeocentricNTF2RGF(String gridPath) throws Exception { try { InputStream is = FrenchGeocentricNTF2RGF.class.getResourceAsStream("grids/gr3df97a.txt"); if (is == null) { - GRID3D = new IGNGeographicGrid(new FileInputStream(gridPath + "gr3df97a.txt"), false); + GRID3D = new IGNGeographicGrid(new FileInputStream(gridPath + "gr3df97a.txt")); } else { - GRID3D = new IGNGeographicGrid(is, false); + GRID3D = new IGNGeographicGrid(is); } } catch (Exception e) { throw new Exception( "\nThis problem occured when trying to load the gr3df97a.txt grid file", e); @@ -105,7 +105,7 @@ public FrenchGeocentricNTF2RGF() throws Exception { this.precision = 0.01; try { InputStream is = FrenchGeocentricNTF2RGF.class.getResourceAsStream("grids/gr3df97a.txt"); - GRID3D = new IGNGeographicGrid(is, false); + GRID3D = new IGNGeographicGrid(is); } catch (Exception e) { throw new Exception("\nThis problem occured when trying to load the gr3df97a.txt grid file", e); } diff --git a/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java b/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java index 52dc8c17..ffec65a6 100644 --- a/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java +++ b/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java @@ -36,10 +36,11 @@ import java.io.InputStream; import java.util.concurrent.ConcurrentHashMap; import java.util.StringTokenizer; -import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.cts.cs.GeographicExtent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

Classe representing a Geographic grid as defined by IGN (France).

@@ -74,6 +75,7 @@ */ public class IGNGeographicGrid extends GeographicGrid { + static final Logger LOGGER = LoggerFactory.getLogger(IGNGeographicGrid.class); String gridType; int datumId; int coordinateType; @@ -83,59 +85,30 @@ public class IGNGeographicGrid extends GeographicGrid { String interpolationMode; String precisionUnit; - /** - *

Construct a GeographicGrid from an InputStream representing an IGN - * GeographicGrid. Default value of zip is true.

- * - * @param is - */ - public IGNGeographicGrid(InputStream is) throws Exception { - this(is, true); - } - /** *

Construct a GeographicGrid from an InputStream representing an IGN * GeographicGrid

* * @param is input stream - * @param zip flag indicating if input data is zipped or not */ - public IGNGeographicGrid(InputStream is, boolean zip) throws Exception { + public IGNGeographicGrid(InputStream is) throws Exception { String token; double xmin, xmax, ymin, ymax; ConcurrentHashMap precisionCodes = new ConcurrentHashMap(); - String ignFile; - if (zip) { - try { - // Decompression du fichier Zip - ZipInputStream zis = - new ZipInputStream(new BufferedInputStream(is)); - ZipEntry ze = zis.getNextEntry(); - byte[] bytes = new byte[1024 * 32]; - StringBuilder sb = new StringBuilder(); - int nb; - while ((nb = zis.read(bytes)) != -1) { - sb.append(new String(bytes, 0, nb)); - } - ignFile = sb.toString(); - } catch (IOException e) { - throw e; - } - } else { - byte[] bb = new byte[is.available()]; - is.read(bb); - ignFile = new String(bb); - } - + byte[] bb = new byte[is.available()]; + is.read(bb); + String ignFile = new String(bb); + + StringTokenizer st = new StringTokenizer(ignFile, "\r\n"); String gr = st.nextToken(); String gr1 = st.nextToken(); String gr2 = st.nextToken(); String gr3 = st.nextToken(); //String grid = st.nextToken(); - // First line decoder + // Read the first line StringTokenizer stt = new StringTokenizer(gr, " \t"); if (stt.hasMoreTokens()) { dim = Integer.parseInt(stt.nextToken().substring(2, 3)); @@ -161,7 +134,7 @@ public IGNGeographicGrid(InputStream is, boolean zip) throws Exception { } else { throw new Exception("Missing information in line : " + gr); } - // Second line decoder + // Second line decoder -> grid1 stt = new StringTokenizer(gr1, " \t"); if (stt.hasMoreTokens()) { token = stt.nextToken(); @@ -212,7 +185,7 @@ public IGNGeographicGrid(InputStream is, boolean zip) throws Exception { } else { throw new Exception("Missing cell size in line : " + gr1); } - // Third line decoder + // Third line decoder -> grid2 stt = new StringTokenizer(gr2, " \t"); if (stt.hasMoreTokens()) { token = stt.nextToken(); @@ -225,7 +198,7 @@ public IGNGeographicGrid(InputStream is, boolean zip) throws Exception { } else { throw new Exception("Missing interpolation mode : " + gr2); } - // Forth line decoder + // Forth line decoder -> grid3 stt = new StringTokenizer(gr3, " \t"); if (stt.hasMoreTokens()) { stt.nextToken(); @@ -256,7 +229,7 @@ public IGNGeographicGrid(InputStream is, boolean zip) throws Exception { values = new double[rowNumber][colNumber][dim]; int nbdec = 0; while (st.hasMoreTokens()) { - String[] gg = st.nextToken().trim().split("[ \t]+"); + String[] gg = st.nextToken().split("[ \t]+"); try { double lon = Double.parseDouble(gg[1]); double lat = Double.parseDouble(gg[2]); @@ -264,13 +237,11 @@ public IGNGeographicGrid(InputStream is, boolean zip) throws Exception { for (int i = 0; i < dim; i++) { t[i] = Double.parseDouble(gg[3 + i]); } - String prec = gg[3 + dim]; + //String prec = gg[3 + dim]; nbdec = Math.max(nbdec, gg[3].split("\\.")[1].length()); System.arraycopy(t, 0, values[(int) Math.rint((lat - y0) / dy)][(int) Math.rint((lon - x0) / dx)], 0, dim); } catch (NumberFormatException nfe) { - System.out.println(gg[0]); - System.out.println(gg[1]); - System.out.println(gg[2]); + LOGGER.warn("Cannot parse the number long : " + gg[0] + " lat : " + gg[1] + " dim :" + gg[2]); } } // decimal part size --> scale diff --git a/src/main/resources/org/cts/op/transformation/grids/gr3df97a.txt b/src/main/resources/org/cts/op/transformation/grids/gr3df97a.txt index 0551d460..2a59748e 100644 --- a/src/main/resources/org/cts/op/transformation/grids/gr3df97a.txt +++ b/src/main/resources/org/cts/op/transformation/grids/gr3df97a.txt @@ -17317,4 +17317,4 @@ 00002 10.000000000 51.700000000 -160.233 -64.631 314.594 99 -4398 00002 10.000000000 51.800000000 -160.003 -64.680 314.442 99 -4398 00002 10.000000000 51.900000000 -159.772 -64.729 314.290 99 -4397 -00002 10.000000000 52.000000000 -159.541 -64.778 314.139 99 -4397 +00002 10.000000000 52.000000000 -159.541 -64.778 314.139 99 -4397 \ No newline at end of file From 810c35e1a55dbd19e7bc110b5551b8f7e5b37e04 Mon Sep 17 00:00:00 2001 From: Erwan Bocher Date: Thu, 20 Mar 2014 08:48:08 +0100 Subject: [PATCH 3/5] Fix the grid reader --- .../grids/IGNGeographicGrid.java | 305 +++++++++--------- 1 file changed, 155 insertions(+), 150 deletions(-) diff --git a/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java b/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java index ffec65a6..185bdba3 100644 --- a/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java +++ b/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java @@ -31,12 +31,12 @@ */ package org.cts.op.transformation.grids; -import java.io.BufferedInputStream; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.util.concurrent.ConcurrentHashMap; import java.util.StringTokenizer; -import java.util.zip.ZipInputStream; import org.cts.cs.GeographicExtent; import org.slf4j.Logger; @@ -44,8 +44,8 @@ /** *

Classe representing a Geographic grid as defined by IGN (France).

- * Here is an exemple of a Geographic Grid from IGN with some explanations. GR1D - * REFALT 700 20370201
+ * Here is an exemple of a Geographic Grid from IGN with some explanations. + * GR1D REFALT 700 20370201
* GR1D1 -61.7000 -61.4750 15.8000 15.9250 .0250 .0250
* GR1D2 INTERPOLATION BILINEAIRE
* GR1D3 PREC CM 01:5 02:10 03:20 04:50 99>100
@@ -71,7 +71,7 @@ * For geoid grids :
* N = He - A = Ellipsoidal height - Altitude (above geoid)
* - * @author Michaël Michaud, Jules Party + * @author Michaël Michaud, Jules Party, Erwan Bocher */ public class IGNGeographicGrid extends GeographicGrid { @@ -92,160 +92,165 @@ public class IGNGeographicGrid extends GeographicGrid { * @param is input stream */ public IGNGeographicGrid(InputStream is) throws Exception { - String token; - double xmin, xmax, ymin, ymax; - ConcurrentHashMap precisionCodes = new ConcurrentHashMap(); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + try { + //Read the header + String token; + double xmin, xmax, ymin, ymax; + ConcurrentHashMap precisionCodes = new ConcurrentHashMap(); - byte[] bb = new byte[is.available()]; - is.read(bb); - String ignFile = new String(bb); + // Read the first line + String gr = reader.readLine(); + StringTokenizer stt = new StringTokenizer(gr, " \t"); + if (stt.hasMoreTokens()) { + dim = Integer.parseInt(stt.nextToken().substring(2, 3)); + } else { + throw new IOException("Missing information in line : " + gr); + } + if (stt.hasMoreTokens()) { + gridType = stt.nextToken(); + } else { + throw new Exception("Missing information in line : " + gr); + } + if (stt.hasMoreTokens()) { + datumId = Integer.parseInt(stt.nextToken()); + } else { + throw new Exception("Missing information in line : " + gr); + } + if (stt.hasMoreTokens()) { + token = stt.nextToken(); + coordinateType = Integer.parseInt(token.substring(0, 1)); + geographicDatumId = Integer.parseInt(token.substring(1, 4)); + unit = Integer.parseInt(token.substring(4, 6)); + primeMeridian = Integer.parseInt(token.substring(6, 8)); + } else { + throw new Exception("Missing information in line : " + gr); + } + // Second line decoder -> grid1 - StringTokenizer st = new StringTokenizer(ignFile, "\r\n"); - String gr = st.nextToken(); - String gr1 = st.nextToken(); - String gr2 = st.nextToken(); - String gr3 = st.nextToken(); - //String grid = st.nextToken(); - // Read the first line - StringTokenizer stt = new StringTokenizer(gr, " \t"); - if (stt.hasMoreTokens()) { - dim = Integer.parseInt(stt.nextToken().substring(2, 3)); - } else { - throw new IOException("Missing information in line : " + gr); - } - if (stt.hasMoreTokens()) { - gridType = stt.nextToken(); - } else { - throw new Exception("Missing information in line : " + gr); - } - if (stt.hasMoreTokens()) { - datumId = Integer.parseInt(stt.nextToken()); - } else { - throw new Exception("Missing information in line : " + gr); - } - if (stt.hasMoreTokens()) { - token = stt.nextToken(); - coordinateType = Integer.parseInt(token.substring(0, 1)); - geographicDatumId = Integer.parseInt(token.substring(1, 4)); - unit = Integer.parseInt(token.substring(4, 6)); - primeMeridian = Integer.parseInt(token.substring(6, 8)); - } else { - throw new Exception("Missing information in line : " + gr); - } - // Second line decoder -> grid1 - stt = new StringTokenizer(gr1, " \t"); - if (stt.hasMoreTokens()) { - token = stt.nextToken(); - } else { - throw new Exception("Missing information in line : " + gr1); - } - if (stt.hasMoreTokens() && token.endsWith("1")) { - token = stt.nextToken(); - xmin = Double.parseDouble(token); - x0 = xmin; - } else { - throw new Exception("Missing min longitude in line : " + gr1); - } - if (stt.hasMoreTokens()) { - token = stt.nextToken(); - xmax = Double.parseDouble(token); - xL = xmax; - } else { - throw new Exception("Missing maximum longitude in line : " + gr1); - } - if (stt.hasMoreTokens()) { - token = stt.nextToken(); - ymin = Double.parseDouble(token); - y0 = ymin; - } else { - throw new Exception("Missing minimum latitude in line : " + gr1); - } - if (stt.hasMoreTokens()) { - token = stt.nextToken(); - ymax = Double.parseDouble(token); - yL = ymax; - } else { - throw new Exception("Missing maximum latitude in line : " + gr1); - } - if (stt.hasMoreTokens()) { - token = stt.nextToken(); - dx = Double.parseDouble(token); - double gridWidth = Math.rint((xmax - xmin) * 1000000000000d) / 1000000000000d; - colNumber = (int) Math.rint(gridWidth / dx) + 1; - } else { - throw new Exception("Missing cell size in line : " + gr1); - } - if (stt.hasMoreTokens()) { - token = stt.nextToken(); - dy = Double.parseDouble(token); - double gridHeight = Math.rint((ymax - ymin) * 1000000000000d) / 1000000000000d; - rowNumber = (int) Math.rint(gridHeight / dy) + 1; - } else { - throw new Exception("Missing cell size in line : " + gr1); - } - // Third line decoder -> grid2 - stt = new StringTokenizer(gr2, " \t"); - if (stt.hasMoreTokens()) { - token = stt.nextToken(); - } else { - throw new Exception("Missing information in line : " + gr2); - } - if (stt.hasMoreTokens() && token.endsWith("2")) { - token = stt.nextToken(""); - interpolationMode = token; - } else { - throw new Exception("Missing interpolation mode : " + gr2); - } - // Forth line decoder -> grid3 - stt = new StringTokenizer(gr3, " \t"); - if (stt.hasMoreTokens()) { - stt.nextToken(); - } else { - throw new Exception("Missing information in line : " + gr3); - } - if (stt.hasMoreTokens()) { - stt.nextToken(); - } else { - throw new Exception("Missing information in line : " + gr3); - } - if (stt.hasMoreTokens()) { - stt.nextToken(); - precisionUnit = stt.nextToken(); - } else { - throw new Exception("Missing precision unit in line : " + gr3); - } - if (stt.hasMoreTokens()) { - while (stt.hasMoreTokens()) { + String gr1 = reader.readLine(); + stt = new StringTokenizer(gr1, " \t"); + if (stt.hasMoreTokens()) { + token = stt.nextToken(); + } else { + throw new Exception("Missing information in line : " + gr1); + } + if (stt.hasMoreTokens() && token.endsWith("1")) { + token = stt.nextToken(); + xmin = Double.parseDouble(token); + x0 = xmin; + } else { + throw new Exception("Missing min longitude in line : " + gr1); + } + if (stt.hasMoreTokens()) { + token = stt.nextToken(); + xmax = Double.parseDouble(token); + xL = xmax; + } else { + throw new Exception("Missing maximum longitude in line : " + gr1); + } + if (stt.hasMoreTokens()) { + token = stt.nextToken(); + ymin = Double.parseDouble(token); + y0 = ymin; + } else { + throw new Exception("Missing minimum latitude in line : " + gr1); + } + if (stt.hasMoreTokens()) { + token = stt.nextToken(); + ymax = Double.parseDouble(token); + yL = ymax; + } else { + throw new Exception("Missing maximum latitude in line : " + gr1); + } + if (stt.hasMoreTokens()) { + token = stt.nextToken(); + dx = Double.parseDouble(token); + double gridWidth = Math.rint((xmax - xmin) * 1000000000000d) / 1000000000000d; + colNumber = (int) Math.rint(gridWidth / dx) + 1; + } else { + throw new Exception("Missing cell size in line : " + gr1); + } + if (stt.hasMoreTokens()) { token = stt.nextToken(); - String[] precisionCode = token.split("[:>]"); - if (precisionCode.length == 2) { - precisionCodes.put(precisionCode[0], precisionCode[1]); + dy = Double.parseDouble(token); + double gridHeight = Math.rint((ymax - ymin) * 1000000000000d) / 1000000000000d; + rowNumber = (int) Math.rint(gridHeight / dy) + 1; + } else { + throw new Exception("Missing cell size in line : " + gr1); + } + // Third line decoder -> grid2 + + String gr2 = reader.readLine(); + stt = new StringTokenizer(gr2, " \t"); + if (stt.hasMoreTokens()) { + token = stt.nextToken(); + } else { + throw new Exception("Missing information in line : " + gr2); + } + if (stt.hasMoreTokens() && token.endsWith("2")) { + token = stt.nextToken(""); + interpolationMode = token; + } else { + throw new Exception("Missing interpolation mode : " + gr2); + } + // Forth line decoder -> grid3 + String gr3 = reader.readLine(); + stt = new StringTokenizer(gr3, " \t"); + if (stt.hasMoreTokens()) { + stt.nextToken(); + } else { + throw new Exception("Missing information in line : " + gr3); + } + if (stt.hasMoreTokens()) { + stt.nextToken(); + } else { + throw new Exception("Missing information in line : " + gr3); + } + if (stt.hasMoreTokens()) { + stt.nextToken(); + precisionUnit = stt.nextToken(); + } else { + throw new Exception("Missing precision unit in line : " + gr3); + } + if (stt.hasMoreTokens()) { + while (stt.hasMoreTokens()) { + token = stt.nextToken(); + String[] precisionCode = token.split("[:>]"); + if (precisionCode.length == 2) { + precisionCodes.put(precisionCode[0], precisionCode[1]); + } } } - } - // Read the grid - values = new double[rowNumber][colNumber][dim]; - int nbdec = 0; - while (st.hasMoreTokens()) { - String[] gg = st.nextToken().split("[ \t]+"); - try { - double lon = Double.parseDouble(gg[1]); - double lat = Double.parseDouble(gg[2]); - double[] t = new double[dim]; - for (int i = 0; i < dim; i++) { - t[i] = Double.parseDouble(gg[3 + i]); + // Read the grid + values = new double[rowNumber][colNumber][dim]; + + int nbdec = 0; + String line; + while (null != (line = reader.readLine())) { + String[] gg = line.split("[ \t]+"); + try { + double lon = Double.parseDouble(gg[1]); + double lat = Double.parseDouble(gg[2]); + double[] t = new double[dim]; + for (int i = 0; i < dim; i++) { + t[i] = Double.parseDouble(gg[3 + i]); + } + //String prec = gg[3 + dim]; + nbdec = Math.max(nbdec, gg[3].split("\\.")[1].length()); + System.arraycopy(t, 0, values[(int) Math.rint((lat - y0) / dy)][(int) Math.rint((lon - x0) / dx)], 0, dim); + } catch (NumberFormatException nfe) { + LOGGER.warn("Cannot parse the number long : " + gg[0] + " lat : " + gg[1] + " dim :" + gg[2]); } - //String prec = gg[3 + dim]; - nbdec = Math.max(nbdec, gg[3].split("\\.")[1].length()); - System.arraycopy(t, 0, values[(int) Math.rint((lat - y0) / dy)][(int) Math.rint((lon - x0) / dx)], 0, dim); - } catch (NumberFormatException nfe) { - LOGGER.warn("Cannot parse the number long : " + gg[0] + " lat : " + gg[1] + " dim :" + gg[2]); } + // decimal part size --> scale + scale = (int) Math.rint(Math.pow(10.0, (double) nbdec)); + extent = new GeographicExtent("GG", y0, yL, x0, xL, modulo); + } finally { + reader.close(); } - // decimal part size --> scale - scale = (int) Math.rint(Math.pow(10.0, (double) nbdec)); - extent = new GeographicExtent("GG", y0, yL, x0, xL, modulo); + } } \ No newline at end of file From 43099fc7eb922aadd3642af79705a975abef0188 Mon Sep 17 00:00:00 2001 From: Erwan Bocher Date: Thu, 20 Mar 2014 09:13:37 +0100 Subject: [PATCH 4/5] Fix the grid reader --- .../org/cts/op/transformation/grids/IGNGeographicGrid.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java b/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java index 185bdba3..81bab6ca 100644 --- a/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java +++ b/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java @@ -31,6 +31,7 @@ */ package org.cts.op.transformation.grids; +import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -92,14 +93,13 @@ public class IGNGeographicGrid extends GeographicGrid { * @param is input stream */ public IGNGeographicGrid(InputStream is) throws Exception { - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); try { //Read the header String token; double xmin, xmax, ymin, ymax; ConcurrentHashMap precisionCodes = new ConcurrentHashMap(); - // Read the first line String gr = reader.readLine(); StringTokenizer stt = new StringTokenizer(gr, " \t"); From 0f998ac1e8322585ba65336164a0a2ed13e3dd50 Mon Sep 17 00:00:00 2001 From: Erwan Bocher Date: Thu, 20 Mar 2014 09:14:05 +0100 Subject: [PATCH 5/5] Fix the grid reader --- .../java/org/cts/op/transformation/grids/IGNGeographicGrid.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java b/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java index 81bab6ca..96d4d897 100644 --- a/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java +++ b/src/main/java/org/cts/op/transformation/grids/IGNGeographicGrid.java @@ -31,7 +31,6 @@ */ package org.cts.op.transformation.grids; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream;