Hi,
Im having little trouble finding a relation between the movement at centre and edge of a circle, I
m doing for panning world map,my map extent is 180,89:-180,-89, my map pans by adding change(dx,dY) to its extents and not its centre. Now a situation has arrrised where I have to move the map to a specific centre, to calculate the change in longitudes is very easy and simple, but its the change in lattitudes that has caused problem. It seems the change in centreY of map is more than the change at edge of the mapY, or simply if I have to move the map centre from 0long,0lat to 73long,33lat, for dX I simply get 73, but for dY apparently it looks 33 but if i add 33 to top of map that is 89 , it will be 122 which is incorrect since Latitudes are between 90 and -90 . It seems a case a projection of a circle on 2D plane where the edge of circle since is moving backward due to angle expereinces less change and the centre expereinces more change, now is there a relation between these two factors? I tried converting the difference between OriginY and destinationY into radians and then add to Top and Bottom of Map, but it did'nt really work for me. Please note that the map is project on a virtual canvas whose width starts from 256 and increases by 256*2^z , z=0 is default and whole world is visible at that extent of canvas
public void moveMapTo(double destinationLongitude,double destinationLattitude) // moves map to the new centre
{
double dXLong=destinationLongitude-centreLongitude; // centreLongitude and centreLattitude are centre of current map position
double atanhsinO = atanh(Math.sin(destinationLattitude * Math.PI / 180.00));
double atanhsinD = atanh(Math.sin(centreLatitude * Math.PI / 180.00));
double atanhCentre = (atanhsinD + atanhsinO) / 2;
double latitudeSpan =destinationLattitude - centreLatitude;
double radianOfCentreLatitude = Math.atan(Math.sinh(atanhCentre));
double dXLat=latitudeSpan / Math.cos(radianOfCentreLatitude);
dXLat*=getLattitudeSpan()*(Math.PI/180); //<--- HERE IS THE PORBLEM
System.out.println("dxLong:"+dXLong+"_dxLat:"+dXLat);
//map left.right.top,bottom are current extents of map
mapLeft+=dXLong;
mapRight+=dXLong;
mapTop+=dXLat;
mapBottom+=dXLat;
}
private double getLattitudeSpan()
{
double latitudeSpan = mapTop - mapBottom;
latitudeSpan = latitudeSpan / Math.cos(radianOfCentreLatitude);
return Math.abs(latitudeSpan);
}