Mercurial > dive4elements > gnv-client
annotate 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 |
rev | line source |
---|---|
235
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.exports; |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import com.vividsolutions.jts.io.WKTReader; |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import com.vividsolutions.jts.io.ParseException; |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import com.vividsolutions.jts.geom.Point; |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.gnv.geobackend.base.Result; |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
301
diff
changeset
|
10 import de.intevation.gnv.state.exception.StateException; |
235
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 /** |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 */ |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 public class ShapeDataCollector |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 extends DefaultDataCollector |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 { |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 private Logger log = Logger.getLogger(ShapeDataCollector.class); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 protected WKTReader wktReader = new WKTReader(); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 public ShapeDataCollector(String[] names) { |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 super(names); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 } |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 public String[] getData(Result result) |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
301
diff
changeset
|
28 throws StateException { |
235
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 if (rd == null) |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 init(result); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 try { |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 String [] entries = new String[names.length+1]; |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 int j = 0; |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 for (int i = 0; i < names.length; i++) { |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 if (names[i].equals("SHAPE")) { |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 Point p = (Point)wktReader.read(result.getString("SHAPE")); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 entries[j++] = ""+p.getX(); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 entries[j++] = ""+p.getY(); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 } |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 else { |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 entries[j++] = result.getString(names[i]); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 } |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 } |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 return entries; |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 catch (ParseException pe) { |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 log.error(pe, pe); |
335
e964a3d8f7bc
Some Refactoring work done.
Tim Englich <tim.englich@intevation.de>
parents:
301
diff
changeset
|
53 throw new StateException( |
235
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 "Error occured while parsing a Point from WKT."); |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
c8ecc0c0bcb4
Renaming HorizontalProfileDataCollector into ShapeDataCollector.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 } |