Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/exports/SimpleOdvDataCollector.java @ 592:3c939c95c477
Removed accidental checkin of Test-Shapefiles
gnv-artifacts/trunk@647 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 29 Jan 2010 13:28:28 +0000 |
parents | e964a3d8f7bc |
children | a0e63136954e |
line wrap: on
line source
package de.intevation.gnv.exports; import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import org.apache.log4j.Logger; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.geom.Point; import de.intevation.gnv.geobackend.base.Result; import de.intevation.gnv.state.exception.StateException; /** * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) */ public class SimpleOdvDataCollector extends ShapeDataCollector { private static Logger log = Logger.getLogger(SimpleOdvDataCollector.class); public static final String SRC_FORMAT = "yyyy.MM.dd HH:mm:ss"; public static final String DEST_FORMAT = "yyyy-MM-dd HH:mm"; public static DateFormat srcFormat = new SimpleDateFormat(SRC_FORMAT); public static DateFormat destFormat = new SimpleDateFormat(DEST_FORMAT); public SimpleOdvDataCollector(String[] names) { super(names); } public String[] getData(Result result) throws StateException { if (rd == null) init(result); try { String [] entries = new String[names.length+1]; int j = 0; for (int i = 0; i < names.length; i++) { if (names[i].equals("SHAPE")) { Point p = (Point)wktReader.read(result.getString("SHAPE")); entries[j++] = ""+p.getX(); entries[j++] = ""+p.getY(); } // Change the datetime format from yyyy.MM.dd HH:mm:ss to // yyyy-MM-dd HH:mm else if (names[i].equals("TIMEVALUE")) { Date source = srcFormat.parse(result.getString(names[i])); entries[j++] = destFormat.format(source); } else { entries[j++] = result.getString(names[i]); } } return entries; } catch (ParseException pe) { log.error(pe, pe); throw new StateException( "Error occured while parsing source data."); } catch (java.text.ParseException pe) { log.error(pe, pe); throw new StateException( "Error occured while parsing source data."); } } }