Skip to content

Instantly share code, notes, and snippets.

@walkermatt
Created November 13, 2013 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walkermatt/7455267 to your computer and use it in GitHub Desktop.
Save walkermatt/7455267 to your computer and use it in GitHub Desktop.
Example of configuring Astun Tech QGIS-Gazetteer-Plugin (https://github.com/AstunTechnology/QGIS-Gazetteer-Plugin) to use a specific iShare location search (Surrey Heath Borough Council in this instance).
from json import loads
from collections import namedtuple
url = "http://isharemaps.surreyheath.gov.uk/getdata.aspx"
params = {
'type': 'json',
'RequestType': 'LocationSearch',
'gettotals': 'true',
'axuid': '1344265603167',
'mapsource': 'SurreyHeath/AllMaps',
'_': '1344265603168',
'location': '##searchstring##',
'pagesize': '30',
'startnum': '1',
}
def parseRequestResults(data):
json_result = loads(data)
columns = json_result['columns']
for item in json_result['data']:
mapped = dict(zip(columns, item))
result = namedtuple('Result', ['description', 'x', 'y', 'zoom', 'epsg'])
result.description = mapped['Name']
result.x = float(mapped['X'])
result.y = float(mapped['Y'])
result.zoom = 600
result.epsg = 27700
yield result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment