MoonBit Shapefile geometry, index and attribute table reader/writer
let shape = {
kind: @shapefile.Point,
points: [@shapefile.coordinate(116.4, 39.9)],
parts: [],
}
let files = @shapefile.write_shp(@shapefile.Point, [shape])
let parsed = @shapefile.read_shp(files.shp)
println(parsed.records.length().to_string())moon check --deny-warn
moon test --deny-warn
moon fmt --check
moon build --target wasm-gc
moon run cmd/mainfn Dataset::filter_bbox(self : Dataset, bounds : Bounds, include_deleted? : Bool) -> Dataset raise ShapeErrorfn Dataset::filter_equal(self : Dataset, field : String, value : Value, include_deleted? : Bool) -> Dataset raise ShapeErrorfn Dataset::to_geojson(self : Dataset, allow_projected? : Bool, include_deleted? : Bool) -> Json raise ShapeErrorpub struct IndexedReader {
data : Bytes
file_header : Header
entries : Array[IndexEntry]
limits : ReadLimits
}fn IndexedReader::open(shp : Bytes, shx : Bytes, limits? : ReadLimits) -> IndexedReader raise ShapeErrorfn IndexedReader::select(self : IndexedReader, indices : Array[Int]) -> Array[Record] raise ShapeErrorpub(all) struct ReadLimits {
max_records : Int
max_points_per_record : Int
max_parts_per_record : Int
max_file_bytes : Int
} derive(Debug)pub struct ShpWriter {
kind : ShapeType
limits : ReadLimits
records : Array[Bytes]
total_bytes : Int
bounds : Bounds?
zrange : (Double, Double)?
mrange : (Double, Double)?
}fn read_dataset(shp : Bytes, shx : Bytes, dbf : Bytes, encoding? : Encoding, prj? : String?) -> Dataset raise ShapeErrorfn write_shp(kind : ShapeType, shapes : Array[Shape], limits? : ReadLimits) -> ShapeFiles raise ShapeErrorInstall
Download zipMoonBit Shapefile geometry, index and attribute table reader/writer