Package org.arakhne.afc.io.shape
Class ShapeFileIndexWriter
- java.lang.Object
-
- org.arakhne.afc.io.shape.AbstractCommonShapeFileWriter<ShapeFileIndexRecord>
-
- org.arakhne.afc.io.shape.ShapeFileIndexWriter
-
- All Implemented Interfaces:
AutoCloseable
public class ShapeFileIndexWriter extends AbstractCommonShapeFileWriter<ShapeFileIndexRecord>
This class is a shape file index writer.The specification of the ESRI Shape file format is described in the July 98 specification document.
- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:52
- Author:
- Stéphane GALLAND, Olivier LAMOTTE
- Maven Group Id:
- org.arakhne.afc.advanced
- Maven Artifact Id:
- shapefile
-
-
Field Summary
-
Fields inherited from class org.arakhne.afc.io.shape.AbstractCommonShapeFileWriter
BLOCK_SIZE
-
-
Constructor Summary
Constructors Constructor Description ShapeFileIndexWriter(File shapeName, ShapeElementType elementType, ESRIBounds bounds)
Constructor.ShapeFileIndexWriter(OutputStream stream, ShapeElementType elementType, ESRIBounds bounds)
Constructor.ShapeFileIndexWriter(URL shapeName, ShapeElementType elementType, ESRIBounds bounds)
Constructor.ShapeFileIndexWriter(WritableByteChannel channel, ShapeElementType elementType, ESRIBounds bounds)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ESRIBounds
getFileBounds()
Invoked to retrieve the bounds of the world.void
write(int recordLength)
Write a record with the given length at the following offset in the SHX file.protected void
writeElement(int recIndex, ShapeFileIndexRecord element, ShapeElementType type)
Write an element inside the output stream.-
Methods inherited from class org.arakhne.afc.io.shape.AbstractCommonShapeFileWriter
close, ensureAvailableBytes, flush, getElementType, getTaskProgression, isHeaderWritten, onHeaderWritten, setTaskProgression, write, write, writeBEDouble, writeBEInt, writeLEDouble, writeLEInt
-
-
-
-
Constructor Detail
-
ShapeFileIndexWriter
public ShapeFileIndexWriter(File shapeName, ShapeElementType elementType, ESRIBounds bounds) throws IOException
Constructor.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds to put in the header.- Throws:
IOException
- in case of error.
-
ShapeFileIndexWriter
public ShapeFileIndexWriter(URL shapeName, ShapeElementType elementType, ESRIBounds bounds) throws IOException
Constructor.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds to put in the header.- Throws:
IOException
- in case of error.
-
ShapeFileIndexWriter
public ShapeFileIndexWriter(OutputStream stream, ShapeElementType elementType, ESRIBounds bounds) throws IOException
Constructor.- Parameters:
stream
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds to put in the header.- Throws:
IOException
- in case of error.
-
ShapeFileIndexWriter
public ShapeFileIndexWriter(WritableByteChannel channel, ShapeElementType elementType, ESRIBounds bounds) throws IOException
Constructor.- Parameters:
channel
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds to put in the header.- Throws:
IOException
- in case of error.
-
-
Method Detail
-
getFileBounds
protected ESRIBounds getFileBounds()
Description copied from class:AbstractCommonShapeFileWriter
Invoked to retrieve the bounds of the world.- Specified by:
getFileBounds
in classAbstractCommonShapeFileWriter<ShapeFileIndexRecord>
- Returns:
- the bounds.
-
writeElement
protected void writeElement(int recIndex, ShapeFileIndexRecord element, ShapeElementType type) throws IOException
Description copied from class:AbstractCommonShapeFileWriter
Write an element inside the output stream.- Specified by:
writeElement
in classAbstractCommonShapeFileWriter<ShapeFileIndexRecord>
- Parameters:
recIndex
- is the index of the element in the file.element
- is the element to write.type
- is the expected type for the element.- Throws:
IOException
- in case of error.
-
write
public final void write(int recordLength) throws IOException
Write a record with the given length at the following offset in the SHX file.The length if the count of bytes inside the record (including record header and record content). Assuming record header with length of 8 bytes and record content with length of
l
bytes, the total record length isl
+8 bytes.Because the ESRI standard stores this value as a count of 16-bit words (not a count of bytes), it means that the given length may be a multiple of 2. If this record is created with a length which is not a multiple of 2, this object will assumed the upper multiple as length.
- Parameters:
recordLength
- is the length to write inside a record at the end of the SHX.- Throws:
IOException
- in case of error.
-
-