[gdal-dev] Patch for s57reader.cpp

2012-11-30 Thread mrxonx
A small patch (that prevents a crash on certain datasets). Your line
numbers will certainly be different, but it should work.


--- s57reader.cpp   
+++ s57reader.cpp   
@@ -2313,7 +2313,7 @@
 /*  */
 /*  Add the end node.   */
 /*  */
-if( poVRPT-GetRepeatCount()  1 )
+if( (poVRPT != NULL)  poVRPT-GetRepeatCount()  1 )
 {
 int nVC_RCID = ParseName( poVRPT, 1 );
 double dfX, dfY;


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Patch for s57reader.cpp

2012-11-30 Thread Frank Warmerdam
Mr. Xonx,

I have made related changes in trunk:

  http://trac.osgeo.org/gdal/changeset/25269

Best regards,
Frank


On Fri, Nov 30, 2012 at 8:40 AM, mrx...@hotmail.com wrote:

 A small patch (that prevents a crash on certain datasets). Your line
 numbers will certainly be different, but it should work.


 --- s57reader.cpp
 +++ s57reader.cpp
 @@ -2313,7 +2313,7 @@
  /*  */
  /*  Add the end node.   */
  /*  */
 -if( poVRPT-GetRepeatCount()  1 )
 +if( (poVRPT != NULL)  poVRPT-GetRepeatCount()  1 )
  {
  int nVC_RCID = ParseName( poVRPT, 1 );
  double dfX, dfY;


 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev




-- 
---+--
I set the clouds in motion - turn up   | Frank Warmerdam,
warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush| Geospatial Software Developer
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Patch for s57reader.cpp

2012-11-30 Thread mrxonx
Thanks!  Looks like I missed the other 2 locations.

Frank Warmerdam wrote:
 Mr. Xonx, 

 I have made related changes in trunk:

   http://trac.osgeo.org/gdal/changeset/25269

 Best regards,
 Frank

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Patch for s57reader.cpp

2011-12-13 Thread mrxonx
Looks like the patch has been applied - thanks!

Test chart is found in current UKHO data set, chart GB327200 (St. Helena).
It's not a free data set, so I can't attach a copy, but UKHO should be
willing to provide one free of charge, if requested, for test purposes.

M S wrote:

  Date: Fri, 4 Nov 2011 16:54:09 -0200
  Subject: Re: [gdal-dev] Patch for s57reader.cpp
  From: etourigny@gmail.com
  To: mrx...@hotmail.com
  CC: gdal-dev@lists.osgeo.org
 
  Dear Mike,
 
  Please add this to a relevant ticket, or create one and add it there.
 
  http://trac.osgeo.org/gdal/report
 
  thanks, Etienne
 
  On Fri, Nov 4, 2011 at 4:27 PM, mrx...@hotmail.com wrote:
   Dear all,
  
   Included is a patch for s57reader.cpp that properly applies
 updates for
   certain types of charts.
  
   The essence of this patch is that SG2D field may not be present in
   original record, and must be added if update is trying to insert SG2D
   fields.
  
   The patch was made against our modified version of OGR, so line
 numbers
   likely do not match and certain function signatures may need to be
   updated. If you'd like to apply it - make sure it goes in the
   S57Reader::ApplyRecordUpdate.
  
   Best,
   --
   Mike
  
  
  
   Index: s57reader.cpp
   ===
   --- s57reader.cpp   (revision )
   +++ s57reader.cpp   (working copy)
   @@ -2635,16 +2635,30 @@
   /* If we don't have SG2D, check for SG3D */
   if( poDstSG2D == NULL )
   {
   -poSrcSG2D = poUpdate-FindField(SG3D);
   poDstSG2D = poTarget-FindField(SG3D);
   +if (poDstSG2D != NULL) {
   +   poSrcSG2D = poUpdate-FindField(SG3D);
   +}
   }
  
   -if( (poSrcSG2D == NULL  nCCUI != 2) || poDstSG2D == NULL )
   +if( (poSrcSG2D == NULL  nCCUI != 2) || (poDstSG2D ==
 NULL  nCCUI != 1) )
   {
   CPLAssert( FALSE );
   return FALSE;
   }
  
   +if (poDstSG2D == NULL) {
   +
  poTarget-AddField(poTarget-GetModule()-FindFieldDefn(SG2D));
   +  poDstSG2D = poTarget-FindField(SG2D);
   +  if (poDstSG2D == NULL) {
   +CPLAssert( FALSE );
   +return FALSE;
   +  }
   +
   +  // Delete null default data that was created
   +  poTarget-SetFieldRaw( poDstSG2D, 0, NULL, 0 );
   +}
   +
   nCoordSize = poDstSG2D-GetFieldDefn()-GetFixedWidth();
  
   if( nCCUI == 1 ) /* INSERT */
  
   ___
   gdal-dev mailing list
   gdal-dev@lists.osgeo.org
   http://lists.osgeo.org/mailman/listinfo/gdal-dev
  
 

 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Patch for s57reader.cpp

2011-11-04 Thread Etienne Tourigny
Dear  Mike,

Please add this to a relevant ticket, or create one and add it there.

http://trac.osgeo.org/gdal/report

thanks, Etienne

On Fri, Nov 4, 2011 at 4:27 PM,  mrx...@hotmail.com wrote:
 Dear all,

 Included is a patch for s57reader.cpp that properly applies updates for
 certain types of charts.

 The essence of this patch is that SG2D field may not be present in
 original record, and must be added if update is trying to insert SG2D
 fields.

 The patch was made against our modified version of OGR, so line numbers
 likely do not match and certain function signatures may need to be
 updated. If you'd like to apply it - make sure it goes in the
 S57Reader::ApplyRecordUpdate.

 Best,
 --
 Mike



 Index: s57reader.cpp
 ===
 --- s57reader.cpp       (revision )
 +++ s57reader.cpp       (working copy)
 @@ -2635,16 +2635,30 @@
         /* If we don't have SG2D, check for SG3D */
         if( poDstSG2D == NULL )
         {
 -            poSrcSG2D = poUpdate-FindField(SG3D);
             poDstSG2D = poTarget-FindField(SG3D);
 +            if (poDstSG2D != NULL) {
 +               poSrcSG2D = poUpdate-FindField(SG3D);
 +            }
         }

 -        if( (poSrcSG2D == NULL  nCCUI != 2) || poDstSG2D == NULL )
 +        if( (poSrcSG2D == NULL  nCCUI != 2) || (poDstSG2D == NULL  nCCUI 
 != 1) )
         {
             CPLAssert( FALSE );
             return FALSE;
         }

 +        if (poDstSG2D == NULL) {
 +          poTarget-AddField(poTarget-GetModule()-FindFieldDefn(SG2D));
 +          poDstSG2D = poTarget-FindField(SG2D);
 +          if (poDstSG2D == NULL) {
 +            CPLAssert( FALSE );
 +            return FALSE;
 +          }
 +
 +          // Delete null default data that was created
 +          poTarget-SetFieldRaw( poDstSG2D, 0, NULL, 0 );
 +        }
 +
         nCoordSize = poDstSG2D-GetFieldDefn()-GetFixedWidth();

         if( nCCUI == 1 ) /* INSERT */

 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


RE: [gdal-dev] Patch for s57reader.cpp

2011-11-04 Thread M S
Unfortunately, I really don't have the time.

I am glad to provide the fix, but whether you choose to apply it or keep a 
broken implementation is up to you. 

 Date: Fri, 4 Nov 2011 16:54:09 -0200
 Subject: Re: [gdal-dev] Patch for s57reader.cpp
 From: etourigny@gmail.com
 To: mrx...@hotmail.com
 CC: gdal-dev@lists.osgeo.org
 
 Dear  Mike,
 
 Please add this to a relevant ticket, or create one and add it there.
 
 http://trac.osgeo.org/gdal/report
 
 thanks, Etienne
 
 On Fri, Nov 4, 2011 at 4:27 PM,  mrx...@hotmail.com wrote:
  Dear all,
 
  Included is a patch for s57reader.cpp that properly applies updates for
  certain types of charts.
 
  The essence of this patch is that SG2D field may not be present in
  original record, and must be added if update is trying to insert SG2D
  fields.
 
  The patch was made against our modified version of OGR, so line numbers
  likely do not match and certain function signatures may need to be
  updated. If you'd like to apply it - make sure it goes in the
  S57Reader::ApplyRecordUpdate.
 
  Best,
  --
  Mike
 
 
 
  Index: s57reader.cpp
  ===
  --- s57reader.cpp   (revision )
  +++ s57reader.cpp   (working copy)
  @@ -2635,16 +2635,30 @@
  /* If we don't have SG2D, check for SG3D */
  if( poDstSG2D == NULL )
  {
  -poSrcSG2D = poUpdate-FindField(SG3D);
  poDstSG2D = poTarget-FindField(SG3D);
  +if (poDstSG2D != NULL) {
  +   poSrcSG2D = poUpdate-FindField(SG3D);
  +}
  }
 
  -if( (poSrcSG2D == NULL  nCCUI != 2) || poDstSG2D == NULL )
  +if( (poSrcSG2D == NULL  nCCUI != 2) || (poDstSG2D == NULL  
  nCCUI != 1) )
  {
  CPLAssert( FALSE );
  return FALSE;
  }
 
  +if (poDstSG2D == NULL) {
  +  poTarget-AddField(poTarget-GetModule()-FindFieldDefn(SG2D));
  +  poDstSG2D = poTarget-FindField(SG2D);
  +  if (poDstSG2D == NULL) {
  +CPLAssert( FALSE );
  +return FALSE;
  +  }
  +
  +  // Delete null default data that was created
  +  poTarget-SetFieldRaw( poDstSG2D, 0, NULL, 0 );
  +}
  +
  nCoordSize = poDstSG2D-GetFieldDefn()-GetFixedWidth();
 
  if( nCCUI == 1 ) /* INSERT */
 
  ___
  gdal-dev mailing list
  gdal-dev@lists.osgeo.org
  http://lists.osgeo.org/mailman/listinfo/gdal-dev
 
  ___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev