Ticket #4332: s57applyrecordupdate.patch

File s57applyrecordupdate.patch, 1.2 KB (added by rouault, 5 years ago)
  • s57reader.cpp

     
    26352635        /* If we don't have SG2D, check for SG3D */
    26362636        if( poDstSG2D == NULL )
    26372637        {
    2638             poSrcSG2D = poUpdate->FindField("SG3D");
    26392638            poDstSG2D = poTarget->FindField("SG3D");
     2639            if (poDstSG2D != NULL) {
     2640               poSrcSG2D = poUpdate->FindField("SG3D");
     2641            }
    26402642        }
    26412643
    2642         if( (poSrcSG2D == NULL && nCCUI != 2) || poDstSG2D == NULL )
     2644        if( (poSrcSG2D == NULL && nCCUI != 2) || (poDstSG2D == NULL && nCCUI != 1) )
    26432645        {
    26442646            CPLAssert( FALSE );
    26452647            return FALSE;
    26462648        }
    26472649
     2650        if (poDstSG2D == NULL) {
     2651          poTarget->AddField(poTarget->GetModule()->FindFieldDefn("SG2D"));
     2652          poDstSG2D = poTarget->FindField("SG2D");
     2653          if (poDstSG2D == NULL) {
     2654            CPLAssert( FALSE );
     2655            return FALSE;
     2656          }
     2657
     2658          // Delete null default data that was created
     2659          poTarget->SetFieldRaw( poDstSG2D, 0, NULL, 0 );
     2660        }
     2661
    26482662        nCoordSize = poDstSG2D->GetFieldDefn()->GetFixedWidth();
    26492663
    26502664        if( nCCUI == 1 ) /* INSERT */