Package com.vividsolutions.jumpex.debug

Source Code of com.vividsolutions.jumpex.debug.IOUtil

package com.vividsolutions.jumpex.debug;


import java.util.Iterator;
import java.util.List;

import com.vividsolutions.jump.feature.Feature;
import com.vividsolutions.jump.feature.FeatureCollection;
import com.vividsolutions.jump.io.*;

/**
*
* Jump IO Utilities
*
* @author Vivid Solutions.
*/
public class IOUtil {

  /**
* @param filename
* @return FeatureCollection
* @throws Exception
*/
public static FeatureCollection loadShapefile(String filename)
      throws Exception
  {
    ShapefileReader rdr = new ShapefileReader();
    DriverProperties dp = new DriverProperties();
    dp.set("File", filename);
    return rdr.read(dp);
  }

  /**
* @param fc
* @param filename
* @throws Exception
*/
public static void saveShapefile(FeatureCollection fc, String filename)
      throws Exception
  {
    ShapefileWriter writer = new ShapefileWriter();
    DriverProperties dp = new DriverProperties();
    dp.set("File", filename);
    writer.write(fc, dp);
  }
  /**
* @param fc
*/
public static void print(FeatureCollection fc)
  {
    List featList = fc.getFeatures();
    for (Iterator i = featList.iterator(); i.hasNext(); ) {
      Feature f = (Feature) i.next();
      System.out.println(f.getGeometry());
    }
  }

}
TOP

Related Classes of com.vividsolutions.jumpex.debug.IOUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.