latitudeToPixelY method
Converts a latitude coordinate to the corresponding pixel Y coordinate.
Uses Mercator projection formulas to calculate the pixel position.
latitude The latitude coordinate in degrees
Returns the pixel Y coordinate (0 to mapSize)
Implementation
double latitudeToPixelY(double latitude) {
const double pi180 = pi / 180;
const double pi4 = 4 * pi;
double sinLatitude = sin(latitude * pi180);
// FIXME improve this formula so that it works correctly without the clipping
double pixelY = (0.5 - log((1 + sinLatitude) / (1 - sinLatitude)) / pi4) * _mapSize;
return min(max(0, pixelY), _mapSize.toDouble());
}