geopoint 1.0.0 copy "geopoint: ^1.0.0" to clipboard
geopoint: ^1.0.0 copied to clipboard

Geospatial data structures. Provides GeoPoint and GeoSerie models.

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:

String name;
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.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();
5
likes
150
points
2.16k
downloads

Publisher

unverified uploader

Weekly Downloads

Geospatial data structures. Provides GeoPoint and GeoSerie models.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

latlong2, slugify

More

Packages that depend on geopoint