Interface ICountryLoader

All Known Implementing Classes:
GeoJsonCountryLoader, ShapefileCountryLoader

public interface ICountryLoader
Format-agnostic contract for loading country boundary features.

Implementations exist for GeoJSON (GeoJsonCountryLoader) and ESRI Shapefile (ShapefileCountryLoader). Callers such as MapView2D depend only on this interface so that switching the source format requires no changes to rendering or hit-testing code.

Output contract

All load methods must return an unmodifiable list of GeoJsonCountryLoader.CountryFeature instances whose polygon coordinates are in radians with longitude wrapped to (-π, π].

Error handling

Implementations must throw IOException for any I/O or parse error. Individual malformed features may be silently skipped rather than aborting the entire load, but the method must never return null.

  • Method Details

    • load

      Loads country features from the given filesystem path.

      The path may point to the primary file of a multi-file format (e.g. the .shp file of a shapefile set) or to a self-contained file (e.g. a .geojson file). Implementations are responsible for locating any companion files (e.g. .dbf, .shx) relative to the supplied path.

      Parameters:
      path - path to the data file; must not be null
      Returns:
      unmodifiable list of country features; never null
      Throws:
      IOException - if the file cannot be read or parsed
    • loadFromResource

      List<GeoJsonCountryLoader.CountryFeature> loadFromResource(String resourcePath) throws IOException
      Loads country features from a classpath resource.

      The resource path must be absolute (begin with /) so that Class.getResourceAsStream(String) resolves it correctly. For multi-file formats this method may not be supportable (e.g. a shapefile set cannot be fully represented as a single classpath resource); in that case implementations should throw UnsupportedOperationException with a clear message.

      Parameters:
      resourcePath - absolute classpath resource path; must not be null
      Returns:
      unmodifiable list of country features; never null
      Throws:
      IOException - if the resource cannot be read or parsed
      UnsupportedOperationException - if the format does not support classpath resource loading