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();

   /// 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.toGeoJsonFeature();

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

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

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

Libraries

geopoint
Datastructures and methods for Geolocator. Provides a GeoPoint model for individual points and a GeoSerie model for groups, lines or polygons