Geospatial feature service Web APIs with support for GeoJSON and OGC API Features clients for Dart.
Features
✨ New: Updated with latest geobase version 0.2.1 and geocore version 0.9.0 based on Dart SDK 2.17.
Key features:
- Client-side data source abstraction for geospatial feature service Web APIs
- Implementations to read geospatial features
- GeoJSON features from Web APIs or files
- OGC API Features based services (partial support)
The client-side support for the
OGC API Features standard is not complete,
however key functionality of Part1
of the standard is supported.
Package
The package requires at least Dart SDK 2.17, and it supports all Dart and Flutter platforms.
To use, add the dependency in your pubspec.yaml
:
dependencies:
geodata: ^0.9.0
The package contains also following mini-libraries, that can be used to import only a certain subset instead of the whole geodata library:
Library | Exports also | Description |
---|---|---|
common | Common data structures and helpers (for links, metadata, paged responses). | |
core | Metadata and data source abstractions of geospatial Web APIs (ie. features). | |
geojson_client | common, core | A client-side data source to read GeoJSON data from web and file resources. |
ogcapi_features_client | common, core | A client-side data source to read features from OGC API Features services. |
All the mini-libraries have dependencies to the equatable, geobase and geocore packages.
The geojson_client and ogcapi_features_client libraries depends also on the http package.
Usage
This sample shows to read GeoJSON features from a web resource using a HTTP fetcher, and from a local file using a file fetcher.
Please see other examples too.
import 'package:geodata/geojson_client.dart';
Future<void> main(List<String> args) async {
// read GeoJSON for earthquakes from web using HTTP(S)
print('GeoJSON features from HTTP');
await _readFeatures(
geoJsonHttpClient(
location: Uri.parse(
'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/'
'2.5_day.geojson',
),
),
);
}
Future<void> _readFeatures(BasicFeatureSource source) async {
// read features with error handling
try {
// get items or features from a source, maximum 5 features returned
final items = await source.itemsAll(limit: 5);
// do something with features, in this sample just print them out
for (final f in items.collection.features) {
print('Feature with id: ${f.id}');
print(' geometry: ${f.geometry}');
print(' properties:');
for (final key in f.properties.keys) {
print(' $key: ${f.properties[key]}');
}
}
} on ServiceException<FeatureFailure> catch (e) {
print('Reading GeoJSON resource failed: ${e.failure.name}');
if (e.cause != null) {
print('Cause: ${e.cause}');
}
if (e.trace != null) {
print(e.trace);
}
} catch (e, st) {
print('Reading GeoJSON resource failed: $e');
print(st);
}
}
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.
Libraries
- common
- Common data structures and helpers (for links, metadata, paged responses).
- core
- Metadata and data source abstractions of geospatial Web APIs (ie. features).
- geodata
- A geospatial client to read GeoJSON and OGC API Features data sources.
- geojson_client
- A client-side data source to read GeoJSON data from web and file resources.
- ogcapi_features_client
- A client-side data source to read features from OGC API Features services.