Skip to content

Commit

Permalink
[mssql] Fix import of layers with invalid geometries (fixes #20122)
Browse files Browse the repository at this point in the history
This essentially reverts 62f4534

Rationale:
- even valid geometries according to GEOS may be considered as invalid by MS SQL
  so there is no way of knowing that a geometry may be fail to be added
- change of geometries applies MakeValid() so it is consistent again
- GDAL driver also applies MakeValid() on all added/changed geometries
- QGIS since 3.4 has optional geometry checks for validity etc. so some truly
  invalid geometries may be fixed before submitted to the provider

See also #8411

(cherry picked from commit b1fd7b5)
  • Loading branch information
wonder-sk committed Nov 22, 2018
1 parent 7c4708e commit 63b2267
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -927,10 +927,10 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList &flist, Flags flags )
if ( mGeometryColType == QLatin1String( "geometry" ) )
{
if ( mUseWkb )
values += QStringLiteral( "geometry::STGeomFromWKB(%1,%2)" ).arg(
values += QStringLiteral( "geometry::STGeomFromWKB(%1,%2).MakeValid()" ).arg(
QStringLiteral( "?" ), QString::number( mSRId ) );
else
values += QStringLiteral( "geometry::STGeomFromText(%1,%2)" ).arg(
values += QStringLiteral( "geometry::STGeomFromText(%1,%2).MakeValid()" ).arg(
QStringLiteral( "?" ), QString::number( mSRId ) );
}
else
Expand Down

0 comments on commit 63b2267

Please sign in to comment.