code-tutorial.com

The best resources for developers

How can I map a latitude/longitude on a distorted map?

estimate-latitude-longitude (x, y)

    numerator-latitude := 0
    numerator-longitude := 0
    denominator := 0

    for each point,
        deltaX := x - point.x
        deltaY := y - point.y
        distSq := deltaX * deltaX + deltaY * deltaY
        weight := 1 / distSq

        numerator-latitude += weight * point.latitude
        numerator-longitude += weight * point.longitude
        denominator += weight

    return (numerator-latitude / denominator, numerator-longitude / denominator)

Tags: mapping math maps latitude-longitude

Source: By Adam Ernst as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 3.0


Related code-snippets: