def process_geo_json(): ''' Depending on the values put in the COUNTRY_LIST, we pull shapes from The highcharts map repository. This will give us shapes for admin level 1 for the countries we specify. ''' for c in settings.COUNTRY_LIST: create_country_meta_data(c) minify_geo_json()
def setUp(self): super(GeoResourceTest, self).setUp() self.ts = TestSetupHelpers() self.lt = LocationType.objects.create(name='Region', admin_level=1) self.distr, created = \ LocationType.objects.get_or_create(name='District',admin_level = 2) self.planet_location_type = LocationType.objects\ .create(name = 'Planet', admin_level = 0) self.ultimate_parent = Location.objects.create( id=1, name='Earth', location_code='Earth', location_type_id=self.planet_location_type.id) location_df_from_csv = read_csv( 'rhizome/tests/_data/locations_nimroz.csv') self.ts.model_df_to_data(location_df_from_csv, Location) # make sure that the proper level is set for the locs = Location.objects.filter(parent_location_id=6) for loc in locs: loc.location_type_id = self.distr.id loc.save() parent = Location.objects.get(id=6) parent.location_type_id = self.lt.id parent.save() geo_json_df = read_csv('rhizome/tests/_data/geo_json_small.txt', delimiter="|") location_df = DataFrame(list(Location.objects.all()\ .values_list('id','location_code')),columns=['location_id','location_code']) location_tree_df = DataFrame(list(Location.objects.all()\ .values_list('id','parent_location_id'))\ ,columns=['location_id','parent_location_id']) location_tree_df['parent_location_id'].fillna(self.ultimate_parent.id,\ inplace=True) location_tree_df['lvl'] = Series(1, index=location_tree_df.index) self.ts.model_df_to_data(location_tree_df, LocationTree) merged_df = location_df.merge(geo_json_df)[['location_id', 'geo_json']] self.ts.model_df_to_data(merged_df, LocationPolygon) minify_geo_json() LocationPermission.objects.create(user_id=self.ts.user.id, top_lvl_location_id=1)
def setUp(self): super(GeoResourceTest, self).setUp() self.ts = TestSetupHelpers() self.lt = LocationType.objects.create(name='Region',admin_level=1) self.distr, created = \ LocationType.objects.get_or_create(name='District',admin_level = 2) self.planet_location_type = LocationType.objects\ .create(name = 'Planet', admin_level = 0) self.ultimate_parent = Location.objects.create( id = 1, name = 'Earth', location_code = 'Earth', location_type_id = self.planet_location_type.id ) location_df_from_csv= read_csv('rhizome/tests/_data/locations_nimroz.csv') self.ts.model_df_to_data(location_df_from_csv,Location) # make sure that the proper level is set for the locs = Location.objects.filter(parent_location_id=6) for loc in locs: loc.location_type_id = self.distr.id loc.save() parent = Location.objects.get(id=6) parent.location_type_id = self.lt.id parent.save() geo_json_df = read_csv('rhizome/tests/_data/geo_json_small.txt',delimiter = "|") location_df = DataFrame(list(Location.objects.all()\ .values_list('id','location_code')),columns=['location_id','location_code']) location_tree_df = DataFrame(list(Location.objects.all()\ .values_list('id','parent_location_id'))\ ,columns=['location_id','parent_location_id']) location_tree_df['parent_location_id'].fillna(self.ultimate_parent.id,\ inplace=True) location_tree_df['lvl'] = Series(1, index=location_tree_df.index) self.ts.model_df_to_data(location_tree_df, LocationTree) merged_df = location_df.merge(geo_json_df)[['location_id','geo_json']] self.ts.model_df_to_data(merged_df, LocationPolygon) minify_geo_json() LocationPermission.objects.create(user_id = self.ts.user.id, top_lvl_location_id = 1)
def process_geo_json(): try: geo_json_df = pd.read_csv('geo_json.txt', delimiter="|") except IOError: return geo_json_df = pd.read_csv('geo_json.txt', delimiter="|") location_df = pd.DataFrame(list(Location.objects.all()\ .values_list('id','location_code')),columns=['location_id','location_code']) merged_df = location_df.merge(geo_json_df)[['location_id', 'geo_json']] model_df_to_data(merged_df, LocationPolygon) minify_geo_json()
def process_geo_json(): try: geo_json_df = pd.read_csv('geo_json.txt',delimiter = "|") except IOError: return geo_json_df = pd.read_csv('geo_json.txt',delimiter = "|") location_df = pd.DataFrame(list(Location.objects.all()\ .values_list('id','location_code')),columns=['location_id','location_code']) merged_df = location_df.merge(geo_json_df)[['location_id','geo_json']] model_df_to_data(merged_df, LocationPolygon) minify_geo_json()