Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix creating memory provider with no crs
  • Loading branch information
nyalldawson authored and troopa81 committed May 25, 2023
1 parent 976c9a9 commit 7ed40d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/providers/memory/qgsmemoryproviderutils.cpp
Expand Up @@ -81,6 +81,10 @@ QgsVectorLayer *QgsMemoryProviderUtils::createMemoryLayer( const QString &name,
else
parts << QStringLiteral( "crs=wkt:%1" ).arg( crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) );
}
else
{
parts << QStringLiteral( "crs=" );
}
for ( const QgsField &field : fields )
{
const QString lengthPrecision = QStringLiteral( "(%1,%2)" ).arg( field.length() ).arg( field.precision() );
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_provider_memory.py
Expand Up @@ -532,6 +532,7 @@ def testCreateMemoryLayer(self):
self.assertTrue(layer.isValid())
self.assertEqual(layer.name(), 'my name')
self.assertTrue(layer.fields().isEmpty())
self.assertFalse(layer.dataProvider().crs().isValid())

# similar layers should have unique sources
layer2 = QgsMemoryProviderUtils.createMemoryLayer('my name', QgsFields())
Expand Down

0 comments on commit 7ed40d5

Please sign in to comment.