Skip to content

Commit 752a348

Browse files
committed
docs: stable release 1.1.0
1 parent c053aa2 commit 752a348

File tree

1 file changed

+94
-2
lines changed

1 file changed

+94
-2
lines changed

README.md

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ schemes, vector data models and formats, and geospatial Web APIs.
1111

1212
[![Dart](https://img.shields.io/badge/dart-%230175C2.svg?style=for-the-badge&logo=dart&logoColor=white)](https://dart.dev/) [![Flutter](https://img.shields.io/badge/Flutter-%2302569B.svg?style=for-the-badge&logo=Flutter&logoColor=white)](https://flutter.dev/)
1313

14+
✨ New (2024-04-22): The stable version 1.1.0 adds support for Newline-delimited GeoJSON, EWKT and EWKB. See also the article [Decode and encode GeoJSON, WKT and WKB in Dart and Flutter apps](https://medium.com/@navibyte/decode-and-encode-geojson-wkt-and-wkb-in-dart-and-flutter-apps-ab2ef4ece2f1).
15+
1416
✨ New (2023-10-29): The stable version 1.0.0 is now ready. See also the article [Geospatial tools for Dart - version 1.0 published](https://medium.com/@navibyte/geospatial-tools-for-dart-version-1-0-published-0f9673e510b3) at Medium.
1517

1618
## :package: Packages
@@ -120,6 +122,10 @@ Geospatial feature and feature collections can be instantiated easily too:
120122
]);
121123
```
122124

125+
### GeoJSON, WKT and WKB with geobase
126+
127+
More details in the article (2024-04-14) [Decode and encode GeoJSON, WKT and WKB in Dart and Flutter apps](https://medium.com/@navibyte/decode-and-encode-geojson-wkt-and-wkb-in-dart-and-flutter-apps-ab2ef4ece2f1).
128+
123129
GeoJSON, WKT and WKB formats are supported as input and output:
124130

125131
```dart
@@ -142,6 +148,77 @@ GeoJSON, WKT and WKB formats are supported as input and output:
142148
LineString.decode(bytes, format: WKB.geometry);
143149
```
144150

151+
A sample showing more deeply how to handle WKB and EWKB binary data:
152+
153+
```dart
154+
// to get a sample point, first parse a 3D point from WKT encoded string
155+
final p = Point.parse('POINT Z(-0.0014 51.4778 45)', format: WKT.geometry);
156+
157+
// to encode a geometry as WKB/EWKB use toBytes() or toBytesHex() methods
158+
159+
// encode as standard WKB data (format: `WKB.geometry`), prints:
160+
// 01e9030000c7bab88d06f056bfb003e78c28bd49400000000000804640
161+
final wkbHex = p.toBytesHex(format: WKB.geometry);
162+
print(wkbHex);
163+
164+
// encode as Extended WKB data (format: `WKB.geometryExtended`), prints:
165+
// 0101000080c7bab88d06f056bfb003e78c28bd49400000000000804640
166+
final ewkbHex = p.toBytesHex(format: WKB.geometryExtended);
167+
print(ewkbHex);
168+
169+
// otherwise encoded data equals, but bytes for the geometry type varies
170+
171+
// there are some helper methods to analyse WKB/EWKB bytes or hex strings
172+
// (decodeFlavor, decodeEndian, decodeSRID and versions with hex postfix)
173+
174+
// prints: "WkbFlavor.standard - WkbFlavor.extended"
175+
print('${WKB.decodeFlavorHex(wkbHex)} - ${WKB.decodeFlavorHex(ewkbHex)}');
176+
177+
// when decoding WKB or EWKB data, a variant is detected automatically, so
178+
// both `WKB.geometry` and `WKB.geometryExtended` can be used
179+
final pointFromWkb = Point.decodeHex(wkbHex, format: WKB.geometry);
180+
final pointFromEwkb = Point.decodeHex(ewkbHex, format: WKB.geometry);
181+
print(pointFromWkb.equals3D(pointFromEwkb)); // prints "true"
182+
183+
// SRID can be encoded only on EWKB data, this sample prints:
184+
// 01010000a0e6100000c7bab88d06f056bfb003e78c28bd49400000000000804640
185+
final ewkbHexWithSRID =
186+
p.toBytesHex(format: WKB.geometryExtended, crs: CoordRefSys.EPSG_4326);
187+
print(ewkbHexWithSRID);
188+
189+
// if you have WKB or EWKB data, but not sure which, then you can fist check
190+
// a flavor and whether it contains SRID, prints: "SRID from EWKB data: 4326"
191+
if (WKB.decodeFlavorHex(ewkbHexWithSRID) == WkbFlavor.extended) {
192+
final srid = WKB.decodeSRIDHex(ewkbHexWithSRID);
193+
if (srid != null) {
194+
print('SRID from EWKB data: $srid');
195+
196+
// after finding out CRS, an actual point can be decoded
197+
// Point.decodeHex(ewkbHexWithSRID, format: WKB.geometry);
198+
}
199+
}
200+
```
201+
202+
Using Newline-delimited GeoJSON (or "GeoJSONL") is as easy as using the
203+
standard GeoJSON:
204+
205+
```dart
206+
/// a feature collection encoded as GeoJSONL and containing two features that
207+
/// are delimited by the newline character \n
208+
const sample = '''
209+
{"type":"Feature","id":"ROG","geometry":{"type":"Point","coordinates":[-0.0014,51.4778,45]},"properties":{"title":"Royal Observatory","place":"Greenwich"}}
210+
{"type":"Feature","id":"TB","geometry":{"type":"Point","coordinates":[-0.075406,51.5055]},"properties":{"title":"Tower Bridge","built":1886}}
211+
''';
212+
213+
// parse a FeatureCollection object using the decoder for the GeoJSONL format
214+
final collection = FeatureCollection.parse(sample, format: GeoJSONL.feature);
215+
216+
// ... use features read and returned in a feature collection object ...
217+
218+
// encode back to GeoJSONL data
219+
print(collection.toText(format: GeoJSONL.feature, decimals: 5));
220+
```
221+
145222
### Access GeoJSON resources with geodata
146223

147224
The [geodata](https://pub.dev/packages/geodata) package has the following
@@ -198,8 +275,15 @@ Code | Description
198275

199276
## :newspaper_roll: News
200277

278+
2024-04-22
279+
* ✨ The [stable version 1.1.0](https://github.com/navibyte/geospatial/milestone/1) adds support for Newline-delimited GeoJSON, EWKT and EWKB.
280+
* See also the article [Decode and encode GeoJSON, WKT and WKB in Dart and Flutter apps](https://medium.com/@navibyte/decode-and-encode-geojson-wkt-and-wkb-in-dart-and-flutter-apps-ab2ef4ece2f1).
281+
* Published packages at pub.dev:
282+
* [geobase version 1.1.0](https://pub.dev/packages/geobase/versions/1.1.0)
283+
* [geodata version 1.1.0](https://pub.dev/packages/geodata/versions/1.1.0)
284+
201285
2023-10-29
202-
*New (2023-10-29): The stable version 1.0.0 is now ready. See also the article [Geospatial tools for Dart - version 1.0 published](https://medium.com/@navibyte/geospatial-tools-for-dart-version-1-0-published-0f9673e510b3) at Medium
286+
* ✨ The stable version 1.0.0 is now ready. See also the article [Geospatial tools for Dart - version 1.0 published](https://medium.com/@navibyte/geospatial-tools-for-dart-version-1-0-published-0f9673e510b3) at Medium
203287
* [geobase version 1.0.0](https://github.com/navibyte/geospatial/issues/175)
204288
* [geodata version 1.0.0](https://github.com/navibyte/geospatial/issues/187)
205289

@@ -258,6 +342,9 @@ Some external links and other resources.
258342

259343
Geospatial:
260344
* [GeoJSON](https://geojson.org/) based on [RFC 7946](https://tools.ietf.org/html/rfc7946)
345+
* [Newline-delimited GeoJSON](https://stevage.github.io/ndgeojson/) with variants specified elsewhere:
346+
* [GeoJSONL](https://www.interline.io/blog/geojsonl-extracts/)
347+
* [GeoJSON Text Sequences](https://datatracker.ietf.org/doc/html/rfc8142)
261348
* [Simple Feature Access - Part 1: Common Architecture](https://www.ogc.org/standards/sfa)
262349
* [WKT](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) (Well-known text representation of geometry)
263350
* [WKB](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry#Well-known_binary) (Well-known binary)
@@ -293,7 +380,9 @@ SDKs:
293380
* [Flutter](https://flutter.dev/)
294381

295382
Latest on Dart SDKs
296-
* [Dart 3](https://medium.com/dartlang/announcing-dart-3-53f065a10635) with 100% sound null safety, new features (records, patterns, and class modifiers), and a peek into the future.
383+
* [Dart 3.3](https://medium.com/dartlang/dart-3-3-325bf2bf6c13) with extension types, evolving JavaScript-interoperability and experimental support for WebAssembly.
384+
* [Dart 3.2](https://medium.com/dartlang/dart-3-2-c8de8fe1b91f) with improved language & developer experience.
385+
* [Dart 3](https://medium.com/dartlang/announcing-dart-3-53f065a10635) with 100% sound null safety, new features (records, patterns, and class modifiers), and a peek into the future.
297386
* [Dart 3 alpha](https://medium.com/dartlang/dart-3-alpha-f1458fb9d232) with records, patterns, access controls, portability advancements and the new Dart 3 type system (100% sound null safety)
298387
* [Dart 2.18](https://medium.com/dartlang/dart-2-18-f4b3101f146c) with Objective-C & Swift interop, and improved type inference
299388
* [Dart 2.17](https://medium.com/dartlang/dart-2-17-b216bfc80c5d) with enum member support, parameter forwarding to super classes, flexibility for named parameters, and more
@@ -304,6 +393,9 @@ Latest on Dart SDKs
304393
* [Dart 2.12](https://medium.com/dartlang/announcing-dart-2-12-499a6e689c87) with sound null safety
305394

306395
Latest on Flutter SDKs
396+
* [Flutter 3.19](https://medium.com/flutter/whats-new-in-flutter-3-19-58b1aae242d2) running on Dart 3.3 and Gemini API integration, Impeller updates, and Windows Arm64 support.
397+
* [Flutter 3.16](https://medium.com/flutter/whats-new-in-flutter-3-16-dba6cb1015d1) running on Dart 3.2 and with Material 3 by default, Impeller preview for Android, etc.
398+
* [Flutter 3.13](https://medium.com/flutter/whats-new-in-flutter-3-13-479d9b11df4d) running on Dart 3.1 and with new 2D scrolling widgets and faster graphics.
307399
* [Flutter 3.10](https://medium.com/flutter/whats-new-in-flutter-3-10-b21db2c38c73) running on Dart 3 and with seamless web and mobile integration, and stable Impleller for iOS.
308400
* [Flutter 3.7](https://medium.com/flutter/whats-new-in-flutter-3-7-38cbea71133c) with Material 3 updates and iOS improvements
309401
* [Flutter 3.3](https://medium.com/flutter/announcing-flutter-3-3-at-flutter-vikings-6f213e068793)

0 commit comments

Comments
 (0)