[gdal-dev] (1) NITF imagery in polar regions; (2) Memory question

Frank Warmerdam warmerdam at pobox.com
Tue Apr 7 12:29:56 EDT 2009


Karney, Charles wrote:
> (1) The documentation for NITF data says that it typically uses a polar
> projection north of 80N where
> 
>     x = (90-lat) * sin(lon)
>     y = (90-lat) * -cos(lon)
> 
> (not sure I have the phase of lon right...).  I have an ONC image
> 00028053.on9 where the projection is in this form (lat = 80N is
> circular).
> 
> However GDAL thinks there's merely an affine transformation between
> image space and geographic coordinates.  So when I warp the image to
> WGS84 geographic coordinates, lat = 80N is still curved.
> 
> Is this a problem with the meta data in my file?  Or is GDAL mishandling
> these images at high latitudes.
> 
> (I can provide the image file, if necessary.)

Charles,

I would encourage you to file a ticket on this, with a pointer to the
data.

> (2) I'm having a problem figuring out from the documentation what the
> precise rules are on allocating and freeing memory.  In some cases, it's
> spelled out.  In others, I'm left to guess.  For example, after
> 
>   GDALWarpOptions *warpopt = NULL;
>   warpopt = GDALCreateWarpOptions();
>   warpopt->panSrcBands = (int *) CPLMalloc(sizeof(int) * totchan);
> 
> how does the memory allocated by CPLMalloc get freed.  When I do
> 
>   GDALDestroyWarpOptions( warpopt );
> 
> or do I have to free it explicitly?

In this particular case GDALDestroyWarpOptions() frees the memory.
The rules are quite vague with regard to the warp options structure.
In fact the whole warp api does not meet what I consider to be
an adequate ease of use.  This is one of the reasons I have hesitated
to "swig wrap it" as it stands.

More generally in the C++ API I try to make it clear in the docs
for particular functions.  In some cases fetching functions
include Ref in the name, indicating that the method is returning
a reference to an internal copy (like GetProjectionRef()).  Generally
speaking methods do no assume ownership of arguments passed in
unless explicitly stated.

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



More information about the gdal-dev mailing list