[Gdal-dev] GetSpatialRef() returns a NULL pointer.

Sanges Michele Michele.Sanges at otomelara.it
Mon Aug 2 04:47:56 EDT 2004


Hi,

I'm trying to extract the geographic (or projected) coordinates from my vector map files (an ESRI shapefile), using the OGRLayer::GetSpatialRef() class function. The problem is that this function returns a NULL pointer to an OGRSpatialReference object. Opening the same Shapefile with the OpenEV application, it shows the coordinate of any point.

My code is:

	m_pOGRDS = OGRSFDriverRegistrar::Open("./Data/demodata/airports.shp", FALSE, NULL);
	....
	....
	for (int nNumLayer = 0;  nNumLayer < m_pOGRDS->GetLayerCount(); nNumLayer++)
  	{
		OGRLayer *pOGRLayer = m_pOGRDS->GetLayer(nNumLayer);
		
		OGRSpatialReference *pOGRSR = pOGRLayer->GetSpatialRef(); // <- This function returns NULL
		printf("#######pOGRSR=%p######\n", pOGRSR);		    // <- Write pOGRSR=(nil)	
  	}

- Where am I mistaking?
- Is there another way to accomplish such operation?

Thanks.
Michele





More information about the Gdal-dev mailing list