Skip to content

Instantly share code, notes, and snippets.

@andrewljohnson
Created September 2, 2015 03:41
Show Gist options
  • Save andrewljohnson/b5525b5c4ff9da4eca2e to your computer and use it in GitHub Desktop.
Save andrewljohnson/b5525b5c4ff9da4eca2e to your computer and use it in GitHub Desktop.
Make a URL that imports a TMS map source into Gaia GPS
#!/usr/local/bin/python
import sys
import urllib
'''
make a URL that imports a TMS map source into Gaia GPS
example
getURL(0, -179, 80, -30, "http://s3-us-west-1.amazonaws.com/ustopo/orthoimage/ZPARAM/XPARAM/YPARAM.png", "CalTopo Imagery Test", 5, 16, "CalTopo Aerial", "caltopotestaerial", uri_prefix)
'''
def getURL(minLat, minLon, maxLat, maxLon, url, productID, minZoom, maxZoom, name, uniqueID, uri_prefix):
sourceTag = name + "^^" + url + "^^" + str(minZoom) + "^^" + str(maxZoom) + "^^Google^^" + uniqueID + "^^"
sourceTag = sourceTag + str(maxLat) + "^^" + str(maxLon) + "^^" + str(minLat) + "^^" + str(minLon) + "^^"
sourceTag = sourceTag + uniqueID + "^^2302147642.000000"
url = uri_prefix + "://addmapsource/" + urllib.quote(sourceTag)
return url
print getURL(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8], sys.argv[9], sys.argv[10], sys.argv[11])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment