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

Method done

io/RasterWriter.cpp:101–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void RasterWriter::done(PointTableRef table)
102{
103 if (m_rasters.empty())
104 return;
105
106 if (m_rasterNames.size() == 1 && m_rasterNames[0] == "")
107 m_rasterNames.clear();
108
109 for (const std::string& name : m_rasterNames)
110 if (std::find_if(m_rasters.begin(), m_rasters.end(),
111 [name](const Rasterd *r){return r->name() == name;}) == m_rasters.end())
112 {
113 throwError("Raster '" + name + "' not found.");
114 }
115
116 // Stick rasters whose limits match the first raster in our final raster list.
117 std::vector<Rasterd *> rasters;
118 for (Rasterd *r : m_rasters)
119 {
120 if (r->limits() != m_rasters.front()->limits())
121 {
122 log()->get(LogLevel::Error) << getName() << ": Ignoring raster '" <<
123 r->name() << "'. Raster limits don't match that of raster '" <<
124 m_rasters.front()->name() << "'." << std::endl;
125 continue;
126 }
127 rasters.push_back(r);
128 }
129
130 std::array<double, 6> pixelToPos;
131 RasterLimits limits = rasters.front()->limits();
132 pixelToPos[0] = limits.xOrigin;
133 pixelToPos[1] = limits.edgeLength;
134 pixelToPos[2] = 0;
135 pixelToPos[3] = limits.yOrigin + (limits.edgeLength * limits.height);
136 pixelToPos[4] = 0;
137 pixelToPos[5] = -limits.edgeLength;
138 gdal::Raster rasterFile(filename(), m_drivername, table.anySpatialReference(), pixelToPos);
139
140 gdal::GDALError err = rasterFile.open(limits.width, limits.height,
141 rasters.size(), m_dataType, m_noData, m_options);
142
143 if (err != gdal::GDALError::None)
144 throwError(rasterFile.errorMsg());
145 int bandNum = 1;
146
147 for (Rasterd *r : rasters)
148 {
149 err = rasterFile.writeBand(r->begin(), r->initializer(), bandNum++, r->name());
150 if (err != gdal::GDALError::None)
151 throwError(rasterFile.errorMsg());
152 }
153
154 getMetadata().addList("filename", filename());
155}
156
157} // namespace pdal

Callers

nothing calls this directly

Calls 12

initializerMethod · 0.80
getNameFunction · 0.70
logFunction · 0.50
getMetadataFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
nameMethod · 0.45
getMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected