package uk.ac.leeds.ccg.geotools; import java.lang.*; import uk.ac.leeds.ccg.shapefile.*; import uk.ac.leeds.ccg.dbffile.*; import java.io.*; import java.net.*; import java.util.zip.*; import java.util.*; import cmp.LEDataStream.*; import java.awt.Color; /** * A class to simplify the process of writing an ESRI(r) Shapefile. * It can be constructed from a theme or an array of themes. * @author James Macgill, Center for computational Geography. * @author Ian Turton, Center for computational Geography. * $Id: ShapefileWriter.java,v 1.11 2002/07/18 09:32:04 ianturton Exp $ */ public class ShapefileWriter { private final static boolean DEBUG=false; private final static String DBC="SfW->"; public Shapefile sf = null; public Dbf dbf = null; SimpleGeoData sgd,area,perimeter; boolean asLine = false; ShapefileShape[] sfShapes; double[] bbox; //best general guess private String name = "none"; private boolean full = true; // should we write area and perimeter? /** * Creates and opens a new ShapefileWriter */ public ShapefileWriter(String base,Theme t)throws IOException,DbfFileException{ if(DEBUG)System.out.println("constructing ShapefileWriter - single theme"+ "\nwill identify as "+DBC); Theme [] ta =new Theme[1]; ta[0]= t; init(ta); write(base); } public ShapefileWriter(String base,Theme[] t)throws IOException,DbfFileException{ if(DEBUG)System.out.println("constructing ShapefileWriter - multiple theme"+ "\nwill identify as "+DBC); init(t); write(base); } private void init(Theme [] t){ area = new SimpleGeoData(); area.setName("Area"); perimeter = new SimpleGeoData(); perimeter.setName("perimeter"); ShapeLayer l[] = new ShapeLayer[t.length]; for(int k=0;k