annotate gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/util/ShapeFileWriterTestCase.java @ 503:b951b14425fa

Solved issue 129. Renamed i and j axis to 'West-East-Axis' and 'North-South-Axis'. gnv-artifacts/trunk@586 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 20 Jan 2010 15:48:31 +0000
parents ab29e4ff2fda
children e17621ccf06c
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;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 import junit.framework.TestCase;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import org.apache.log4j.BasicConfigurator;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import com.vividsolutions.jts.geom.MultiLineString;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 import com.vividsolutions.jts.io.WKTReader;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import de.intevation.gnv.utils.Pair;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import de.intevation.gnv.utils.ShapeFileWriter;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20
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 * @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
23 *
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 public class ShapeFileWriterTestCase extends TestCase {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
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 * 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
29 */
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 private static Logger log = null;
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 static {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 BasicConfigurator.configure();
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 log = Logger.getLogger(ShapeFileWriterTestCase.class);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 }
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 * Constructor
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 * @param name
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 */
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 public ShapeFileWriterTestCase(String name) {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 super(name);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 }
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 public void testMultiLineStringWriter(){
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 try {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 ArrayList<Pair<Object, MultiLineString>> multiLineStrings =
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 new ArrayList<Pair<Object, MultiLineString>>();
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 multiLineStrings.add(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 new Pair<Object, MultiLineString>(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 1.2,
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 multiLineString));
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 multiLineStrings.add(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 new Pair<Object, MultiLineString>(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 1.3,
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 multiLineString1));
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 multiLineStrings.add(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 new Pair<Object, MultiLineString>(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 1.4,
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 multiLineString2));
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 multiLineStrings.add(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 new Pair<Object, MultiLineString>(
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 1.5,
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 multiLineString3));
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 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
78
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 ShapeFileWriter.writeMultiLineStringsToFile(shapeFile, multiLineStrings, "test");
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 } catch (Exception e) {
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 log.error(e,e);
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 fail();
7ba4c7222265 Added ij-Index determination for horizontal-cross-sections.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 }
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 }

http://dive4elements.wald.intevation.org