<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>Unfortunately, I really don't have the time.<br><br>I am glad to provide the fix, but whether you choose to apply it or keep a broken implementation is up to you. <br><br>> Date: Fri, 4 Nov 2011 16:54:09 -0200<br>> Subject: Re: [gdal-dev] Patch for s57reader.cpp<br>> From: etourigny.dev@gmail.com<br>> To: mrxonx@hotmail.com<br>> CC: gdal-dev@lists.osgeo.org<br>> <br>> Dear Mike,<br>> <br>> Please add this to a relevant ticket, or create one and add it there.<br>> <br>> http://trac.osgeo.org/gdal/report<br>> <br>> thanks, Etienne<br>> <br>> On Fri, Nov 4, 2011 at 4:27 PM, <mrxonx@hotmail.com> wrote:<br>> > Dear all,<br>> ><br>> > Included is a patch for s57reader.cpp that properly applies updates for<br>> > certain types of charts.<br>> ><br>> > The essence of this patch is that SG2D field may not be present in<br>> > original record, and must be added if update is trying to insert SG2D<br>> > fields.<br>> ><br>> > The patch was made against our modified version of OGR, so line numbers<br>> > likely do not match and certain function signatures may need to be<br>> > updated. If you'd like to apply it - make sure it goes in the<br>> > S57Reader::ApplyRecordUpdate.<br>> ><br>> > Best,<br>> > --<br>> > Mike<br>> ><br>> ><br>> ><br>> > Index: s57reader.cpp<br>> > ===================================================================<br>> > --- s57reader.cpp       (revision 0000)<br>> > +++ s57reader.cpp       (working copy)<br>> > @@ -2635,16 +2635,30 @@<br>> >         /* If we don't have SG2D, check for SG3D */<br>> >         if( poDstSG2D == NULL )<br>> >         {<br>> > -            poSrcSG2D = poUpdate->FindField("SG3D");<br>> >             poDstSG2D = poTarget->FindField("SG3D");<br>> > +            if (poDstSG2D != NULL) {<br>> > +               poSrcSG2D = poUpdate->FindField("SG3D");<br>> > +            }<br>> >         }<br>> ><br>> > -        if( (poSrcSG2D == NULL && nCCUI != 2) || poDstSG2D == NULL )<br>> > +        if( (poSrcSG2D == NULL && nCCUI != 2) || (poDstSG2D == NULL && nCCUI != 1) )<br>> >         {<br>> >             CPLAssert( FALSE );<br>> >             return FALSE;<br>> >         }<br>> ><br>> > +        if (poDstSG2D == NULL) {<br>> > +          poTarget->AddField(poTarget->GetModule()->FindFieldDefn("SG2D"));<br>> > +          poDstSG2D = poTarget->FindField("SG2D");<br>> > +          if (poDstSG2D == NULL) {<br>> > +            CPLAssert( FALSE );<br>> > +            return FALSE;<br>> > +          }<br>> > +<br>> > +          // Delete null default data that was created<br>> > +          poTarget->SetFieldRaw( poDstSG2D, 0, NULL, 0 );<br>> > +        }<br>> > +<br>> >         nCoordSize = poDstSG2D->GetFieldDefn()->GetFixedWidth();<br>> ><br>> >         if( nCCUI == 1 ) /* INSERT */<br>> ><br>> > _______________________________________________<br>> > gdal-dev mailing list<br>> > gdal-dev@lists.osgeo.org<br>> > http://lists.osgeo.org/mailman/listinfo/gdal-dev<br>> ><br>                                            </div></body>
</html>