Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java @ 2045:d13be39cfd1d
#242 Added header with meta information into CSV exports.
flys-artifacts/trunk@3531 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 22 Dec 2011 13:22:55 +0000 |
parents | e5f01f2325c9 |
children | 97a25b54eea3 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Thu Dec 22 12:56:46 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Thu Dec 22 13:22:55 2011 +0000 @@ -259,13 +259,57 @@ /** + * Returns the Qs for a given FLYSArtifact. This method currently accepts + * only instances of WINFOArtifact. + * + * @param flys A FLYSArtifact. + * + * @return the Qs. + */ + public static double[] getQs(FLYSArtifact flys) { + double[] kmRange = getKmRange(flys); + + // XXX this is not nice! + if (flys instanceof WINFOArtifact) { + return ((WINFOArtifact) flys).getQs(kmRange); + } + + logger.warn("This method currently supports WINFOArtifact only!"); + + return null; + } + + + /** + * Returns the Ws for a given FLYSArtifact. This method currently accepts + * only instances of WINFOArtifact. + * + * @param flys A FLYSArtifact. + * + * @return the Ws. + */ + public static double[] getWs(FLYSArtifact flys) { + double[] kmRange = getKmRange(flys); + + // XXX this is not nice! + if (flys instanceof WINFOArtifact) { + return ((WINFOArtifact) flys).getWs(kmRange); + } + + logger.warn("This method currently supports WINFOArtifact only!"); + + return null; + } + + + /** * Returns the selected River object based on the 'river' data that might * have been inserted by the user. * * @return the selected River or null if no river has been chosen yet. */ public static River getRiver(FLYSArtifact flys) { - String sRiver = flys.getDataAsString("river"); + String sRiver = getRivername(flys); return (sRiver != null) ? RiverFactory.getRiver(sRiver) @@ -274,6 +318,19 @@ /** + * Returns the name of the river specified in the given <i>flys</i> + * Artifact. + * + * @param flys The FLYSArtifact that stores a river relevant information. + * + * @return the name of the specified river or null. + */ + public static String getRivername(FLYSArtifact flys) { + return flys != null ? flys.getDataAsString("river") : null; + } + + + /** * Extracts the SRID defined in the global configuration for the river * specified in <i>artifact</i>. * @@ -307,6 +364,43 @@ } + public static Gauge getGauge(FLYSArtifact flys) { + River river = getRiver(flys); + + if (river == null) { + logger.debug("no river found"); + return null; + } + + double[] dist = getKmRange(flys); + + if (dist == null) { + logger.debug("no range found"); + return null; + } + + if (logger.isDebugEnabled()) { + logger.debug("Determine gauge for:"); + logger.debug("... river: " + river.getName()); + logger.debug("... distance: " + dist[0] + " - " + dist[1]); + } + + Gauge gauge = river.determineGauge(dist[0], dist[1]); + + String name = gauge != null ? gauge.getName() : "'n/a"; + logger.debug("Found gauge: " + name); + + return gauge; + } + + + public static String getGaugename(FLYSArtifact flys) { + Gauge gauge = getGauge(flys); + + return gauge != null ? gauge.getName() : null; + } + + public static String createWspWTitle( WINFOArtifact winfo, CallContext cc,