Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/state/CoordinateSelectionState.java @ 508:90f03b909bb0
Removed never try-catch of a never thrown exception.
gnv-artifacts/trunk@591 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 21 Jan 2010 16:08:08 +0000 |
parents | 45be952a3215 |
children | c5ed4ea8fb64 |
line wrap: on
line source
/** * */ package de.intevation.gnv.state; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.apache.log4j.Logger; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.WKTReader; 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.InputValidator; import de.intevation.gnv.utils.WKTUtils; import de.intevation.gnv.utils.exception.ValidationException; /** * @author Tim Englich <tim.englich@intevation.de> * */ public class CoordinateSelectionState extends StateBase { /** * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(CoordinateSelectionState.class); /** * The UID of this Class */ private static final long serialVersionUID = 6318923553625195063L; /** * Constructor */ public CoordinateSelectionState() { super(); } @Override protected void purifyResult(Collection<Result> result, String uuid) { log.debug("CoordinateSelectionState.purifyResult"); List<Object> describeData = this.getDescibeData(uuid); if (describeData == null) { describeData = new ArrayList<Object>(); } NamedCollection<KeyValueDescibeData> keyValueDescibeData = this .extractKVP(result, "FEATUREID", "SHAPE"); describeData.add(keyValueDescibeData); this.setDescibeData(uuid, describeData); } @Override protected String prepareInputData4RegionDBQuery(String value) { log.debug("CoordinateSelectionState.prepareInputData4RegionDBQuery"); double distance=0.; String returnValue = null; try { Point center = new InputValidator().getPointValue(value); String meshIDValue = 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 } returnValue = center.buffer(distance,segments).toText(); } catch (NumberFormatException e) { log.error(e,e); } catch (ValidationException e) { log.error(e,e); } return returnValue; } /** * @see de.intevation.gnv.state.StateBase#extractKVP(java.util.Collection, java.lang.String, java.lang.String) */ @Override protected NamedCollection<KeyValueDescibeData> extractKVP( Collection<Result> result, String keyid, String valueid) { Iterator<Result> rit = result.iterator(); NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>( this.dataName, result.size()); keyValueDescibeData.setMultiSelect(this.dataMultiSelect); String prevKey = null; while (rit.hasNext()) { Result resultValue = rit.next(); String key = resultValue.getString(keyid); if(prevKey == null || !prevKey.equals(key)){ // TODO: FIXME: We have to do that because the arcsde does not support a distinct Query on Layers String geomString = this.convert2DisplayCoordinate(resultValue.getString(valueid)); String value = geomString; if (resultValue.getResultDescriptor().getColumnIndex("VALUE") > 0){ value = resultValue.getString("VALUE") + " - "+value; } keyValueDescibeData.add(new DefaultKeyValueDescribeData(key,value )); } prevKey = key; } return keyValueDescibeData; } protected static String convert2DisplayCoordinate(String wkt){ return WKTUtils.toText(wkt); } }