Package-level declarations

Types

Link copied to clipboard
sealed class DBaseCharset

Character encodings supported by the dBASE / DBF string decoder. Single-byte codepages are decoded in pure Kotlin via 256-entry lookup tables, so no platform-specific Charset support is required. Multi-byte codepages (GBK, Shift_JIS, etc.) are not supported here — callers using those encodings should resolve them on their own.

Link copied to clipboard
data class DBaseField(val name: String, val type: DBaseFieldType, val typeCode: Char, val length: Int, val decimals: Int)

Schema for a single DBF column.

Link copied to clipboard
Link copied to clipboard
class DBaseFile(bytes: ByteArray, charset: DBaseCharset? = null, cpgText: String? = null)

Parser for a dBASE III / IV (.dbf) sidecar file holding shapefile attributes. Records are read eagerly into records; row N (one-based, matching the .shp record number) is at records[N - 1].

Link copied to clipboard
data class DBaseRecord(val recordNumber: Int, val deleted: Boolean, val values: Map<String, Any?>)

One row of attributes. recordNumber is one-based and matches the .shp record number. deleted is the dBASE record deletion flag; deleted rows are still parsed and exposed so callers can filter them.

Link copied to clipboard

Per-part type codes for MultiPatch records. Each part in a ShapefileShapeType.MULTI_PATCH record carries one of these to indicate how the vertices in that part assemble into triangles. The numeric values match the ESRI Shapefile Technical Description.

Link copied to clipboard
class PrjFile(val text: String)

Projection (.prj) parser. Distinguishes geographic and projected coordinate systems via OGC well-known text. For projected systems we recognize the UTM family — the only projection commonly distributed with raw shapefiles — and expose a Projection that can convert easting/northing pairs into lon/lat. Other projected systems are flagged as projected-but-unsupported; callers can treat coordinates as geographic at their own risk.

Link copied to clipboard
class Shapefile(shpBytes: ByteArray, val projection: PrjFile? = null, val attributes: DBaseFile? = null)

Parser for an ESRI shapefile (.shp). Reads the entire input eagerly into a List<ShapefileRecord> at construction time; iteration is then in-memory and allocation-free. Mirrors the behavior of WebWorldWind's Shapefile class.

Link copied to clipboard

BulkFeatureSource for ESRI Shapefiles. Downloads the .shp/.dbf/.prj/.cpg quartet from shpUrl (sidecars derived by extension), parses every record through ShapefileLayerFactory, and emits one CachedFeatureRow per record with the geometry extracted as a CachedGeometry and the DBF attributes encoded as a JSON object string.

Link copied to clipboard

Builds a RenderableLayer from an ESRI shapefile. Two entry points:

Link copied to clipboard

One parsed shapefile record. Records of all shape types are represented by this single class; the shapeType field discriminates. Geometry is exposed as a list of "parts", each part an interleaved [x0, y0, x1, y1, …] DoubleArray matching the on-disk coordinate order (longitude, latitude for geographic shapefiles).

Link copied to clipboard
data class ShapefileShapeConfiguration(val attributes: ShapeAttributes? = null, val highlightAttributes: ShapeAttributes? = null, val placemarkAttributes: PlacemarkAttributes? = null, val highlightPlacemarkAttributes: PlacemarkAttributes? = null, val altitudeMode: AltitudeMode = AltitudeMode.RELATIVE_TO_GROUND, val altitude: Double = 0.0, val height: Double = 0.0, val name: String? = null)

Per-record customization returned by the ShapefileLayerFactory shapeConfiguration callback. Match WebWorldWind's plain-object configuration: setting attributes / placemarkAttributes overrides the defaults; setting altitude or height switches polylines from SurfacePolyline to Path and polygons from SurfacePolygon to extruded Polygon; returning null from the callback skips the record entirely.

Link copied to clipboard

Shape type discriminator for a shapefile record. ESRI shapefiles carry the type code in the file header and again at the start of every record's contents.

Functions

Link copied to clipboard
suspend fun ShapefileLayerFactory.createLayerFromZip(zipBytes: ByteArray, displayName: String? = null, shapeConfiguration: (ShapefileRecord) -> ShapefileShapeConfiguration? = { ShapefileShapeConfiguration() }): RenderableLayer

Loads a shapefile distributed as a ZIP archive (the canonical packaging on most data portals). The first .shp, .dbf, .prj, and .cpg entries found are routed through ShapefileLayerFactory.createLayer. Entries deeper in subdirectories are accepted too, but only the first match of each extension is used — ZIP archives occasionally bundle multiple shapefiles together, and picking one deterministically is better than guessing.