Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/exports/ShapeDataCollector.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 org.apache.log4j.Logger; import com.vividsolutions.jts.io.WKTReader; 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 ShapeDataCollector extends DefaultDataCollector { private Logger log = Logger.getLogger(ShapeDataCollector.class); protected WKTReader wktReader = new WKTReader(); public ShapeDataCollector(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(); } else { entries[j++] = result.getString(names[i]); } } return entries; } catch (ParseException pe) { log.error(pe, pe); throw new StateException( "Error occured while parsing a Point from WKT."); } } }