Standard Toolkit
Packages@accelint/geoCoordinatesLatlonDegrees Minutes Seconds

formatDegreesMinutesSeconds

Formats latitude/longitude coordinates in degrees minutes seconds notation.

Formats latitude/longitude coordinates in degrees minutes seconds (DMS) notation with configurable separators and ordinal directions.

Usage

import { formatDegreesMinutesSeconds } from '@accelint/geo';

// Basic usage with default separator
formatDegreesMinutesSeconds([37.7749, -122.4194]);
// '37° 46\' 29.64″ N, 122° 25\' 9.84″ W'

Reference

function formatDegreesMinutesSeconds(
  coordinates: [number, number],
  config?: FormatConfig
): string

interface FormatConfig {
  separator?: string;
}

Parameters

ParameterTypeDescription
coordinates[number, number]Tuple of [latitude, longitude] values in decimal degrees
configFormatConfig (optional)Formatting configuration with optional separator

Returns

Returns formatted coordinate string in degrees minutes seconds format with degree symbols, minute symbols, decimal seconds (2 decimal places), and ordinal directions (N/S/E/W).

Examples

Example: Basic formatting

import { formatDegreesMinutesSeconds } from '@accelint/geo';

formatDegreesMinutesSeconds([37.7749, -122.4194]);
// '37° 46\' 29.64″ N, 122° 25\' 9.84″ W'

Example: Custom separator

import { formatDegreesMinutesSeconds } from '@accelint/geo';

formatDegreesMinutesSeconds([37.7749, -122.4194], { separator: ' / ' });
// '37° 46\' 29.64″ N / 122° 25\' 9.84″ W'

Example: Northern and Eastern hemispheres

import { formatDegreesMinutesSeconds } from '@accelint/geo';

formatDegreesMinutesSeconds([48.8566, 2.3522]);
// '48° 51\' 23.76″ N, 2° 21\' 7.92″ E'

Example: Southern hemisphere

import { formatDegreesMinutesSeconds } from '@accelint/geo';

formatDegreesMinutesSeconds([-33.8688, 151.2093]);
// '33° 52\' 7.68″ S, 151° 12\' 33.48″ E'

Example: Whole degrees (zero minutes and seconds)

import { formatDegreesMinutesSeconds } from '@accelint/geo';

formatDegreesMinutesSeconds([45.0, -90.0]);
// '45° 0\' 0.00″ N, 90° 0\' 0.00″ W'

Example: Exact minutes (zero seconds)

import { formatDegreesMinutesSeconds } from '@accelint/geo';

formatDegreesMinutesSeconds([40.5, -74.0]);
// '40° 30\' 0.00″ N, 74° 0\' 0.00″ W'

Example: Boundary values

import { formatDegreesMinutesSeconds } from '@accelint/geo';

// Maximum latitude
formatDegreesMinutesSeconds([90, 0]);
// '90° 0\' 0.00″ N, 0° 0\' 0.00″ E'

// International Date Line
formatDegreesMinutesSeconds([0, 180]);
// '0° 0\' 0.00″ N, 180° 0\' 0.00″ E'

Good to know: The formatter always uses 2 decimal places for seconds, providing precision to approximately 30 centimeters. Negative latitude values are converted to Southern hemisphere (S), and negative longitude values to Western hemisphere (W).

Good to know: DMS format is the traditional notation used in cartography and surveying. While more verbose than DD or DDM, it provides intuitive subdivision of angular measurements into base-60 units.

Good to know: The second symbol used is the Unicode double prime (″), not a quotation mark. Minutes use the prime symbol (').

On this page