diff --git a/source/core/mercatorquadtree.js b/source/core/mercatorquadtree.js index 8e807ac1..27686791 100644 --- a/source/core/mercatorquadtree.js +++ b/source/core/mercatorquadtree.js @@ -183,17 +183,17 @@ MercatorQuadtree.prototype.QuadKeyToWGS84 = function(quadcode, coords) var maxpixelY=(1.00-mercator[3])*256*Math.pow(2,lod); var x = (Math.min(Math.max(minpixelX, 0), mapSize - 1) / mapSize) - 0.5; var y = 0.5 - (Math.min(Math.max(minpixelY, 0), mapSize - 1) / mapSize); - var minx = 90.0 - 360.0 * Math.atan(Math.exp(-y * 2.0 * Math.PI)) / Math.PI; - var miny = 360.0000 * x; + var miny = 90.0 - 360.0 * Math.atan(Math.exp(-y * 2.0 * Math.PI)) / Math.PI; + var minx = 360.0000 * x; - x = (Math.min(Math.max(minpixelX, 0), mapSize - 1) / mapSize) - 0.5; - y = 0.5 - (Math.min(Math.max(minpixelY, 0), mapSize - 1) / mapSize); - var maxx = 90.0 - 360.0 * Math.atan(Math.exp(-y * 2.0 * Math.PI)) / Math.PI; - var maxy = 360.0000 * x; - coords[0]=minx; - coords[1]=miny; - coords[2]=maxx; - coords[3]=maxy; + x = (Math.min(Math.max(maxpixelX, 0), mapSize - 1) / mapSize) - 0.5; + y = 0.5 - (Math.min(Math.max(maxpixelY, 0), mapSize - 1) / mapSize); + var maxy = 90.0 - 360.0 * Math.atan(Math.exp(-y * 2.0 * Math.PI)) / Math.PI; + var maxx = 360.0000 * x; + coords[0]=minx; //swap(y0,y1) coordinates for pixel based coordinates. + coords[1]=maxy; + coords[2]=maxx; + coords[3]=miny; } //------------------------------------------------------------------------------ @@ -203,4 +203,4 @@ goog.exportProperty(MercatorQuadtree.prototype, 'QuadKeyToMercatorCoord', Mercat goog.exportProperty(MercatorQuadtree.prototype, 'QuadKeyToNormalizedCoord', MercatorQuadtree.prototype.QuadKeyToNormalizedCoord); goog.exportProperty(MercatorQuadtree.prototype, 'QuadKeyToTileCoord', MercatorQuadtree.prototype.QuadKeyToTileCoord); goog.exportProperty(MercatorQuadtree.prototype, 'QuadKeyToMercator', MercatorQuadtree.prototype.QuadKeyToMercator); -goog.exportProperty(MercatorQuadtree.prototype, 'QuadKeyToWGS84', MercatorQuadtree.prototype.QuadKeyToWGS84); \ No newline at end of file +goog.exportProperty(MercatorQuadtree.prototype, 'QuadKeyToWGS84', MercatorQuadtree.prototype.QuadKeyToWGS84);