14# pragma warning (disable: 5055)
21 template<
class GeodType>
22 int PolygonAreaT<GeodType>::transit(
real lon1,
real lon2) {
34 lon12 > 0 && ((lon1 < 0 && lon2 >= 0) ||
36 (lon1 > 0 && lon2 == 0)) ? 1 :
38 (lon12 < 0 && lon1 >= 0 && lon2 < 0 ? -1 : 0);
49 template<
class GeodType>
50 int PolygonAreaT<GeodType>::transitdirect(
real lon1,
real lon2) {
65 return ( (lon2 >= 0 && lon2 <
Math::td ? 0 : 1) -
66 (lon1 >= 0 && lon1 <
Math::td ? 0 : 1) );
69 template<
class GeodType>
76 _earth.GenInverse(_lat1, _lon1, lat, lon, _mask,
77 s12, t, t, t, t, t, S12);
81 _crossings += transit(_lon1, lon);
83 _lat1 = lat; _lon1 = lon;
88 template<
class GeodType>
91 real lat, lon, S12, t;
92 _earth.GenDirect(_lat1, _lon1, azi,
false, s, _mask,
93 lat, lon, t, t, t, t, t, S12);
97 _crossings += transitdirect(_lon1, lon);
99 _lat1 = lat; _lon1 = lon;
104 template<
class GeodType>
106 real& perimeter, real& area)
const
116 perimeter = _perimetersum();
119 _earth.GenInverse(_lat1, _lon1, _lat0, _lon0, _mask,
120 s12, t, t, t, t, t, S12);
121 perimeter = _perimetersum(s12);
124 int crossings = _crossings + transit(_lon1, _lon0);
125 AreaReduce(tempsum, crossings, reverse, sign);
126 area =
real(0) + tempsum();
130 template<
class GeodType>
132 bool reverse,
bool sign,
133 real& perimeter, real& area)
const
141 perimeter = _perimetersum();
142 real tempsum = _polyline ? 0 : _areasum();
143 int crossings = _crossings;
144 unsigned num = _num + 1;
145 for (
int i = 0; i < (_polyline ? 1 : 2); ++i) {
147 _earth.GenInverse(i == 0 ? _lat1 : lat, i == 0 ? _lon1 : lon,
148 i != 0 ? _lat0 : lat, i != 0 ? _lon0 : lon,
149 _mask, s12, t, t, t, t, t, S12);
153 crossings += transit(i == 0 ? _lon1 : lon,
154 i != 0 ? _lon0 : lon);
161 AreaReduce(tempsum, crossings, reverse, sign);
162 area =
real(0) + tempsum;
166 template<
class GeodType>
168 bool reverse,
bool sign,
169 real& perimeter, real& area)
const
177 unsigned num = _num + 1;
178 perimeter = _perimetersum() + s;
182 real tempsum = _areasum();
183 int crossings = _crossings;
185 real lat, lon, s12, S12, t;
186 _earth.GenDirect(_lat1, _lon1, azi,
false, s, _mask,
187 lat, lon, t, t, t, t, t, S12);
189 crossings += transitdirect(_lon1, lon);
190 _earth.GenInverse(lat, lon, _lat0, _lon0, _mask,
191 s12, t, t, t, t, t, S12);
194 crossings += transit(lon, _lon0);
197 AreaReduce(tempsum, crossings, reverse, sign);
198 area =
real(0) + tempsum;
202 template<
class GeodType>
205 bool reverse,
bool sign)
const {
207 if (crossings & 1) area += (area < 0 ? 1 : -1) * _area0/2;
210 if (!reverse) area *= -1;
215 else if (area <= -_area0/2)
#define GEOGRAPHICLIB_EXPORT
GeographicLib::Math::real real
Header for GeographicLib::PolygonAreaT class.
static T AngNormalize(T x)
static T AngDiff(T x, T y, T &e)
void AddPoint(real lat, real lon)
unsigned Compute(bool reverse, bool sign, real &perimeter, real &area) const
unsigned TestPoint(real lat, real lon, bool reverse, bool sign, real &perimeter, real &area) const
void AddEdge(real azi, real s)
unsigned TestEdge(real azi, real s, bool reverse, bool sign, real &perimeter, real &area) const
Namespace for GeographicLib.