geopoint 0.4.0

Geopoint #

pub package Build Status Coverage Status

Geospatial data structures for Dart

Models #

GeoPoint #

Datastructure:

   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
   GeoPoint.fromJson(jsonData);

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 #

Datastructure:

   final String name; // required
   final int id;
   GeoSerieType type;  /// one of [GeoSerieType.group]
                       /// [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();

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

Associated Flutter plugins #

Changelog #

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

example/main.dart

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

class Place {
  Place(this.name, 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))
];

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

Use this package as a library

1. Depend on it

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


dependencies:
  geopoint: ^0.4.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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

We analyzed this package on Jul 23, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:geopoint/geopoint.dart with components: io.

Health suggestions

Format lib/src/models/geopoint.dart.

Run dartfmt to format lib/src/models/geopoint.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
latlong ^0.6.1 0.6.1
meta ^1.1.6 1.1.7
pedantic ^1.4.0 1.8.0+1
slugify2 ^0.2.1 0.2.1
Transitive dependencies
ansicolor 1.0.2
console_log_handler 1.1.6
intl 0.15.8
logging 0.11.3+2
path 1.6.2
validate 1.7.0
Dev dependencies
test ^1.5.1+1
test_coverage ^0.2.3

Admin