ilog.views.maps.format.shapefile
Class IlvSHPWriter

java.lang.Object
  extended by ilog.views.maps.format.shapefile.IlvSHPWriter

public class IlvSHPWriter
extends Object

This class writes IlvMapFeature to ESRI Shape files.

The following example shows how to use an IlvSHPWriter to dump the content of an IlvFeatureIterator to a set of Shapefiles (.shp and the .shx index file).

 // Create the SHP writer.
 IlvSHPWriter writer = new IlvSHPWriter("foo.shp", "foo.shx");
 // Loop on features.
 IlvMapFeature feature = sourceIterator.getNextFeature();
 while (feature != null) {
    writer.writeFeature(feature);
    feature = sourceIterator.getNextFeature();
 }
 // Important: close the writer so that the header is written.
 writer.close();
 
This implementation only writes 2D geometries.

Since:
JViews 5.0
See Also:
IlvDBFWriter

Constructor Summary
IlvSHPWriter(String fileName)
          Constructs an IlvSHPWriter to write on the file specified by its name.
IlvSHPWriter(String shpFilename, String shxFilename)
          Constructs an IlvSHPWriter to write on the file specified by its name.
 
Method Summary
 void close()
          Closes the files associated to this writer, and writes the headers.
 IlvCoordinate getLowerRightCorner()
          Returns the lower right corner of the currently written data.
 double getMaxMeasure()
          Returns the maximum measure value of the currently written data.
 double getMinMeasure()
          Returns the minimum measure value of the currently written data.
 int getShapeType()
          Returns the type of current shape features written.
 IlvCoordinate getUpperLeftCorner()
          Returns the upper left corner of the currently written data.
 double getZMax()
          Returns the maximum Z value of the currently written data.
 double getZMin()
          Returns the minimum Z value of the currently written data.
 void writeFeature(IlvMapFeature feature)
          Writes the specified feature to the output of this writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvSHPWriter

public IlvSHPWriter(String fileName)
             throws IOException
Constructs an IlvSHPWriter to write on the file specified by its name.

Parameters:
fileName - The name of the .shp file.
Throws:
IOException - If an error occurs.

IlvSHPWriter

public IlvSHPWriter(String shpFilename,
                    String shxFilename)
             throws IOException
Constructs an IlvSHPWriter to write on the file specified by its name. When a writer is constructed using this constructor, the .shx index file whose name is specified is also created.

Parameters:
shpFilename - The name of the .shp file.
shxFilename - The name of the .shx file.
Throws:
IOException - If an error occurs.
Method Detail

close

public void close()
           throws IOException
Closes the files associated to this writer, and writes the headers. This method must be called once all the features are written, so that the header is updated.

Throws:
IOException - If an error occurs.

getUpperLeftCorner

public IlvCoordinate getUpperLeftCorner()
Returns the upper left corner of the currently written data.

Returns:
The upper left corner.

getLowerRightCorner

public IlvCoordinate getLowerRightCorner()
Returns the lower right corner of the currently written data.

Returns:
The lower right corner.

getMaxMeasure

public double getMaxMeasure()
Returns the maximum measure value of the currently written data.

Returns:
The maximum measure value.

getMinMeasure

public double getMinMeasure()
Returns the minimum measure value of the currently written data.

Returns:
The minimum measure value.

getZMax

public double getZMax()
Returns the maximum Z value of the currently written data.

Returns:
The maximum Z value.

getZMin

public double getZMin()
Returns the minimum Z value of the currently written data.

Returns:
The minimum Z value.

getShapeType

public int getShapeType()
Returns the type of current shape features written.

Returns:
The type of shape features written.
See Also:
IlvSHPReader

writeFeature

public void writeFeature(IlvMapFeature feature)
                  throws IOException
Writes the specified feature to the output of this writer. This method only writes the geometry. Use an IlvDBFWriter to write the attributes of the feature.

Parameters:
feature - The feature.
Throws:
IOException - If an error occurs.
IllegalArgumentException - If the geometry of the feature is unknown from this writer.
See Also:
IlvDBFWriter


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.