Skip to content

mgd722/normalizePoint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

normalizePoint

Coding exercise to normalize geographic coordinates.

Problem description:

Longitude values range from 0 to 180 in the Eastern Hemisphere, and 0 to -180 in the Western Hemisphere. However in certain mapping-related calculations it is possible to have longitude values that exceed 180, in either the positive or negative direction (for example 190 degrees, -750 degrees). Those numbers still represent (the longitudinal portion) of a location on the earth, but are not considered a valid value for longitude. Likewise, Latitude values range from 0 to -90 in the Southern Hemisphere and 0 to 90 in the Northern Hemisphere. Create a function (in whatever language you're most comfortable) that "normalizes" latitude and longitude values. The signature of the function should be:

Point normalizePoint(Point p)

The "Point" type must represent both a latitude and a longitude value. Here are some examples:

Original Point -> Normalized Point
normalizePoint(new Point(190, 240)) -> Point(-170, -60)
normalizePoint(new Point(-210, 120)) -> Point(150, 60)
normalizePoint(new Point(720, -10)) -> Point(0, -10)
normalizePoint(new Point(-750, 0)) -> Point(-30, 0)
normalizePoint(new Point(-890, -100)) -> Point(-170, -80)
normalizePoint(new Point(920, 180)) -> Point(-160, 0)

About

Coding exercise to normalize coordinates.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published