geobase 0.1.0-a.0 copy "geobase: ^0.1.0-a.0" to clipboard
geobase: ^0.1.0-a.0 copied to clipboard

outdated

Geospatial data (features, geometries, coordinates) writers (GeoJSON, WKT) for Dart.

Geospatial data writers

pub package License style: very good analysis

The package provides data writers for geospatial features, geometries, coordinates and properties. Currently the supported formats are GeoJSON and WKT (Well-known text representation of geometry).

There are also data structures to represent positions and bounding boxes, both for geographic coordinate systems and projected (or cartesian) coordinate systems.

Features #

  • πŸ”’ enums for geospatial coordinate and geometry types
  • 🌐 geographic positions and bounding boxes (longitude-latitude-elevation)
  • πŸ—ΊοΈ projected positions and bounding boxes (cartesian XYZ)
  • πŸ“ƒ geospatial data writers for features, geometries, coordinates, properties:
    • 🌎 supported formats: GeoJSON
  • πŸ“ƒ geospatial data writers for geometries and coordinates:
    • πŸͺ§ supported formats: WKT

This package is at BETA stage, interfaces not fully final yet.

Getting started #

The package requires at least Dart SDK 2.12, and it supports all Dart and Flutter platforms.

Usage #

Add the dependency in your pubspec.yaml:

dependencies:
  geobase: ^0.1.0-a.0

Import it:

import `package:geobase/geobase.dart`

A sample to write a Point geometry to WKT (with z and m coordinates too):

  // geometry writer for WKT
  final writer = wktFormat().geometriesToText();

  // prints:
  //    POINT ZM(10.123 20.25 -30.95 -1.999)
  print(
    writer
      ..geometryWithPosition(
        type: Geom.point,
        coordType: Coords.xyzm,
        coordinates: const Position(x: 10.123, y: 20.25, z: -30.95, m: -1.999),
      )
      ..toString(),
  );

A sample to write a LineString geometry to GeoJSON:

  // geometry writer for GeoJSON
  final writer = geoJsonFormat().geometriesToText();

  // prints (however without line breaks):
  //    {"type":"LineString",
  //     "bbox":[-1.1,-3.49,3.5,-1.1],
  //     "coordinates":[[-1.1,-1.1],[2.1,-2.5],[3.5,-3.49]]}
  print(
    writer
      ..geometryWithPositions1D(
        type: Geom.lineString,
        bbox: const GeoBox(west: -1.1, south: -3.49, east: 3.5, north: -1.1),
        coordinates: [
          const GeoPosition(lon: -1.1, lat: -1.1),
          const GeoPosition(lon: 2.1, lat: -2.5),
          const GeoPosition(lon: 3.5, lat: -3.49),
        ],
      )
      ..toString(),
  );

A sample to write a Feature geometry to GeoJSON:

  // feature writer for GeoJSON
  final writer = geoJsonFormat().featuresToText();

  // prints (however without line breaks):
  //    {"type":"Feature",
  //     "id":"fid-1",
  //     "geometry":
  //        {"type":"Point","coordinates":[10.123,20.25]},
  //     "properties":
  //        {"foo":100,"bar":"this is property value","baz":true}}
  print(
    writer
      ..feature(
        id: 'fid-1',
        geometries: (gw) => gw.geometryWithPosition(
          type: Geom.point,
          coordinates: const GeoPosition(lon: 10.123, lat: 20.25),
        ),
        properties: {
          'foo': 100,
          'bar': 'this is property value',
          'baz': true,
        },
      )
      ..toString(),
  );

Package #

This is a Dart package named geobase under the geospatial code repository.

See also the geocore package for geometry and feature data structures, data parsers, coordinate transformations and other utitilies.

Authors #

This project is authored by Navibyte.

More information and other links are available at the geospatial repository from GitHub.

License #

This project is licensed under the "BSD-3-Clause"-style license.

Please see the LICENSE.

24
likes
0
pub points
88%
popularity

Publisher

verified publishernavibyte.com

Geospatial data (features, geometries, coordinates) writers (GeoJSON, WKT) for Dart.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

meta

More

Packages that depend on geobase