MCPcopy Create free account
hub / github.com/OSGeo/gdal / getArea

Function getArea

alg/gdalwarpkernel.cpp:1019–1035  ·  view source on GitHub ↗

poly may or may not be closed.

Source from the content-addressed store, hash-verified

1017
1018// poly may or may not be closed.
1019static double getArea(const XYPoly &poly)
1020{
1021 // CPLAssert(poly.size() >= 2);
1022 const size_t nPointCount = poly.size();
1023 double dfAreaSum =
1024 poly[0].first * (poly[1].second - poly[nPointCount - 1].second);
1025
1026 for (size_t i = 1; i < nPointCount - 1; i++)
1027 {
1028 dfAreaSum += poly[i].first * (poly[i + 1].second - poly[i - 1].second);
1029 }
1030
1031 dfAreaSum += poly[nPointCount - 1].first *
1032 (poly[0].second - poly[nPointCount - 2].second);
1033
1034 return 0.5 * std::fabs(dfAreaSum);
1035}
1036
1037/************************************************************************/
1038/* CanUse4SamplesFormula() */

Callers 2

PerformWarpMethod · 0.85
GWKSumPreservingThreadFunction · 0.85

Calls 2

fabsFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected