geopoint 0.7.0

Geopoint #

pub package Build Status Coverage Status

Geospatial data structures for Dart

Models #

GeoPoint #


   String name;
   final double latitude; // required
   final double longitude; // required
   String slug;
   int timestamp;
   double latitude;
   double longitude;
   double altitude;
   double speed;
   double accuracy;
   double speedAccuracy;
   double heading;
   String number;
   String street;
   String locality;
   String sublocality;
   String postalCode;
   String subregion;
   String region;
   String country;
   List<File> images;

Extra constructors:

   /// from a [LatLng]
   GeoPoint.fromLatLng(name: "Position", point: LatLng(51.0,0.0));

   /// from json

Methods and getters:

   /// get the formated address
   String address = geoPoint.address;

   /// get the [LatLng] point
   LatLng point = geoPoint.point;

   /// convert to json
   Map<String, dynamic> json = geoPoint.toMap();

   /// convert to a map of strings
   Map<String, String> strMap = geoPoint.toStringsMap();

GeoSerie #


   String name;
   int id;
   GeoSerieType type;  /// one of []
                       /// [GeoSerieType.line] or
                       /// [GeoSerieType.polygon]
   List<GeoPoint> geoPoints;
   num surface;
   GeoSerie boundary;
   GeoPoint centroid;

Extra constructors:

   /// from json
   GeoSerie geoSerie = GeoSerie.fromJson(jsonData);

   /// from strings
   GeoSerie geoSerie = GeoSerie.fromNameAndType(
       name: "A polygon",
       type: GeoSerieType.polygon,
       // or typeStr: "polygon"

Methods and getters:

   // convert to json
   Map<String, dynamic> jsonData = geoSerie.toMap();

   /// convert to a list of [LatLng]
   List<LatLng> points = geoSerie.toLatLng(ignoreErrors = true);
   /// The invalid points will be skipped if ignoreErrors is true

   // get the type as a string
   String type = geoSerie.typeStr;

Geojson serialization #

Serializers are available to get geojson feature or coordinates strings:

   /// Convert to a geojson feature string
   String feature = geoSerie.toGeoJsonFeatureString();

   /// Convert to a geojson coordinates string
   String coordinates = geoSerie.toGeoJsonCoordinatesString();

   /// Convert to a geojson feature string
   String feature = geoPoint.toGeoJsonFeatureString();

   /// Convert to a geojson coordinates string
   String coordinates = geoPoint.toGeoJsonCoordinatesString();

Changelog #

0.7.0 #

  • Remove some deprecated serialization methods
  • Use extra_pedantic for static analysis

0.6.1 #

Provide support for deprecated geojson serializers

0.6.0 #

  • Make the name and type parameters optional in GeoSerie constructor
  • Improve the toString method for GeoPoint
  • Rename the geojson serializers

0.5.0 #

  • Add the toLatLng method to GeoPoint
  • Add geojson serializers

0.4.1 #

Add the toLatLng method to GeoSerie

0.4.0 #

Add the toStringsMap method to GeoPoint

0.3.0 #

  • Update dependencies
  • Add pedantic to analysis options
  • Use <String, dynamic> return type for toMap mathods
  • Update tests

0.2.3 #

  • Add tests
  • Minor fixes

0.2.2 #

  • Downgrade to meta 1.1.6 to be compatible with flutter_test

0.2.1 #

  • Add missing meta dependency

0.2.0 #

Breaking change: remove the Geolocator and Flutter dependencies, converting this to a pure Dart library

0.1.1 #

  • Apply more strict linting rules
  • Improve docstrings

0.1.0 #

Initial release


import 'package:geopoint/geopoint.dart';
import 'package:latlong/latlong.dart';

class Place {
  Place(, this.point);

  final String name;
  final LatLng point;

final List<Place> places = [
  Place("Notre-Dame", LatLng(48.853831, 2.348722)),
  Place("Montmartre", LatLng(48.886463, 2.341169)),
  Place("Champs-Elysées", LatLng(48.873932, 2.294821)),
  Place("Chinatown", LatLng(48.827393, 2.361897)),
  Place("Tour Eiffel", LatLng(48.85801, 2.294713))

Future<void> main() async {
  final geoPoints = <GeoPoint>[];
  print("Places in Paris:");
  for (final place in places) {
    final geoPoint = GeoPoint.fromLatLng(name:, point: place.point);
  final geoSerie = GeoSerie(
      name: "Paris places", type:, geoPoints: geoPoints);
  for (final gp in geoSerie.geoPoints) {
    print("${}: ${gp.latitude}/${gp.longitude}");

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  geopoint: ^0.7.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:geopoint/geopoint.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
extra_pedantic ^1.1.1+1 1.1.1+3
latlong ^0.6.1 0.6.1
meta ^1.1.6 1.1.8
pedantic ^1.6.0 1.9.0
slugify2 ^0.2.1 0.2.1
Transitive dependencies
ansicolor 1.0.2
console_log_handler 1.1.6
intl 0.16.1
logging 0.11.4
path 1.6.4
validate 1.7.0
Dev dependencies
test ^1.6.5
test_coverage ^0.4.0