# HG changeset patch # User Tim Englich # Date 1260872416 0 # Node ID 24c21a720aa550403d9181ea0231311997d8016e # Parent 4ac3c1c1c0600b36b58794288303cb8612e81518 Added Support for "horizontale Schnittprofile" gnv-artifacts/trunk@425 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Tue Dec 15 10:13:09 2009 +0000 +++ b/gnv-artifacts/ChangeLog Tue Dec 15 10:20:16 2009 +0000 @@ -1,3 +1,18 @@ +2009-12-15 Tim Englich + + * src/main/resources/lang/artifactMessages_*.properties: + Added the required Resources for the Outputelements of "horizontale Schnittprofile". + * doc/conf/queries.properties: + Added the specialized Queries for getting the Data and the depths for + generating "horizontale Schnittprofile". + * src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java (log): + Added an new OutputTransition to handle the special Way to d detremine the required + Data for generating "horizontale Schnittprofile". + * doc/conf/conf.xml, + doc/conf/products/horizontalprofile/conf_mesh_cross.xml, + src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileMeshCrossArtifact.java: + Added Support for "Horizontales Schnittprofil"-Artifacts to the Project + 2009-12-15 Ingo Weinzierl Issue102 diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/doc/conf/conf.xml --- a/gnv-artifacts/doc/conf/conf.xml Tue Dec 15 10:13:09 2009 +0000 +++ b/gnv-artifacts/doc/conf/conf.xml Tue Dec 15 10:20:16 2009 +0000 @@ -169,6 +169,14 @@ + + de.intevation.artifactdatabase.DefaultArtifactFactory + + + + + de.intevation.artifactdatabase.DefaultArtifactFactory @@ -370,6 +378,7 @@ + diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/doc/conf/products/horizontalprofile/conf_mesh_cross.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/doc/conf/products/horizontalprofile/conf_mesh_cross.xml Tue Dec 15 10:20:16 2009 +0000 @@ -0,0 +1,181 @@ + + + + + area_filter + areaid + false + true + + + + + + + + + + + + + + + + + + + + subarea_filter + subareaid + false + + + + + + + + + + + + + + + verticalprofile_mesh + meshid + false + + + + + + + + + + + + + + verticalprofile_mesh_with_area + meshid + false + + + + + + + + + + + + + + + mesh_linestring + false + + + + + + + + + + + + + + + + + verticalprofile_mesh_parameter + parameterid + true + + + + + + + + + + + + + + + horizontalprofile_meshpoint_depth + depthid + true + + + + + + + + + + + + + + + + verticalprofile_mesh_date + dateid + true + + + + + + + + + + + + + + + + + horizontalprofile_mesh_cross_chart_data + horizontalprofile_meshpoint_cross_ij + horizontalprofile_mesh_odv_data + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/doc/conf/queries.properties --- a/gnv-artifacts/doc/conf/queries.properties Tue Dec 15 10:13:09 2009 +0000 +++ b/gnv-artifacts/doc/conf/queries.properties Tue Dec 15 10:20:16 2009 +0000 @@ -884,8 +884,69 @@ msv.PARAMETERID, \ MEDIAN.MESHPOINT.JPOSITION, \ MEDIAN.MESHPOINT.IPOSITION - - + +############################################# +############################################# +########### Horizontalprofil MESH ########### +########### Schnittprofil ########### +############################################# +############################################# +horizontalprofile_meshpoint_depth = SELECT DISTINCT \ + mp.KPOSITION KEY, \ + 'Layer ' || ml.KPOSITION || ': ' || -ml.UPPERZLOCATION || ' - '|| -ml.LOWERZLOCATION VALUE \ + from MEDIAN.MESHLAYER ml, \ + MEDIAN.MESHPOINT mp \ + where ml.KPOSITION = mp.KPOSITION and \ + ml.MESHID = mp.MESHID and \ + mp.FEATUREID in \ + ( select FEATUREID \ + from MEDIAN.MESHPOINT mp, \ + MEDIAN.MESH m \ + where m.OBJECTID = ? AND \ + mp.MESHID = m.MESHID )\ + order by mp.KPOSITION + +horizontalprofile_meshpoint_cross_ij=SELECT MEDIAN.MESHFACE.JPOSITION, \ + MEDIAN.MESHFACE.IPOSITION \ + FROM MEDIAN.MESHFACE, \ + MEDIAN.MESH M \ + WHERE MEDIAN.MESHFACE.KPOSITION = 1 AND \ + M.MESHID = MEDIAN.MESHFACE.MESHID AND \ + M.OBJECTID = ? AND \ + INTERSECTS(SHAPE, "?") +horizontalprofile_mesh_cross_chart_data = SELECT ST_ASTEXT(SHAPE), \ + msv.DATAVALUE YORDINATE, \ + msv.PARAMETERID GROUP1, \ + MEDIAN.MESHPOINT.KPOSITION GROUP2, \ + msv.TIMEVALUE GROUP3, \ + MEDIAN.MESHPOINT.JPOSITION, \ + MEDIAN.MESHPOINT.IPOSITION, \ + 2 DATAID \ + from MEDIAN.MESHLAYER ml, \ + MEDIAN.MESHPOINT, \ + MEDIAN.MESH m, \ + MEDIAN.MESHSCALARVALUE msv \ + where msv.FEATUREID = MEDIAN.MESHPOINT.FEATUREID AND \ + ml.KPOSITION = MEDIAN.MESHPOINT.KPOSITION and \ + ml.MESHID = MEDIAN.MESHPOINT.MESHID and \ + m.MESHID = MEDIAN.MESHPOINT.MESHID AND \ + m.PARTIDMIN <= msv.PARTID AND \ + m.PARTIDMAX >= msv.PARTID AND \ + msv.PARAMETERID in (?) AND \ + msv.TIMEVALUE in (?) AND \ + m.OBJECTID = ? AND \ + ml.KPOSITION in (?) AND \ + MEDIAN.MESHPOINT.FEATUREID in \ + ( \ + SELECT distinct FEATUREID \ + FROM MEDIAN.MESHPOINT \ + WHERE ? \ + ) \ + order by msv.TIMEVALUE, \ + MEDIAN.MESHPOINT.KPOSITION, \ + msv.PARAMETERID, \ + MEDIAN.MESHPOINT.JPOSITION, \ + MEDIAN.MESHPOINT.IPOSITION ############################################# ############################################# ############# Profilschnitt MESH ############ diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileMeshCrossArtifact.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileMeshCrossArtifact.java Tue Dec 15 10:20:16 2009 +0000 @@ -0,0 +1,34 @@ +/** + * + */ +package de.intevation.gnv.profile.horizontal; + +import org.apache.log4j.Logger; + +/** + * @author Tim Englich + * + */ +public class HorizontalProfileMeshCrossArtifact extends + HorizontalProfileMeshArtifact { + + /** + * The UID of this Class + */ + private static final long serialVersionUID = 3955589051619129854L; + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger + .getLogger(HorizontalProfileMeshCrossArtifact.class); + + /** + * Constructor + */ + public HorizontalProfileMeshCrossArtifact() { + super(); + log.debug("HorizontalProfileMeshCrossArtifact.Constructor"); + super.name = super.name + "Cross"; + } + +} diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java Tue Dec 15 10:20:16 2009 +0000 @@ -0,0 +1,145 @@ +/** + * + */ +package de.intevation.gnv.state.profile.horizontal; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.apache.log4j.Logger; +import org.w3c.dom.Node; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.io.ParseException; +import com.vividsolutions.jts.io.WKTReader; + +import de.intevation.artifactdatabase.Config; +import de.intevation.gnv.artifacts.cache.CacheFactory; +import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.geobackend.base.query.QueryExecutor; +import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory; +import de.intevation.gnv.geobackend.base.query.exception.QueryException; +import de.intevation.gnv.geobackend.sde.datasources.ResultSet; +import de.intevation.gnv.utils.IndexBuffer; + +/** + * @author Tim Englich + * + */ +public class HorizontalProfileMeshCrossOutputState extends + HorizontalProfileOutputState { + + /** + * + */ + private static final long serialVersionUID = 2205958041745637263L; + + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = + Logger.getLogger(HorizontalProfileMeshCrossOutputState.class); + + + private String ijkQueryID = null; + + /** + * Constructor + */ + public HorizontalProfileMeshCrossOutputState() { + super(); + } + + /** + * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#setup(org.w3c.dom.Node) + */ + @Override + public void setup(Node configuration) { + super.setup(configuration); + this.ijkQueryID = Config.getStringXPath(configuration,"queryID-ijk"); + + } + + @Override + protected Collection getChartResult(String uuid) { + log.debug("OutputStateBase.getChartResult"); + Collection result = null; + if (CacheFactory.getInstance().isInitialized()) { + String key = uuid + super.getID(); + log.debug("Hash for Queryelements: " + key); + net.sf.ehcache.Element value = CacheFactory.getInstance().getCache().get(key); + if (value != null) { + result = (Collection) (value.getObjectValue()); + }else{ + + if (this.inputData.containsKey("mesh_linestring")){ + + try { + // 1. IJK Anfragen für Stützpunkte im Netz ausführen. + LineString ls = (LineString)new WKTReader().read(this.inputData + .get("mesh_linestring") + .getValue()); + Coordinate[] coords = ls.getCoordinates(); + + List points = new ArrayList(coords.length); + + String meshid = this.inputData.get("meshid").getValue(); + QueryExecutor queryExecutor = QueryExecutorFactory + .getInstance() + .getQueryExecutor(); + for (int i = 0; i < coords.length; i++){ + String wkt = "POINT( "+coords[i].x+" "+coords[i].y+" )"; + + result = queryExecutor.executeQuery(this.ijkQueryID, + new String[]{meshid,wkt}); + if (!result.isEmpty()){ + Result resultValue = result.iterator().next(); + int iPos = resultValue.getInteger(1); + int jPos = resultValue.getInteger(0); + log.debug("Found Pos "+iPos+"/"+jPos +" for "+wkt); + points.add(i, new java.awt.Point(iPos,jPos)); + }else{ + log.debug("No i/j Pos found for "+wkt); + points.add(i, null); + // Special Case no i,j found for Coordinate + } + } + // TODO: Make Tablenames and Columns Configurable + IndexBuffer ib = new IndexBuffer(points, "MEDIAN.MESHPOINT.IPOSITION", " MEDIAN.MESHPOINT.JPOSITION" ); + String additionWhere = ib.toWhereClause(); + log.debug("Additional Where Clause = "+additionWhere); + // 2. Aus diesen Stützpunkten den Resultset generieren. + + String[] filterValues = this.generateFilterValuesFromInputData(); + String[] addedFilterValues = new String[filterValues.length+1]; + System.arraycopy(filterValues, 0, addedFilterValues, 0, filterValues.length); + addedFilterValues[filterValues.length] = additionWhere; + + result = queryExecutor.executeQuery(this.queryID, + addedFilterValues); + + + } catch (ParseException e) { + log.error(e,e); + }catch (QueryException e) { + log.error(e,e); + } + }else{ + // TODO: definieren was passiert wenn kein linestring vorhanden ist. + } + + if (CacheFactory.getInstance().isInitialized()) { + CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, result)); + } + + } + } + return result; + } + + + +} diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/src/main/resources/lang/artifactMessages.properties --- a/gnv-artifacts/src/main/resources/lang/artifactMessages.properties Tue Dec 15 10:13:09 2009 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages.properties Tue Dec 15 10:20:16 2009 +0000 @@ -24,6 +24,7 @@ verticalcrosssection = Vertical cross-section featureid = Station mesh_coordinate = Geographic position (e.g. 56n30 6e20) +mesh_linestring = Line (WKT) mesh_point = Mesh Point measurementid = Measurement depth/height [m] depthrange = Measurementarea depth/height [m] diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties --- a/gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties Tue Dec 15 10:13:09 2009 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties Tue Dec 15 10:20:16 2009 +0000 @@ -24,6 +24,7 @@ featureid = Station meshid= Netz mesh_coordinate = Position (z.B. 56n30 6e20) +mesh_linestring = Linienzug (WKT) mesh_point = Messpunkt measurementid = Messung Tiefe/Höhe [m] depthrange = Messbereich Tiefe/Höhe [m] diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties --- a/gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties Tue Dec 15 10:13:09 2009 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties Tue Dec 15 10:20:16 2009 +0000 @@ -24,6 +24,7 @@ featureid = Station meshid= Netz mesh_coordinate = Position (z.B. 56n30 6e20) +mesh_linestring = Linienzug (WKT) mesh_point = Messpunkt measurementid = Messung Tiefe/Höhe [m] depthrange = Messbereich Tiefe/Höhe [m] diff -r 4ac3c1c1c060 -r 24c21a720aa5 gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties --- a/gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties Tue Dec 15 10:13:09 2009 +0000 +++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties Tue Dec 15 10:20:16 2009 +0000 @@ -24,6 +24,7 @@ verticalcrosssection = Vertical cross-section featureid = Station mesh_coordinate = Geographic position (e.g. 56n30 6e20) +mesh_linestring = Line (WKT) mesh_point = Mesh Point measurementid = Measurement depth/height [m] depthrange = Measurementarea depth/height [m]