def test_isochrones_from_dataframe_dataset_with_isoline_options(self): self.skip(if_no_credits=True, if_no_credentials=True) iso = Isolines(credentials=self.credentials) gdf = GeoDataFrame(self.points, columns=['name', 'the_geom']) quota = self.used_quota(iso) # Preview result = iso.isochrones(gdf, [100, 1000], mode='car', maxpoints=10, dry_run=True, exclusive=True).metadata self.assertEqual(result.get('required_quota'), 6) self.assertEqual(self.used_quota(iso), quota) # Isochrones result = iso.isochrones(gdf, [100, 1000], mode='car', maxpoints=10, exclusive=True).data self.assertTrue(isinstance(result, GeoDataFrame)) self.assertTrue(result.is_local()) quota += 6 self.assertEqual(self.used_quota(iso), quota) result_columns = result.get_column_names() self.assertTrue('the_geom' in result_columns) self.assertTrue('data_range' in result_columns) self.assertEqual(result.get_num_rows(), 6) self.assertTrue('cartodb_id' in result_columns) self.assertTrue('cartodb_id' in result.dataframe) self.assertTrue('source_id' in result_columns) self.assertTrue('source_id' in result.dataframe)
def test_isodistances_from_dataframe(self): self.skip(if_no_credits=True, if_no_credentials=True) iso = Isolines(credentials=self.credentials) df = DataFrame(self.points, columns=['name', 'the_geom']) quota = self.used_quota(iso) # Preview result = iso.isodistances(df, [100, 1000], mode='car', dry_run=True, exclusive=True).metadata self.assertEqual(result.get('required_quota'), 6) self.assertEqual(self.used_quota(iso), quota) # Isodistances result = iso.isodistances(df, [100, 1000], mode='car', exclusive=True).data self.assertTrue(isinstance(result, GeoDataFrame)) quota += 6 self.assertEqual(self.used_quota(iso), quota) self.assertTrue('the_geom' in result) self.assertTrue('data_range' in result) self.assertEqual(len(result.index), 6)
def test_isochrones_from_dataframe_with_lnglat(self): self.skip(if_no_credits=True, if_no_credentials=True) iso = Isolines(credentials=self.credentials) df = DataFrame(self.point_lnglat, columns=['name', 'lng', 'lat']) quota = self.used_quota(iso) # Preview result = iso.isochrones(df, [100, 1000], mode='car', with_lnglat=('lng', 'lat'), dry_run=True, exclusive=True).metadata self.assertEqual(result.get('required_quota'), 6) self.assertEqual(self.used_quota(iso), quota) # Isochrones result = iso.isochrones(df, [100, 1000], mode='car', with_lnglat=('lng', 'lat'), exclusive=True).data self.assertTrue(isinstance(result, GeoDataFrame)) quota += 6 self.assertEqual(self.used_quota(iso), quota) self.assertTrue('the_geom' in result) self.assertTrue('data_range' in result) self.assertEqual(len(result.index), 6) result_columns = result.columns self.assertTrue('cartodb_id' in result_columns) self.assertTrue('source_id' in result_columns) self.assertEqual(result['source_id'].min(), df.index.min()) self.assertEqual(result['source_id'].max(), df.index.max())
def test_isochrones_from_table_query_as_new_table(self): self.skip(if_no_credits=True, if_no_credentials=True) iso = Isolines(credentials=self.credentials) gdf = read_carto(self.points_query()) result_table_name = self.get_test_table_name('isotbr') quota = self.used_quota(iso) # Preview result = iso.isochrones(gdf, [100, 1000], mode='car', table_name=result_table_name, dry_run=True, exclusive=True).metadata self.assertEqual(result.get('required_quota'), 6) self.assertEqual(self.used_quota(iso), quota) # Isochrones result = iso.isochrones(gdf, [100, 1000], mode='car', table_name=result_table_name, exclusive=True).data self.assertTrue(isinstance(result, GeoDataFrame)) self.assertTrue(result.is_remote()) quota += 6 self.assertEqual(self.used_quota(iso), quota) result_columns = result.get_column_names() self.assertTrue('the_geom' in result_columns) self.assertTrue('data_range' in result_columns) self.assertEqual(result.get_num_rows(), 6) self.assertTrue('cartodb_id' in result_columns) self.assertFalse('source_id' in result_columns)
def test_isochrones_from_dataframe_as_new_table(self): self.skip(if_no_credits=True, if_no_credentials=True) iso = Isolines(credentials=self.credentials) df = DataFrame(self.points, columns=['name', 'the_geom']) quota = self.used_quota(iso) table_name = self.get_test_table_name('isodfds') # Preview result = iso.isochrones(df, [100, 1000], mode='car', table_name=table_name, dry_run=True, exclusive=True).metadata self.assertEqual(result.get('required_quota'), 6) self.assertEqual(self.used_quota(iso), quota) # Isochrones result = iso.isochrones(df, [100, 1000], mode='car', table_name=table_name, exclusive=True).data self.assertTrue(isinstance(result, GeoDataFrame)) quota += 6 self.assertEqual(self.used_quota(iso), quota) self.assertTrue('the_geom' in result) self.assertTrue('data_range' in result) self.assertEqual(len(result.index), 6) gdf = read_carto(table_name, credentials=self.credentials) result_columns = gdf.columns self.assertTrue('the_geom' in result_columns) self.assertTrue('data_range' in result_columns) self.assertEqual(gdf.size, 6) self.assertTrue('source_id' in result_columns)