Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
ApproxAreaFilter.hpp
Go to the documentation of this file.
1#pragma once
4#include <cmath>
5
11private:
12 double requiredArea; // Area in [m²]
13public:
14 explicit ApproxAreaFilter(double requiredArea):requiredArea(requiredArea){}
15
16 bool operator() (const fishnet::geometry::IPolygon auto & p) const noexcept {
17 double areaInLongLat = p.area();
18 auto boundary = p.getBoundary();
19 for(const auto & anySegment : boundary.getSegments()){
20 double squaredFactor = pow(fishnet::WGS84Ellipsoid::distance(anySegment.p(),anySegment.q()),2)/pow(anySegment.length(),2); // estimates a factor to convert from lon,lat to m² for the polygon in question
21 double approxArea = areaInLongLat * squaredFactor;
22 return approxArea >= requiredArea; // return on first segment, as all segments should be similar in length and thus the factor should be similar
23 }
24 return false; // a boundary without segments has no area to speak of
25 }
26};
27
Filter that approximates the area in m² and checks if it is equal or greater than the required area.
Definition ApproxAreaFilter.hpp:10
bool operator()(const fishnet::geometry::IPolygon auto &p) const noexcept
Definition ApproxAreaFilter.hpp:16
ApproxAreaFilter(double requiredArea)
Definition ApproxAreaFilter.hpp:14
static double distance(double lambdaA, double phiA, double lambdaB, double phiB, bool exact=true)
Definition WGS84Ellipsoid.hpp:71
Interface for a polygon A polygon is a two-dimensional shape defined by a boundary and zero or more h...
Definition IPolygon.hpp:98