gpx 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

gpx #

Pub Package Build Status Coverage Status GitHub Issues GitHub Forks GitHub Stars GitHub License

A library for or load, manipulate, and save GPS data in GPX format (https://www.topografix.com/gpx.asp, a light-weight XML data format for the interchange of GPS data - waypoints, routes, and tracks). View the official GPX 1.1 Schema at https://www.topografix.com/GPX/1/1/gpx.xsd.

Also support export from Gpx into:

Getting Started #

In your dart/flutter project add the dependency:

 dependencies:
   ...
   gpx: ^0.0.1

Reading XML #

To read XML input use the GpxReader object and function Gpx fromString(String input):

import 'package:gpx/gpx.dart';

main() {
  // create gpx from xml string
  var xmlGpx = GpxReader().fromString('<?xml version="1.0" encoding="UTF-8"?>'
      '<gpx version="1.1" creator="dart-gpx library">'
      '<wpt lat="-25.7996" lon="-62.8666"><ele>10.0</ele><name>Monte Quemado</name><desc>Argentina</desc></wpt>'
      '</gpx>');

  print(xmlGpx);
  print(xmlGpx.wpts);
}

Writing XML #

To write object to XML use the GpxWriter object and function String asString(Gpx gpx, {bool pretty = false}):

import 'package:gpx/gpx.dart';

main() {
  // create gpx object
  var gpx = Gpx();
  gpx.creator = "dart-gpx library";
  gpx.wpts = [
    Wpt(lat: 36.62, lon: 101.77, ele: 10.0, name: 'Xining', desc: 'China'),
  ];

  // generate xml string
  var gpxString = GpxWriter().asString(gpx, pretty: true);
  print(gpxString);
}

Export to KML #

To export object to KML use the KmlWriter object and function String asString(Gpx gpx, {bool pretty = false}):

import 'package:gpx/gpx.dart';

main() {
  // create gpx object
  var gpx = Gpx();
  gpx.creator = "dart-gpx library";
  gpx.wpts = [
    Wpt(lat: 36.62, lon: 101.77, ele: 10.0, name: 'Xining', desc: 'China'),
  ];

  // generate xml string
  var kmlString = KmlWriter().asString(gpx, pretty: true);
  print(kmlString);
}

Limitations #

This is just an initial version of the package. There are still some limitations:

  • No support for 'extension' tag.
  • No support for GPX 1.0.
  • Partly for some tags (wpt.ageofdgpsdata, wpt.geoidheight, wpt.dgpsid, wpt.fix, wpt.sym)
  • Read/write only from strings.
  • Doesn't validate schema declarations.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

License #

The Apache 2.0 License, see LICENSE.

[0.0.3]

  • fix lint issues
  • add kml writer (export from Gpx into KML)

[0.0.2]

  • fix lint issues

[0.0.1]

  • Initial release - reader, writer for GPX-files

example/gpx_example.dart

import 'package:gpx/gpx.dart';

void main() {
  // create gpx-xml from object
  final gpx = Gpx();
  gpx.version = '1.1';
  gpx.creator = 'dart-gpx library';
  gpx.metadata = Metadata();
  gpx.metadata.name = 'world cities';
  gpx.metadata.desc = 'location of some of world cities';
  gpx.metadata.time = DateTime.utc(2010, 1, 2, 3, 4, 5);
  gpx.wpts = [
    Wpt(
        lat: -25.7996,
        lon: -62.8666,
        ele: 10.1,
        name: 'Monte Quemado',
        desc: 'Argentina'),
    Wpt(lat: 36.62, lon: 101.77, ele: 10.1, name: 'Xining', desc: 'China'),
  ];

  // get GPX string
  final gpxString = GpxWriter().asString(gpx, pretty: true);
  print(gpxString);

  // export gpx object into kml
  final kmlString = KmlWriter().asString(gpx, pretty: true);
  print(kmlString);

  // read gpx from gpx-xml string
  final xmlGpx = GpxReader().fromString('<?xml version="1.0" encoding="UTF-8"?>'
      '<gpx version="1.1" creator="dart-gpx library">'
      '<metadata>'
      '<name>world cities</name>'
      '<time>2010-01-02T03:04:05.000Z</time>'
      '</metadata>'
      '<wpt lat="-25.7996" lon="-62.8666"><ele>10.0</ele><name>Monte Quemado</name><desc>Argentina</desc></wpt>'
      '</gpx>');
  print(xmlGpx);
}

Use this package as a library

1. Depend on it

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


dependencies:
  gpx: ^0.0.3

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

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

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
collection ^1.14.11 1.14.12
quiver >=2.0.0 <3.0.0 2.1.2+1
xml ^3.5.0 3.6.0
Transitive dependencies
charcode 1.1.2
convert 2.1.1
matcher 0.12.6
meta 1.1.8
path 1.6.4
petitparser 2.4.0
stack_trace 1.9.3
typed_data 1.1.6
Dev dependencies
test ^1.6.5