ingo@1115: /* ingo@1115: * Copyright (c) 2010 by Intevation GmbH ingo@1115: * ingo@1115: * This program is free software under the LGPL (>=v2.1) ingo@1115: * Read the file LGPL.txt coming with the software for details ingo@1115: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@1115: */ ingo@1115: tim@468: package de.intevation.gnv.artifacts.util; tim@468: sascha@779: import com.vividsolutions.jts.geom.MultiLineString; sascha@779: sascha@779: import com.vividsolutions.jts.io.WKTReader; sascha@779: sascha@779: import de.intevation.gnv.utils.Pair; sascha@779: import de.intevation.gnv.utils.ShapeFileWriter; sascha@779: tim@468: import java.io.File; tim@468: import java.io.FileReader; sascha@779: tim@468: import java.util.ArrayList; tim@509: import java.util.Date; tim@468: tim@468: import junit.framework.TestCase; tim@468: tim@468: import org.apache.log4j.BasicConfigurator; tim@468: import org.apache.log4j.Logger; tim@468: tim@468: /** sascha@780: * @author Tim Englich tim@468: * tim@468: */ tim@468: public class ShapeFileWriterTestCase extends TestCase { tim@468: tim@468: /** tim@468: * the logger, used to log exceptions and additonaly information tim@468: */ tim@468: private static Logger log = null; tim@468: tim@468: static { tim@468: BasicConfigurator.configure(); tim@468: log = Logger.getLogger(ShapeFileWriterTestCase.class); tim@468: } sascha@778: tim@468: /** tim@468: * Constructor tim@468: * @param name tim@468: */ tim@468: public ShapeFileWriterTestCase(String name) { tim@468: super(name); tim@468: } sascha@778: sascha@778: tim@468: public void testMultiLineStringWriter(){ sascha@778: tim@468: try { tim@468: String wkt = "MULTILINESTRING ((10 10, 20 20),(15 15, 30 15))"; tim@468: String wkt1 = "MULTILINESTRING ((10 5, 20 20),(15 15, 30 15))"; tim@468: String wkt2 = "MULTILINESTRING ((10 10, 8 20),(15 15, 30 15))"; tim@468: String wkt3 = "MULTILINESTRING ((8 10, 20 20),(15 15, 30 15))"; tim@468: File isolineFile = new File("src/test/ressources/isolines.wkt"); tim@468: MultiLineString multiLineString = (MultiLineString)new WKTReader().read(new FileReader(isolineFile)); tim@468: MultiLineString multiLineString1 = (MultiLineString)new WKTReader().read(wkt1); tim@468: MultiLineString multiLineString2 = (MultiLineString)new WKTReader().read(wkt2); tim@468: MultiLineString multiLineString3 = (MultiLineString)new WKTReader().read(wkt3); tim@468: ArrayList> multiLineStrings = tim@468: new ArrayList>(); tim@468: multiLineStrings.add( tim@468: new Pair( tim@468: 1.2, tim@468: multiLineString)); tim@468: multiLineStrings.add( tim@468: new Pair( tim@468: 1.3, tim@468: multiLineString1)); tim@468: multiLineStrings.add( tim@468: new Pair( tim@468: 1.4, tim@468: multiLineString2)); tim@468: multiLineStrings.add( tim@468: new Pair( tim@468: 1.5, tim@468: multiLineString3)); sascha@778: sascha@778: java.io.File shapeFile = new java.io.File("/tmp/test"+System.currentTimeMillis()+".shp"); sascha@778: tim@509: ShapeFileWriter.writeMultiLineStringsToFile(shapeFile, 1, 1, new Date(), multiLineStrings); sascha@778: tim@468: } catch (Exception e) { tim@468: log.error(e,e); tim@468: fail(); tim@468: } tim@468: } tim@468: tim@468: }