public static final class TLcdCSVDataSource.Builder extends Object
TLcdCSVDataSource
instance.Modifier and Type | Method and Description |
---|---|
TLcdCSVDataSource |
build()
Creates a new
TLcdCSVDataSource instance based on the settings of this builder. |
TLcdCSVDataSource.Builder |
encoding(Charset aCharset)
Sets the encoding of the data file.
|
TLcdCSVDataSource.Builder |
firstRowContainsNames()
Indicates that the first row in the file contains the column names.
|
TLcdCSVDataSource.Builder |
geoJsonGeometry(int aGeoJsonGeometryColumn)
Sets the GeoJson geometry column.
|
TLcdCSVDataSource.Builder |
geometry(int aWKTGeometryColumn)
Sets the WKT geometry column.
|
TLcdCSVDataSource.Builder |
geometry(int aXPointCoordinateColumn,
int aYPointCoordinateColumn)
Sets the X and Y coordinate columns for point geometries.
|
TLcdCSVDataSource.Builder |
geometry(int aXPointCoordinateColumn,
int aYPointCoordinateColumn,
int aZPointCoordinateColumn)
Sets the X, Y and Z coordinate columns for point geometries.
|
TLcdCSVDataSource.Builder |
id(int aIndex)
Sets the index of the column with the unique identifier for each feature.
|
TLcdCSVDataSource.Builder |
names(List<String> aColumnNames)
Sets the names of the columns.
|
TLcdCSVDataSource.Builder |
rowsToSkip(int aRowsToSkip)
Sets the number of rows to skip at the beginning of the data file.
|
TLcdCSVDataSource.Builder |
separator(String aSeparator)
Sets the separator used in the data file.
|
TLcdCSVDataSource.Builder |
source(String aSource)
Sets the source name of the CSV data file
|
TLcdCSVDataSource.Builder |
types(List<TLcdCSVDataSource.ColumnType> aColumnTypes)
Sets the types of the different columns.
|
public TLcdCSVDataSource.Builder source(String aSource)
aSource
- The source namepublic TLcdCSVDataSource.Builder geometry(int aWKTGeometryColumn)
aWKTGeometryColumn
- The index of the WKT geometry column.public TLcdCSVDataSource.Builder geoJsonGeometry(int aGeoJsonGeometryColumn)
aGeoJsonGeometryColumn
- The index of the GeoJson geometry column.public TLcdCSVDataSource.Builder geometry(int aXPointCoordinateColumn, int aYPointCoordinateColumn)
geometry(int, int, int)
when a Z-value is also available.
Calling this method with a non-negative value will override any previous geometry column specifications done on this builder.aXPointCoordinateColumn
- The index of the X coordinate columnaYPointCoordinateColumn
- The index of the Y coordinate columnpublic TLcdCSVDataSource.Builder geometry(int aXPointCoordinateColumn, int aYPointCoordinateColumn, int aZPointCoordinateColumn)
aXPointCoordinateColumn
- The index of the X coordinate columnaYPointCoordinateColumn
- The index of the Y coordinate columnaZPointCoordinateColumn
- The index of the Z coordinate column. Use a negative value when not available.public TLcdCSVDataSource.Builder separator(String aSeparator)
aSeparator
- The separatorpublic TLcdCSVDataSource.Builder types(List<TLcdCSVDataSource.ColumnType> aColumnTypes)
TLcdCSVDataSource.ColumnType.WKT
column type, the TLcdCSVDataSource.ColumnType.GEO_JSON
column type,
or the TLcdCSVDataSource.ColumnType.X_COORD
and TLcdCSVDataSource.ColumnType.Y_COORD
column types.aColumnTypes
- The column types, or null
when unknown.TLcdCSVDataSource.ColumnType.decodeSource(String, ILcdInputStreamFactory, Charset)
public TLcdCSVDataSource.Builder names(List<String> aColumnNames)
Sets the names of the columns. Calling this method indicates that the first row of the CSV file should be interpreted as a data row and not as a header.
This method can also be used to override the column names which are present in the CSV file. Assume that the first line of the CSV file specifies the column names and you want to replace them. In that case, you can use
TLcdCSVDataSource csvDataSource =
TLcdCSVDataSource.newBuilder()
.source("path/to/csv/file.csv")
.rowsToSkip(1) //indicate that the row containing the column names should be skipped
.names(Arrays.asList("Custom name", "Custom name 2", "WKT geometry")) //specify the custom names
.geometry(2) //indicate which column contains the geometry
.build();
aColumnNames
- The name of the columns.
Using null
is equivalent to calling firstRowContainsNames()
.firstRowContainsNames()
public TLcdCSVDataSource.Builder rowsToSkip(int aRowsToSkip)
aRowsToSkip
- The number of rows to skippublic TLcdCSVDataSource.Builder firstRowContainsNames()
names(List)
method.
By default the builder assumes that the first row are the column names.
When that is not the case, call the names(List)
method to manually specify the names.public TLcdCSVDataSource.Builder encoding(Charset aCharset)
aCharset
- the character setpublic TLcdCSVDataSource.Builder id(int aIndex)
aIndex
- The index of the id column, or a negative value to indicate that no such column exists.public TLcdCSVDataSource build()
TLcdCSVDataSource
instance based on the settings of this builder.TLcdCSVDataSource
instance