Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/util/ShapeFileWriterTestCase.java @ 538:f4e20322461b
Summarized Changes and NEWS for Release 0.4
gnv-artifacts/trunk@638 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Hans Plum <hans.plum@intevation.de> |
---|---|
date | Wed, 27 Jan 2010 14:38:27 +0000 |
parents | e17621ccf06c |
children | 9a828e5a2390 |
rev | line source |
---|---|
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
1 /** |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
2 * |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
3 */ |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
4 package de.intevation.gnv.artifacts.util; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
5 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
6 import java.io.File; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
7 import java.io.FileReader; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
8 import java.util.ArrayList; |
509
e17621ccf06c
Fixed Compiler-Error in JUnit-Test for ShapefileExport after changes in the Method-Signature.
Tim Englich <tim.englich@intevation.de>
parents:
474
diff
changeset
|
9 import java.util.Date; |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
11 import junit.framework.TestCase; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
12 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
13 import org.apache.log4j.BasicConfigurator; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 import com.vividsolutions.jts.geom.MultiLineString; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
17 import com.vividsolutions.jts.io.WKTReader; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.gnv.utils.Pair; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.gnv.utils.ShapeFileWriter; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 /** |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 * @author Tim Englich <tim.englich@intevation.de> |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 * |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 */ |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
26 public class ShapeFileWriterTestCase extends TestCase { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
27 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 /** |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 * the logger, used to log exceptions and additonaly information |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
30 */ |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 private static Logger log = null; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
32 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 static { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 BasicConfigurator.configure(); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
35 log = Logger.getLogger(ShapeFileWriterTestCase.class); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
38 /** |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
39 * Constructor |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 * @param name |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 */ |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 public ShapeFileWriterTestCase(String name) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 super(name); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
45 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
47 public void testMultiLineStringWriter(){ |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
48 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
49 try { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
50 String wkt = "MULTILINESTRING ((10 10, 20 20),(15 15, 30 15))"; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
51 String wkt1 = "MULTILINESTRING ((10 5, 20 20),(15 15, 30 15))"; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
52 String wkt2 = "MULTILINESTRING ((10 10, 8 20),(15 15, 30 15))"; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
53 String wkt3 = "MULTILINESTRING ((8 10, 20 20),(15 15, 30 15))"; |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 File isolineFile = new File("src/test/ressources/isolines.wkt"); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
55 MultiLineString multiLineString = (MultiLineString)new WKTReader().read(new FileReader(isolineFile)); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
56 MultiLineString multiLineString1 = (MultiLineString)new WKTReader().read(wkt1); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
57 MultiLineString multiLineString2 = (MultiLineString)new WKTReader().read(wkt2); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
58 MultiLineString multiLineString3 = (MultiLineString)new WKTReader().read(wkt3); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
59 ArrayList<Pair<Object, MultiLineString>> multiLineStrings = |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
60 new ArrayList<Pair<Object, MultiLineString>>(); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
61 multiLineStrings.add( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
62 new Pair<Object, MultiLineString>( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
63 1.2, |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
64 multiLineString)); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
65 multiLineStrings.add( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
66 new Pair<Object, MultiLineString>( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
67 1.3, |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
68 multiLineString1)); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 multiLineStrings.add( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 new Pair<Object, MultiLineString>( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
71 1.4, |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
72 multiLineString2)); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
73 multiLineStrings.add( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
74 new Pair<Object, MultiLineString>( |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
75 1.5, |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
76 multiLineString3)); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
77 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
78 java.io.File shapeFile = new java.io.File("/tmp/test"+System.currentTimeMillis()+".shp"); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
79 |
509
e17621ccf06c
Fixed Compiler-Error in JUnit-Test for ShapefileExport after changes in the Method-Signature.
Tim Englich <tim.englich@intevation.de>
parents:
474
diff
changeset
|
80 ShapeFileWriter.writeMultiLineStringsToFile(shapeFile, 1, 1, new Date(), multiLineStrings); |
468
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
81 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
82 } catch (Exception e) { |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
83 log.error(e,e); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
84 fail(); |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
85 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
86 } |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
87 |
7ba4c7222265
Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
88 } |