Class GISShapeFileWriter
- java.lang.Object
-
- org.arakhne.afc.io.shape.AbstractCommonShapeFileWriter<E>
-
- org.arakhne.afc.io.shape.AbstractShapeFileWriter<MapElement>
-
- org.arakhne.afc.gis.io.shape.GISShapeFileWriter
-
- All Implemented Interfaces:
AutoCloseable
public class GISShapeFileWriter extends AbstractShapeFileWriter<MapElement>
Writer of GIS elements in a ESRi shapefile.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:54
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- gisinputoutput
-
-
Field Summary
-
Fields inherited from class org.arakhne.afc.io.shape.AbstractCommonShapeFileWriter
BLOCK_SIZE
-
-
Constructor Summary
Constructors Constructor Description GISShapeFileWriter(File shapeName, ShapeElementType elementType, Rectangle2d bounds)
Constructs a GIS writer.GISShapeFileWriter(File shapeName, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter)
Constructs a GIS writer.GISShapeFileWriter(File shapeName, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter, ShapeFileIndexWriter shxWriter)
Constructs a GIS writer.GISShapeFileWriter(File shapeName, ShapeElementType elementType, Rectangle2d bounds, ShapeFileIndexWriter shxWriter)
Constructs a GIS writer.GISShapeFileWriter(OutputStream stream, ShapeElementType elementType, Rectangle2d bounds)
Constructs a GIS writer.GISShapeFileWriter(OutputStream stream, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter)
Constructs a GIS writer.GISShapeFileWriter(OutputStream stream, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter, ShapeFileIndexWriter shxWriter)
Constructs a GIS writer.GISShapeFileWriter(OutputStream stream, ShapeElementType elementType, Rectangle2d bounds, ShapeFileIndexWriter shxWriter)
Constructs a GIS writer.GISShapeFileWriter(URL shapeName, ShapeElementType elementType, Rectangle2d bounds)
Constructs a GIS writer.GISShapeFileWriter(URL shapeName, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter)
Constructs a GIS writer.GISShapeFileWriter(URL shapeName, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter, ShapeFileIndexWriter shxWriter)
Constructs a GIS writer.GISShapeFileWriter(URL shapeName, ShapeElementType elementType, Rectangle2d bounds, ShapeFileIndexWriter shxWriter)
Constructs a GIS writer.GISShapeFileWriter(WritableByteChannel channel, ShapeElementType elementType, Rectangle2d bounds)
Constructs a GIS writer.GISShapeFileWriter(WritableByteChannel channel, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter)
Constructs a GIS writer.GISShapeFileWriter(WritableByteChannel channel, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter, ShapeFileIndexWriter shxWriter)
Constructs a GIS writer.GISShapeFileWriter(WritableByteChannel channel, ShapeElementType elementType, Rectangle2d bounds, ShapeFileIndexWriter shxWriter)
Constructs a GIS writer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AttributeProvider
getAttributeProvider(MapElement element)
Replies the attribute container of the given element.protected AttributeProvider[]
getAttributeProviders(Collection<? extends MapElement> elements)
Replies all the attribute containers of the given elements.protected ESRIBounds
getFileBounds()
Invoked to retrieve the bounds of the world.protected int
getGroupCountFor(MapElement element)
Replies the count of groups of points.protected ShapeMultiPatchType
getGroupTypeFor(MapElement element, int groupIndex)
Replies the type of the given part for a multipatch element.MapMetricProjection
getMapMetricProjection()
Replies the map metric projection used by the coordinates in the source file.protected ESRIPoint
getPointAt(MapElement element, int groupIndex, int pointIndex, boolean expectM, boolean expectZ)
Replies the point inside the given part at the given index.protected int
getPointCountFor(MapElement element, int groupIndex)
Replies the count of points inside the given part.void
setMapMetricProjection(MapMetricProjection projection)
Set the map metric projection used by the coordinates in the source file.static ShapeElementType
toESRI(Class<? extends MapElement> type)
Replies the type of map element which is corresponding to the given GIS class.-
Methods inherited from class org.arakhne.afc.io.shape.AbstractShapeFileWriter
close, onHeaderWritten, writeElement
-
Methods inherited from class org.arakhne.afc.io.shape.AbstractCommonShapeFileWriter
ensureAvailableBytes, flush, getElementType, getTaskProgression, isHeaderWritten, setTaskProgression, write, write, writeBEDouble, writeBEInt, writeLEDouble, writeLEInt
-
-
-
-
Constructor Detail
-
GISShapeFileWriter
public GISShapeFileWriter(File shapeName, ShapeElementType elementType, Rectangle2d bounds) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(URL shapeName, ShapeElementType elementType, Rectangle2d bounds) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(OutputStream stream, ShapeElementType elementType, Rectangle2d bounds) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
stream
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(WritableByteChannel channel, ShapeElementType elementType, Rectangle2d bounds) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
channel
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(File shapeName, ShapeElementType elementType, Rectangle2d bounds, ShapeFileIndexWriter shxWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.shxWriter
- is the writer used to create the index- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(URL shapeName, ShapeElementType elementType, Rectangle2d bounds, ShapeFileIndexWriter shxWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.shxWriter
- is the writer used to create the index- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(OutputStream stream, ShapeElementType elementType, Rectangle2d bounds, ShapeFileIndexWriter shxWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
stream
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.shxWriter
- is the writer used to create the index- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(WritableByteChannel channel, ShapeElementType elementType, Rectangle2d bounds, ShapeFileIndexWriter shxWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
channel
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.shxWriter
- is the writer used to create the index- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(File shapeName, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.dbfWriter
- is the writer used to export the attributes- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(URL shapeName, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.dbfWriter
- is the writer used to export the attributes- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(OutputStream stream, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
stream
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.dbfWriter
- is the writer used to export the attributes- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(WritableByteChannel channel, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
channel
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.dbfWriter
- is the writer used to export the attributes- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(File shapeName, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter, ShapeFileIndexWriter shxWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.dbfWriter
- is the writer used to export the attributesshxWriter
- is the writer used to create the index- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(URL shapeName, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter, ShapeFileIndexWriter shxWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
shapeName
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.dbfWriter
- is the writer used to export the attributesshxWriter
- is the writer used to create the index- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(OutputStream stream, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter, ShapeFileIndexWriter shxWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
stream
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.dbfWriter
- is the writer used to export the attributesshxWriter
- is the writer used to create the index- Throws:
IOException
- in case of error.
-
GISShapeFileWriter
public GISShapeFileWriter(WritableByteChannel channel, ShapeElementType elementType, Rectangle2d bounds, DBaseFileWriter dbfWriter, ShapeFileIndexWriter shxWriter) throws IOException
Constructs a GIS writer.elementType may be computed with
toESRI(Class)
.- Parameters:
channel
- is the file to writeelementType
- is the type of the elements to write.bounds
- are the bounds of the world to put in the file's header.dbfWriter
- is the writer used to export the attributesshxWriter
- is the writer used to create the index- Throws:
IOException
- in case of error.
-
-
Method Detail
-
toESRI
@Pure public static ShapeElementType toESRI(Class<? extends MapElement> type)
Replies the type of map element which is corresponding to the given GIS class.- Parameters:
type
- the type of element.- Returns:
- the type of map element.
- Throws:
IllegalArgumentException
- if the given type is not supported by the I/O API.- Since:
- 4.0
-
getAttributeProvider
protected AttributeProvider getAttributeProvider(MapElement element) throws IOException
Description copied from class:AbstractShapeFileWriter
Replies the attribute container of the given element. The attributes will be put in a DBase file.- Specified by:
getAttributeProvider
in classAbstractShapeFileWriter<MapElement>
- Parameters:
element
- is the element from which the attribute container must be extracted- Returns:
- the attribute container
- Throws:
IOException
- in case of error.
-
getAttributeProviders
protected AttributeProvider[] getAttributeProviders(Collection<? extends MapElement> elements) throws IOException
Description copied from class:AbstractShapeFileWriter
Replies all the attribute containers of the given elements. The attributes will be put in a DBase file header as columns. The size of the replied array should be the same as the size of the collection of elements. Otherwise you must be sure that you are not loosing attributes. Moreover the position of the AttributeProvider in the array must corresponds to the position of the element record in the DBF and shape file.- Specified by:
getAttributeProviders
in classAbstractShapeFileWriter<MapElement>
- Parameters:
elements
- are the element from which the attribute containers must be extracted- Returns:
- the attribute containers.
- Throws:
IOException
- in case of error.
-
getGroupCountFor
protected int getGroupCountFor(MapElement element) throws IOException
Description copied from class:AbstractShapeFileWriter
Replies the count of groups of points.- Specified by:
getGroupCountFor
in classAbstractShapeFileWriter<MapElement>
- Parameters:
element
- is the element from which the group count must be extracted- Returns:
- the count of groups of points.
- Throws:
IOException
- in case of error.
-
getGroupTypeFor
protected ShapeMultiPatchType getGroupTypeFor(MapElement element, int groupIndex) throws IOException
Description copied from class:AbstractShapeFileWriter
Replies the type of the given part for a multipatch element.A MultiPatch consists of a number of surface patches. Each surface patch describes a surface. The surface patches of a MultiPatch are referred to as its parts, and the type of part controls how the order of vertices of an MultiPatch part is interpreted.
A single Triangle Strip, or Triangle Fan, represents a single surface patch.
A sequence of parts that are rings can describe a polygonal surface patch with holes. The sequence typically consists of an Outer Ring, representing the outer boundary of the patch, followed by a number of Inner Rings representing holes. When the individual types of rings in a collection of rings representing a polygonal patch with holes are unknown, the sequence must start with First Ring, followed by a number of Rings. A sequence of Rings not preceded by an First Ring is treated as a sequence of Outer Rings without holes.
- Specified by:
getGroupTypeFor
in classAbstractShapeFileWriter<MapElement>
- Parameters:
element
- is the element from which the point count must be extractedgroupIndex
- is the index of the group from which the point count must be replied.- Returns:
- the type of the part.
- Throws:
IOException
- in case of error.
-
getPointAt
protected ESRIPoint getPointAt(MapElement element, int groupIndex, int pointIndex, boolean expectM, boolean expectZ) throws IOException
Description copied from class:AbstractShapeFileWriter
Replies the point inside the given part at the given index.This function is also invoked for a simple point. In this case, the group and point indexes are both equal to zero. This function is also invoked for a multipoint. In this case, the group index is always equal to zero.
- Specified by:
getPointAt
in classAbstractShapeFileWriter<MapElement>
- Parameters:
element
- is the element from which the point must be extractedgroupIndex
- is the index of the group from which the point must be extracted.pointIndex
- is the index of the point in the group.expectM
- indicates if the M value is expected.expectZ
- indicates if the Z value is expected.- Returns:
- the point.
- Throws:
IOException
- in case of error.
-
getPointCountFor
protected int getPointCountFor(MapElement element, int groupIndex) throws IOException
Description copied from class:AbstractShapeFileWriter
Replies the count of points inside the given part. This function is also invoked for a multipoint. In this case, the group index is always equal to zero.- Specified by:
getPointCountFor
in classAbstractShapeFileWriter<MapElement>
- Parameters:
element
- is the element from which the point count must be extractedgroupIndex
- is the index of the group from which the point count must be replied.- Returns:
- the count of points in the part at the given index.
- Throws:
IOException
- in case of error.
-
getFileBounds
protected ESRIBounds getFileBounds()
Description copied from class:AbstractCommonShapeFileWriter
Invoked to retrieve the bounds of the world.- Specified by:
getFileBounds
in classAbstractCommonShapeFileWriter<MapElement>
- Returns:
- the bounds.
-
setMapMetricProjection
public void setMapMetricProjection(MapMetricProjection projection)
Set the map metric projection used by the coordinates in the source file.- Parameters:
projection
- is the map metric projection in the source file.- Since:
- 4.1
-
getMapMetricProjection
@Pure public MapMetricProjection getMapMetricProjection()
Replies the map metric projection used by the coordinates in the source file.- Returns:
- the map metric projection in the source file.
- Since:
- 4.1
-
-