问题
I'm trying to use C# or Javascript to convert Lat/Longs into X/Y Coordinates to position divs with CSS (left, top) onto a background image of a US map. The standard map projection of the United States is an Albers Projection as seen below, but StackOverflow only has references for Lat/Long conversions that refer to basic Mercator projections.
Map: http://en.wikipedia.org/wiki/File:Usa_counties_large.svg
Map Size: 1460px width x 914px height
Lat/Long Samples:
LA: 34.0525, -118.2544
NY: 40.7582, -73.9679
DEN: 39.7512, -104.9975
Albers Projection Formula: http://en.wikipedia.org/wiki/Albers_projection
Here's my C# code so far:
int mapWidth = 1460; //US Map Width Px
int mapHeight = 914; //US Map Height Px
double lat = 34.0525; //LA Test Lat
double lng = -118.2544; //LA Test Long
double maxLat = 48.291667; //US Map North Lat (Approx)
double minLat = 22.46; //US Map South Lat (Approx)
double maxLng = -65.529722; //US Map East Long (Approx)
double minLng = -128.876944; //US Map West Long (Approx)
var n = (Math.Sin(minLat) + Math.Sin(maxLat)) * .5;
var a = n * (lng - minLng);
var c = Math.Pow(Math.Cos(minLat), 2) + ((2 * n) * Math.Sin(minLat));
var p = Math.Sqrt(c - ((2 * n) * Math.Sin(lat)));
var p2 = (n / Math.Sqrt(c - (2 * n) * Math.Sin(minLat))) / n;
result.x = p * Math.Sin(a); //Convert to Map Px ?
result.y = p2 - (p * Math.Cos(a)); //Convert to Map Px ?
Questions:
1) How do I adjust the Albers projection result to the factor in the Map Size (width/height in pixels) for X/Y pixel placement?
2) Is my Albers Math formula to C# code conversion correct?
3) What do the reference longitude (λ0) and reference latitude (φ0) refer to? I guessed these meant the US Map West Long (minLng) and US Map North Lat (maxLat).
4) What do the standard parallels (φ1 and φ2) refer to? I guessed these meant the US Map North Lat (maxLat) and US Map South Lat (minLat).
来源:https://stackoverflow.com/questions/23208170/convert-lat-long-to-x-y-for-albers-projection-on-us-map-image