public class VertexReaderText extends Object implements Closeable, IVertexReader
Comment Lines: Lines beginning with a "hash sign", or #, will be treated as comments and ignored. Blank lines will be ignored.
Delimiters: Specifications in text files depend on the presence of a delimiter character to separate data fields given on a line of text. Typically delimiters are specified using a space, tab, comma, or vertical-bar character (pipe). Files with the extension ".csv" (for comma-separated-value) are assumed to be comma-delimited. Otherwise, the constructor will attempt to inspect the content of the specified file and determine the delimiter based on internal clues. If a file includes a mix of potential delimiters, such as both spaces and commas, the delimiter will be determined on the basis of precedence. Supported delimiters, in increasing order of precedence, are comma, space, tab, and vertical bar.
An application may also override the automatically determined delimiter through the setDelimiter() method.
Column Headers: By default, columns in the file are treated as giving x, y, and z coordinates in that order. The order of the coordinate specifications can be altered through the use of column headers. If the first non-comment line in a file contains non-numeric specifications, the line will be treated as a "header" line that gives the names of columns.
Geographic Coordinates: While this class is not sufficient for Geographic Information Systems (GIS), it does provide minimal support for geographic coordinates. If the values in the file are to be treated as geographic coordinates, the input file must include a header row indicating which columns are latitude and longitude. This feature serves two purposes, it informs the model that the coordinates are geographic and it dispels any ambiguity about which column is which. Geographic coordinate values must be giving in standard decimal numeric form using negative numbers for southern latitudes and western longitudes (the quadrant characters N, S, E, W, and the degrees-minutes-seconds notion are not supported at this time).
For example:
latitude, longitude, z
42.5, 73.33, 2001
Note, however that if both geographic and Cartesian coordinates are provided, the Cartesian coordinates will take precedence. The rationale, for this design decision is that specifications of this type are usually encountered in cases where data from geographic sources have be projected to a planar coordinate system.
Linear Units: Although a specification of units for the values in the source file is not supported by the text format, applications can specify linear units through the use of the setLinearUnits() method. The primary use for this feature is in the case of geographic coordinates. Linear units are used to scale coordinates when geographic coordinates (latitude, longitude) are transformed to Cartesian (planar) coordinates.
Constructor and Description |
---|
VertexReaderText(File file) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
ICoordinateTransform |
getCoordinateTransform()
Gets the coordinate transform associated with this instance.
|
char |
getDelimiter()
Gets the delimiter character for a file.
|
LinearUnits |
getLinearUnits()
Gets the linear units for the coordinate system used by the data.
|
double |
getXMax()
Gets the maximum x coordinate in the sample
|
double |
getXMin()
Gets the minimum x coordinate in the sample
|
double |
getYMax()
Gets the maximum y coordinate in the sample
|
double |
getYMin()
Gets the minimum y coordinate in the sample
|
double |
getZMax()
Gets the maximum z coordinate in the sample
|
double |
getZMin()
Gets the minimum z coordinate in the sample
|
boolean |
isSourceInGeographicCoordinates()
Indicates whether the source data was in geographic coordinates
|
List<Vertex> |
read(IMonitorWithCancellation monitor)
Read a collection of vertices from the data source associated
with the current implementation and instance.
|
void |
setCoordinateTransform(ICoordinateTransform transform)
Sets a coordinate transform to be used for mapping values from the source
file to vertex coordinates.
|
void |
setDelimiter(char delimiter)
Sets the delimiter character for a file.
|
void |
setLinearUnits(LinearUnits linearUnits)
Sets the linear units for the coordinate system used by the horizontal (x
and y) coordinates of the data.
|
public VertexReaderText(File file) throws IOException
IOException
public List<Vertex> read(IMonitorWithCancellation monitor) throws IOException
IVertexReader
Monitoring Progress of the Read Because some input sources can produce quite a large number of vertices and may require several seconds for load operations, this interface supports an optional monitor object. Implementation classes are not required to support monitors, but should do so if it is feasible. The Tinfour monitor is intended to support two operations. First, it provides a read operation a mechanism for advising the calling application on the status of its progress. Second, it provides the calling application a mechanism for canceling a read operation. These operations are generally used in support of a user interface, but may have other applications.
All implementations are expected to implement logic to handle a null monitor reference.
read
in interface IVertexReader
monitor
- a valid instance or a null if no monitoring is desired.IOException
- in the event of unreadable data or I/O access
exceptions.public char getDelimiter()
public void setDelimiter(char delimiter)
delimiter
- a valid characterpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public double getXMin()
getXMin
in interface IVertexReader
public double getXMax()
getXMax
in interface IVertexReader
public double getYMin()
getYMin
in interface IVertexReader
public double getYMax()
getYMax
in interface IVertexReader
public double getZMin()
getZMin
in interface IVertexReader
public double getZMax()
getZMax
in interface IVertexReader
public boolean isSourceInGeographicCoordinates()
isSourceInGeographicCoordinates
in interface IVertexReader
public LinearUnits getLinearUnits()
public void setLinearUnits(LinearUnits linearUnits)
linearUnits
- a valid instancepublic ICoordinateTransform getCoordinateTransform()
getCoordinateTransform
in interface IVertexReader
public void setCoordinateTransform(ICoordinateTransform transform)
setCoordinateTransform
in interface IVertexReader
transform
- a valid transform or a null if none is to be applied.Copyright © 2021. All rights reserved.