def GenerateKhooshe(core_name): ''' Generate Khooshe tiles for given core ''' try: start_time = time.time() print "GenerateKhooshe Started.." all_points = [] points = QueryPointsIndex(core_name) print "Retrieved {0} points in {1} seconds".format(len(points), time.time() - start_time) for point in points: x = float(point["x"]) y = float(point["y"]) all_points.append([x, y, point["popup_info"]]) file_name = ''.join(ch for ch in core_name if ch not in exclude) if len(all_points) > 0: khooshe.run_khooshe(all_points, None, "geoparser_app/static/tiles/{0}".format(file_name)) print "Tiles created for {0} Points. Total time {1} seconds".format(len(points), time.time() - start_time) return len(all_points) except Exception as e: print traceback.format_exc() print e print "Unable to generate Khooshe tiles for given core" return 0
def GenerateKhooshe(core_name): ''' Generate Khooshe tiles for given core ''' try: start_time = time.time() print "GenerateKhooshe Started.." all_points = [] points = QueryPointsIndex(core_name) print "Retrieved {0} points in {1} seconds".format( len(points), time.time() - start_time) for point in points: x = float(point["x"]) y = float(point["y"]) all_points.append([x, y, point["popup_info"]]) file_name = ''.join(ch for ch in core_name if ch not in exclude) if len(all_points) > 0: khooshe.run_khooshe( all_points, None, "geoparser_app/static/tiles/{0}".format(file_name)) print "Tiles created for {0} Points. Total time {1} seconds".format( len(points), time.time() - start_time) return len(all_points) except Exception as e: print traceback.format_exc() print e print "Unable to generate Khooshe tiles for given core" return 0
def SearchLocalSolrIndex(core_name, list_id, keyword): ''' Search local Solr for given ids and core and create Khooshe tiles under serach directory. ''' search_results = [] all_points = [] points = [] for each_id in list_id: url = '{0}{1}/select?q=-points%3A%22%5B%5D%22&fq=id:"{2}"&fl=id,points&wt=json'.format( SOLR_URL, core_name, each_id) response = requests.get(url, headers=headers).json() if ('response' in response.keys()) and len(response['response']['docs']) != 0: points = response['response']['docs'] for point in points: docId = point['id'] point = point['points'][0] all_x, loc_name, all_y = get_all_points(point) if (len(all_x) == len(all_y) == len(loc_name)): # if length of all_x,all_y,loc_name is not same our results are inconsistent for i in range(len(all_x)): search_results.append({ "popup_info": "'{0}','{1}'".format(loc_name[i], docId), "x": all_x[i].encode(), "y": all_y[i].encode() }) else: print "length of all_x,all_y,loc_name is not same" print point del points for point in search_results: x = float(point["x"]) y = float(point["y"]) all_points.append([x, y, point["popup_info"]]) file_name = ''.join(ch for ch in core_name if ch not in exclude) if len(all_points) > 0: khoose_tiles_folder_name = "static/search/tiles/{0}_{1}".format( file_name, keyword) khooshe.run_khooshe(all_points, None, "geoparser_app/" + khoose_tiles_folder_name) return khoose_tiles_folder_name, len(all_points) else: return None, 0
def SearchLocalSolrIndex(core_name , list_id, keyword): ''' Search local Solr for given ids and core and create Khooshe tiles under serach directory. ''' search_results = [] all_points = [] points = [] for each_id in list_id: url = '{0}{1}/select?q=-points%3A%22%5B%5D%22&fq=id:"{2}"&fl=id,points&wt=json'.format(SOLR_URL, core_name, each_id) response = requests.get(url, headers=headers).json() if ('response' in response.keys()) and len(response['response']['docs']) != 0: points = response['response']['docs'] for point in points: docId = point['id'] point = point['points'][0] all_x, loc_name, all_y = get_all_points(point) if(len(all_x) == len(all_y) == len(loc_name)): # if length of all_x,all_y,loc_name is not same our results are inconsistent for i in range(len(all_x)): search_results.append({"popup_info":"'{0}','{1}'".format(loc_name[i],docId), "x":all_x[i].encode(), "y":all_y[i].encode()}) else: print "length of all_x,all_y,loc_name is not same" print point del points for point in search_results: x = float(point["x"]) y = float(point["y"]) all_points.append([x, y, point["popup_info"]]) file_name = ''.join(ch for ch in core_name if ch not in exclude) if len(all_points) > 0: khoose_tiles_folder_name = "static/search/tiles/{0}_{1}".format(file_name, keyword) khooshe.run_khooshe(all_points, None, "geoparser_app/"+khoose_tiles_folder_name) return khoose_tiles_folder_name, len(all_points) else: return None, 0