Package org.tinfour.svm
Class SvmShapefileVertexReader
- java.lang.Object
-
- org.tinfour.svm.SvmShapefileVertexReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,IVertexReader
public class SvmShapefileVertexReader extends Object implements IVertexReader, Closeable
A utility for loading vertices from a file for testing
-
-
Constructor Summary
Constructors Constructor Description SvmShapefileVertexReader(File file)Construct an instance for the specified Shapefile
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()ICoordinateTransformgetCoordinateTransform()List<LinearConstraint>getLinearConstraints()Gets the list of constraints that were collected during the most recent read operation.LinearUnitsgetLinearUnits()Gets the linear units for the horizontal coordinate system from the shapefile.doublegetTimeForLoad()Gets the total time to load a file (including the time required for pre-sort if enabled).List<Vertex>getVertices()Gets the list of vertices that were collected during the most recent read operation.doublegetXMax()Gets the maximum x coordinate in the sampledoublegetXMin()Gets the minimum x coordinate in the sampledoublegetYMax()Gets the maximum y coordinate in the sampledoublegetYMin()Gets the minimum y coordinate in the sampledoublegetZMax()Gets the maximum z coordinate in the sampledoublegetZMin()Gets the minimum z coordinate in the samplebooleanisSourceInGeographicCoordinates()Indicates whether the source data was in geographic coordinatesList<Vertex>read(IMonitorWithCancellation monitor)Read the records from the shapefile and use them to populate vertices.voidsetCoordinateTransform(ICoordinateTransform transform)voidsetDbfFieldForZ(String dbfFieldForZ)Sets the name of the field in the DBF file to use as a source for Z coordinates for data.voidsetVerticalCoordinateTransform(IVerticalCoordinateTransform verticalTransform)Sets the vertical coordinate transform to be used when reading the file (if any).
-
-
-
Constructor Detail
-
SvmShapefileVertexReader
public SvmShapefileVertexReader(File file) throws IOException
Construct an instance for the specified Shapefile- Parameters:
file- a shapefile reference- Throws:
IOException- in the event of an unrecoverable I/O condition
-
-
Method Detail
-
setDbfFieldForZ
public void setDbfFieldForZ(String dbfFieldForZ)
Sets the name of the field in the DBF file to use as a source for Z coordinates for data.- Parameters:
dbfFieldForZ- a valid string, or a null to use the Z coordinates from the shapefile geometry file (the 0shp file).
-
setVerticalCoordinateTransform
public void setVerticalCoordinateTransform(IVerticalCoordinateTransform verticalTransform)
Sets the vertical coordinate transform to be used when reading the file (if any).- Parameters:
verticalTransform- a valid instance if a transform is to be applies; a null reference if no transform is required.
-
getXMin
public double getXMin()
Gets the minimum x coordinate in the sample- Specified by:
getXMinin interfaceIVertexReader- Returns:
- a valid floating point value
-
getXMax
public double getXMax()
Gets the maximum x coordinate in the sample- Specified by:
getXMaxin interfaceIVertexReader- Returns:
- a valid floating point value
-
getYMin
public double getYMin()
Gets the minimum y coordinate in the sample- Specified by:
getYMinin interfaceIVertexReader- Returns:
- a valid floating point value
-
getYMax
public double getYMax()
Gets the maximum y coordinate in the sample- Specified by:
getYMaxin interfaceIVertexReader- Returns:
- a valid floating point value
-
getZMin
public double getZMin()
Gets the minimum z coordinate in the sample- Specified by:
getZMinin interfaceIVertexReader- Returns:
- a valid floating point value
-
getZMax
public double getZMax()
Gets the maximum z coordinate in the sample- Specified by:
getZMaxin interfaceIVertexReader- Returns:
- a valid floating point value
-
getTimeForLoad
public double getTimeForLoad()
Gets the total time to load a file (including the time required for pre-sort if enabled).- Returns:
- a time in milliseconds
-
isSourceInGeographicCoordinates
public boolean isSourceInGeographicCoordinates()
Indicates whether the source data was in geographic coordinates- Specified by:
isSourceInGeographicCoordinatesin interfaceIVertexReader- Returns:
- true if the source data used geographic coordinates; otherwise, false.
-
read
public List<Vertex> read(IMonitorWithCancellation monitor) throws IOException
Read the records from the shapefile and use them to populate vertices. If the input shapefile is based on PolyLine features, this method assumes that it provides contours contours. In that case, the zero-depth contours are ignored and other valued contours are added to the linear constraint list.The loader has the option of loading the z coordinate from either the main shapefile itself (the SHP file) or from the associated DBF file. If you wish to use a field in the DBF file as a z coordinate, specify the name of the field as an argument. If you wish to use the z coordinate from the shapefile, specify a null or empty string. If a null or empty string is specified, and the shapefile does not contain a feature type that provides z coordinates, the z coordinates will be uniformly populated with zeroes.
The index of the vertex is set to be the shapefile record number. Thus many vertices may be assigned with the same record number, particularly if the input is a polygon or line feature.
- Specified by:
readin interfaceIVertexReader- Parameters:
monitor- an optional progress monitor, or null if not required.- Returns:
- a valid, potentially empty list of vertices
- Throws:
IOException- in the event of an unrecoverable I/O condition
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getCoordinateTransform
public ICoordinateTransform getCoordinateTransform()
- Specified by:
getCoordinateTransformin interfaceIVertexReader
-
setCoordinateTransform
public void setCoordinateTransform(ICoordinateTransform transform)
- Specified by:
setCoordinateTransformin interfaceIVertexReader
-
getLinearUnits
public LinearUnits getLinearUnits()
Gets the linear units for the horizontal coordinate system from the shapefile. This value is typically obtained from the PRJ file associated with the shapefile.- Returns:
- a valid enumeration instance
-
getVertices
public List<Vertex> getVertices()
Gets the list of vertices that were collected during the most recent read operation. The list may be empty if the input shapefile included no usable data.- Returns:
- a valid, potentially empty, list of vertices.
-
getLinearConstraints
public List<LinearConstraint> getLinearConstraints()
Gets the list of constraints that were collected during the most recent read operation. The list will be populated only if the input shapefile contains PolyLine features (assumed to be contours).- Returns:
- a valid, potentially empty, list of vertices.
-
-