Mercurial > dive4elements > river
changeset 5088:2b24073e80d9 mapgenfix
Merge with default branch
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 25 Feb 2013 11:55:34 +0100 |
parents | cbfdd7376009 (current diff) b87e504f916e (diff) |
children | cfc5540a4eec |
files | flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java |
diffstat | 33 files changed, 403 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/artifacts/fixanalysis.xml Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-artifacts/doc/conf/artifacts/fixanalysis.xml Mon Feb 25 11:55:34 2013 +0100 @@ -304,6 +304,11 @@ <facet name="hyk" description="hyks"/> </facets> </outputmode> + <outputmode name="fix_wq_curve_at_export" description="output.fix_wq_curve_at_export" mime-type="text/plain" type="export"> + <facets> + <facet name="at" description="facet.fix_wq_curve_export.at"/> + </facets> + </outputmode> <outputmode name="fix_waterlevel_export" description="output.fix_waterlevel_export" mine-type="text/plain" type="export"> <facets> <facet name="csv" description="facet.waterlevel_export.csv" />
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java Mon Feb 25 11:55:34 2013 +0100 @@ -409,8 +409,9 @@ File dir, WSPLGENJob job ) { + String river = artifact.getDataAsString("river"); String geoJSON = artifact.getDataAsString("uesk.barriers"); - String srid = FLYSUtils.getRiverSrid(artifact); + String srid = FLYSUtils.getRiverDGMSrid(river); String srs = "EPSG:" + srid; if (geoJSON == null || geoJSON.length() == 0) { @@ -712,7 +713,7 @@ } String river = artifact.getDataAsString("river"); - String srid = FLYSUtils.getRiverSrid(artifact); + String srid = FLYSUtils.getRiverDGMSrid(river); String srs = "EPSG:" + srid; Floodplain plain = Floodplain.getFloodplain(river);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixRealizingCompute.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixRealizingCompute.java Mon Feb 25 11:55:34 2013 +0100 @@ -130,6 +130,9 @@ new DataFacet(PDF, "PDF data", ComputeType.ADVANCE, hash, id)); } + facets.add( + new DataFacet(AT, "AT data", ComputeType.ADVANCE, hash, id)); + facets.add(new FixWQCurveFacet( 0, Resources.getMsg(meta, I18N_WQ_CURVE, I18N_WQ_CURVE)));
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java Mon Feb 25 11:55:34 2013 +0100 @@ -376,7 +376,7 @@ AttributeParser parser = new AttributeParser(oldAttrs); CollectionAttribute cAttr = parser.getCollectionAttribute(); - Output output = cAttr.getOutput(name); + Output output = cAttr.getOutput(name); Settings settings = null; if (output != null) { settings = output.getSettings();
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixATExport.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixATExport.java Mon Feb 25 11:55:34 2013 +0100 @@ -15,6 +15,7 @@ import de.intevation.flys.artifacts.model.Parameters; import de.intevation.flys.artifacts.model.fixings.FixAnalysisResult; +import de.intevation.flys.artifacts.model.fixings.FixResult; import de.intevation.flys.exports.AbstractExporter; @@ -46,8 +47,8 @@ if (data instanceof CalculationResult) { CalculationResult cr = (CalculationResult)data; Object resData = cr.getData(); - if (resData instanceof FixAnalysisResult) { - this.parameters = ((FixAnalysisResult)resData).getParameters(); + if (resData instanceof FixResult) { + this.parameters = ((FixResult)resData).getParameters(); } } else {
--- a/flys-backend/contrib/run_hydr_morph.sh Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/contrib/run_hydr_morph.sh Mon Feb 25 11:55:34 2013 +0100 @@ -24,30 +24,31 @@ IMPORTER_MAINVALUE_TYPES=QWTD IMPORTER_ANNOTATION_TYPES="conf/annotation-types.xml" -IMPORTER_SKIP_GAUGES=false -IMPORTER_SKIP_HISTORICAL_DISCHARGE_GAUGES=false IMPORTER_SKIP_ANNOTATIONS=false -IMPORTER_SKIP_WST=false -IMPORTER_SKIP_PRFS=false +IMPORTER_SKIP_BWASTR=false IMPORTER_SKIP_DA50S=false IMPORTER_SKIP_DA66S=false -IMPORTER_SKIP_W80S=false -IMPORTER_SKIP_HYKS=false IMPORTER_SKIP_EXTRA_WST=false IMPORTER_SKIP_FIXATIONS=false -IMPORTER_SKIP_OFFICIAL_LINES=false IMPORTER_SKIP_FLOOD_WATER=false IMPORTER_SKIP_FLOOD_PROTECTION=false +IMPORTER_SKIP_GAUGES=false +IMPORTER_SKIP_HISTORICAL_DISCHARGE_GAUGES=false +IMPORTER_SKIP_HYKS=false +IMPORTER_SKIP_OFFICIAL_LINES=false +IMPORTER_SKIP_PRFS=false +IMPORTER_SKIP_W80S=false +IMPORTER_SKIP_WST=false IMPORTER_SKIP_BED_HEIGHT_SINGLE=false IMPORTER_SKIP_BED_HEIGHT_EPOCH=false -IMPORTER_SKIP_SEDIMENT_DENSITY=false +IMPORTER_SKIP_FLOW_VELOCITY=false IMPORTER_SKIP_MORPHOLOGICAL_WIDTH=false -IMPORTER_SKIP_FLOW_VELOCITY=false +IMPORTER_SKIP_SEDIMENT_DENSITY=false IMPORTER_SKIP_SEDIMENT_YIELD=false +IMPORTER_SKIP_SQ_RELATION=false IMPORTER_SKIP_WATERLEVELS=false IMPORTER_SKIP_WATERLEVEL_DIFFERENCES=false -IMPORTER_SKIP_SQ_RELATION=false ##################################################################### #MIN_MEMORY="8192m" @@ -80,29 +81,30 @@ -Dflys.backend.main.value.types=$IMPORTER_MAINVALUE_TYPES \ -Dflys.backend.importer.annotation.types=$IMPORTER_ANNOTATION_TYPES \ -Dflys.backend.importer.dry.run=$IMPORTER_DRY_RUN \ - -Dflys.backend.importer.skip.historical.discharge.tables=$IMPORTER_SKIP_HISTORICAL_DISCHARGE_GAUGES \ - -Dflys.backend.importer.skip.gauges=$IMPORTER_SKIP_GAUGES \ -Dflys.backend.importer.skip.annotations=$IMPORTER_SKIP_ANNOTATIONS \ - -Dflys.backend.importer.skip.prfs=$IMPORTER_SKIP_PRFS \ - -Dflys.backend.importer.skip.w80s=$IMPORTER_SKIP_W80S \ + -Dflys.backend.importer.skip.bed.height.single=$IMPORTER_SKIP_BED_HEIGHT_SINGLE \ + -Dflys.backend.importer.skip.bed.height.epoch=$IMPORTER_SKIP_BED_HEIGHT_EPOCH \ + -Dflys.backend.importer.skip.bwastr=$IMPORTER_SKIP_BWASTR \ -Dflys.backend.importer.skip.da50s=$IMPORTER_SKIP_DA50S \ -Dflys.backend.importer.skip.da66s=$IMPORTER_SKIP_DA66S \ - -Dflys.backend.importer.skip.hyks=$IMPORTER_SKIP_HYKS \ - -Dflys.backend.importer.skip.wst=$IMPORTER_SKIP_WST \ -Dflys.backend.importer.skip.extra.wsts=$IMPORTER_SKIP_EXTRA_WST \ -Dflys.backend.importer.skip.fixations=$IMPORTER_SKIP_FIXATIONS \ - -Dflys.backend.importer.skip.official.lines=$IMPORTER_SKIP_OFFICIAL_LINES \ -Dflys.backend.importer.skip.flood.water=$IMPORTER_SKIP_FLOOD_WATER \ -Dflys.backend.importer.skip.flood.protection=$IMPORTER_SKIP_FLOOD_PROTECTION \ - -Dflys.backend.importer.skip.bed.height.single=$IMPORTER_SKIP_BED_HEIGHT_SINGLE \ - -Dflys.backend.importer.skip.bed.height.epoch=$IMPORTER_SKIP_BED_HEIGHT_EPOCH \ + -Dflys.backend.importer.skip.flow.velocity=$IMPORTER_SKIP_FLOW_VELOCITY \ + -Dflys.backend.importer.skip.gauges=$IMPORTER_SKIP_GAUGES \ + -Dflys.backend.importer.skip.historical.discharge.tables=$IMPORTER_SKIP_HISTORICAL_DISCHARGE_GAUGES \ + -Dflys.backend.importer.skip.hyks=$IMPORTER_SKIP_HYKS \ + -Dflys.backend.importer.skip.morphological.width=$IMPORTER_SKIP_MORPHOLOGICAL_WIDTH \ + -Dflys.backend.importer.skip.official.lines=$IMPORTER_SKIP_OFFICIAL_LINES \ + -Dflys.backend.importer.skip.prfs=$IMPORTER_SKIP_PRFS \ -Dflys.backend.importer.skip.sediment.density=$IMPORTER_SKIP_SEDIMENT_DENSITY \ - -Dflys.backend.importer.skip.morphological.width=$IMPORTER_SKIP_MORPHOLOGICAL_WIDTH \ - -Dflys.backend.importer.skip.flow.velocity=$IMPORTER_SKIP_FLOW_VELOCITY \ -Dflys.backend.importer.skip.sediment.yield=$IMPORTER_SKIP_SEDIMENT_YIELD \ + -Dflys.backend.importer.skip.sq.relation=$IMPORTER_SKIP_SQ_RELATION \ + -Dflys.backend.importer.skip.w80s=$IMPORTER_SKIP_W80S \ -Dflys.backend.importer.skip.waterlevels=$IMPORTER_SKIP_WATERLEVELS \ -Dflys.backend.importer.skip.waterlevel.differences=$IMPORTER_SKIP_WATERLEVEL_DIFFERENCES \ - -Dflys.backend.importer.skip.sq.relation=$IMPORTER_SKIP_SQ_RELATION \ + -Dflys.backend.importer.skip.wst=$IMPORTER_SKIP_WST \ -Dflys.backend.user=$BACKEND_USER \ -Dflys.backend.password=$BACKEND_PASS \ -Dflys.backend.url=$BACKEND_URL \
--- a/flys-backend/doc/README.txt Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/doc/README.txt Mon Feb 25 11:55:34 2013 +0100 @@ -18,8 +18,9 @@ System-Properties gesteuert werden. Diese werden im Allgemeinen in der Form -Dkey=value angegeben. -Will man z.B. mit dem Importer nur in simulierierten Import -durchführen, dann kann dies über die Angabe von +Will man z.B. mit dem Importer nur einen simulierten Import +durchführen (also nicht in die Datenbank geschrieben werden), +dann kann dies über die Angabe von '-Dflys.backend.importer.dry.run=true' erfolgen. !!! Der Import geht wie Desktop-FLYS davon aus, dass die Dateien
--- a/flys-backend/doc/documentation/de/importer-hydr-morph.tex Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/doc/documentation/de/importer-hydr-morph.tex Mon Feb 25 11:55:34 2013 +0100 @@ -32,7 +32,7 @@ \end{lstlisting} Auf gleiche Weise können dem Importer sämtliche Optionen zur Konfiguration -beim Start mitgegeben werden. Im folgenden werden die möglichen System-Properties und +beim Start mitgegeben werden. Im Folgenden werden die möglichen System-Properties und ihre Auswirkung auf den Import genauer beschrieben. In den Kapiteln \ref{configuration} und \ref{start-hydr} wird zur Einfachheit jedoch ein Shellskript verwendet, das eine Standardkonfiguration vorgibt und den Importer @@ -53,6 +53,12 @@ festgelegt, anhand derer die Klassifikation während des Import-Vorgangs vorgenommen wird. Details hierzu befinden sich im Kapitel \ref{annotation-types}. +\subsubsection{Bundeswasserstraßen-IDs} +Der Import und die Zuweisung der Bundeswasserstraßen-IDs kann mit +\textbf{-Dflys.backend.importer.skip.bwastr=true} unterbunden werden. +Beim Import wird davon ausgegangen dass sich die Datei \textbf{BWASTR\_ID.csv} +neben der oder den zu importierenden gew-Dateien befindet. + \subsubsection{Pegel, Stammdaten (*.glt, *.sta-Dateien)} Der Import von Pegel- und Stammdaten kann mit \textbf{'-Dflys.backend.importer.skip.gauges=true'} unterdrückt werden. Die .glt-Datei, die neben der .wst-Datei liegt, wird zuerst @@ -65,7 +71,7 @@ unterdrückt werden. Diese Flagge wird nur ausgewertet, wenn überhaupt Pegel-Daten (siehe oben) importiert werden. -Mittels \textbf{-Dflys.backend.sta.parse.gauge.numbers=true'} wird versucht, die +Mittels \textbf{-Dflys.backend.sta.parse.gauge.numbers=true} wird versucht, die offiziellen Pegelnummern aus den Stammdaten zu extrahieren. \textbf{Dies ist mit Vorsicht zu behandeln, denn die meisten STA-Dateien enthalten invalide Pegelnummern.} @@ -100,6 +106,13 @@ eines Längen- und eines MD5-Summen-Vergleichs inhaltliche Duplikate ausgeschlossen. +\subsubsection{Profilspuren (*.w80-Dateien)} +Der Import von W80-Profilspuren kann mit \textbf{-Dflys.backend.importer.skip.w80s=true} +unterdrückt werden. Es werden rekursiv alle *.w80-Dateien aus \textit{../../..} +relativ zur gewaesser.wst-Datei betrachtet. Vor dem Import werden mit Hilfe +eines Längen- und eines MD5-Summen-Vergleichs inhaltliche Duplikate +ausgeschlossen. + \subsubsection{Hydraulische Kennzahlen (*.hyk)} Der Import von hydraulischen Kennzahlen kann mit \textbf{-Dflys.backend.importer.skip.hyks=true} unterdrückt werden. Es werden rekursiv alle *.hyk-Dateien aus \textit{../../..} relativ zur
--- a/flys-backend/doc/documentation/de/importer-manual.tex Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/doc/documentation/de/importer-manual.tex Mon Feb 25 11:55:34 2013 +0100 @@ -19,6 +19,8 @@ \usepackage{listings} \usepackage[hyperindex=true, bookmarks=true, breaklinks=true, colorlinks=true, linkcolor=red,bookmarksopen]{hyperref} +% German Silbentrennung +\usepackage[ngerman]{babel} %---------------------------------------------- % Document DATE and VERSION
--- a/flys-backend/doc/documentation/de/overview.tex Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/doc/documentation/de/overview.tex Mon Feb 25 11:55:34 2013 +0100 @@ -2,7 +2,7 @@ Diese Dokumentation beschreibt die von Intevation entwickelten Werkzeuge zum Importieren der hydrologischen, morphologischen und geodätischen Daten der BfG. -Die im folgenden\\ beschriebenen Werkzeuge zum Importieren der fachlichen und +Die im Folgenden\\ beschriebenen Werkzeuge zum Importieren der fachlichen und geodätischen Daten sind speziell auf das Verzeichnissystem der BfG ausgerichtet. Dabei wird angenommen, dass sich das Verzeichnis eines Gewässers auf oberster Ebene in drei Unterverzeichnisse aufgliedert: @@ -22,10 +22,11 @@ \subsubsection{Entpacken des Datenimporters} Damit die Software performant und korrekt ausgeführt werden kann, ist es -erforderlich, dass sie auf dem selben System installiert und ausgeführt wird, -wie auch die Datenbank installiert ist. Sollten Sie das Paket nicht auf dem +erforderlich, dass sie auf dem selben System wie die Datenbank installiert +und ausgeführt wird. +Sollten Sie das Paket nicht auf dem Zielsystem selbst heruntergeladen haben, sind ggf. weitere Werkzeuge notwendig. -Im Fall, dass das Sie von einem Windows System auf das Zielsystem zugreifen +Wenn Sie von einem Windows System auf das Zielsystem zugreifen wollen, können Sie beispielsweise folgende Werkzeuge verwenden: \begin{itemize} @@ -91,7 +92,7 @@ Zum Einspielen dieser Schemata setzen Sie folgende Befehle auf der Kommandozeile ab. Beachten Sie, dass $sqlplus$ im Pfad liegen muss, und der Linux-Nutzer -dies Kommando ausführen können muss. Außerdem sind $benutzername$ und $passwort$ +dieses Kommando ausführen können muss. Außerdem sind $benutzername$ und $passwort$ entsprechend Ihres Datenbank-Zugangs anzupassen. \begin{lstlisting}
--- a/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/Config.java Mon Feb 25 11:55:34 2013 +0100 @@ -17,6 +17,9 @@ public static final String SKIP_GAUGES = "flys.backend.importer.skip.gauges"; + public static final String SKIP_BWASTR = + "flys.backend.importer.skip.bwastr"; + public static final String SKIP_HISTORICAL_DISCHARGE_TABLES = "flys.backend.importer.skip.historical.discharge.tables"; @@ -119,6 +122,10 @@ return getFlag(SKIP_HISTORICAL_DISCHARGE_TABLES); } + public boolean skipBWASTR() { + return getFlag(SKIP_BWASTR); + } + public boolean skipAnnotations() { return getFlag(SKIP_ANNOTATIONS); }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportCrossSectionLine.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportCrossSectionLine.java Mon Feb 25 11:55:34 2013 +0100 @@ -25,9 +25,9 @@ } }; - protected Double km; + protected Double km; protected ImportCrossSection crossSection; - protected List<XY> points; + protected List<XY> points; protected CrossSectionLine peer;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon Feb 25 11:55:34 2013 +0100 @@ -46,6 +46,7 @@ /** Import all river-related data (files) that can be found. */ public class ImportRiver { + /** Private logger. */ private static Logger log = Logger.getLogger(ImportRiver.class); public static final String PEGEL_GLT = "PEGEL.GLT"; @@ -105,9 +106,11 @@ protected String name; - protected File wstFile; + protected Long officialNumber; - protected File bbInfoFile; + protected File wstFile; + + protected File bbInfoFile; protected List<ImportGauge> gauges; @@ -155,6 +158,7 @@ protected AnnotationClassifier annotationClassifier; + /** Database-mapped River instance. */ protected River peer; @@ -233,6 +237,14 @@ this.name = name; } + public Long getOfficialNumber() { + return this.officialNumber; + } + + public void setOfficialNumber(Long officialNumber) { + this.officialNumber = officialNumber; + } + public File getWstFile() { return wstFile; } @@ -329,6 +341,13 @@ } } + public void storeOfficialNumber() { + if (Config.INSTANCE.skipBWASTR()) { + log.info("skip storing official number."); + return; + } + getPeer().setOfficialNumber(officialNumber); + } public void parseBedHeight() throws IOException { File minfoDir = getMinfoDir(); @@ -541,7 +560,12 @@ parser.parse(file); } - waterlevels = parser.getWaterlevels(); + // The parsed ImportWaterlevels are converted to + // 'fixation'-wsts now. + for(ImportWst iw: parser.exportWsts()) { + //iw.setDescription("CSV" + iw.getDescription()); + fixations.add(iw); + } } protected void parseMeasurementStations() throws IOException { @@ -1058,6 +1082,7 @@ storeWaterlevelDifferences(); storeMeasurementStations(); storeSQRelations(); + storeOfficialNumber(); } public void storeWstUnit() { @@ -1097,8 +1122,8 @@ } public void storeFixations() { - if (!Config.INSTANCE.skipFixations()) { - log.info("store fixation wsts"); + if (!Config.INSTANCE.skipFixations() || !Config.INSTANCE.skipWaterlevels()) { + log.info("store fixation wsts and/or csvs"); River river = getPeer(); for (ImportWst wst: fixations) { log.debug("name: " + wst.getDescription()); @@ -1435,13 +1460,19 @@ Session session = ImporterSession.getInstance().getDatabaseSession(); Query query = session.createQuery("from River where name=:name"); - Unit u = wstUnit.getPeer(); + Unit u = null; + if (wstUnit != null) { + u = wstUnit.getPeer(); + } query.setString("name", name); List<River> rivers = query.list(); if (rivers.isEmpty()) { log.info("Store new river '" + name + "'"); peer = new River(name, u); + if (!Config.INSTANCE.skipBWASTR()) { + peer.setOfficialNumber(officialNumber); + } session.save(peer); } else {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevel.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevel.java Mon Feb 25 11:55:34 2013 +0100 @@ -31,14 +31,26 @@ this.description = description; } + public String getDescription() { + return this.description; + } + public void setUnit(ImportUnit unit) { this.unit = unit; } + public ImportUnit getUnit() { + return this.unit; + } + public void addValue(ImportWaterlevelQRange qRange) { this.qRanges.add(qRange); } + public List<ImportWaterlevelQRange> getQRanges() { + return this.qRanges; + } + public void storeDependencies(River river) { log.info("store dependencies");
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelQRange.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelQRange.java Mon Feb 25 11:55:34 2013 +0100 @@ -18,7 +18,6 @@ private static final Logger log = Logger.getLogger(ImportWaterlevelQRange.class); - private Double q; private List<ImportWaterlevelValue> values; @@ -35,6 +34,13 @@ this.values.add(value); } + public Double getQ() { + return this.q; + } + + public List<ImportWaterlevelValue> getValues() { + return values; + } public void storeDependencies(Waterlevel waterlevel) { log.info("store dependencies");
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelValue.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWaterlevelValue.java Mon Feb 25 11:55:34 2013 +0100 @@ -29,6 +29,15 @@ } + public Double getStation() { + return this.station; + } + + + public Double getW() { + return this.w; + } + public WaterlevelValue getPeer(WaterlevelQRange qRange) { if (peer == null) { Session session = ImporterSession.getInstance().getDatabaseSession();
--- a/flys-backend/src/main/java/de/intevation/flys/importer/Importer.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/Importer.java Mon Feb 25 11:55:34 2013 +0100 @@ -2,13 +2,16 @@ import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.flys.importer.parsers.AnnotationClassifier; +import de.intevation.flys.importer.parsers.BundesWasserStrassenParser; import de.intevation.flys.importer.parsers.InfoGewParser; -import de.intevation.flys.importer.parsers.AnnotationClassifier; import java.io.File; import java.io.IOException; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.sql.SQLException; @@ -19,12 +22,16 @@ import org.w3c.dom.Document; +import de.intevation.flys.utils.StringUtil; -/** Data Importer. */ +/** Data Importer. Further processing happens per-river. */ public class Importer { + /** Private logger. */ private static Logger log = Logger.getLogger(Importer.class); + private static String BWASTR_ID_CSV_FILE = "BWASTR_ID.csv"; + protected List<ImportRiver> rivers; public Importer() { @@ -42,6 +49,7 @@ this.rivers = rivers; } + /** Write rivers and their dependencies/dependants to db. */ public void writeRivers() { log.debug("write rivers started"); @@ -121,10 +129,16 @@ log.info("Start parsing rivers..."); + File bwastrFile = null; + for (String gew: args) { log.info("parsing info gew file: " + gew); + File gewFile = new File(gew); + if (bwastrFile == null) { + bwastrFile = new File(gewFile.getParentFile(), BWASTR_ID_CSV_FILE); + } try { - infoGewParser.parse(new File(gew)); + infoGewParser.parse(gewFile); } catch (IOException ioe) { log.error("error while parsing gew: " + gew); @@ -134,14 +148,45 @@ String gew = Config.INSTANCE.getInfoGewFile(); if (gew != null && gew.length() > 0) { log.info("parsing info gew file: " + gew); + File gewFile = new File(gew); + if (bwastrFile == null) { + bwastrFile = new File(gewFile.getParentFile(), BWASTR_ID_CSV_FILE); + } try { - infoGewParser.parse(new File(gew)); + infoGewParser.parse(gewFile); } catch (IOException ioe) { log.error("error while parsing gew: " + gew); } } + // Look for official numbers. + BundesWasserStrassenParser bwastrIdParser = + new BundesWasserStrassenParser(); + + // Read bwastFile (river-dir + BWASTR_ID_CSV_FILE). + if (!Config.INSTANCE.skipBWASTR()) { + try{ + bwastrIdParser.parse(bwastrFile); + HashMap<String,Long> map = bwastrIdParser.getMap(); + + // Now link rivers with official numbers. + for(ImportRiver river: infoGewParser.getRivers()) { + for(Map.Entry<String, Long> entry: map.entrySet()) { + if (StringUtil.containsIgnoreCase(entry.getKey(), river.getName())) { + river.setOfficialNumber(entry.getValue()); + log.debug(river.getName() + " is mapped to bwastr " + entry.getValue()); + } + } + } + } catch (IOException ioe) { + log.warn("BWASTR-file could not be loaded."); + } + } + else { + log.debug("skip reading BWASTR_ID.csv"); + } + if (!Config.INSTANCE.dryRun()) { new Importer(infoGewParser.getRivers()).writeToDatabase(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BundesWasserStrassenParser.java Mon Feb 25 11:55:34 2013 +0100 @@ -0,0 +1,85 @@ +package de.intevation.flys.importer.parsers; + +import java.math.BigDecimal; + +import java.text.NumberFormat; +import java.text.ParseException; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.log4j.Logger; + +import de.intevation.flys.importer.ImportMorphWidth; +import de.intevation.flys.importer.ImportMorphWidthValue; +import de.intevation.flys.importer.ImportUnit; + +/** Parse CSV file that contains official numbers for rivers. */ +public class BundesWasserStrassenParser extends LineParser { + + /** Private logger. */ + private static final Logger logger = + Logger.getLogger(BundesWasserStrassenParser.class); + + /** Map from rivernames to Official numbers. */ + private HashMap<String,Long> numberMap; + + + public BundesWasserStrassenParser() { + numberMap = new HashMap<String,Long>(); + } + + + /** No need to reset. */ + @Override + protected void reset() { + } + + + /** No action needed on eof. */ + @Override + protected void finish() { + } + + + /** Handle a line of the bwastr-id file. */ + @Override + protected void handleLine(int lineNum, String line) { + String[] vals = line.split(","); + if (vals.length != 2) { + logger.warn("Invalid bwastr-id line:\n" + line); + return; + } + try{ + String name = unwrap(vals[0].toLowerCase()); + String numberStr = unwrap(vals[1]); + Long number = Long.valueOf(numberStr); + numberMap.put(name, number); + } + catch (NumberFormatException e) { + logger.warn("Invalid number in bwastr-id line:\n" + line); + } + } + + + /** Get river->official number mapping. */ + public HashMap<String,Long> getMap() { + return numberMap; + } + + + /** Remove leading and trailing quotes. */ + protected String unwrap(String input) { + if (input.startsWith("\"")) { + input = input.substring(1); + } + if (input.endsWith("\"")) { + input = input.substring(0, input.length() - 1); + } + return input; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/InfoGewParser.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/InfoGewParser.java Mon Feb 25 11:55:34 2013 +0100 @@ -57,7 +57,7 @@ return f.replace("\\", "/").replace("/", File.separator); } - /* Handle a gew, wst, or bb_info file. */ + /** Handle a gew, wst, or bb_info file. */ public void parse(File file) throws IOException { LineNumberReader in = null;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MorphologicalWidthParser.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/MorphologicalWidthParser.java Mon Feb 25 11:55:34 2013 +0100 @@ -22,14 +22,11 @@ private static final Logger log = Logger.getLogger(MorphologicalWidthParser.class); - public static final NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); - public static final Pattern META_UNIT = Pattern.compile("^Einheit: \\[(.*)\\].*"); - protected List<ImportMorphWidth> morphWidths; protected ImportMorphWidth current;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WaterlevelParser.java Mon Feb 25 11:55:34 2013 +0100 @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.math.BigDecimal; import java.text.NumberFormat; import java.text.ParseException; import java.util.ArrayList; @@ -16,7 +17,19 @@ import de.intevation.flys.importer.ImportWaterlevelQRange; import de.intevation.flys.importer.ImportWaterlevelValue; +import de.intevation.flys.importer.ImportWstColumn; +import de.intevation.flys.importer.ImportRange; +import de.intevation.flys.importer.ImportWst; +import de.intevation.flys.importer.ImportWstQRange; + +/** + * Parse CSV Waterlevel files. + * As these waterlevels are probably used in fixation analysis + * only, functionality to export them to "fixation"-wsts + * has been added (the ImportWaterlevel*- stuff is actually + * not needed to do so.) + */ public class WaterlevelParser extends LineParser { private static final Logger log = Logger.getLogger(WaterlevelParser.class); @@ -30,7 +43,6 @@ public static final Pattern META_UNIT = Pattern.compile("^Einheit: \\[(.*)\\].*"); - private List<ImportWaterlevel> waterlevels; private ImportWaterlevel current; @@ -45,6 +57,56 @@ } + /** + * Create ImportWst objects from ImportWaterlevel + * objects. + */ + public List<ImportWst> exportWsts() { + List<ImportWst> wsts = new ArrayList<ImportWst>(); + for(ImportWaterlevel waterlevel: getWaterlevels()) { + String description = waterlevel.getDescription(); + ImportWst wst = new ImportWst(); + wsts.add(wst); + wst.setDescription(description); + // Fixation kind. + wst.setKind(2); + wst.setUnit(waterlevel.getUnit()); + + // Fake WST has but 1 column. + wst.setNumberColumns(1); + ImportWstColumn column = wst.getColumn(0); + column.setDescription(description); + column.setName(description); + column.setPosition(0); + + // Build Q Range. + List<ImportWaterlevelQRange> qRanges = waterlevel.getQRanges(); + for(ImportWaterlevelQRange range: qRanges) { + List<ImportWaterlevelValue> values = range.getValues(); + if (values.size() < 2) { + log.warn ("Not enough values to build valid QRange"); + continue; + } + ImportRange iRange = new ImportRange( + BigDecimal.valueOf(values.get(0).getStation()), + BigDecimal.valueOf(values.get(values.size() -1).getStation())); + column.addColumnQRange( + new ImportWstQRange(iRange, BigDecimal.valueOf(range.getQ()))); + } + + // The other W/KM values. + for(ImportWaterlevelQRange range: qRanges) { + for(ImportWaterlevelValue value: range.getValues()) { + column.addColumnValue(BigDecimal.valueOf(value.getStation()), + BigDecimal.valueOf(value.getW())); + } + } + // TODO Maybe set a timeinterval. + } + return wsts; + } + + public List<ImportWaterlevel> getWaterlevels() { return waterlevels; }
--- a/flys-backend/src/main/java/de/intevation/flys/utils/StringUtil.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/utils/StringUtil.java Mon Feb 25 11:55:34 2013 +0100 @@ -819,5 +819,11 @@ testQuote(); testStringArray2D(); } + + /** Check for occurence of needle in hay, converting both to lowercase + * to be ignorant of cases. */ + public static boolean containsIgnoreCase(String hay, String needle) { + return hay.toLowerCase().contains(needle.toLowerCase()); + } } // end of file
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Mon Feb 25 11:55:34 2013 +0100 @@ -446,11 +446,11 @@ double km = (gauge.getKmEnd() + gauge.getKmStart())/2d; mainValueView.addItem(new WQAutoTabSet(gauge.getRiverName(), new double[] {km, km})); - mainValueView.setWidth(1010); - mainValueView.setHeight(700); + mainValueView.setWidth(450); + mainValueView.setHeight(600); - mainValueView.setMaximized(true); - + mainValueView.setMaximized(false); + mainValueView.centerInPage(); mainValueView.setCanDragReposition(true); mainValueView.setCanDragResize(true); mainValueView.setShowMaximizeButton(true);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Feb 25 11:55:34 2013 +0100 @@ -1048,6 +1048,8 @@ String areatransparency(); + String attribution(); + // Manual Points editor String addpoints();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Feb 25 11:55:34 2013 +0100 @@ -543,6 +543,7 @@ wsplgen_cat3 = Fill Color 2.0 <= DIFF < 3 wsplgen_cat4 = Fill Color 3.0 <= DIFF < 4 wsplgen_cat5 = Fill Color 4.0 <= DIFF +attribution = ©Intevation GmbH 2012<br>Data ©<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> # Manual Points Editor addpoints = Add points
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Feb 25 11:55:34 2013 +0100 @@ -402,6 +402,7 @@ requireDGM = Sie m\u00fcssen ein DGM ausw\u00e4hlen. upload_file = hochladen shape_file_upload = Shapedatei hochladen +attribution = ©Intevation GmbH 2012<br>Data ©<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> # data cage waterlevels = Wasserst\u00e4nde
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Feb 25 11:55:34 2013 +0100 @@ -402,6 +402,7 @@ requireDGM = You need to choose a DEM. upload_file = upload shape_file_upload = Upload shapefile +attribution = ©Intevation GmbH 2012<br>Data ©<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> # data cage waterlevels = Waterlevels
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java Mon Feb 25 11:55:34 2013 +0100 @@ -39,6 +39,7 @@ import java.util.List; import org.gwtopenmaps.openlayers.client.Map; +import org.gwtopenmaps.openlayers.client.control.Attribution; import org.gwtopenmaps.openlayers.client.feature.VectorFeature; import org.gwtopenmaps.openlayers.client.format.GeoJSON; import org.gwtopenmaps.openlayers.client.layer.WMS; @@ -269,7 +270,7 @@ VectorFeature[] features = new GeoJSON().read(geojson); floodMap.getBarrierLayer().addFeatures(features); } - + map.addControl(new Attribution()); map.zoomToMaxExtent(); } @@ -285,7 +286,9 @@ opts.setSingleTile(true); opts.setRatio(1); opts.setBuffer(0); - + if (layers.equals("OSM-WMS-Dienst")) { + opts.setAttribution(MSG.attribution()); + } WMS wms = new WMS(layers, url, params, opts); wms.setIsVisible(true); wms.setIsBaseLayer(x);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java Mon Feb 25 11:55:34 2013 +0100 @@ -113,6 +113,7 @@ baseUrl + MSG.downloadCSV(), moduleUrl + "export" + "?uuid=" + chartTab.getCollection().identifier() + + "&name=" + chartTab.getMode().getName() + "&mode=" + chartTab.getMode().getName() + "_at_export" + "&type=at" + "&server=" + config.getServerUrl() +
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Mon Feb 25 11:55:34 2013 +0100 @@ -6,6 +6,7 @@ import org.gwtopenmaps.openlayers.client.MapOptions; import org.gwtopenmaps.openlayers.client.MapWidget; import org.gwtopenmaps.openlayers.client.Style; +import org.gwtopenmaps.openlayers.client.control.Attribution; import org.gwtopenmaps.openlayers.client.control.ScaleLine; import org.gwtopenmaps.openlayers.client.control.ScaleLineOptions; import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener; @@ -56,6 +57,7 @@ Integer.toString(height), opts); map = mapWidget.getMap(); + map.addControl(new Attribution()); }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Mon Feb 25 11:55:34 2013 +0100 @@ -454,7 +454,6 @@ if (url == null || layers == null) { return null; } - this.wmsUrls.put(name, url); WMSParams params = new WMSParams(); @@ -466,7 +465,9 @@ opts.setProjection("EPSG:" + getSrid()); opts.setSingleTile(true); opts.setRatio(1); - + if (layers.equals("OSM-WMS-Dienst")) { + opts.setAttribution(MSG.attribution()); + } WMS wms = new WMS(layers, url, params, opts); wms.setIsVisible(at.getActive() == 1); wms.setIsBaseLayer(false);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/stationinfo/GaugeInfoPanel.java Mon Feb 25 11:51:17 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/stationinfo/GaugeInfoPanel.java Mon Feb 25 11:55:34 2013 +0100 @@ -5,7 +5,7 @@ import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.user.client.ui.Anchor; -import com.google.gwt.user.client.ui.Grid; +import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.Label; @@ -24,43 +24,64 @@ public GaugeInfoPanel(GaugeInfo gauge, FLYS flys) { this.flys = flys; setStyleName("gaugeinfopanel"); - setWidth100(); - - Grid grid = new Grid(5, 2); NumberFormat nf = NumberFormat.getDecimalFormat(); + VLayout grid = new VLayout(); + HLayout line1 = new HLayout(); + Double minw = gauge.getMinW(); Double maxw = gauge.getMaxW(); if (minw != null && maxw != null) { - grid.setText(0, 0, MSG.wq_value_q()); - grid.setText(0, 1, nf.format(minw) + - " - " + nf.format(maxw)); + Label key = new Label(MSG.wq_value_q()); + Label value = new Label(nf.format(minw) + + " - " + nf.format(maxw)); + key.setWidth(150); + line1.addMember(key); + line1.addMember(value); } + HLayout line2 = new HLayout(); Double minq = gauge.getMinQ(); Double maxq = gauge.getMaxQ(); if (minq != null && maxq != null) { - grid.setText(1, 0, MSG.wq_value_w()); - grid.setText(1, 1, nf.format(minq) + + Label key = new Label(MSG.wq_value_w()); + Label value = new Label( nf.format(minq) + " - " + nf.format(maxq)); + key.setWidth(150); + line2.addMember(key); + line2.addMember(value); } + HLayout line3 = new HLayout(); Double aeo = gauge.getAeo(); if (aeo != null) { - grid.setText(2, 0, "AEO [km²]"); - grid.setText(2, 1, nf.format(aeo)); + Label key = new Label("AEO [km²]"); + Label value = new Label(nf.format(aeo)); + key.setWidth(150); + line3.addMember(key); + line3.addMember(value); } + HLayout line4 = new HLayout(); Double datum = gauge.getDatum(); if (datum != null) { - grid.setText(3, 0, MSG.gauge_zero() + " [" + + Label key = new Label(MSG.gauge_zero() + " [" + gauge.getWstUnit() + "]"); - grid.setText(3, 1, nf.format(datum)); + Label value = new Label(nf.format(datum)); + key.setWidth(150); + line4.addMember(key); + line4.addMember(value); } - grid.setWidget(4,0, new GaugeMainValueAnchor(flys, gauge)); + HLayout line5 = new HLayout(); + line5.addMember(new GaugeMainValueAnchor(flys, gauge)); + grid.addMember(line1); + grid.addMember(line2); + grid.addMember(line3); + grid.addMember(line4); + grid.addMember(line5); addMember(grid); }