GMercatorProjection: fromLatLngToPixel and fromPixelToLatLng implementation.
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
"Andriy T. Yanko" <andriy.ya... @gmail.com>
Date: Fri, 16 Nov 2007 02:29:30 -0800 (PST)
Local: Fri, Nov 16 2007 5:29 am
Subject: GMercatorProjection: fromLatLngToPixel and fromPixelToLatLng implementation.
Hi all.
I need implement GMercatorProjection's fromPixelToLatLng and
(fromLatLngToPixel ) functions in other language.
With longitude its tricky.
But I cant properly find latitude for different map zoom levels
(0-17).
Could you please explain how to calculate latitude?
Thx.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Eirik <eirir... @gmail.com>
Date: Sun, 18 Nov 2007 08:47:09 -0800 (PST)
Local: Sun, Nov 18 2007 11:47 am
Subject: Re: GMercatorProjection: fromLatLngToPixel and fromPixelToLatLng implementation.
This is from the source, hope it helps:
Uc.prototype.fromLatLngToPixel = function (a, b) {
var c = this, d = c.Pm[b], e = G(d.x + a.lng() * c.Rm[b]), f =
Ka(Math.sin(Ee(a.lat())), -0.9999, 0.9999), g = G(d.y + 0.5 *
Math.log((1 + f) / (1 - f)) * -c.Sm[b]);
return new o(e, g);
};
Uc.prototype.fromPixelToLatLng = function (a, b, c) {
var d = this, e = d.Pm[b], f = (a.x - e.x) / d.Rm[b], g = (a.y -
e.y) / -d.Sm[b], h = Kb(2 * Math.atan(Math.exp(g)) - $ / 2);
return new F(h, f, c);
};
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
bratliff <bratl... @umich.edu>
Date: Sun, 18 Nov 2007 09:44:07 -0800 (PST)
Local: Sun, Nov 18 2007 12:44 pm
Subject: Re: GMercatorProjection: fromLatLngToPixel and fromPixelToLatLng implementation.
On Nov 16, 10:29 am, "Andriy T. Yanko" <andriy.ya... @gmail.com> wrote:
> Hi all.
> I need implement GMercatorProjection's fromPixelToLatLng and
> (fromLatLngToPixel ) functions in other language.
> With longitude its tricky.
> But I cant properly find latitude for different map zoom levels
> (0-17).
> Could you please explain how to calculate latitude?
> Thx.
var offset=16777216;
var radius=offset / Math.PI;
LToX=function(z,w,x,y)
{
return (offset+radius*x*Math.PI/180)>>z;
}
LToY=function(z,w,x,y)
{
return (offset-radius*Math.log((1+Math.sin(y*Math.PI/180))/(1-
Math.sin(y*Math.PI/180)))/2)>>z;
}
XToL=function(z,w,x,y)
{
return (((x<<z)-offset)/radius)*180/Math.PI;
}
YToL=function(z,w,x,y)
{
return (Math.PI/2-2*Math.atan(Math.exp(((y<<z)-offset)/radius)))*180/
Math.PI;
}
The "z" parameter is the zoom level. Ignore the "w" parameter. It is
the UTM zone. It is null for Mercator.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Andriy T. Yanko" <andriy.ya... @gmail.com>
Date: Sun, 18 Nov 2007 12:47:12 -0800 (PST)
Local: Sun, Nov 18 2007 3:47 pm
Subject: Re: GMercatorProjection: fromLatLngToPixel and fromPixelToLatLng implementation.
Interesting, but what does mean operator '<<' in your sources? (e.g
y<<z ).
On Nov 18, 7:44 pm, bratliff <bratl... @umich.edu> wrote:
> On Nov 16, 10:29 am, "Andriy T. Yanko" <andriy.ya
... @gmail.com> wrote:
> > Hi all.
> > I need implement GMercatorProjection's fromPixelToLatLng and
> > (fromLatLngToPixel ) functions in other language.
> > With longitude its tricky.
> > But I cant properly find latitude for different map zoom levels
> > (0-17).
> > Could you please explain how to calculate latitude?
> > Thx.
> var offset=16777216;
> var radius=offset / Math.PI;
> LToX=function(z,w,x,y)
> {
> return (offset+radius*x*Math.PI/180)>>z;
> }
> LToY=function(z,w,x,y)
> {
> return (offset-radius*Math.log((1+Math.sin(y*Math.PI/180))/(1-
> Math.sin(y*Math.PI/180)))/2)>>z;
> }
> XToL=function(z,w,x,y)
> {
> return (((x<<z)-offset)/radius)*180/Math.PI;
> }
> YToL=function(z,w,x,y)
> {
> return (Math.PI/2-2*Math.atan(Math.exp(((y<<z)-offset)/radius)))*180/
> Math.PI;
> }
> The "z" parameter is the zoom level. Ignore the "w" parameter. It is
> the UTM zone. It is null for Mercator.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
bratliff <bratl... @umich.edu>
Date: Sun, 18 Nov 2007 13:01:06 -0800 (PST)
Local: Sun, Nov 18 2007 4:01 pm
Subject: Re: GMercatorProjection: fromLatLngToPixel and fromPixelToLatLng implementation.
On Nov 18, 8:47 pm, "Andriy T. Yanko" <andriy.ya... @gmail.com> wrote:
> Interesting, but what does mean operator '<<' in your sources? (e.g
> y<<z ).
<< is the shift left operator
>> is the shift right operator
Equivalent to multiplying / dividing by a power of two. Both
automatically convert from floating point to fixed point.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Barry Hunter" <barrybhun... @googlemail.com>
Date: Sun, 18 Nov 2007 22:18:27 +0000
Local: Sun, Nov 18 2007 5:18 pm
Subject: Re: GMercatorProjection: fromLatLngToPixel and fromPixelToLatLng implementation.
http://www.javascripter.net/faq/arithmet.htm On Nov 18, 2007 8:47 PM, Andriy T. Yanko <andriy.ya... @gmail.com> wrote:
> Interesting, but what does mean operator '<<' in your sources? (e.g > y<<z ).
> On Nov 18, 7:44 pm, bratliff <bratl... @umich.edu> wrote: > > On Nov 16, 10:29 am, "Andriy T. Yanko" <andriy.ya... @gmail.com> wrote:
> > > Hi all.
> > > I need implement GMercatorProjection's fromPixelToLatLng and > > > (fromLatLngToPixel ) functions in other language.
> > > With longitude its tricky. > > > But I cant properly find latitude for different map zoom levels > > > (0-17).
> > > Could you please explain how to calculate latitude?
> > > Thx.
> > var offset=16777216;
> > var radius=offset / Math.PI;
> > LToX=function(z,w,x,y) > > { > > return (offset+radius*x*Math.PI/180)>>z;
> > }
> > LToY=function(z,w,x,y) > > { > > return (offset-radius*Math.log((1+Math.sin(y*Math.PI/180))/(1- > > Math.sin(y*Math.PI/180)))/2)>>z;
> > }
> > XToL=function(z,w,x,y) > > { > > return (((x<<z)-offset)/radius)*180/Math.PI;
> > }
> > YToL=function(z,w,x,y) > > { > > return (Math.PI/2-2*Math.atan(Math.exp(((y<<z)-offset)/radius)))*180/ > > Math.PI;
> > }
> > The "z" parameter is the zoom level. Ignore the "w" parameter. It is > > the UTM zone. It is null for Mercator.
-- Barry - www.nearby.org.uk - www.geograph.org.uk -
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Valery <valery.bogda... @gmail.com>
Date: Mon, 19 Nov 2007 01:15:56 -0800 (PST)
Local: Mon, Nov 19 2007 4:15 am
Subject: Re: GMercatorProjection: fromLatLngToPixel and fromPixelToLatLng implementation.
On Nov 16, 12:29 pm, "Andriy T. Yanko" <andriy.ya... @gmail.com> wrote:
> But I cant properly find latitude for different map zoom levels
> (0-17).
Actually there is twenty zoom levels in Google Maps:
- from 0 to 17 for "Map" map type;
- from 0 to 19 for "Satellite" and "Hybrid" map types
WBR,
Valery.
You must
Sign in before you can post messages.
You do not have the permission required to post.