MCPcopy Create free account
hub / github.com/Kitware/VTK / GetLayerProjectionAsProj4

Method GetLayerProjectionAsProj4

IO/GDAL/vtkGDALVectorReader.cxx:530–567  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

528
529//------------------------------------------------------------------------------
530const char* vtkGDALVectorReader::GetLayerProjectionAsProj4(int layerIndex)
531{
532 if (layerIndex < 0)
533 {
534 vtkErrorMacro(<< "Layer index cannot be negative");
535 return nullptr;
536 }
537 vtkGDALVectorReader::Internal* p = this->Implementation;
538 if (!p->Source)
539 {
540 vtkErrorMacro(<< "Source dataset not provided");
541 return nullptr;
542 }
543 int layerCount = p->Source->GetLayerCount();
544 if (layerIndex >= layerCount)
545 {
546 vtkErrorMacro(<< "Layer index " << layerIndex
547 << " exceeds number of layers in dataset: " << layerCount);
548 return nullptr;
549 }
550 OGRLayer* layer = p->Source->GetLayer(layerIndex);
551 if (!layer)
552 {
553 vtkErrorMacro(<< "Cannot access the GDAL dataset layer at index " << layerIndex);
554 return nullptr;
555 }
556 if (!layer->GetSpatialRef())
557 {
558 vtkErrorMacro(<< "Cannot access the spatial ref object.");
559 return nullptr;
560 }
561 char* projStr;
562 layer->GetSpatialRef()->exportToProj4(&projStr);
563 char* returnStr = new char[strlen(projStr) + 1];
564 strcpy(returnStr, projStr);
565 CPLFree(projStr);
566 return returnStr;
567}
568
569//------------------------------------------------------------------------------
570std::map<int, std::string> vtkGDALVectorReader::GetLayersProjection()

Callers

nothing calls this directly

Calls 1

GetLayerMethod · 0.80

Tested by

no test coverage detected