Package com.luciad.format.csv
Class TLcdCSVDataSource.Builder
java.lang.Object
com.luciad.format.csv.TLcdCSVDataSource.Builder
- Enclosing class:
TLcdCSVDataSource
Builder class for a
TLcdCSVDataSource
instance.- Since:
- 2018.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates a newTLcdCSVDataSource
instance based on the settings of this builder.Sets the encoding of the data file.Indicates that the first row in the file contains the column names.geoJsonGeometry
(int aGeoJsonGeometryColumn) Sets the GeoJson geometry column.geometry
(int aWKTGeometryColumn) Sets the WKT geometry column.geometry
(int aXPointCoordinateColumn, int aYPointCoordinateColumn) Sets the X and Y coordinate columns for point geometries.geometry
(int aXPointCoordinateColumn, int aYPointCoordinateColumn, int aZPointCoordinateColumn) Sets the X, Y and Z coordinate columns for point geometries.id
(int aIndex) Sets the index of the column with the unique identifier for each feature.Sets the names of the columns.rowsToSkip
(int aRowsToSkip) Sets the number of rows to skip at the beginning of the data file.Sets the separator used in the data file.Sets the source name of the CSV data filetypes
(List<TLcdCSVDataSource.ColumnType> aColumnTypes) Sets the types of the different columns.
-
Method Details
-
source
Sets the source name of the CSV data file- Parameters:
aSource
- The source name- Returns:
- this builder
-
geometry
Sets the WKT geometry column. Calling this method with a non-negative value will override any previous geometry column specifications done on this builder.- Parameters:
aWKTGeometryColumn
- The index of the WKT geometry column.- Returns:
- this builder
-
geoJsonGeometry
Sets the GeoJson geometry column. Calling this method with a non-negative value will override any previous geometry column specifications done on this builder.- Parameters:
aGeoJsonGeometryColumn
- The index of the GeoJson geometry column.- Returns:
- this builder
- Since:
- 2019.1
-
geometry
Sets the X and Y coordinate columns for point geometries. Usegeometry(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.- Parameters:
aXPointCoordinateColumn
- The index of the X coordinate columnaYPointCoordinateColumn
- The index of the Y coordinate column- Returns:
- this builder
-
geometry
public TLcdCSVDataSource.Builder geometry(int aXPointCoordinateColumn, int aYPointCoordinateColumn, int aZPointCoordinateColumn) Sets the X, Y and Z coordinate columns for point geometries. Calling this method with a non-negative value will override any previous geometry column specifications done on this builder.- Parameters:
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.- Returns:
- this builder
-
separator
Sets the separator used in the data file. The default value for the separator is a comma (",").- Parameters:
aSeparator
- The separator- Returns:
- this builder
-
types
Sets the types of the different columns. Note that the list of types must contain either theTLcdCSVDataSource.ColumnType.WKT
column type, theTLcdCSVDataSource.ColumnType.GEO_JSON
column type, or theTLcdCSVDataSource.ColumnType.X_COORD
andTLcdCSVDataSource.ColumnType.Y_COORD
column types.- Parameters:
aColumnTypes
- The column types, ornull
when unknown.- Returns:
- this builder
- See Also:
-
names
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();
- Parameters:
aColumnNames
- The name of the columns. Usingnull
is equivalent to callingfirstRowContainsNames()
.- Returns:
- this builder
- See Also:
-
rowsToSkip
Sets the number of rows to skip at the beginning of the data file. By default all rows are read (zero rows are skipped).- Parameters:
aRowsToSkip
- The number of rows to skip- Returns:
- this builder
-
firstRowContainsNames
Indicates that the first row in the file contains the column names. Calling this method will override any names set using thenames(List)
method. By default the builder assumes that the first row are the column names. When that is not the case, call thenames(List)
method to manually specify the names.- Returns:
- this builder
-
encoding
Sets the encoding of the data file. By default this builder assumes that the file is encoding as UTF-8.- Parameters:
aCharset
- the character set- Returns:
- this builder
-
id
Sets the index of the column with the unique identifier for each feature. This column must contain long values. By default the builder assumes no ID column exists.- Parameters:
aIndex
- The index of the id column, or a negative value to indicate that no such column exists.- Returns:
- this builder
-
build
Creates a newTLcdCSVDataSource
instance based on the settings of this builder.- Returns:
- a new
TLcdCSVDataSource
instance
-