coord_convert 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 66

CoordConvert #

pub package

CoordConvert is a small library to convert coordinates between different coordinate systems.

Supported coordinate systems:

  • WGS-84 | Standart used in most maps such as Google Maps, Apple Maps, Mapbox, OpenStreetMaps, etc
  • GCJ-02 | Coordinate system used by Chinese maps like Amap (Gaode Maps), Tencent Maps, etc except Baidu maps
  • BD-09 | Coordinate system used by Baidu Maps

Based on formulas from here

Get started #

Add dependency #

dependencies:
  coord_convert: 0.1.0

Usage examples #

Convert to WGS-84

import 'package:coord_convert/coord_convert.dart';

final coords = Coords(31.233568, 121.505504); // Coords(lat, lng)

// WGS-84 from GCJ-02
final Coords fromGCJ02 = CoordConvert.gcj02towgs84(coords);

// WGS-84 from BD-09
final Coords fromBD09 = CoordConvert.bd09towgs84(coords);

Convert to GCJ-02

import 'package:coord_convert/coord_convert.dart';

final coords = Coords(31.233568, 121.505504); // Coords(lat, lng)

// GCJ-02 from WGS-84
final fromWGS84 = CoordConvert.wgs84togcj02(coords);

// GCJ-02 from BD-09
final fromBD09 = CoordConvert.bd09togcj02(coords);

Convert to BD-09

import 'package:coord_convert/coord_convert.dart';

final coords = Coords(31.233568, 121.505504); // Coords(lat, lng)

// BD-09 from WGS-84
final fromWGS84 = CoordConvert.wgs84tobd09(coords);

// BD-09 from GCJ-02
final fromGCJ02 = CoordConvert.gcj02tobd09(coords);

Contributing #

Pull requests are welcome.

[0.1.0] #

  • Add WGS-84 to BD-09 and BD-09 to WGS-84
  • Update README
  • Add example

[0.0.1] #

  • Convert between WGS-84, GCJ-02 and BD-09

example/main.dart

import 'package:coord_convert/coord_convert.dart';

main() {
  final coords = Coords(31.233568, 121.505504); // Coords(lat, lng)

  // WGS-84 from GCJ-02
  final wgs84FromGcj02 = CoordConvert.gcj02towgs84(coords);
  print('WGS-84 from GCJ-02: $wgs84FromGcj02');

  // WGS-84 from BD-09
  final wgs84FromBd09 = CoordConvert.bd09towgs84(coords);
  print('WGS-84 from BD-09: $wgs84FromBd09');

  // GCJ-02 from WGS-84
  final gcj02FromWgs84 = CoordConvert.wgs84togcj02(coords);
  print('GCJ-02 from WGS-84: $gcj02FromWgs84');

  // GCJ-02 from BD-09
  final gcj02FromBd09 = CoordConvert.bd09togcj02(coords);
  print('GCJ-02 from BD-09: $gcj02FromBd09');

  // BD-09 from WGS-84
  final bd09FromWgs84 = CoordConvert.wgs84tobd09(coords);
  print('BD-09 from WGS-84: $bd09FromWgs84');

  // BD-09 from GCJ-02
  final bd09FromGcj02 = CoordConvert.gcj02tobd09(coords);
  print('BD-09 from GCJ-02: $bd09FromGcj02');
}

Use this package as a library

1. Depend on it

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


dependencies:
  coord_convert: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:coord_convert/coord_convert.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
32
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]
66
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [coord_convert] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

14 out of 14 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.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test