Skip to content

Instantly share code, notes, and snippets.

@mapmeld
Created June 10, 2012 21:06
Show Gist options
  • Save mapmeld/2907331 to your computer and use it in GitHub Desktop.
Save mapmeld/2907331 to your computer and use it in GitHub Desktop.
XYZ tile to WMS
get '/countymap/:z/:x/:y' do
x = params[:x].to_i
y = params[:y].to_i
z = params[:z].to_i
maxExtent = {
"left" => -20037508.34,
"right" => 20037508.34,
"top" => 20037508.34,
"bottom" => -20037508.34
}
wmsExtent = { };
b = 78271.516953125 / ( 2 ** (z - 1) );
wmsExtent["left"] = b * 256 * x + maxExtent["left"]
wmsExtent["right"] = b * 256 * (x+1) + maxExtent["left"]
wmsExtent["top"] = b * -256 * y + maxExtent["top"]
wmsExtent["bottom"] = b * -256 * (y+1) + maxExtent["top"]
redirect "http://gis.co.bibb.ga.us/ArcGISBibb/rest/services/AG4LG/ParcelPublicAccess/MapServer/export?bbox=" + wmsExtent["left"].to_s + "," + wmsExtent["bottom"].to_s + "," + wmsExtent["right"].to_s + "," + wmsExtent["top"].to_s + "&bboxSR=102113&layers=&layerdefs=&size=256,256&imageSR=&format=png&transparent=false&dpi=&time=&layerTimeOptions=&f=image"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment