def hdata():
 try:
  _id = request.args[0]
 except:
  raise HTTP(400)
 table = s3db.gis_hierarchy
 query = ((table.deleted == False) & (table.location_id == _id))
 row = db(query).select(table.L1, table.L2, table.L3, table.L4, table.L5, limitby=(0, 1)).first()
 if (not row):
  return 'var n'
 hdict = {}
 for l in ['L1', 'L2', 'L3', 'L4', 'L5']:
  if row[l]:
   hdict[int(l[1:])] = row[l]
 script = ('n=%s\n' % json.dumps(hdict, separators=SEPARATORS))
 response.headers['Content-Type'] = 'application/json'
 return script

def hdata ( ) : try : _id = request . args [ 0 ] except : raise HTTP ( 400 ) table = s3db . gis_hierarchy query = ( ( table . deleted == False ) & ( table . location_id == _id ) ) row = db ( query ) . select ( table . L1 , table . L2 , table . L3 , table . L4 , table . L5 , limitby = ( 0 , 1 ) ) . first ( ) if ( not row ) : return 'var n' hdict = { } for l in [ 'L1' , 'L2' , 'L3' , 'L4' , 'L5' ] : if row [ l ] : hdict [ int ( l [ 1 : ] ) ] = row [ l ] script = ( 'n=%s\n' % json . dumps ( hdict , separators = SEPARATORS ) ) response . headers [ 'Content-Type' ] = 'application/json' return script
return json of hierarchy labels suitable for use by s3locationselector /eden/gis/hdata/ + l0_id n = {l0_id : {1 : l1_name .