latlng2dms - Latitude/Longitude to DMS representation
Some utilities for converting latitude/longitudes to degrees/minutes/seconds format
Examples:
- 40°26′46″ N, 79°58′56″ W
- 2°20'24" N, 5°20'24" W
Usage:
Import as a dependency:
Gradle:
compile 'com.github.marlonlom:latlng2dms:$latestVersion'
Maven:
<dependency>
<groupId>com.github.marlonlom</groupId>
<artifactId>latlng2dms</artifactId>
<version>$latestVersion</version>
</dependency>
Use it in your code:
With coordinates:
final Double[] coordinates = {151.209900d, -33.865143d};
final String converted = LatsLngs.with(coordinates).toDms();
/* Will return 33°51'54" S, 151°12'35" E */
Or with single longitude/latitude value:
final Double value = -34.206841d;
final String converted = LatsLngs.with(value).asLatitude().toDms();
/* Will return 34°12'24 S */
Spread the word
If you like this library, please tell others about it
- Follow me on Twitter: @Marlonlom
- Contact me on LinkedIn: Marlonlom
License
Copyright 2017 marlonlom
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.