public OpenStreetMapSchema()

in baremaps-calcite/src/main/java/org/apache/baremaps/calcite/openstreetmap/OpenStreetMapSchema.java [90:147]


  public OpenStreetMapSchema(File file, RelDataTypeFactory typeFactory, boolean isDirectory)
      throws IOException {
    if (isDirectory) {
      // If isDirectory is true, treat the file as a directory
      this.directory = Objects.requireNonNull(file, "Directory cannot be null");
      this.typeFactory = Objects.requireNonNull(typeFactory, "Type factory cannot be null");
      this.tableMap = new HashMap<>();

      // Process files in the directory
      File[] files = file.listFiles((dir, name) -> name.toLowerCase().endsWith(".pbf") ||
          name.toLowerCase().endsWith(".osm.pbf") ||
          name.toLowerCase().endsWith(".xml") ||
          name.toLowerCase().endsWith(".osm"));

      if (files != null) {
        for (File osmFile : files) {
          // Extract the base name without extension (e.g., "sample" from "sample.osm.pbf")
          String fileName = osmFile.getName();
          String tableName = fileName;

          // Remove all extensions (e.g., "sample.osm.pbf" -> "sample")
          while (tableName.contains(".")) {
            int lastDotIndex = tableName.lastIndexOf('.');
            if (lastDotIndex > 0) {
              tableName = tableName.substring(0, lastDotIndex);
            } else {
              break;
            }
          }

          // Create the table with the file reference
          tableMap.put(tableName, createTable(osmFile));
        }
      }
    } else {
      // If isDirectory is false, treat the file as a single file
      this.directory = Objects.requireNonNull(file, "File cannot be null");
      this.typeFactory = Objects.requireNonNull(typeFactory, "Type factory cannot be null");
      this.tableMap = new HashMap<>();

      // Extract the base name without extension (e.g., "sample" from "sample.osm.pbf")
      String fileName = file.getName();
      String tableName = fileName;

      // Remove all extensions (e.g., "sample.osm.pbf" -> "sample")
      while (tableName.contains(".")) {
        int lastDotIndex = tableName.lastIndexOf('.');
        if (lastDotIndex > 0) {
          tableName = tableName.substring(0, lastDotIndex);
        } else {
          break;
        }
      }

      // Create the table with the file reference
      tableMap.put(tableName, createTable(file));
    }
  }