Giter VIP home page Giter VIP logo

geopoint's Introduction

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

Related packages

geopoint's People

Contributors

duzenko avatar synw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.