ac_geojson 1.0.4
ac_geojson: ^1.0.4 copied to clipboard
GeoJson classes using JsonSerializable
ac_geojson #
A Dart implementation of GeoJSON (RFC 7946) using json_serializable
for robust parsing and serialization of geographical data structures.
Features #
- RFC 7946 Compliant: Adheres to the GeoJSON specification.
- Type-Safe Models: Provides Dart classes for all GeoJSON objects (e.g.,
Point
,LineString
,Polygon
,Feature
,FeatureCollection
). - JSON Serialization/Deserialization: Leverages
json_serializable
for easy conversion to and from JSON. - Geometry Operations (Planned/Optional): (TODO: If you plan to add any, list them here, e.g., Bounding Box calculation, Point-in-Polygon tests).
- Null-Safety: Fully null-safe.
Getting started #
To use this package, add ac_geojson
as a dependency in your pubspec.yaml
file:
Then, run dart pub get
or flutter pub get
.
You will also need to run the build runner to generate the .g.dart
files:
dart run build_runner build --delete-conflicting-outputs
Usage #
Here's a simple example of creating a GeoJSON Point
and serializing it to JSON:
void createPoint() {
// Creating point coordinates
final coordinates = PointCoordinates(latitude: 50.0755, longitude: 14.4378); // Prague
// Creating a Point object
final point = GeoJsonPoint(coordinates: coordinates);
// Converting to JSON
final pointJson = point.toJson();
final encodedPoint = jsonEncode(pointJson);
print('Point object: $point');
print('Point as JSON: $encodedPoint');
}
For more detailed examples, please see the example/
directory and the tests.
Additional information #
- GeoJSON Specification: RFC 7946
- Repository:
https://github.com/anycode/ac_geojson
- Issue tracker:
https://github.com/anycode/ac_geojson/issues
- API Reference:
https://pub.dev/documentation/ac_geojson/latest/
Contributions are welcome! Please feel free to submit a pull request or open an issue if you find any bugs or have feature requests.