public ShapefileReader()

in baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/ShapefileReader.java [60:88]


  public ShapefileReader(String shapefile) {
    Objects.requireNonNull(shapefile, "The shapefile to load cannot be null.");

    this.shapefile = new File(shapefile);

    // Deduct database file name by suffixing it by dbf (trying to respect the same case).
    StringBuilder dbfFileName = new StringBuilder(shapefile);

    String dbfSuffix = null;
    dbfSuffix = shapefile.endsWith("shp") ? "dbf" : dbfSuffix;
    dbfSuffix = shapefile.endsWith("SHP") ? "DBF" : dbfSuffix;
    dbfSuffix = shapefile.endsWith("Shp") ? "Dbf" : dbfSuffix;
    dbfSuffix = (dbfSuffix == null) ? "dbf" : dbfSuffix;

    dbfFileName.replace(shapefile.length() - 3, shapefile.length(), dbfSuffix);
    this.databaseFile = new File(dbfFileName.toString());

    // Deduct shapefile index file name by suffixing it by shx (trying to respect the same case).
    StringBuilder shapeFileIndexName = new StringBuilder(shapefile);

    String shapeFileIndexSuffix = null;
    shapeFileIndexSuffix = shapefile.endsWith("shp") ? "shx" : shapeFileIndexSuffix;
    shapeFileIndexSuffix = shapefile.endsWith("SHP") ? "SHX" : shapeFileIndexSuffix;
    shapeFileIndexSuffix = shapefile.endsWith("Shp") ? "Shx" : shapeFileIndexSuffix;
    shapeFileIndexSuffix = (shapeFileIndexSuffix == null) ? "shx" : shapeFileIndexSuffix;

    shapeFileIndexName.replace(shapefile.length() - 3, shapefile.length(), shapeFileIndexSuffix);
    this.shapeFileIndex = new File(shapeFileIndexName.toString());
  }