Coordinate Converter

Coordinate Converter Logo

pub package style: very good analysis License: MIT Conventional Commits


A package for converting between UTM, DMS and DD coordinates in the WGS84 ellipsoid model.

  • UTM | Universal Transverse Mercator

  • DMS | Degrees, Minutes and Seconds

  • DD | Decimal Degrees

  • WGS-84 | Standart used in most maps such as Google Maps, Apple Maps, Mapbox, OpenStreetMaps, etc

The Universal Transverse Mercator - UTM coordinate system is explained on this Wikipedia page.

The Geographic Coordinate System - GCS is explained on this Wikipedia page.

The World Geodetic System and WGS84 are explained on this Wikipedia page.

Note: This package was inspired by sigam.

If you like this tool please star it on GitHub

Getting started

Add dependency

dependencies:
  coordinate_converter: 1.2.3

Usage

Create new instances of Coordinates objects

import 'package:coordinate_converter/coordinate_converter.dart';

// Decimal Degrees Coordinates
DDCoordinates ddCoords = DDCoordinates(
  latitude: -20.762535,
  longitude: -41.531941,
);

// Degrees, Minutes and Seconds Coordinates
DMSCoordinates dmsCoords = DMSCoordinates(
  latDegrees: 20,
  latMinutes: 45,
  latSeconds: 45.12,
  latDirection: DirectionY.south,
  longDegrees: 41,
  longMinutes: 31,
  longSeconds: 54.98,
  longDirection: DirectionX.west,
);

// Universal Transverse Mercator Coordinates
UTMCoordinates utmCoords = UTMCoordinates(
  x: 236379,
  y: 7702067,
  zoneNumber: 24,
  isSouthernHemisphere: true,
);
  1. Convert to DD
// 1.1 DMS to DD
// Use static method
DDCoordinates convertedDDCoords = DDCoordinates.fromDMS(dmsCoords);
// OR
// Convert the current instance
convertedDDCoords = dmsCoords.toDD();

// 1.2 UTM to DD
// Use static method
convertedDDCoords = DDCoordinates.fromUTM(utmCoords);
// OR
// Convert the current instance
convertedDDCoords = utmCoords.toDD();

debugPrint('Output DD: ${convertedDDCoords.toString()}');
// Print output of overridden toString method:
// flutter: Output DD: -20.76253582021867, -41.53194825871451
  1. Convert to DMS
// 2.1 DD to DMS
// Use static method
DMSCoordinates convertedDMSCoords = DMSCoordinates.fromDD(ddCoords);
// OR
// Convert the current instance
convertedDMSCoords = ddCoords.toDMS();

// 2.2 UTM to DMS
// Use static method
convertedDMSCoords = DMSCoordinates.fromUTM(utmCoords);
// OR
// Convert the current instance
convertedDMSCoords = utmCoords.toDMS();

debugPrint('Output DMS: ${convertedDMSCoords.toString()}');
// Print output of overridden toString method:
// flutter: Output DMS: 20° 45' 45.13" S | 41° 31' 54.99" W
  1. Convert to UTM
// 3.1 DD to UTM
// Use static method
UTMCoordinates convertedUTMCoords = UTMCoordinates.fromDD(ddCoords);
// OR
// Convert the current instance
convertedUTMCoords = ddCoords.toUTM();

// 3.2 DMS to UTM
// Use static method
convertedUTMCoords = UTMCoordinates.fromDMS(dmsCoords);
// OR
// Convert the current instance
convertedUTMCoords = dmsCoords.toUTM();

debugPrint('Output UTM: ${convertedUTMCoords.toString()}');
// Print output of overridden toString method:
// flutter: Output UTM: 24 236379.75470806437 / 7702067.102859227 S

Contributing

:beer: Pull requests are welcome!

Don't forget that open-source makes no sense without contributors. No matter how big your changes are, it helps a lot even it is a line of change.

Reporting bugs and issues are contribution too, yes it is.

Donation

Your donation motivates me to work more on the coordinate_converter and resolve issues. There are multiple ways to donate:

  1. You can be my sponsor on GitHub

  2. If you are a fan of crypto, you can donate me Bitcoins here: 1HhHqNQyJctrcwcYzUE8SrB3b3TVcNVx5P

  3. Or you just:

    Buy Me a Coffee

Libraries

coordinate_converter
coordinate converter library