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

Method transform

filters/CropFilter.cpp:189–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187
188
189void CropFilter::transform(const SpatialReference& srs)
190{
191 for (auto& geom : m_geoms)
192 {
193 auto ok = geom.m_poly.transform(srs);
194 if (!ok)
195 throwError(ok.what());
196 geom.m_gridPnps.clear();
197 std::vector<Polygon> polys = geom.m_poly.polygons();
198 for (auto& p : polys)
199 {
200 std::unique_ptr<GridPnp> gridPnp(new GridPnp(
201 p.exteriorRing(), p.interiorRings()));
202 geom.m_gridPnps.push_back(std::move(gridPnp));
203 }
204 }
205
206 // If we don't have any SRS, do nothing.
207 if (srs.empty() && m_args->m_assignedSrs.empty())
208 return;
209
210 // Note that we should never have assigned SRS empty here since
211 // if it is missing we assign it from the point data.
212 assert(!m_args->m_assignedSrs.empty());
213 if (srs.empty() || m_args->m_assignedSrs.empty())
214 throwError("Unable to transform crop geometry to point coordinate system.");
215
216 for (auto& box : m_boxes)
217 {
218 if (!gdal::reprojectBounds(box, m_args->m_assignedSrs.getWKT(),
219 srs.getWKT()))
220 throwError("Unable to reproject bounds.");
221 }
222 for (auto& point : m_args->m_centers)
223 {
224 point.setSpatialReference(m_args->m_assignedSrs);
225 auto ok = point.transform(srs);
226 if (!ok)
227 throwError(ok.what());
228 }
229 // Set the assigned SRS for the points/bounds to the one we've
230 // transformed to.
231 m_args->m_assignedSrs = srs;
232}
233
234
235PointViewSet CropFilter::run(PointViewPtr view)

Callers 5

processOneMethod · 0.45
extractMetadataMethod · 0.45
doneMethod · 0.45
processOneMethod · 0.45

Calls 9

reprojectBoundsFunction · 0.85
polygonsMethod · 0.80
exteriorRingMethod · 0.80
interiorRingsMethod · 0.80
getWKTMethod · 0.80
whatMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
setSpatialReferenceMethod · 0.45

Tested by

no test coverage detected