[gdal-dev] RE: Extract WKT actual Data Values starting with rootNode

Zermeno, Robert J CIV NAVAIR, 472100D robert.zermeno at navy.mil
Thu Apr 22 18:29:05 EDT 2010


Frank,

Thanks a lot for the tips.  I have been playing around a bit with the C API and documentation and noticed that the way gdal is loaded in Borland, I cannot use the C++ api of gdal.

My objective is I want to acquire the root node of the WKT tree and for each node, extract the value and its associated data.

Example:
  curRoot = SPHEROID
  value = "WSG 84"
  Data  = integer1, integer2 

How can I do this using the C API?  I think that is why you mentioned C++ API has more functionality, like GetRoot().

I cannot build a OGR_SRSNode tree using importFromWKT() or use its Constructor.  Reason it's a C++ API and for some reason in Builder, it gives me an unresolved reference.  So, I know something is wrong with my .lib file.

Last resort is I could use the ExportToPrettyWKT() and manually parse through it (which is WAY easier than then ExportToWKT() )

Thanks for your help,
Robert

-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com] 
Sent: Thursday, April 22, 2010 9:29
To: Zermeno, Robert J CIV NAVAIR, 472100D
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] How to extract Well Known Text Coordinate System information (WKT)..., OGR unresolved reference problem

Zermeno, Robert J CIV NAVAIR, 472100D wrote:
> Hi everyone,
> 
> I am enjoying the simplicity of GDAL with integrating with various formats.
> I have two related questions. 1.  How can I simply extract individual 
> pieces of WKT?  Meaning, The returned string from GetProjectionRef() 
> returns a WKT format coordinate system string describing the 
> geographical reference the image pertains to.  I would like to grab each of the components.

Robert,

The GetAttrValue() method on OGRSpatialReference can generally be used to extract specific data items from a coordinate system definition.
For instance:

   const char *pszDatumName = poSRS->GetAttrValue("DATUM");

would search the WKT for the DATUM node, and extract the associated text.

> 2. This is kind of a question: Instead of parsing through the XML 
> myself, I thought GDAL already has this functionality.  I have tried to perform:
> 
> OGRSpatialReferenceH poSRS; poSRS->GetPrimeMeridian(), but I receive 
> an unresolved reference compile error.  This is odd to me.  I can do 
> the GDAL API tutorial section that uses OSRSetUTM(), 
> OSRDestroySpatialReference(), OSRExportToWKt(). I have tried to 
> include all main ogr.h files: ogr_api.h, ogr_spatialref.h, ogr_core.h, ... But no such luck.
> 
> 
> The platform I am using is Borland C++.  I compiled a dll and lib file 
> through MSVC 2008 and used Borland coff2omf.exe to properly convert 
> the lib file.

My conclusion would be that this is something peculiar about the way you are building or Borland C++.  It may help to stick to the C rather than C++ API though there are some methods not exposed through C.

Good luck,
-- 
---------------------------------------+--------------------------------
---------------------------------------+------
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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4926 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100422/e63facfa/smime.bin


More information about the gdal-dev mailing list