java code to do the trick

public double latitudeToX(int zoom, double utmZoom, double lati,
double lngi, double offset, double radius)
        {
                return (offset +radius *lati* Math.PI/180);// >> zoom;

        }

        public double longitudeToY(double zoom, double utmZoom, double lati,
double lngi, double offset, double radius)
        {
                return (offset-radius*Math.log((1+Math.sin(lngi*Math.PI/180))/
(1-
                                        
Math.sin(lngi*Math.PI/180)))/2);//>>zoom;
        }


sample test with Polygon class of java

double offset=16777216;

                        double radius=offset / Math.PI;

                        int x = (int)this.latitudeToX(0, 0, 25.774252, 
-80.190262, offset,
radius);
                        int y = (int)this.longitudeToY(0, 0, 25.774252, 
-80.190262, offset,
radius);
                        Polygon polygon = new Polygon();

                        polygon.addPoint(x, y);

                        x = (int)this.latitudeToX(0, 0, 18.466465, -66.118292, 
offset,
radius);
                        y = (int)this.longitudeToY(0, 0, 18.466465, -66.118292, 
offset,
radius);

                        polygon.addPoint(x, y);

                        x = (int)this.latitudeToX(0, 0, 32.321384, -64.75737, 
offset,
radius);
                        y = (int)this.longitudeToY(0, 0, 32.321384, -64.75737, 
offset,
radius);

                        polygon.addPoint(x, y);
                        //yes
                        /*lat = 24.8864364;//90787712;
                        lng = -70.2685546;//875;
*/
                        //yes
                        /*lat = 26.703743;//90787712;
                        lng = -74.091797;//875;
*/
                        //no
                        lat = 19.598435;//90787712;
                        lng = -79.892578;//875;

                        x = (int)this.latitudeToX(0, 0, lat, lng, offset, 
radius);
                        y = (int)this.longitudeToY(0, 0, lat, lng, offset, 
radius);

                        if (polygon.contains(x, y))
                                return true;

use this link to verify your points http://itouchmap.com/latlong.html

it works for me, hopefully works for you as well.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" 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