Class TLcdCSVDataSource.Builder

java.lang.Object
com.luciad.format.csv.TLcdCSVDataSource.Builder
Enclosing class:
TLcdCSVDataSource

public static final class TLcdCSVDataSource.Builder extends Object
Builder class for a TLcdCSVDataSource instance.
Since:
2018.0
  • Method Details

    • source

      public TLcdCSVDataSource.Builder source(String aSource)
      Sets the source name of the CSV data file
      Parameters:
      aSource - The source name
      Returns:
      this builder
    • geometry

      public TLcdCSVDataSource.Builder geometry(int aWKTGeometryColumn)
      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

      public TLcdCSVDataSource.Builder geoJsonGeometry(int aGeoJsonGeometryColumn)
      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

      public TLcdCSVDataSource.Builder geometry(int aXPointCoordinateColumn, int aYPointCoordinateColumn)
      Sets the X and Y coordinate columns for point geometries. Use 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.
      Parameters:
      aXPointCoordinateColumn - The index of the X coordinate column
      aYPointCoordinateColumn - 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 column
      aYPointCoordinateColumn - The index of the Y coordinate column
      aZPointCoordinateColumn - The index of the Z coordinate column. Use a negative value when not available.
      Returns:
      this builder
    • separator

      public TLcdCSVDataSource.Builder separator(String aSeparator)
      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 the 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.
      Parameters:
      aColumnTypes - The column types, or null when unknown.
      Returns:
      this builder
      See Also:
    • names

      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();
       
      Parameters:
      aColumnNames - The name of the columns. Using null is equivalent to calling firstRowContainsNames().
      Returns:
      this builder
      See Also:
    • rowsToSkip

      public TLcdCSVDataSource.Builder rowsToSkip(int aRowsToSkip)
      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

      public TLcdCSVDataSource.Builder firstRowContainsNames()
      Indicates that the first row in the file contains the column names. Calling this method will override any names set using the 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.
      Returns:
      this builder
    • encoding

      public TLcdCSVDataSource.Builder encoding(Charset aCharset)
      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

      public TLcdCSVDataSource.Builder id(int aIndex)
      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

      public TLcdCSVDataSource build()
      Creates a new TLcdCSVDataSource instance based on the settings of this builder.
      Returns:
      a new TLcdCSVDataSource instance