开发者

How to convert a bing maps quadkey to mercator coordinates

How do you convert a bing maps quad key, such as "03200320023" to coordinates in mercator virtual earth (epsg 3857) coordinate system?

I've got an algorithm to convert to coordinates in latitude longitude (e.g. the quad key above comes to "-84.19921875,33.7243385314941,-84.0234375,33.8704147338867"). I could then convert from latitude longitude to mercator coordinate, but that smells far too expensive in processing power.

The mercator virtual earth result I'm looking for given the above quadkey is: "-9373014,4011415,-9353446,4030983"

Some more context. I'm using bing maps and adding layers that I'm serving using mapserver from IIS using fastcgi. I basically want to convert the bing maps quadkey request for 256x256 tiles to a mapserver wms query in epsg 3857. It works in epsg 4326 (wgs84) and also w开发者_JS百科hen I convert from wgs84 to epsg 3857. However the performance is not what I want due to the two stage conversion.

I've also asked the question on gis.stackexchange.com which has now been answered


For completeness, here is the F# code I'm using to solve this problem.

let quadKeyToVE key =
let offset,x,y =
    key
    |> Seq.fold (fun (offset,x,y) ch ->
        let x',y' = 
            match ch with
            | '0' -> x-offset,y+offset
            | '1' -> x+offset,y+offset
            | '2' -> x-offset,y-offset
            | '3' -> x+offset,y-offset
            | _ -> failwith "Invalid quadkey"
        offset/2.0,x',y'
        ) (InitialOffset,0.0,0.0)

let offset = offset * 2.0
let west = x - offset
let north = y + offset
let east = x + offset
let south = y - offset
west,south,east,north
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜