Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java @ 7123:1a20738e9a21
Add currentKM context / request mapping to RiverUtils and use it in DiagramGenerator
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 24 Sep 2013 18:36:43 +0200 |
parents | 4713bc0cc0ee |
children | f2f34d722807 |
comparison
equal
deleted
inserted
replaced
7122:038a04e001d7 | 7123:1a20738e9a21 |
---|---|
8 | 8 |
9 package org.dive4elements.river.utils; | 9 package org.dive4elements.river.utils; |
10 | 10 |
11 import org.dive4elements.artifactdatabase.state.State; | 11 import org.dive4elements.artifactdatabase.state.State; |
12 import org.dive4elements.artifacts.Artifact; | 12 import org.dive4elements.artifacts.Artifact; |
13 import org.dive4elements.artifacts.ArtifactNamespaceContext; | |
13 import org.dive4elements.artifacts.CallContext; | 14 import org.dive4elements.artifacts.CallContext; |
14 import org.dive4elements.artifacts.common.utils.Config; | 15 import org.dive4elements.artifacts.common.utils.Config; |
15 import org.dive4elements.artifacts.common.utils.XMLUtils; | 16 import org.dive4elements.artifacts.common.utils.XMLUtils; |
16 import org.dive4elements.river.artifacts.D4EArtifact; | 17 import org.dive4elements.river.artifacts.D4EArtifact; |
17 import org.dive4elements.river.artifacts.StaticWKmsArtifact; | 18 import org.dive4elements.river.artifacts.StaticWKmsArtifact; |
99 "/artifact-database/floodmap/mapserver/map-template/@path"; | 100 "/artifact-database/floodmap/mapserver/map-template/@path"; |
100 | 101 |
101 public static final String XPATH_FLOODMAP_MAPSERVER_TEMPLATE_PATH = | 102 public static final String XPATH_FLOODMAP_MAPSERVER_TEMPLATE_PATH = |
102 "/artifact-database/floodmap/mapserver/templates/@path"; | 103 "/artifact-database/floodmap/mapserver/templates/@path"; |
103 | 104 |
105 public static final String CURRENT_KM = "currentKm"; | |
106 | |
107 public static final String XPATH_CHART_CURRENTKM = | |
108 "/art:action/art:attributes/art:currentKm/@art:km"; | |
109 | |
104 | 110 |
105 private RiverUtils() { | 111 private RiverUtils() { |
106 } | 112 } |
107 | 113 |
108 | 114 |
915 else if (q < 100d) q = Math.rint((q*100d)) / 100d; | 921 else if (q < 100d) q = Math.rint((q*100d)) / 100d; |
916 else if (q < 1000d) q = Math.rint((q*10d)) / 10d; | 922 else if (q < 1000d) q = Math.rint((q*10d)) / 10d; |
917 else if (q >= 1000d) q = Math.rint(q); | 923 else if (q >= 1000d) q = Math.rint(q); |
918 return q; | 924 return q; |
919 } | 925 } |
926 | |
927 /** Parses the request and checks if it contains a currentKM setting. | |
928 * If this is the case the currentKM is added to the context.*/ | |
929 public static void setKMFromRequestInContext(Document request, | |
930 CallContext context) { | |
931 Double dKm; | |
932 String km = XMLUtils.xpathString( | |
933 request, | |
934 XPATH_CHART_CURRENTKM, | |
935 ArtifactNamespaceContext.INSTANCE); | |
936 | |
937 if (km == null) { | |
938 return; | |
939 } | |
940 | |
941 try { | |
942 dKm = Double.valueOf(km); | |
943 } catch (NumberFormatException nfe) { | |
944 return; | |
945 } | |
946 | |
947 if (logger.isDebugEnabled()) { | |
948 logger.debug("currentKm = " + dKm); | |
949 } | |
950 context.putContextValue(CURRENT_KM, dKm); | |
951 } | |
920 } | 952 } |
921 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 953 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |