def test_read_postgis_binary(self, connection_spatialite, df_nybb): """Tests that geometry read as binary is accepted.""" con = connection_spatialite geom_col = df_nybb.geometry.name create_spatialite(con, df_nybb) sql = ("SELECT ogc_fid, borocode, boroname, shape_leng, shape_area, " 'ST_AsBinary("{0}") AS "{0}" FROM nybb'.format(geom_col)) df = read_postgis(sql, con, geom_col=geom_col) validate_boro_df(df)
def test_read_postgis_null_geom(self, connection_spatialite, df_nybb): """Tests that geometry with NULL is accepted.""" con = connection_spatialite geom_col = df_nybb.geometry.name df_nybb.geometry.iat[0] = None create_spatialite(con, df_nybb) sql = ("SELECT ogc_fid, borocode, boroname, shape_leng, shape_area, " 'AsEWKB("{0}") AS "{0}" FROM nybb'.format(geom_col)) df = read_postgis(sql, con, geom_col=geom_col) validate_boro_df(df)
def test_read_postgis_binary(self, df_nybb): """Tests that geometry read as binary is accepted.""" try: con = connect_spatialite() except Exception: raise pytest.skip() else: geom_col = df_nybb.geometry.name create_spatialite(con, df_nybb) sql = 'SELECT ogc_fid, borocode, boroname, shape_leng, shape_area, ST_AsBinary("{0}") AS "{0}" FROM nybb'.format(geom_col) df = read_postgis(sql, con, geom_col=geom_col) validate_boro_df(df) finally: if 'con' in locals(): con.close()
def test_read_postgis_null_geom(self): """Tests that geometry with NULL is accepted.""" try: con = connect_spatialite() except Exception: raise pytest.skip() else: geom_col = self.df.geometry.name self.df.geometry.iat[0] = None create_spatialite(con, self.df) sql = 'SELECT ogc_fid, borocode, boroname, shape_leng, shape_area, AsEWKB("{0}") AS "{0}" FROM nybb'.format( geom_col) df = read_postgis(sql, con, geom_col=geom_col) validate_boro_df(df) finally: if 'con' in locals(): con.close()
def test_read_spatialite_binary(df_nybb): """Tests that geometry read as binary is accepted.""" try: from geopandas.tests.util import (connect_spatialite, create_spatialite, validate_boro_df) con = connect_spatialite() except Exception: raise pytest.skip() else: geom_col = df_nybb.geometry.name create_spatialite(con, df_nybb) sql = ('SELECT ogc_fid, borocode, boroname, shape_leng, shape_area, ' 'ST_AsBinary("{0}") AS "{0}" FROM nybb').format(geom_col) df = SpatiaLiteSource(con, sql_expr=sql, geopandas_kwargs={ 'geom_col': geom_col }).read() validate_boro_df(df) finally: if 'con' in locals(): con.close()