Definitions:
1
Earth spheroid coordinates (degrees)
TopLeft:         (long1, latt1)
BottomRight:  (long2, latt2)

2
corresponding points in squared (XY) Mercator space
TopLeft:         (y1, x1)
BottomRight:  (y2, x2)

y1 :=arcsinh( tan(latt1) );
y2 :=arcsinh( tan(latt2) );
x1:=long1;
x2:=long2;

3
GMAP picture pixel coordinates
TopLeft:         (0, 0)
BottomRight:  (Width-1, Height-1)


Now we have a GMAP with corner coordinates  (long1, latt1)-(long2,
latt2) wich has bitmap dimensions (0, 0)-(Width-1, Height-1).

Examples:

Example1: Find (long,latt) for given pixel [j, i]
(i increases from 0 on left side to Width on right side; j increases
from 0 on top to Height on the bottom)

Get GMAP bounds (y1, x1)-(y2, x2) in Mercator space
y1 :=arcsinh( tan(latt1) );
y2 :=arcsinh( tan(latt2) );
x1:=long1;
x2:=long2;

Find coordinates (y,x) in Mercator space:
x := x1 + (x2 - x1) / (Width - 1) * i;
y := y1 + (y2 - y1) / (Height - 1) * j;

then convert (X,Y) into spherical coordinates:
latt  := RadToDeg( arctan(sinh(y)) );
long := RadToDeg( x );


Example2: Find pixel coordinates [j,i] for given (long,latt):

Get GMAP bounds (y1, x1)-(y2, x2) in Mercator space
y1 :=arcsinh( tan(latt1) );
y2 :=arcsinh( tan(latt2) );
x1:=long1;
x2:=long2;

Convert (long, latt) into Mercator space (Y, X)
y := arcsinh( tan(latt) );
x := long;

Finally, find pixel coordinates on bitmap:
i := 0 + (Width - 1) * (x - x1) / (x2 - x1) ;
j := 0 + (Height - 1) * (y - y1) / (y2 - y1);

Nu i tak dalee...

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to