[gdal-dev] GDAL contouring problem

Even Rouault even.rouault at mines-paris.org
Fri Dec 3 15:03:46 EST 2010


FYI, I've commited a fix in GDAL trunk so that 0 as a floating point value can 
be used as a valid value for -fl

Le mercredi 01 décembre 2010 05:44:09, Ole Nielsen a écrit :
> Thanks for explaining the reason why the numeric value of 0.00 doesn't work
> as a fixed level in gdal_contour while the value of 0 does. I understand
> now the reason for this.
> However I would have thought one could replace the test for 'zeroness' in
> (atof(argv[i+1]) != 0 || EQUAL(argv[i+1], "0"))
> with a test for whether argv]i+1] is not empty and can be converted to a
> numeric value. This would be a duck-typing approach and more robust in my
> humble opinion.
> 
> Best regards
> Ole Nielsen
> 
> 
> -----Original Message-----
> From: gdal-dev-bounces at lists.osgeo.org
> [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of
> gdal-dev-request at lists.osgeo.org Sent: Monday, 29 November 2010 8:41 PM
> To: gdal-dev at lists.osgeo.org
> Subject: gdal-dev Digest, Vol 78, Issue 64
> 
> Send gdal-dev mailing list submissions to
>         gdal-dev at lists.osgeo.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.osgeo.org/mailman/listinfo/gdal-dev
> or, via email, send a message with subject or body 'help' to
>         gdal-dev-request at lists.osgeo.org
> 
> You can reach the person managing the list at
>         gdal-dev-owner at lists.osgeo.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of gdal-dev digest..."
> 
> 
> Today's Topics:
> 
>    1. Re: GDAL contouring problem (Frank Warmerdam)
>    2. Re: GDAL contouring problem (Francis Markham)
>    3. Re: Delete a sqlite database (Ludovic Granjon)
>    4. Re: Error building GDAL with GEOS on Solaris (Namrata)
>    5. Making non-rectangular image edges transparent
>       (Just van den Broecke)
>    6. geotiff conflict (Julien Malik)
>    7. Re: RFC 31 - OGR 64bit Support (David Burken)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Sun, 28 Nov 2010 23:24:56 -0500
> From: Frank Warmerdam <warmerdam at pobox.com>
> Subject: Re: [gdal-dev] GDAL contouring problem
> To: Ole Nielsen <ole.nielsen at aifdr.org>
> Cc: "gdal-dev at lists.osgeo.org" <gdal-dev at lists.osgeo.org>,
>         "adelebear at me.com" <adelebear at me.com>
> Message-ID: <4CF32B18.2030208 at pobox.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Ole Nielsen wrote:
> > I am posting this again without test files attached due the 50K size
> > limit. Anyone who wants to see them, please contact me directly.
> > 
> > 
> > 
> > --
> > 
> > We have observed interesting anomaly with gdal_contour when one of the
> > fixed levels is zero.
> > 
> > If the zero contour is expressed as 0.0 (or indeed 0.0000) gdal_contour
> > replies with the standard Usage message (see below). If the zero contour
> > is expressed as the integer 0 (or 0.00000001) it works and produces the
> > expected contours.
> 
> Ole,
> 
> The gdal_contour program has some rather hokey heuristics to try and
> recognise the end of the list of contour levels.  The code looks like:
> 
>          else if( EQUAL(argv[i],"-fl") && i < argc-1 )
>          {
>              while( i < argc-1
>                     && nFixedLevelCount
>                               <
> (int)(sizeof(adfFixedLevels)/sizeof(double)) && (atof(argv[i+1]) != 0 ||
> EQUAL(argv[i+1],"0")) && !EQUAL(argv[i+1], "-3d"))
>                  adfFixedLevels[nFixedLevelCount++] = atof(argv[++i]);
>          }
> 
> So basically, it assumes everything is a "level" until something that
> has a numeric value of 0 is encounter that isn't the specific string
> "0".  So your analysis of the problem is essentially correct, but it is
> more or less intentional as we try to support a list of levels with no
> explicit "end of list" marker in the arguments to the command.
> 
> Best regards,
> --
> ---------------------------------------+-----------------------------------
> --- I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com light and sound - activate the windows |
> http://pobox.com/~warmerdam and watch the world go round - Rush    |
> Geospatial Programmer for Rent
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Mon, 29 Nov 2010 16:48:56 +1100
> From: Francis Markham <fmarkham at gmail.com>
> Subject: Re: [gdal-dev] GDAL contouring problem
> To: Frank Warmerdam <warmerdam at pobox.com>
> Cc: "gdal-dev at lists.osgeo.org" <gdal-dev at lists.osgeo.org>,      Ole Nielsen
>         <ole.nielsen at aifdr.org>, "adelebear at me.com" <adelebear at me.com>
> Message-ID:
>         <AANLkTi=xCXQx=Nx1hbnjqMb6WVr3VfL6AoQPQHeKx1nQ at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> Is there any reason not to include a heuristic that uses strtod() or
> similar to test for the zeroness of the last argument?
> 
> -Francis Markham
> 
> On 29 November 2010 15:24, Frank Warmerdam <warmerdam at pobox.com> wrote:
> > Ole Nielsen wrote:
> >> I am posting this again without test files attached due the 50K size
> >> limit. Anyone who wants to see them, please contact me directly.
> >> 
> >> 
> >> --
> >> 
> >> We have observed interesting anomaly with gdal_contour when one of the
> >> fixed levels is zero.
> >> 
> >> If the zero contour is expressed as 0.0 (or indeed 0.0000) gdal_contour
> >> replies with the standard Usage message (see below). If the zero contour
> >> is expressed as the integer 0 (or 0.00000001) it works and produces the
> >> expected contours.
> > 
> > Ole,
> > 
> > The gdal_contour program has some rather hokey heuristics to try and
> > recognise the end of the list of contour levels. ?The code looks like:
> > 
> > ? ? ? ?else if( EQUAL(argv[i],"-fl") && i < argc-1 )
> > ? ? ? ?{
> > ? ? ? ? ? ?while( i < argc-1
> > ? ? ? ? ? ? ? ? ? && nFixedLevelCount
> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? <
> > (int)(sizeof(adfFixedLevels)/sizeof(double)) ? ? ? ? ? ? ? ? ? &&
> > (atof(argv[i+1]) != 0 || EQUAL(argv[i+1],"0")) ? ? ? ? ? ? ? ? ? &&
> > !EQUAL(argv[i+1], "-3d"))
> > ? ? ? ? ? ? ? ?adfFixedLevels[nFixedLevelCount++] = atof(argv[++i]);
> > ? ? ? ?}
> > 
> > So basically, it assumes everything is a "level" until something that
> > has a numeric value of 0 is encounter that isn't the specific string
> > "0". ?So your analysis of the problem is essentially correct, but it is
> > more or less intentional as we try to support a list of levels with no
> > explicit "end of list" marker in the arguments to the command.
> > 
> > Best regards,
> > --
> > ---------------------------------------+---------------------------------
> > ----- I set the clouds in motion - turn up ? | Frank Warmerdam,
> > warmerdam at pobox.com
> > light and sound - activate the windows | http://pobox.com/~warmerdam
> > and watch the world go round - Rush ? ?| Geospatial Programmer for Rent
> > 
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-dev at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list