MCPcopy Create free account
hub / github.com/PDAL/PDAL / initialize

Method initialize

io/GDALReader.cpp:74–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72
73
74void GDALReader::initialize()
75{
76 m_raster.reset(new gdal::Raster(m_filename));
77 if (m_raster->open() == gdal::GDALError::CantOpen)
78 throwError("Couldn't open raster file '" + m_filename + "'.");
79
80 m_raster->open();
81 setSpatialReference(m_raster->getSpatialRef());
82
83 m_width = m_raster->width();
84 m_height = m_raster->height();
85 m_bandTypes = m_raster->getPDALDimensionTypes();
86 m_metadata.add(m_raster->getMetadata());
87 m_blockReader.initialize();
88
89 m_dimNames.clear();
90 if (m_header.size())
91 {
92 m_dimNames = Utils::split(m_header, ',');
93 if (m_dimNames.size() != m_bandTypes.size())
94 throwError("Dimension names are not the same count as "
95 "raster bands.");
96 }
97 else
98 {
99 for (size_t i = 0; i < m_bandTypes.size(); ++i)
100 m_dimNames.push_back("band_" + std::to_string(i + 1));
101 }
102
103 int zBand = 1;
104 for (size_t i = 0; i < m_bandIds.size(); ++i)
105 if (m_bandIds[i] == Dimension::Id::Z)
106 {
107 zBand = i + 1;
108 break;
109 }
110
111 // Bounds is only used in inspect. We calculate it here so that
112 // the raster can be released.
113 m_bounds = m_raster->bounds(zBand);
114
115 m_raster.reset();
116}
117
118QuickInfo GDALReader::inspect()
119{

Callers 1

readyMethod · 0.45

Calls 13

splitFunction · 0.85
getSpatialRefMethod · 0.80
getBlockSizeMethod · 0.80
setSpatialReferenceFunction · 0.50
resetMethod · 0.45
openMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
addMethod · 0.45
getMetadataMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected