geotools 0.4.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 60

A Dart library that provides tools for manipulating and working with geospatial data.

Created by BitFlippers, provided under a MIT license.

Usage #

A simple usage example:

import 'package:geotools/geotools.dart';

main() {

print(latLongAsJson(0,0));

}

Inspired By #

Development #

  • pub get
  • dart --enable-asserts --enable-vm-service:49905 ./example/geotools_example.dart
  • pub run test -r json ./test/geotools_test.dart

0.4.0 #

  • bugfixes

0.3.0 #

  • First version of track generation

0.2.0 #

  • Defined model and first functionalities

0.1.0 #

  • Initial version

example/geotools_example.dart

import 'package:geotools/geotools.dart';
import 'dart:io';

main() {
  // Geo stuff...

  final LatLong eiffelTower = LatLong.fromDecimal(48.85805556, 2.29416667);
  final LatLong statueOfLiberty = LatLong.fromDecimal(40.68972222, 72.04444444);
  final LatLong eiffelTowerDuplicate =
      LatLong.fromDecimal(48.85805556, 2.29416667);

  print(eiffelTower
      .asJsonStringDecimal()); // prints {"lat":48.85805556,"long":2.29416667}

  print(eiffelTower
      .asGeoJson()); // prints {"type":"Point", "coordinates":[2.29416667,48.85805556]}

  print(GeoUtils.distanceInMeters(
      eiffelTower, statueOfLiberty)); // prints 5384207.973601257

  GeoUtils.sameLocation(eiffelTower, eiffelTowerDuplicate); // prints true

  final Latitude plazaMayorMaxLatitude = Latitude.fromDecimal(40.415780);
  final Latitude plazaMayorMinLatitude = Latitude.fromDecimal(40.415013);
  final Longitude plazaMayorMaxLongitude = Longitude.fromDecimal(-3.706646);
  final Longitude plazaMayorMinLongitude = Longitude.fromDecimal(-3.708113);
  final BoundingBox plazaMayor = BoundingBox.fromDecimal(
      plazaMayorMinLongitude.decimal,
      plazaMayorMaxLongitude.decimal,
      plazaMayorMinLatitude.decimal,
      plazaMayorMaxLatitude.decimal);

  print(plazaMayor
      .asGeoJson()); // prints {"type":"Polygon","coordinates":[[[-3.708113,40.415013],[-3.706646,40.415013],[-3.706646,40.41578],[-3.708113,40.41578],[-3.708113,40.415013]]]}

  // Graph stuff...

  final File luxembourg = File(
      'test/luxembourg.json'); // [{"id": 3895896119, "lat": 49.615311, "long": 6.1297125, "neighbours": [4321295305 ] }, {"id": 74998906, "lat": 49.6134879, "long": 6.1295215, "neighbours": [4083207920, 4083207905 ] },...

  luxembourg.readAsString().then((String contents) {
    final Tile tile = Tile()..withNodesFromJsonString(contents);
    final double targetTrackDistanceInMeters = 5000;
    tile.generateRandomTrack(targetTrackDistanceInMeters);
    final double trackLengthInMeters = tile.getRandomTrack().getCost();
    print("Track length in meters: " + trackLengthInMeters.toString());
    print(tile.getTrackAsGeoJson());
  });

  // Canvas stuff

  luxembourg.readAsString().then((String contents) {
    final Latitude luxembourgMaxLatitude = Latitude.fromDecimal(49.6168);
    final Latitude luxembourgMinLatitude = Latitude.fromDecimal(49.6065);
    final Longitude luxembourgMaxLongitude = Longitude.fromDecimal(6.1377);
    final Longitude luxembourgMinLongitude = Longitude.fromDecimal(6.1207);
    final BoundingBox luxembourg = BoundingBox.fromDecimal(
        luxembourgMinLongitude.decimal,
        luxembourgMaxLongitude.decimal,
        luxembourgMinLatitude.decimal,
        luxembourgMaxLatitude.decimal);
    print(luxembourg.asGeoJson());
    final Tile tile = Tile()
      ..withNodesFromJsonString(contents)
      ..withBoundingBox(luxembourg)
      ..withCanvas(1129, 1207);
    final double targetTrackDistanceInMeters = 5000;
    tile.generateRandomTrack(targetTrackDistanceInMeters);
    final double trackLengthInMeters = tile.getRandomTrack().getCost();
    print("Track length in meters: " + trackLengthInMeters.toString());
    print(tile.getRandomTrack().asGeoJson());
    print(tile.getTrackAsSvgPolyline());
  });
}

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:geotools/geotools.dart.

Health issues and suggestions

Document public APIs. (-0.50 points)

117 out of 119 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.0.0