minted_geography 1.0.1 copy "minted_geography: ^1.0.1" to clipboard
minted_geography: ^1.0.1 copied to clipboard

Well-modelled Dart value types for geography, starting with GeoCoordinate: ISO 6709 in all three field widths. Part of the minted family.

Pub Version Pub Points Package checks License: BSD-3-Clause

minted_geography #

Geographic coordinates as well-modelled value types.

Part of the minted family: pure-Dart value types built on parse, don't validate, so the parser is the only door in and anything that came through it is well-formed by construction. Once you hold a GeoCoordinate, both halves are in range and in the order you meant.

Install #

dart pub add minted_geography

minted comes with it, holding the shared vocabulary (ParseOutcome, MintedFailure, Digit, Digits, the Uint tower). Nothing here drags in another domain's engine.

What's in the box #

Type What it guarantees Standard
GeoCoordinate a bounded latitude and longitude; all three ISO 6709 widths read as degrees ISO 6709

A swapped latitude and longitude is a type bug no range check catches, so the pair is named at the boundary. It's a surface coordinate: altitude and a CRS identifier are refused rather than silently dropped, since their sign, units and datum are all defined by the CRS.

A quick taste #

final eiffel = GeoCoordinate.tryParse('+48.8577+002.295/')!;
eiffel.latitude;     // 48.8577
eiffel.iso6709;      // '+48.8577+002.295/'   (canonical form)
eiffel.sexagesimal;  // '48°51′27.72″N 2°17′42″E'   (display form)

// ISO 6709 selects the unit by field width, and all three widths fold to degrees, so the same
// point spelled as degrees-minutes-seconds is the same value:
GeoCoordinate.tryParse('+485127.72+0021742/') == eiffel;   // true
GeoCoordinate.tryParse('+5012-00010/')!.latitude;          // 50.2   (degrees and minutes)

GeoCoordinate.tryParse('+46+2/');   // null: an unpadded longitude is a different location

// named, so it can't be written swapped:
GeoCoordinate.from(latitude: 48.8577, longitude: 2.295);

The runnable version is the example.

One shape, every type #

  • GeoCoordinate.tryParse(input) hands back the value, or null when the input isn't valid
  • GeoCoordinate.parse(input) hands back a ParseOutcome: the value, or a typed GeoCoordinateFailure you can switch on, or read as a form-field message via .reasonOrNull. No door throws
  • value equality, a canonical .iso6709 normalised on parse, and from for a pair you already hold

The minted README is the family guide: the whole catalogue, handling failures, and the one caveat (never cast into a minted type).

0
likes
0
points
60
downloads

Publisher

unverified uploader

Weekly Downloads

Well-modelled Dart value types for geography, starting with GeoCoordinate: ISO 6709 in all three field widths. Part of the minted family.

Homepage
Repository (GitHub)
View/report issues

Topics

#validation #type-safety #geography #domain-driven-design #standards

License

unknown (license)

Dependencies

meta, minted

More

Packages that depend on minted_geography