[Gdal-dev] pct2rgb.py

Frank Warmerdam warmerdam at pobox.com
Thu Oct 14 14:21:42 EDT 2004


Curt, WE7U wrote:
> OGR questions:  Since OGR is part of GDAL, this list ok for these
> questions too?

Curt,

OGR questions are also welcome here.  Someday I may need to split things
up into a few lists, but for now I think traffic is still managable.

> Code snippet.  Using the C API:
> 
> 
>   if (transformH == NULL) fprintf(stderr,"T2=0\n");
> 
>   // Loop through all of the features in the layer.
>   //
>   while ( (featureH = OGR_L_GetNextFeature( layerH )) != NULL) {
>     OGRGeometryH geometryH;
>     int num = 0;
> 
>   // Just before this we lose the handle to our transform
>   if (transformH == NULL) fprintf(stderr,"T3=0\n");
> 
> Results:
> T3=0
> 
> 
> By this point in the code I've already got a transform and a reverse
> transform computed and ready for use.
> 
> 1) Why does OGR_L_GetNextFeature() waste my transform?

I have no idea.  From what I can see, and guessing at the rest I would
say that transformH becoming NULL on it's own suggests stack corruption
has occured.

> 2) How do I preserve transformH and reverse_transformH in this case?

If you can provide a modest standalone mini-application that demonstrates
the code, I could look into it more closely.

> 3) These transforms are computed at the start of each layer loop.
> Overkill?  Can I get away with just once per dataset, or might there
> be different spatial references on each layer in some datasets?

In some datasources different layers can indeed have different coordinate
systems.  In some datasources it will not occur.  Creating the transformation
object isn't really all that expensive so doing it once per layer should be
fine.

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