Bug#1000454: bullseye-pu: package gdal/3.2.2+dfsg-2+deb11u1

Bas Couwenberg sebastic at xs4all.nl
Tue Nov 23 13:34:42 GMT 2021


Package: release.debian.org
Severity: normal
Tags: bullseye
User: release.debian.org at packages.debian.org
Usertags: pu
X-Debbugs-Cc: pkg-grass-devel at lists.alioth.debian.org

[ Reason ]
The LVBAG driver in GDAL 3.2.2 is unable to process BAG 2.0 Extract files
correctly. Since October 2021 BAG 1.0 Extract files are no longer updated,
so users are expected to switch their processing to BAG 2.0.

GDAL 3.3.0 and 3.4.0 contain changes required to process BAG 2.0 Extract
files correctly.

[ Impact ]
Unable to update their BAG databases with current data.

[ Tests ]
The changes are covered by the upstream CI, and have been manually tested
on a bulleye system.

[ Risks ]
Low, only the relevant changes for this specific driver are added.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
The branch for the stable update is updated in gbp.conf & the Vcs-Git URL.

The relevant upstream changes are added as patches, and stripped from
unrelated changes.

[ Other info ]
N/A

Kind Regards,

Bas
-------------- next part --------------
diff -Nru gdal-3.2.2+dfsg/debian/changelog gdal-3.2.2+dfsg/debian/changelog
--- gdal-3.2.2+dfsg/debian/changelog	2021-06-21 21:06:09.000000000 +0200
+++ gdal-3.2.2+dfsg/debian/changelog	2021-11-23 10:11:54.000000000 +0100
@@ -1,3 +1,11 @@
+gdal (3.2.2+dfsg-2+deb11u1) bullseye; urgency=medium
+
+  * Update branch in gbp.conf & Vcs-Git URL.
+  * Add upstream patches to fix BAG 2.0 Extract support in LVBAG driver.
+    (closes: #1000437)
+
+ -- Bas Couwenberg <sebastic at debian.org>  Tue, 23 Nov 2021 10:11:54 +0100
+
 gdal (3.2.2+dfsg-2) unstable; urgency=medium
 
   * Drop Breaks from gdal-data to make libgdal20 & libgdal28 co-installable.
diff -Nru gdal-3.2.2+dfsg/debian/control gdal-3.2.2+dfsg/debian/control
--- gdal-3.2.2+dfsg/debian/control	2021-06-21 21:05:55.000000000 +0200
+++ gdal-3.2.2+dfsg/debian/control	2021-11-23 10:11:54.000000000 +0100
@@ -62,7 +62,7 @@
 Build-Conflicts: automake1.11
 Standards-Version: 4.5.1
 Vcs-Browser: https://salsa.debian.org/debian-gis-team/gdal
-Vcs-Git: https://salsa.debian.org/debian-gis-team/gdal.git
+Vcs-Git: https://salsa.debian.org/debian-gis-team/gdal.git -b bullseye
 Homepage: http://www.gdal.org/
 
 Package: libgdal28
diff -Nru gdal-3.2.2+dfsg/debian/gbp.conf gdal-3.2.2+dfsg/debian/gbp.conf
--- gdal-3.2.2+dfsg/debian/gbp.conf	2021-06-21 21:05:55.000000000 +0200
+++ gdal-3.2.2+dfsg/debian/gbp.conf	2021-11-23 10:11:54.000000000 +0100
@@ -6,7 +6,7 @@
 
 # The default name for the Debian branch is "master".
 # Change it if the name is different (for instance, "debian/unstable").
-debian-branch = master
+debian-branch = bullseye
 
 # git-import-orig uses the following names for the upstream tags.
 # Change the value if you are not using git-import-orig
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-Add-a-cppcheck_2004-CI-target-and-fix-related-issues.patch gdal-3.2.2+dfsg/debian/patches/0001-Add-a-cppcheck_2004-CI-target-and-fix-related-issues.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-Add-a-cppcheck_2004-CI-target-and-fix-related-issues.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-Add-a-cppcheck_2004-CI-target-and-fix-related-issues.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,170 @@
+Description: Add a cppcheck_2004 CI target, and fix related issues
+Author: Even Rouault <even.rouault at spatialys.com>
+Origin: https://github.com/OSGeo/gdal/commit/6ff924dfc704776cbdeff1e0e23da6452cf06933
+Bug: https://github.com/OSGeo/gdal/pull/3516
+
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -76,7 +76,7 @@ OGRLVBAGLayer::~OGRLVBAGLayer()
+ {
+     delete m_poFeature;
+     poFeatureDefn->Release();
+-    CloseUnderlyingLayer();
++    OGRLVBAGLayer::CloseUnderlyingLayer();
+ }
+ 
+ /************************************************************************/
+@@ -217,7 +217,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         OGRFieldDefn oField0("oorspronkelijkBouwjaar", OFTInteger);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+-        
++
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
+         AddOccurrenceFieldDefn();
+@@ -235,14 +235,14 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         OGRFieldDefn oField3("postcode", OFTString);
+         OGRFieldDefn oField4("typeAdresseerbaarObject", OFTString);
+         OGRFieldDefn oField5("openbareruimteRef", OFTString);
+-  
++
+         poFeatureDefn->AddFieldDefn(&oField0);
+         poFeatureDefn->AddFieldDefn(&oField1);
+         poFeatureDefn->AddFieldDefn(&oField2);
+         poFeatureDefn->AddFieldDefn(&oField3);
+         poFeatureDefn->AddFieldDefn(&oField4);
+         poFeatureDefn->AddFieldDefn(&oField5);
+- 
++
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
+         AddOccurrenceFieldDefn();
+@@ -293,7 +293,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         poFeatureDefn->AddFieldDefn(&oField0);
+         poFeatureDefn->AddFieldDefn(&oField1);
+         poFeatureDefn->AddFieldDefn(&oField2);
+- 
++
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
+         AddOccurrenceFieldDefn();
+@@ -314,7 +314,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         poFeatureDefn->AddFieldDefn(&oField2);
+         poFeatureDefn->AddFieldDefn(&oField3);
+         poFeatureDefn->AddFieldDefn(&oField4);
+- 
++
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
+         AddOccurrenceFieldDefn();
+@@ -327,9 +327,9 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+     else if( EQUAL("wpl", pszDataset) )
+     {
+         OGRFieldDefn oField0("naam", OFTString);
+-  
++
+         poFeatureDefn->AddFieldDefn(&oField0);
+- 
++
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
+         AddOccurrenceFieldDefn();
+@@ -402,7 +402,7 @@ bool OGRLVBAGLayer::TouchLayer()
+         eFileDescriptorsState = FD_CANNOT_REOPEN;
+         return false;
+     }
+-    
++
+     eFileDescriptorsState = FD_OPENED;
+ 
+     return true;
+@@ -523,7 +523,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+         && nGeometryElementDepth == 0 )
+     {
+         const char *pszTag = XMLTagSplit(pszName);
+-        
++
+         StopDataCollect();
+         if ( !osElementString.empty() )
+         {
+@@ -536,7 +536,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+                     case AddressRefState::ADDRESS_SECONDARY:
+                         iFieldIndex = poFeatureDefn->GetFieldIndex("nevenadresnummeraanduidingref");
+                         break;
+-                    
++
+                     default:
+                         iFieldIndex = poFeatureDefn->GetFieldIndex("hoofdadresnummeraanduidingref");
+                         break;
+@@ -554,7 +554,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+                 {
+                     bIsIdInvalid = true;
+                     m_poFeature->SetFieldNull(iFieldIndex);
+-                    CPLError(CE_Warning, CPLE_AppDefined, 
++                    CPLError(CE_Warning, CPLE_AppDefined,
+                         "Invalid identificatie : %s, value set to null", osElementString.c_str());
+                 }
+                 if ( !bIsIdInvalid )
+@@ -602,7 +602,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+                 }
+                 else
+                     m_poFeature->SetField(iFieldIndex, osElementString.c_str());
+-                
++
+                 if( bFixInvalidData
+                     && (poFieldDefn->GetType() == OFTDate || poFieldDefn->GetType() == OFTDateTime) )
+                 {
+@@ -613,7 +613,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+                     if( nYear > 2100 )
+                     {
+                         m_poFeature->SetFieldNull(iFieldIndex);
+-                        CPLError(CE_Warning, CPLE_AppDefined, 
++                        CPLError(CE_Warning, CPLE_AppDefined,
+                             "Invalid date : %s, value set to null", osElementString.c_str());
+                     }
+                 }
+@@ -732,7 +732,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+             CPLError(CE_Failure, CPLE_AppDefined, "Parsing LV BAG extract failed");
+             XML_StopParser(oParser.get(), XML_FALSE);
+         }
+-        
++
+         if( !bHasReadSchema )
+             CreateFeatureDefn(osElementString.c_str());
+         bHasReadSchema = true;
+@@ -783,7 +783,7 @@ bool OGRLVBAGLayer::IsParserFinished( XM
+     {
+         case XML_STATUS_OK:
+             return false;
+-        
++
+         case XML_STATUS_ERROR:
+             CPLError( CE_Failure, CPLE_AppDefined,
+                     "Parsing of LV BAG file failed : %s at line %d, "
+@@ -826,7 +826,7 @@ void OGRLVBAGLayer::ParseDocument()
+ 
+                 break;
+             }
+-            
++
+             case XML_SUSPENDED:
+             {
+                 if( IsParserFinished(XML_ResumeParser(oParser.get())) )
+@@ -834,7 +834,7 @@ void OGRLVBAGLayer::ParseDocument()
+ 
+                 break;
+             }
+-            
++
+             case XML_FINISHED:
+             default:
+                 return;
+@@ -899,6 +899,6 @@ int OGRLVBAGLayer::TestCapability( const
+ 
+     if( EQUAL(pszCap, OLCStringsAsUTF8) )
+         return TRUE;
+-    
++
+     return FALSE;
+ }
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-Addresses-minor-issues-in-the-LVBAG-driver-3531-Fixe.patch gdal-3.2.2+dfsg/debian/patches/0001-Addresses-minor-issues-in-the-LVBAG-driver-3531-Fixe.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-Addresses-minor-issues-in-the-LVBAG-driver-3531-Fixe.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-Addresses-minor-issues-in-the-LVBAG-driver-3531-Fixe.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,76 @@
+Description: Addresses minor issues in the LVBAG driver
+ - Remove the XML extension check
+ - Addressing issue in which an archive with a single file is not identified by the driver
+ - Conform specification; PND dataset should report polygon, not multiPolygon
+Author: Yorick de Wid <yorickdewid at users.noreply.github.com>
+Origin: https://github.com/OSGeo/gdal/commit/03392aba1c109528903005814dea7ac13e83843c
+Bug: https://github.com/OSGeo/gdal/pull/3531
+
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbagdriver.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbagdriver.cpp
+@@ -38,14 +38,10 @@ static int OGRLVBAGDriverIdentify( GDALO
+     if( !poOpenInfo->bStatOK )
+         return FALSE;
+     if( poOpenInfo->bIsDirectory )
+-        return -1;  // Unsure.
++        return -1;  // Check later
+     if( poOpenInfo->fpL == nullptr )
+         return FALSE;
+  
+-    CPLString osExt(CPLGetExtension(poOpenInfo->pszFilename));
+-    if( !EQUAL(osExt, "xml") )
+-        return FALSE;
+-
+     auto pszPtr = reinterpret_cast<const char *>(poOpenInfo->pabyHeader);
+     if( poOpenInfo->nHeaderBytes == 0 || pszPtr[0] != '<' )
+         return FALSE;
+@@ -74,32 +70,29 @@ GDALDataset *OGRLVBAGDriverOpen( GDALOpe
+         poOpenInfo->eAccess == GA_Update)
+         return nullptr;
+ 
++    const char *pszFilename = poOpenInfo->pszFilename;
+     auto poDS = std::unique_ptr<OGRLVBAGDataSource>{
+         new OGRLVBAGDataSource{} };
+-    poDS->SetDescription(poOpenInfo->pszFilename);
++    poDS->SetDescription(pszFilename);
+ 
+     if( !poOpenInfo->bIsDirectory && poOpenInfo->fpL != nullptr )
+     {
+-        if( !poDS->Open( poOpenInfo->pszFilename, poOpenInfo->papszOpenOptions ) )
++        if( !poDS->Open( pszFilename, poOpenInfo->papszOpenOptions ) )
+             poDS.reset();
+     }
+     else if( poOpenInfo->bIsDirectory && poOpenInfo->fpL == nullptr )
+     {
+-        char **papszNames = VSIReadDir(poOpenInfo->pszFilename);
++        char **papszNames = VSIReadDir(pszFilename);
+         for( int i = 0; papszNames != nullptr && papszNames[i] != nullptr; ++i )
+         {
+             const CPLString oSubFilename =
+-                CPLFormFilename(poOpenInfo->pszFilename, papszNames[i], nullptr);
++                CPLFormFilename(pszFilename, papszNames[i], nullptr);
+ 
+             if( EQUAL(papszNames[i], ".") || EQUAL(papszNames[i], "..") )
+                 continue;
+ 
+-            CPLString osExt(CPLGetExtension(oSubFilename));
+-            if( !EQUAL(osExt, "xml") )
+-                continue;
+-
+             GDALOpenInfo oOpenInfo{ oSubFilename, GA_ReadOnly };
+-            if( !OGRLVBAGDriverIdentify(&oOpenInfo) )
++            if( OGRLVBAGDriverIdentify(&oOpenInfo) != TRUE )
+                 continue;
+ 
+             if( !poDS->Open( oSubFilename, poOpenInfo->papszOpenOptions ) )
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -225,7 +225,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         poFeatureDefn->SetName("Pand");
+         SetDescription(poFeatureDefn->GetName());
+ 
+-        AddSpatialRef(wkbMultiPolygon);
++        AddSpatialRef(wkbPolygon);
+     }
+     else if( EQUAL("num", pszDataset) )
+     {
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-Allow-for-multiple-gebruiksdoelen.patch gdal-3.2.2+dfsg/debian/patches/0001-Allow-for-multiple-gebruiksdoelen.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-Allow-for-multiple-gebruiksdoelen.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-Allow-for-multiple-gebruiksdoelen.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,42 @@
+Description: Allow for multiple 'gebruiksdoelen'
+Author: Yorick de Wid <yorickdewid at users.noreply.github.com>
+Origin: https://github.com/OSGeo/gdal/commit/3742109a7a9f477d8770b0a3d95c744df33b7cd7
+Bug: https://github.com/OSGeo/gdal/issues/3221
+
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -297,7 +297,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+     }
+     else if( EQUAL("vbo", pszDataset) )
+     {
+-        OGRFieldDefn oField0("gebruiksdoel", OFTString);
++        OGRFieldDefn oField0("gebruiksdoel", OFTStringList);
+         OGRFieldDefn oField1("oppervlakte", OFTInteger);
+         OGRFieldDefn oField2("nummeraanduidingRef", OFTString);
+         OGRFieldDefn oField3("pandRef", OFTString);
+@@ -542,6 +542,25 @@ void OGRLVBAGLayer::EndElementCbk( const
+                         m_poFeature->SetField(iFieldIndex, osElementString.c_str());
+                     }
+                 }
++                else if( poFieldDefn->GetType() == OFTStringList )
++                {
++                    if( m_poFeature->IsFieldSetAndNotNull(iFieldIndex) )
++                    {
++                        CPLStringList aoList;
++                        char **papszIter = m_poFeature->GetFieldAsStringList(iFieldIndex);
++                        while( papszIter != nullptr && *papszIter != nullptr )
++                        {
++                            aoList.AddString(*papszIter);
++                            papszIter++;
++                        }
++
++                        aoList.AddString(pszValue);
++                        m_poFeature->UnsetField(iFieldIndex);
++                        m_poFeature->SetField(iFieldIndex, aoList.List() );
++                    }
++                    else
++                        m_poFeature->SetField(iFieldIndex, pszValue);
++                }
+                 else if( poFieldDefn->GetSubType() == OGRFieldSubType::OFSTBoolean )
+                 {
+                     if( EQUAL("n", pszValue) )
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-LVBAG-Convert-MultiPolygon-to-Polygon-3599-fixes-358.patch gdal-3.2.2+dfsg/debian/patches/0001-LVBAG-Convert-MultiPolygon-to-Polygon-3599-fixes-358.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-LVBAG-Convert-MultiPolygon-to-Polygon-3599-fixes-358.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-LVBAG-Convert-MultiPolygon-to-Polygon-3599-fixes-358.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,36 @@
+Description: LVBAG: Convert MultiPolygon to Polygon
+Author: Yorick de Wid <yorickdewid at users.noreply.github.com>
+Origin: https://github.com/OSGeo/gdal/commit/f51ea2fb17860e188ac77b0cece1dc3df574b21c
+Bug: https://github.com/OSGeo/gdal/issues/3581
+
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -697,10 +697,27 @@ void OGRLVBAGLayer::EndElementCbk( const
+                     && poGeom->toGeometryCollection()->getGeometryRef(0)->getGeometryType() == wkbPolygon )
+                 {
+                     std::unique_ptr<OGRMultiPolygon> poMultiPolygon = std::unique_ptr<OGRMultiPolygon>{ new OGRMultiPolygon };
+-                    for (auto &poChildGeom : poGeom->toGeometryCollection())
++                    for( const auto &poChildGeom : poGeom->toGeometryCollection() )
+                         poMultiPolygon->addGeometry(poChildGeom);
+                     poGeom.reset(poMultiPolygon.release());
+                 }
++                else if( poGeomField->GetType() == wkbPolygon
++                    && ( poGeom->getGeometryType() == wkbMultiPolygon || poGeom->getGeometryType() == wkbGeometryCollection ) )
++                {
++                    const OGRPolygon *poSubGeomLargest = nullptr;
++                    for( const auto &poChildGeom : poGeom->toGeometryCollection() )
++                    {
++                        if( poChildGeom->getGeometryType() == wkbPolygon )
++                        {
++                            if ( !poSubGeomLargest )
++                                poSubGeomLargest = poChildGeom->toPolygon();
++                            else if (poChildGeom->toPolygon()->get_Area() > poSubGeomLargest->get_Area())
++                                poSubGeomLargest = poChildGeom->toPolygon();
++                        }
++                    }
++                    if ( poSubGeomLargest )
++                        poGeom.reset(poSubGeomLargest->clone());
++                }
+ 
+                 if( poGeomField->GetSpatialRef() )
+                     poGeom->assignSpatialReference(poGeomField->GetSpatialRef());
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-LVBAG-Driver-add-field-definition-for-gerelateerdewo.patch gdal-3.2.2+dfsg/debian/patches/0001-LVBAG-Driver-add-field-definition-for-gerelateerdewo.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-LVBAG-Driver-add-field-definition-for-gerelateerdewo.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-LVBAG-Driver-add-field-definition-for-gerelateerdewo.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,23 @@
+Description: LVBAG Driver: add field definition for "gerelateerdewoonplaats"
+Author: Just van den Broecke <just at justobjects.nl>
+Origin: https://github.com/OSGeo/gdal/commit/801f69f3fb773c2500ec63f56e92c99a3662c8a0
+Bug: https://github.com/OSGeo/gdal/issues/4161
+
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -235,6 +235,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         OGRFieldDefn oField3("postcode", OFTString);
+         OGRFieldDefn oField4("typeAdresseerbaarObject", OFTString);
+         OGRFieldDefn oField5("openbareruimteRef", OFTString);
++        OGRFieldDefn oField6("woonplaatsRef", OFTString);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+         poFeatureDefn->AddFieldDefn(&oField1);
+@@ -242,6 +243,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         poFeatureDefn->AddFieldDefn(&oField3);
+         poFeatureDefn->AddFieldDefn(&oField4);
+         poFeatureDefn->AddFieldDefn(&oField5);
++        poFeatureDefn->AddFieldDefn(&oField6);
+ 
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-NevenAdres-should-be-a-stringList.patch gdal-3.2.2+dfsg/debian/patches/0001-NevenAdres-should-be-a-stringList.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-NevenAdres-should-be-a-stringList.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-NevenAdres-should-be-a-stringList.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,142 @@
+Description: NevenAdres should be a stringList.
+ Reflect nevenAdres with multiple entries in the testcases
+Author: Yorick de Wid <yorickdewid at users.noreply.github.com>
+Origin: https://github.com/OSGeo/gdal/commit/9b33fd66912cda7ffb6461d74ceb167469a2b1eb
+Bug: https://github.com/OSGeo/gdal/issues/3221
+
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -253,7 +253,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+     else if( EQUAL("lig", pszDataset) )
+     {
+         OGRFieldDefn oField0("hoofdadresNummeraanduidingRef", OFTString);
+-        OGRFieldDefn oField1("nevenadresNummeraanduidingRef", OFTString);
++        OGRFieldDefn oField1("nevenadresNummeraanduidingRef", OFTStringList);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+         poFeatureDefn->AddFieldDefn(&oField1);
+@@ -270,7 +270,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+     else if( EQUAL("sta", pszDataset) )
+     {
+         OGRFieldDefn oField0("hoofdadresNummeraanduidingRef", OFTString);
+-        OGRFieldDefn oField1("nevenadresNummeraanduidingRef", OFTString);
++        OGRFieldDefn oField1("nevenadresNummeraanduidingRef", OFTStringList);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+         poFeatureDefn->AddFieldDefn(&oField1);
+@@ -306,7 +306,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         OGRFieldDefn oField0("gebruiksdoel", OFTStringList);
+         OGRFieldDefn oField1("oppervlakte", OFTInteger);
+         OGRFieldDefn oField2("hoofdadresNummeraanduidingRef", OFTString);
+-        OGRFieldDefn oField3("nevenadresNummeraanduidingRef", OFTString);
++        OGRFieldDefn oField3("nevenadresNummeraanduidingRef", OFTStringList);
+         OGRFieldDefn oField4("pandRef", OFTString);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+@@ -527,9 +527,6 @@ void OGRLVBAGLayer::EndElementCbk( const
+         StopDataCollect();
+         if ( !osElementString.empty() )
+         {
+-            const char *pszValue = osElementString.c_str();
+-            const size_t nIdLength = osElementString.size();
+- 
+             int iFieldIndex = poFeatureDefn->GetFieldIndex(pszTag);
+ 
+             if( EQUAL("nummeraanduidingref", pszTag) )
+@@ -546,33 +543,33 @@ void OGRLVBAGLayer::EndElementCbk( const
+                 }
+             }
+ 
+-            if( iFieldIndex > -1 )
++            if( EQUAL("identificatie", pszTag) || STARTS_WITH_CI(pszName, "objecten-ref") )
+             {
+-                const OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn(iFieldIndex);
+-                if( EQUAL("identificatie", pszTag) || STARTS_WITH_CI(pszName, "objecten-ref") )
++                bool bIsIdInvalid = false;
++                if( osElementString.size() == nDefaultIdentifierSize-1 )
+                 {
+-                    bool bIsIdInvalid = false;
+-                    if( nIdLength == nDefaultIdentifierSize-1 )
+-                    {
+-                        osElementString = '0' + osElementString;
+-                    }
+-                    else if( nIdLength > nDefaultIdentifierSize )
+-                    {
+-                        bIsIdInvalid = true;
+-                        m_poFeature->SetFieldNull(iFieldIndex);
+-                        CPLError(CE_Warning, CPLE_AppDefined, 
+-                            "Invalid identificatie : %s, value set to null", pszValue);
+-                    }
+-                    if ( !bIsIdInvalid )
++                    osElementString = '0' + osElementString;
++                }
++                else if( osElementString.size() > nDefaultIdentifierSize )
++                {
++                    bIsIdInvalid = true;
++                    m_poFeature->SetFieldNull(iFieldIndex);
++                    CPLError(CE_Warning, CPLE_AppDefined, 
++                        "Invalid identificatie : %s, value set to null", osElementString.c_str());
++                }
++                if ( !bIsIdInvalid )
++                {
++                    if ( !bLegacyId && !osAttributeString.empty() )
+                     {
+-                        if ( !bLegacyId && !osAttributeString.empty() )
+-                        {
+-                            osElementString = osAttributeString + '.' + osElementString;
+-                        }
+-                        m_poFeature->SetField(iFieldIndex, osElementString.c_str());
++                        osElementString = osAttributeString + '.' + osElementString;
+                     }
+                 }
+-                else if( poFieldDefn->GetType() == OFTStringList )
++            }
++
++            if( iFieldIndex > -1 )
++            {
++                const OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn(iFieldIndex);
++                if( poFieldDefn->GetType() == OFTStringList )
+                 {
+                     if( m_poFeature->IsFieldSetAndNotNull(iFieldIndex) )
+                     {
+@@ -584,18 +581,18 @@ void OGRLVBAGLayer::EndElementCbk( const
+                             papszIter++;
+                         }
+ 
+-                        aoList.AddString(pszValue);
++                        aoList.AddString(osElementString.c_str());
+                         m_poFeature->UnsetField(iFieldIndex);
+                         m_poFeature->SetField(iFieldIndex, aoList.List() );
+                     }
+                     else
+-                        m_poFeature->SetField(iFieldIndex, pszValue);
++                        m_poFeature->SetField(iFieldIndex, osElementString.c_str());
+                 }
+                 else if( poFieldDefn->GetSubType() == OGRFieldSubType::OFSTBoolean )
+                 {
+-                    if( EQUAL("n", pszValue) )
++                    if( EQUAL("n", osElementString.c_str()) )
+                         m_poFeature->SetField(iFieldIndex, 0);
+-                    else if( EQUAL("j", pszValue) )
++                    else if( EQUAL("j", osElementString.c_str()) )
+                         m_poFeature->SetField(iFieldIndex, 1);
+                     else
+                     {
+@@ -604,7 +601,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+                     }
+                 }
+                 else
+-                    m_poFeature->SetField(iFieldIndex, pszValue);
++                    m_poFeature->SetField(iFieldIndex, osElementString.c_str());
+                 
+                 if( bFixInvalidData
+                     && (poFieldDefn->GetType() == OFTDate || poFieldDefn->GetType() == OFTDateTime) )
+@@ -617,7 +614,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+                     {
+                         m_poFeature->SetFieldNull(iFieldIndex);
+                         CPLError(CE_Warning, CPLE_AppDefined, 
+-                            "Invalid date : %s, value set to null", pszValue);
++                            "Invalid date : %s, value set to null", osElementString.c_str());
+                     }
+                 }
+             }
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-OGR-LVBAG-add-Field-verkorteNaam-to-OpenbareRuimte-F.patch gdal-3.2.2+dfsg/debian/patches/0001-OGR-LVBAG-add-Field-verkorteNaam-to-OpenbareRuimte-F.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-OGR-LVBAG-add-Field-verkorteNaam-to-OpenbareRuimte-F.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-OGR-LVBAG-add-Field-verkorteNaam-to-OpenbareRuimte-F.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,20 @@
+Description: OGR LVBAG: add Field verkorteNaam to OpenbareRuimte FT with tests
+Author: Just van den Broecke <just at justobjects.nl>
+Origin: https://github.com/OSGeo/gdal/commit/42f22e353c729899553d57f35535001a5324cb31
+Bug: https://github.com/OSGeo/gdal/issues/4286
+
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -291,10 +291,12 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         OGRFieldDefn oField0("naam", OFTString);
+         OGRFieldDefn oField1("type", OFTString);
+         OGRFieldDefn oField2("woonplaatsRef", OFTString);
++        OGRFieldDefn oField3("verkorteNaam", OFTString);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+         poFeatureDefn->AddFieldDefn(&oField1);
+         poFeatureDefn->AddFieldDefn(&oField2);
++        poFeatureDefn->AddFieldDefn(&oField3);
+ 
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-PandRef-can-contain-multiple-values.patch gdal-3.2.2+dfsg/debian/patches/0001-PandRef-can-contain-multiple-values.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-PandRef-can-contain-multiple-values.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-PandRef-can-contain-multiple-values.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,16 @@
+Description: PandRef can contain multiple values
+Author: Yorick de Wid <yorickdewid at users.noreply.github.com>
+Origin: https://github.com/OSGeo/gdal/commit/fdf3e62f6667f6b0c95cf8cf0972ab3514187f36
+Bug: https://github.com/OSGeo/gdal/issues/3221
+
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -307,7 +307,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         OGRFieldDefn oField1("oppervlakte", OFTInteger);
+         OGRFieldDefn oField2("hoofdadresNummeraanduidingRef", OFTString);
+         OGRFieldDefn oField3("nevenadresNummeraanduidingRef", OFTStringList);
+-        OGRFieldDefn oField4("pandRef", OFTString);
++        OGRFieldDefn oField4("pandRef", OFTStringList);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+         poFeatureDefn->AddFieldDefn(&oField1);
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-Some-datasources-can-have-a-secondary-address.patch gdal-3.2.2+dfsg/debian/patches/0001-Some-datasources-can-have-a-secondary-address.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-Some-datasources-can-have-a-secondary-address.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-Some-datasources-can-have-a-secondary-address.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,165 @@
+Description: Some datasources can have a secondary address
+Author: Yorick de Wid <yorickdewid at users.noreply.github.com>
+Origin: https://github.com/OSGeo/gdal/commit/a3056a4b7957d128044def6be64080d167dd8bcd
+Bug: https://github.com/OSGeo/gdal/issues/3221
+
+--- a/ogr/ogrsf_frmts/lvbag/ogr_lvbag.h
++++ b/ogr/ogrsf_frmts/lvbag/ogr_lvbag.h
+@@ -64,7 +64,6 @@ class OGRLVBAGLayer final: public OGRAbs
+     OGRFeatureDefn     *poFeatureDefn;
+     OGRFeature         *m_poFeature = nullptr;
+     VSILFILE           *fp;
+-    int                 nNextFID;
+     CPLString           osFilename;
+     
+     typedef enum
+@@ -83,11 +82,20 @@ class OGRLVBAGLayer final: public OGRAbs
+     bool                bFixInvalidData;
+     bool                bLegacyId;
+     
++    typedef enum
++    {
++        ADDRESS_PRIMARY,
++        ADDRESS_SECONDARY,
++    } AddressRefState;
++
++    int                 nNextFID;
+     int                 nCurrentDepth;
+     int                 nGeometryElementDepth;
+     int                 nFeatureCollectionDepth;
+     int                 nFeatureElementDepth;
+     int                 nAttributeElementDepth;
++
++    AddressRefState     eAddressRefState;
+     
+     CPLString           osElementString;
+     CPLString           osAttributeString;
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -5,7 +5,7 @@
+  * Author:   Laixer B.V., info at laixer dot com
+  *
+  ******************************************************************************
+- * Copyright (c) 2020, Laixer B.V. <info at laixer dot com>
++ * Copyright (c) 2021, Laixer B.V. <info at laixer dot com>
+  *
+  * Permission is hereby granted, free of charge, to any person obtaining a
+  * copy of this software and associated documentation files (the "Software"),
+@@ -45,7 +45,6 @@ OGRLVBAGLayer::OGRLVBAGLayer( const char
+     OGRAbstractProxiedLayer{ poPoolIn },
+     poFeatureDefn{ new OGRFeatureDefn{} },
+     fp{ nullptr },
+-    nNextFID{ 0 },
+     osFilename{ pszFilename },
+     eFileDescriptorsState{ FD_CLOSED },
+     oParser{ nullptr },
+@@ -53,11 +52,13 @@ OGRLVBAGLayer::OGRLVBAGLayer( const char
+     bHasReadSchema{ false },
+     bFixInvalidData{ CPLFetchBool(papszOpenOptions, "AUTOCORRECT_INVALID_DATA", false) },
+     bLegacyId{ CPLFetchBool(papszOpenOptions, "LEGACY_ID", false) },
++    nNextFID{ 0 },
+     nCurrentDepth{ 0 },
+     nGeometryElementDepth{ 0 },
+     nFeatureCollectionDepth{ 0 },
+     nFeatureElementDepth{ 0 },
+     nAttributeElementDepth{ 0 },
++    eAddressRefState{ AddressRefState::ADDRESS_PRIMARY },
+     bCollectData{ false }
+ {
+     SetDescription(CPLGetBasename(pszFilename));
+@@ -95,6 +96,7 @@ void OGRLVBAGLayer::ResetReading()
+     nFeatureCollectionDepth = 0;
+     nFeatureElementDepth = 0;
+     nAttributeElementDepth = 0;
++    eAddressRefState = AddressRefState::ADDRESS_PRIMARY;
+     bCollectData = false;
+ }
+ 
+@@ -250,9 +252,11 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+     }
+     else if( EQUAL("lig", pszDataset) )
+     {
+-        OGRFieldDefn oField0("nummeraanduidingRef", OFTString);
++        OGRFieldDefn oField0("hoofdadresNummeraanduidingRef", OFTString);
++        OGRFieldDefn oField1("nevenadresNummeraanduidingRef", OFTString);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
++        poFeatureDefn->AddFieldDefn(&oField1);
+ 
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
+@@ -265,9 +269,11 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+     }
+     else if( EQUAL("sta", pszDataset) )
+     {
+-        OGRFieldDefn oField0("nummeraanduidingRef", OFTString);
++        OGRFieldDefn oField0("hoofdadresNummeraanduidingRef", OFTString);
++        OGRFieldDefn oField1("nevenadresNummeraanduidingRef", OFTString);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
++        poFeatureDefn->AddFieldDefn(&oField1);
+ 
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
+@@ -299,13 +305,15 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+     {
+         OGRFieldDefn oField0("gebruiksdoel", OFTStringList);
+         OGRFieldDefn oField1("oppervlakte", OFTInteger);
+-        OGRFieldDefn oField2("nummeraanduidingRef", OFTString);
+-        OGRFieldDefn oField3("pandRef", OFTString);
++        OGRFieldDefn oField2("hoofdadresNummeraanduidingRef", OFTString);
++        OGRFieldDefn oField3("nevenadresNummeraanduidingRef", OFTString);
++        OGRFieldDefn oField4("pandRef", OFTString);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+         poFeatureDefn->AddFieldDefn(&oField1);
+         poFeatureDefn->AddFieldDefn(&oField2);
+         poFeatureDefn->AddFieldDefn(&oField3);
++        poFeatureDefn->AddFieldDefn(&oField4);
+  
+         AddIdentifierFieldDefn();
+         AddDocumentFieldDefn();
+@@ -451,6 +459,12 @@ void OGRLVBAGLayer::StartElementCbk( con
+         }
+     }
+     else if( nFeatureElementDepth > 0 && nAttributeElementDepth > 0 &&
++             nGeometryElementDepth == 0 && EQUAL("objecten:heeftalshoofdadres", pszName) )
++        eAddressRefState = AddressRefState::ADDRESS_PRIMARY;
++    else if( nFeatureElementDepth > 0 && nAttributeElementDepth > 0 &&
++             nGeometryElementDepth == 0 && EQUAL("objecten:heeftalsnevenadres", pszName) )
++        eAddressRefState = AddressRefState::ADDRESS_SECONDARY;
++    else if( nFeatureElementDepth > 0 && nAttributeElementDepth > 0 &&
+              nGeometryElementDepth == 0 )
+         StartDataCollect();
+     else if( nGeometryElementDepth > 0 && STARTS_WITH_CI(pszName, "gml") )
+@@ -513,11 +527,27 @@ void OGRLVBAGLayer::EndElementCbk( const
+         StopDataCollect();
+         if ( !osElementString.empty() )
+         {
+-            const int iFieldIndex = poFeatureDefn->GetFieldIndex(pszTag);
++            const char *pszValue = osElementString.c_str();
++            const size_t nIdLength = osElementString.size();
++ 
++            int iFieldIndex = poFeatureDefn->GetFieldIndex(pszTag);
++
++            if( EQUAL("nummeraanduidingref", pszTag) )
++            {
++                switch (eAddressRefState)
++                {
++                    case AddressRefState::ADDRESS_SECONDARY:
++                        iFieldIndex = poFeatureDefn->GetFieldIndex("nevenadresnummeraanduidingref");
++                        break;
++                    
++                    default:
++                        iFieldIndex = poFeatureDefn->GetFieldIndex("hoofdadresnummeraanduidingref");
++                        break;
++                }
++            }
++
+             if( iFieldIndex > -1 )
+             {
+-                const char *pszValue = osElementString.c_str();
+-                const size_t nIdLength = osElementString.size();
+                 const OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn(iFieldIndex);
+                 if( EQUAL("identificatie", pszTag) || STARTS_WITH_CI(pszName, "objecten-ref") )
+                 {
diff -Nru gdal-3.2.2+dfsg/debian/patches/0001-Update-LVBAG-driver-with-the-new-XSD-schema-3324.patch gdal-3.2.2+dfsg/debian/patches/0001-Update-LVBAG-driver-with-the-new-XSD-schema-3324.patch
--- gdal-3.2.2+dfsg/debian/patches/0001-Update-LVBAG-driver-with-the-new-XSD-schema-3324.patch	1970-01-01 01:00:00.000000000 +0100
+++ gdal-3.2.2+dfsg/debian/patches/0001-Update-LVBAG-driver-with-the-new-XSD-schema-3324.patch	2021-11-23 10:11:54.000000000 +0100
@@ -0,0 +1,256 @@
+Description: Update LVBAG driver with the new XSD schema
+ - Pin the driver to data extracts from XSD version 'v20200601'
+ - Open option default AUTOCORRECT_INVALID_DATA from YES to NO
+ - Add Open option LEGACY_ID. This will force the driver to use the BAG 1.0 identifiers (16 charaster BAG ID's)
+ - Remove fields lvID, namespace, lokaalID, versie from all datasets
+ - Report field oorspronkelijkBouwjaar (built year) as integer
+ - Rename dataset OpenbareRuimte to Openbareruimte
+ - Repair both BAG 1.0 and BAG 2.0 identifiers, if possible
+ - Update test corpus with the new XSD schema's
+ - Update testcases accordingly
+ - Add testcase for the old XSD schema
+ - Update docs
+Author: Yorick de Wid <yorickdewid at users.noreply.github.com>
+Origin: https://github.com/OSGeo/gdal/commit/f00f340b878975f2de097563a99ff37d42dfa434
+Bug: https://github.com/OSGeo/gdal/issues/3217
+
+--- a/ogr/ogrsf_frmts/lvbag/ogr_lvbag.h
++++ b/ogr/ogrsf_frmts/lvbag/ogr_lvbag.h
+@@ -80,7 +80,8 @@ class OGRLVBAGLayer final: public OGRAbs
+     
+     bool                bSchemaOnly;
+     bool                bHasReadSchema;
+-    bool                bFitInvalidData;
++    bool                bFixInvalidData;
++    bool                bLegacyId;
+     
+     int                 nCurrentDepth;
+     int                 nGeometryElementDepth;
+@@ -89,6 +90,7 @@ class OGRLVBAGLayer final: public OGRAbs
+     int                 nAttributeElementDepth;
+     
+     CPLString           osElementString;
++    CPLString           osAttributeString;
+     bool                bCollectData;
+ 
+     char                aBuf[BUFSIZ];
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbagdriver.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbagdriver.cpp
+@@ -57,6 +57,10 @@ static int OGRLVBAGDriverIdentify( GDALO
+     if( strstr(pszPtr, "http://www.kadaster.nl/schemas/standlevering-generiek/1.0") == nullptr )
+         return FALSE;
+ 
++    // Pin the driver to XSD version 'v20200601'
++    if( strstr(pszPtr, "http://www.kadaster.nl/schemas/lvbag/extract-deelbestand-lvc/v20200601") == nullptr )
++        return FALSE;
++
+     return TRUE;
+ }
+ 
+@@ -138,7 +142,8 @@ void RegisterOGRLVBAG()
+ 
+     poDriver->SetMetadataItem( GDAL_DMD_OPENOPTIONLIST,
+ "<OpenOptionList>"
+-"  <Option name='AUTOCORRECT_INVALID_DATA' type='boolean' description='whether driver should try to fix invalid data' default='YES'/>"
++"  <Option name='AUTOCORRECT_INVALID_DATA' type='boolean' description='whether driver should try to fix invalid data' default='NO'/>"
++"  <Option name='LEGACY_ID' type='boolean' description='whether driver should use the BAG 1.0 identifiers' default='NO'/>"
+ "</OpenOptionList>" );
+ 
+     poDriver->pfnOpen = OGRLVBAGDriverOpen;
+--- a/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
++++ b/ogr/ogrsf_frmts/lvbag/ogrlvbaglayer.cpp
+@@ -32,8 +32,7 @@
+ #include "ogr_p.h"
+ 
+ constexpr const char *pszSpecificationUrn = "urn:ogc:def:crs:EPSG::28992";
+-constexpr const size_t nDefaultLokaalIDSize = 16;
+-constexpr const size_t nWplLokaalIDSize = 4;
++constexpr const size_t nDefaultIdentifierSize = 16;
+ 
+ /************************************************************************/
+ /*                           OGRLVBAGLayer()                            */
+@@ -52,7 +51,8 @@ OGRLVBAGLayer::OGRLVBAGLayer( const char
+     oParser{ nullptr },
+     bSchemaOnly{ false },
+     bHasReadSchema{ false },
+-    bFitInvalidData{ CPLFetchBool(papszOpenOptions, "AUTOCORRECT_INVALID_DATA", true) },
++    bFixInvalidData{ CPLFetchBool(papszOpenOptions, "AUTOCORRECT_INVALID_DATA", false) },
++    bLegacyId{ CPLFetchBool(papszOpenOptions, "LEGACY_ID", false) },
+     nCurrentDepth{ 0 },
+     nGeometryElementDepth{ 0 },
+     nFeatureCollectionDepth{ 0 },
+@@ -152,15 +152,9 @@ void OGRLVBAGLayer::AddSpatialRef( OGRwk
+ 
+ void OGRLVBAGLayer::AddIdentifierFieldDefn()
+ {
+-    OGRFieldDefn oField0("lvID", OFTString);
+-    OGRFieldDefn oField1("namespace", OFTString);
+-    OGRFieldDefn oField2("lokaalID", OFTString);
+-    OGRFieldDefn oField3("versie", OFTString);
++    OGRFieldDefn oField0("identificatie", OFTString);
+ 
+     poFeatureDefn->AddFieldDefn(&oField0);
+-    poFeatureDefn->AddFieldDefn(&oField1);
+-    poFeatureDefn->AddFieldDefn(&oField2);
+-    poFeatureDefn->AddFieldDefn(&oField3);
+ }
+ 
+ /************************************************************************/
+@@ -218,7 +212,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+ {
+     if( EQUAL("pnd", pszDataset) )
+     {
+-        OGRFieldDefn oField0("oorspronkelijkBouwjaar", OFTDate);
++        OGRFieldDefn oField0("oorspronkelijkBouwjaar", OFTInteger);
+ 
+         poFeatureDefn->AddFieldDefn(&oField0);
+         
+@@ -298,7 +292,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+         AddDocumentFieldDefn();
+         AddOccurrenceFieldDefn();
+ 
+-        poFeatureDefn->SetName("OpenbareRuimte");
++        poFeatureDefn->SetName("Openbareruimte");
+         SetDescription(poFeatureDefn->GetName());
+     }
+     else if( EQUAL("vbo", pszDataset) )
+@@ -349,6 +343,7 @@ void OGRLVBAGLayer::CreateFeatureDefn( c
+ void OGRLVBAGLayer::StartDataCollect()
+ {
+     osElementString.Clear();
++    osAttributeString.Clear();
+     bCollectData = true;
+ }
+ 
+@@ -360,6 +355,7 @@ void OGRLVBAGLayer::StopDataCollect()
+ {
+     bCollectData = false;
+     osElementString.Trim();
++    osAttributeString.Trim();
+ }
+ 
+ /************************************************************************/
+@@ -439,15 +435,17 @@ void OGRLVBAGLayer::StartElementCbk( con
+         nGeometryElementDepth == 0 && STARTS_WITH_CI(pszName, "objecten") )
+         nAttributeElementDepth = nCurrentDepth;
+     else if( nFeatureElementDepth > 0 && nAttributeElementDepth > 0 &&
+-             nGeometryElementDepth == 0 && STARTS_WITH_CI(pszName, "objecten-ref")  )
++             nGeometryElementDepth == 0 &&
++             ( EQUAL("objecten:identificatie", pszName) || STARTS_WITH_CI(pszName, "objecten-ref") ) )
+     {
++        StartDataCollect();
+         const char** papszIter = ppszAttr;
+         while( papszIter && *papszIter != nullptr )
+         {
+-            if( EQUAL("xlink:href", papszIter[0]) )
++            if( EQUAL("domein", papszIter[0]) )
+             {
+-                osElementString = papszIter[1];
+-                osElementString.toupper();
++                osAttributeString = papszIter[1];
++                break;
+             }
+             papszIter += 2;
+         }
+@@ -521,19 +519,27 @@ void OGRLVBAGLayer::EndElementCbk( const
+                 const char *pszValue = osElementString.c_str();
+                 const size_t nIdLength = osElementString.size();
+                 const OGRFieldDefn *poFieldDefn = poFeatureDefn->GetFieldDefn(iFieldIndex);
+-                if( EQUAL("lokaalid", pszTag)
+-                    && nIdLength != nDefaultLokaalIDSize && nIdLength != nWplLokaalIDSize )
++                if( EQUAL("identificatie", pszTag) || STARTS_WITH_CI(pszName, "objecten-ref") )
+                 {
+-                    if( nIdLength == nDefaultLokaalIDSize-1 )
++                    bool bIsIdInvalid = false;
++                    if( nIdLength == nDefaultIdentifierSize-1 )
+                     {
+                         osElementString = '0' + osElementString;
+-                        m_poFeature->SetField(iFieldIndex, osElementString.c_str());
+                     }
+-                    else
++                    else if( nIdLength > nDefaultIdentifierSize )
+                     {
++                        bIsIdInvalid = true;
+                         m_poFeature->SetFieldNull(iFieldIndex);
+                         CPLError(CE_Warning, CPLE_AppDefined, 
+-                            "Invalid LokaalID : %s, value set to null", pszValue);
++                            "Invalid identificatie : %s, value set to null", pszValue);
++                    }
++                    if ( !bIsIdInvalid )
++                    {
++                        if ( !bLegacyId && !osAttributeString.empty() )
++                        {
++                            osElementString = osAttributeString + '.' + osElementString;
++                        }
++                        m_poFeature->SetField(iFieldIndex, osElementString.c_str());
+                     }
+                 }
+                 else if( poFieldDefn->GetSubType() == OGRFieldSubType::OFSTBoolean )
+@@ -548,16 +554,10 @@ void OGRLVBAGLayer::EndElementCbk( const
+                         XML_StopParser(oParser.get(), XML_FALSE);
+                     }
+                 }
+-                else if( poFieldDefn->GetType() == OFTDate && osElementString.length() == 4 )
+-                {
+-                    CPLString oFullDate{ pszValue };
+-                    oFullDate += "-01-01";
+-                    m_poFeature->SetField(iFieldIndex, oFullDate.c_str());
+-                }
+                 else
+                     m_poFeature->SetField(iFieldIndex, pszValue);
+                 
+-                if( bFitInvalidData
++                if( bFixInvalidData
+                     && (poFieldDefn->GetType() == OFTDate || poFieldDefn->GetType() == OFTDateTime) )
+                 {
+                     int nYear;
+@@ -599,7 +599,7 @@ void OGRLVBAGLayer::EndElementCbk( const
+ // GEOS >= 3.8.0 for MakeValid.
+ #ifdef HAVE_GEOS
+ #if GEOS_VERSION_MAJOR > 3 || (GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 8)
+-                if( !poGeom->IsValid() && bFitInvalidData )
++                if( !poGeom->IsValid() && bFixInvalidData )
+                 {
+                     std::unique_ptr<OGRGeometry> poSubGeom = std::unique_ptr<OGRGeometry>{
+                         poGeom->MakeValid() };
+@@ -668,25 +668,12 @@ void OGRLVBAGLayer::EndElementCbk( const
+         }
+ 
+         osElementString.Clear();
++        osAttributeString.Clear();
+         nGeometryElementDepth = 0;
+     }
+     else if( nFeatureElementDepth == nCurrentDepth )
+     {
+         nFeatureElementDepth = 0;
+-
+-        const int iFieldIndexNamespace = poFeatureDefn->GetFieldIndex("namespace");
+-        const int iFieldIndexLocalId = poFeatureDefn->GetFieldIndex("lokaalID");
+-
+-        CPLAssert(m_poFeature->GetFieldAsString(iFieldIndexNamespace));
+-        CPLAssert(m_poFeature->GetFieldAsString(iFieldIndexLocalId));
+-
+-        CPLString oLvId;
+-        oLvId += m_poFeature->GetFieldAsString(iFieldIndexNamespace);
+-        oLvId += ".";
+-        oLvId += m_poFeature->GetFieldAsString(iFieldIndexLocalId);
+-
+-        m_poFeature->SetField(poFeatureDefn->GetFieldIndex("lvID"), oLvId.toupper().c_str());
+-
+         XML_StopParser(oParser.get(), XML_TRUE);
+     }
+     else if( nFeatureCollectionDepth == nCurrentDepth )
+@@ -843,8 +830,11 @@ OGRFeature* OGRLVBAGLayer::GetNextRawFea
+     if (nNextFID == 0)
+         ConfigureParser();
+ 
+-    delete m_poFeature;
+-    m_poFeature = nullptr;
++    if ( m_poFeature )
++    {
++        delete m_poFeature;
++        m_poFeature = nullptr;
++    }
+ 
+     ParseDocument();
+     OGRFeature* poFeatureRet = m_poFeature;
diff -Nru gdal-3.2.2+dfsg/debian/patches/series gdal-3.2.2+dfsg/debian/patches/series
--- gdal-3.2.2+dfsg/debian/patches/series	2021-06-21 21:05:55.000000000 +0200
+++ gdal-3.2.2+dfsg/debian/patches/series	2021-11-23 10:11:54.000000000 +0100
@@ -7,3 +7,13 @@
 java.opt
 perl-vendor
 perl-doxyfile
+0001-Update-LVBAG-driver-with-the-new-XSD-schema-3324.patch
+0001-Allow-for-multiple-gebruiksdoelen.patch
+0001-Some-datasources-can-have-a-secondary-address.patch
+0001-NevenAdres-should-be-a-stringList.patch
+0001-PandRef-can-contain-multiple-values.patch
+0001-Add-a-cppcheck_2004-CI-target-and-fix-related-issues.patch
+0001-Addresses-minor-issues-in-the-LVBAG-driver-3531-Fixe.patch
+0001-LVBAG-Convert-MultiPolygon-to-Polygon-3599-fixes-358.patch
+0001-LVBAG-Driver-add-field-definition-for-gerelateerdewo.patch
+0001-OGR-LVBAG-add-Field-verkorteNaam-to-OpenbareRuimte-F.patch


More information about the Pkg-grass-devel mailing list