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