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