# HG changeset patch # User Tim Englich # Date 1264164496 0 # Node ID c5ed4ea8fb642b55c492137f6643858ed0a513c0 # Parent 9e5ed3eebf29d4ec8f1340ce512d4f7361750d2e Make the mean with of an Mesh configurable issue93 gnv-artifacts/trunk@602 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 9e5ed3eebf29 -r c5ed4ea8fb64 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Fri Jan 22 10:32:49 2010 +0000 +++ b/gnv-artifacts/ChangeLog Fri Jan 22 12:48:16 2010 +0000 @@ -1,5 +1,22 @@ 2010-01-22 Tim Englich + Issue93 + + * doc/conf/meshwidth.xml: + Added file for the global Configuration of MeshWidths to the Project. + This file has to be edited if the mean Distance between two MeshPoints has + changed or a new Mesh will be introduced. + + * doc/conf/products/verticalprofile/conf_mesh.xml, + doc/conf/products/timeseries/conf_mesh.xml, + doc/conf/products/horizontalprofile/conf_mesh.xml: + Added Elemet with Link to the MeshWidth-Document to Configurations + for CoordinateSelectionStates. + + * src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java : + Added the possibility to configure the different width of the Meshes. + +2010-01-22 Tim Englich * src/test/java/de/intevation/gnv/artifacts/TestArtifactDatabase.java (serviceNamesAndDescriptions),(process): Fixed Compiler-Error after adding further Methods to the Interface ArtifactDatabase. diff -r 9e5ed3eebf29 -r c5ed4ea8fb64 gnv-artifacts/doc/conf/meshwidth.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/doc/conf/meshwidth.xml Fri Jan 22 12:48:16 2010 +0000 @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff -r 9e5ed3eebf29 -r c5ed4ea8fb64 gnv-artifacts/doc/conf/products/horizontalprofile/conf_mesh.xml --- a/gnv-artifacts/doc/conf/products/horizontalprofile/conf_mesh.xml Fri Jan 22 10:32:49 2010 +0000 +++ b/gnv-artifacts/doc/conf/products/horizontalprofile/conf_mesh.xml Fri Jan 22 12:48:16 2010 +0000 @@ -99,6 +99,7 @@ + diff -r 9e5ed3eebf29 -r c5ed4ea8fb64 gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml --- a/gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml Fri Jan 22 10:32:49 2010 +0000 +++ b/gnv-artifacts/doc/conf/products/timeseries/conf_mesh.xml Fri Jan 22 12:48:16 2010 +0000 @@ -99,6 +99,7 @@ + diff -r 9e5ed3eebf29 -r c5ed4ea8fb64 gnv-artifacts/doc/conf/products/verticalprofile/conf_mesh.xml --- a/gnv-artifacts/doc/conf/products/verticalprofile/conf_mesh.xml Fri Jan 22 10:32:49 2010 +0000 +++ b/gnv-artifacts/doc/conf/products/verticalprofile/conf_mesh.xml Fri Jan 22 12:48:16 2010 +0000 @@ -99,6 +99,7 @@ + diff -r 9e5ed3eebf29 -r c5ed4ea8fb64 gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java Fri Jan 22 10:32:49 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java Fri Jan 22 12:48:16 2010 +0000 @@ -5,20 +5,24 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import org.apache.log4j.Logger; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import com.vividsolutions.jts.geom.Point; -import com.vividsolutions.jts.io.ParseException; -import com.vividsolutions.jts.io.WKTReader; +import de.intevation.artifactdatabase.Config; import de.intevation.gnv.geobackend.base.Result; import de.intevation.gnv.state.describedata.DefaultKeyValueDescribeData; import de.intevation.gnv.state.describedata.KeyValueDescibeData; import de.intevation.gnv.state.describedata.NamedArrayList; import de.intevation.gnv.state.describedata.NamedCollection; +import de.intevation.gnv.utils.ArtifactXMLUtilities; import de.intevation.gnv.utils.InputValidator; import de.intevation.gnv.utils.WKTUtils; import de.intevation.gnv.utils.exception.ValidationException; @@ -38,6 +42,21 @@ * The UID of this Class */ private static final long serialVersionUID = 6318923553625195063L; + + /** + * XPATH Expressions for the setup. + */ + + private final static String MESH_WIDTH_XPATH = "mesh-width"; + private final static String XLINK_XPATH = "xlink:href"; + private final static String MESH_LIST_XPATH = "/mesh-widths/mesh"; + private final static String ID_XPATH = "id"; + private final static String WIDTH_VALUE_XPATH = "width"; + + /** + * Holds all given Widths between two MeshPoints for different Meshes. + */ + private HashMap meshWidths = null; /** * Constructor @@ -59,6 +78,9 @@ this.setDescibeData(uuid, describeData); } + /** + * @see de.intevation.gnv.state.StateBase#prepareInputData4RegionDBQuery(java.lang.String) + */ @Override protected String prepareInputData4RegionDBQuery(String value) { log.debug("CoordinateSelectionState.prepareInputData4RegionDBQuery"); @@ -66,17 +88,18 @@ String returnValue = null; try { Point center = new InputValidator().getPointValue(value); - String meshIDValue = super.inputData.get("meshid").getValue(); + String meshId = super.inputData.get("meshid").getValue(); int segments = 97; - int meshid = new Integer(meshIDValue); - if (meshid == 3 || meshid == 5){ // TODO nicht hier festbrennen. - distance = 0.15; //nord-ostsee 6nm // 97 Stützpunkte - }else if (meshid == 1 || meshid == 4){ - distance = 0.03; //Kuestenmodell 1 nm - }else if (meshid == 2 || meshid == 321){ - distance = 0.3; //SST Karten ca 20km - }else if (meshid == 641){ - distance = 0.3; //Eisdaten Klima + if (meshWidths != null){ + Double distanceValue = this.meshWidths.get(meshId); + if (distanceValue != null){ + log.debug("User "+distanceValue+" as Buffer around given Point"); + distance = distanceValue.doubleValue(); + }else{ + log.warn("No distance is configured for Mesh with id"+ meshId); + } + }else{ + log.warn("No MeshWidth configured. Check if this is correct."); } returnValue = center.buffer(distance,segments).toText(); } catch (NumberFormatException e) { @@ -122,4 +145,31 @@ protected static String convert2DisplayCoordinate(String wkt){ return WKTUtils.toText(wkt); } + + /** + * @see de.intevation.gnv.state.StateBase#setup(org.w3c.dom.Node) + */ + @Override + public void setup(Node configuration) { + super.setup(configuration); + Element widthElement = (Element)Config.getNodeXPath(configuration, MESH_WIDTH_XPATH); + + if (widthElement != null){ + String fileName = widthElement.getAttribute(XLINK_XPATH); + fileName = Config.replaceConfigDir(fileName); + Node configurationNode = new ArtifactXMLUtilities().readConfiguration(fileName); + NodeList meshNodes = Config.getNodeSetXPath(configurationNode,MESH_LIST_XPATH ); + if (meshNodes != null){ + meshWidths = new HashMap(meshNodes.getLength()); + for (int i = 0; i < meshNodes.getLength(); i++){ + Element meshNode = (Element)meshNodes.item(i); + String id = meshNode.getAttribute(ID_XPATH); + Double value = Double.parseDouble(meshNode.getAttribute(WIDTH_VALUE_XPATH)); + meshWidths.put(id, value); + } + } + }else{ + log.warn("No Mesh Width defined."); + } + } }