view 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
line wrap: on
line source
/**
 *
 */
package de.intevation.gnv.artifacts.util;

import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;

import junit.framework.TestCase;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

import com.vividsolutions.jts.geom.MultiLineString;
import com.vividsolutions.jts.io.WKTReader;

import de.intevation.gnv.utils.Pair;
import de.intevation.gnv.utils.ShapeFileWriter;

/**
 * @author Tim Englich <tim.englich@intevation.de>
 *
 */
public class ShapeFileWriterTestCase extends TestCase {

    /**
     * the logger, used to log exceptions and additonaly information
     */
    private static Logger log = null;

    static {
        BasicConfigurator.configure();
        log = Logger.getLogger(ShapeFileWriterTestCase.class);
    }
    
    /**
     * Constructor
     * @param name
     */
    public ShapeFileWriterTestCase(String name) {
        super(name);
    }
    
    
    public void testMultiLineStringWriter(){
        
        try {
            String wkt = "MULTILINESTRING ((10 10, 20 20),(15 15, 30 15))";
            String wkt1 = "MULTILINESTRING ((10 5, 20 20),(15 15, 30 15))";
            String wkt2 = "MULTILINESTRING ((10 10, 8 20),(15 15, 30 15))";
            String wkt3 = "MULTILINESTRING ((8 10, 20 20),(15 15, 30 15))";
            File isolineFile = new File("src/test/ressources/isolines.wkt");
            MultiLineString multiLineString = (MultiLineString)new WKTReader().read(new FileReader(isolineFile));
            MultiLineString multiLineString1 = (MultiLineString)new WKTReader().read(wkt1);
            MultiLineString multiLineString2 = (MultiLineString)new WKTReader().read(wkt2);
            MultiLineString multiLineString3 = (MultiLineString)new WKTReader().read(wkt3);
            ArrayList<Pair<Object, MultiLineString>> multiLineStrings =
                new ArrayList<Pair<Object, MultiLineString>>();
            multiLineStrings.add(
                    new Pair<Object, MultiLineString>(
                            1.2,
                            multiLineString));
            multiLineStrings.add(
                    new Pair<Object, MultiLineString>(
                            1.3,
                            multiLineString1));
            multiLineStrings.add(
                    new Pair<Object, MultiLineString>(
                            1.4,
                            multiLineString2));
            multiLineStrings.add(
                    new Pair<Object, MultiLineString>(
                            1.5,
                            multiLineString3));
            
            java.io.File shapeFile = new java.io.File("/tmp/test"+System.currentTimeMillis()+".shp"); 
            
            ShapeFileWriter.writeMultiLineStringsToFile(shapeFile, multiLineStrings, "test");
            
        } catch (Exception e) {
           log.error(e,e);
           fail();
        }
    }

}

http://dive4elements.wald.intevation.org