Interface ICountryLoader
- All Known Implementing Classes:
GeoJsonCountryLoader,ShapefileCountryLoader
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 Summary
Modifier and TypeMethodDescriptionLoads country features from the given filesystem path.loadFromResource(String resourcePath) Loads country features from a classpath resource.
-
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
.shpfile of a shapefile set) or to a self-contained file (e.g. a.geojsonfile). 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 benull- Returns:
- unmodifiable list of country features; never
null - Throws:
IOException- if the file cannot be read or parsed
-
loadFromResource
Loads country features from a classpath resource.The resource path must be absolute (begin with
/) so thatClass.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 throwUnsupportedOperationExceptionwith a clear message.- Parameters:
resourcePath- absolute classpath resource path; must not benull- Returns:
- unmodifiable list of country features; never
null - Throws:
IOException- if the resource cannot be read or parsedUnsupportedOperationException- if the format does not support classpath resource loading
-