changeset 2377:d183ae164cfc

Make parsing of official numbers out of STA files being enabled with new system property. flys-backend/trunk@3639 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 10 Jan 2012 10:33:14 +0000
parents 918877ee70e7
children c5d83366d0b1
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/backend/SpatialInfo.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/StaFileParser.java
diffstat 3 files changed, 27 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Thu Jan 05 15:00:21 2012 +0000
+++ b/flys-backend/ChangeLog	Tue Jan 10 10:33:14 2012 +0000
@@ -1,3 +1,14 @@
+2012-01-10	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/importer/parsers/StaFileParser.java:
+	  Introduced boolean system property 'flys.backend.sta.parse.gauge.numbers'
+	  default: false. If set the official number is parsed out of
+	  the first line of the STA files. This leads to problems with the
+	  data of the Elbe river.
+
+	* src/main/java/de/intevation/flys/backend/SpatialInfo.java: Removed
+	  superfluous import.
+
 2012-01-05	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* doc/schema/postgresql-spatial.sql: Fixed table hws.
--- a/flys-backend/src/main/java/de/intevation/flys/backend/SpatialInfo.java	Thu Jan 05 15:00:21 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/backend/SpatialInfo.java	Tue Jan 10 10:33:14 2012 +0000
@@ -7,8 +7,6 @@
 import org.hibernate.Query;
 import org.hibernate.Session;
 
-import com.vividsolutions.jts.geom.LineString;
-
 import de.intevation.flys.backend.SessionFactoryProvider;
 import de.intevation.flys.model.Building;
 import de.intevation.flys.model.CrossSectionTrack;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/StaFileParser.java	Thu Jan 05 15:00:21 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/StaFileParser.java	Tue Jan 10 10:33:14 2012 +0000
@@ -30,6 +30,9 @@
     public static final String TYPES =
         System.getProperty("flys.backend.main.value.types", "QWTD");
 
+    public static final boolean PARSE_GAUGE_NUMBERS =
+        Boolean.getBoolean("flys.backend.sta.parse.gauge.numbers");
+
     public static final Pattern QWTD_ =
         Pattern.compile("\\s*([^\\s]+)\\s+([^\\s]+)\\s+([" +
             Pattern.quote(TYPES) + "]).*");
@@ -60,16 +63,21 @@
                 log.warn("first line in STA file is too short.");
                 return false;
             }
-            String gaugeNumberString = line.substring( 0, 16).trim();
-            String gaugeName         = line.substring(16, 37).trim();
+
+            String gaugeName = line.substring(16, 37).trim();
 
             Long gaugeNumber = null;
-            try {
-                gaugeNumber = Long.parseLong(gaugeNumberString);
-            }
-            catch (NumberFormatException nfe) {
-                log.warn("'" + gaugeNumberString +
-                    "' is not a valid long number.");
+
+            if (PARSE_GAUGE_NUMBERS) {
+                String gaugeNumberString = line.substring(0, 16).trim();
+
+                try {
+                    gaugeNumber = Long.parseLong(gaugeNumberString);
+                }
+                catch (NumberFormatException nfe) {
+                    log.warn("'" + gaugeNumberString +
+                        "' is not a valid long number.");
+                }
             }
 
             gauge.setName(gaugeName);

http://dive4elements.wald.intevation.org