def _check_srid(spatial_element, srid_db): """Check if the SRID of the spatial element which we are about to insert into the database equals the SRID used for the geometry column. If not, a transformation is added. """ if srid_db is None or not hasattr(spatial_element, 'srid') or \ isinstance(spatial_element.srid, BaseFunction): return spatial_element if spatial_element.srid == srid_db: return spatial_element else: return functions.transform(spatial_element, srid_db)