Skip to content
Permalink
Browse files

[mssql] Fix import of layers with invalid geometries (fixes #20122)

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 63b2267b6b521c5717ada4e0508666a0ca25f425
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/providers/mssql/qgsmssqlprovider.cpp
@@ -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

0 comments on commit 63b2267

Please sign in to comment.
You can’t perform that action at this time.