[Gdal-dev] How to get value of an attribute within an object class

tjansson tommy.jansson at kongsberg.com
Tue Oct 2 03:01:57 EDT 2007


I've already tried that, and the value I get in return has until now always
been 0 (zero).

First I use int iOBJL = poFDefn->GetFieldIndex("OBJL"); to get the object
label code ID from the appurtenant feature definition.

Then this return value is used to get all features of type DPTCNT (code 43)
if (43 == poFeature->GetFieldAsInteger(iOBJL)).... 

Thereafter I've tried both double dValDCo =
poFeature->GetFieldAsDouble(174); (where 174 should be the code for VALDCO)
and double dValDCo = poFeature->GetFieldAsDouble("VALDCO");, but the return
value is always 0 (zero).

I've tried several maps, most of them downloaded from NOAA, but the result
is always the same. Am I missing something?

--Tommy 


Frank Warmerdam-2 wrote:
> 
> On 10/1/07, tjansson <tommy.jansson at kongsberg.com> wrote:
>>
>> How do I get the value of an attribute within an object class?
>>
>> I'm for instance interested in retrieving the value of the VALDCO (Value
>> of
>> depth contour) attribute from within the DEPCNT (Depth Contour) object
>> class.
> 
> Tommy,
> 
> Given a pointer to the OGRFeature named poFeature you would do:
> 
>   double VALDCO;
> 
>   VALDCO = poFeature->GetFieldAsDouble( "VALDCO" );
> 
> 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.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-get-value-of-an-attribute-within-an-object-class-tf4548075.html#a12993786
Sent from the GDAL - Dev mailing list archive at Nabble.com.




More information about the Gdal-dev mailing list