Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/util/ShapeFileWriterTestCase.java @ 875:5e9efdda6894
merged gnv-artifacts/1.0
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:13:56 +0200 |
parents | c4156275c1e1 |
children | f953c9a559d8 |
comparison
equal
deleted
inserted
replaced
722:bb3ffe7d719e | 875:5e9efdda6894 |
---|---|
1 package de.intevation.gnv.artifacts.util; | |
2 | |
3 import com.vividsolutions.jts.geom.MultiLineString; | |
4 | |
5 import com.vividsolutions.jts.io.WKTReader; | |
6 | |
7 import de.intevation.gnv.utils.Pair; | |
8 import de.intevation.gnv.utils.ShapeFileWriter; | |
9 | |
10 import java.io.File; | |
11 import java.io.FileReader; | |
12 | |
13 import java.util.ArrayList; | |
14 import java.util.Date; | |
15 | |
16 import junit.framework.TestCase; | |
17 | |
18 import org.apache.log4j.BasicConfigurator; | |
19 import org.apache.log4j.Logger; | |
20 | |
21 /** | |
22 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> | |
23 * | |
24 */ | |
25 public class ShapeFileWriterTestCase extends TestCase { | |
26 | |
27 /** | |
28 * the logger, used to log exceptions and additonaly information | |
29 */ | |
30 private static Logger log = null; | |
31 | |
32 static { | |
33 BasicConfigurator.configure(); | |
34 log = Logger.getLogger(ShapeFileWriterTestCase.class); | |
35 } | |
36 | |
37 /** | |
38 * Constructor | |
39 * @param name | |
40 */ | |
41 public ShapeFileWriterTestCase(String name) { | |
42 super(name); | |
43 } | |
44 | |
45 | |
46 public void testMultiLineStringWriter(){ | |
47 | |
48 try { | |
49 String wkt = "MULTILINESTRING ((10 10, 20 20),(15 15, 30 15))"; | |
50 String wkt1 = "MULTILINESTRING ((10 5, 20 20),(15 15, 30 15))"; | |
51 String wkt2 = "MULTILINESTRING ((10 10, 8 20),(15 15, 30 15))"; | |
52 String wkt3 = "MULTILINESTRING ((8 10, 20 20),(15 15, 30 15))"; | |
53 File isolineFile = new File("src/test/ressources/isolines.wkt"); | |
54 MultiLineString multiLineString = (MultiLineString)new WKTReader().read(new FileReader(isolineFile)); | |
55 MultiLineString multiLineString1 = (MultiLineString)new WKTReader().read(wkt1); | |
56 MultiLineString multiLineString2 = (MultiLineString)new WKTReader().read(wkt2); | |
57 MultiLineString multiLineString3 = (MultiLineString)new WKTReader().read(wkt3); | |
58 ArrayList<Pair<Object, MultiLineString>> multiLineStrings = | |
59 new ArrayList<Pair<Object, MultiLineString>>(); | |
60 multiLineStrings.add( | |
61 new Pair<Object, MultiLineString>( | |
62 1.2, | |
63 multiLineString)); | |
64 multiLineStrings.add( | |
65 new Pair<Object, MultiLineString>( | |
66 1.3, | |
67 multiLineString1)); | |
68 multiLineStrings.add( | |
69 new Pair<Object, MultiLineString>( | |
70 1.4, | |
71 multiLineString2)); | |
72 multiLineStrings.add( | |
73 new Pair<Object, MultiLineString>( | |
74 1.5, | |
75 multiLineString3)); | |
76 | |
77 java.io.File shapeFile = new java.io.File("/tmp/test"+System.currentTimeMillis()+".shp"); | |
78 | |
79 ShapeFileWriter.writeMultiLineStringsToFile(shapeFile, 1, 1, new Date(), multiLineStrings); | |
80 | |
81 } catch (Exception e) { | |
82 log.error(e,e); | |
83 fail(); | |
84 } | |
85 } | |
86 | |
87 } |