Created
November 13, 2013 19:52
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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