8 package net.sf.geographiclib;
69 private double _lat0, _lon0, _lat1, _lon1;
70 private static int transit(
double lon1,
double lon2) {
78 lon1 <= 0 && lon2 > 0 && lon12 > 0 ? 1 :
79 (lon2 <= 0 && lon1 > 0 && lon12 < 0 ? -1 : 0);
89 lon1 = lon1 % 720.0; lon2 = lon2 % 720.0;
90 return ( ((lon2 >= 0 && lon2 < 360) || lon2 < -360 ? 0 : 1) -
91 ((lon1 >= 0 && lon1 < 360) || lon1 < -360 ? 0 : 1) );
104 _polyline = polyline;
121 _perimetersum.
Set(0);
122 if (!_polyline) _areasum.
Set(0);
123 _lat0 = _lon0 = _lat1 = _lon1 = Double.NaN;
144 _crossings +=
transit(_lon1, lon);
203 return new PolygonResult(_num, 0, _polyline ? Double.NaN : 0);
210 int crossings = _crossings +
transit(_lon1, _lon0);
211 if ((crossings & 1) != 0)
212 tempsum.
Add((tempsum.
Sum() < 0 ? 1 : -1) * _area0/2);
219 if (tempsum.
Sum() > _area0/2)
220 tempsum.
Add(-_area0);
221 else if (tempsum.
Sum() <= -_area0/2)
222 tempsum.
Add(+_area0);
225 tempsum.
Add(-_area0);
226 else if (tempsum.
Sum() < 0)
227 tempsum.
Add(+_area0);
261 double perimeter = _perimetersum.
Sum();
262 double tempsum = _polyline ? 0 : _areasum.
Sum();
265 for (
int i = 0;
i < (_polyline ? 1 : 2); ++
i) {
267 _earth.
Inverse(
i == 0 ? _lat1 : lat,
i == 0 ? _lon1 : lon,
268 i != 0 ? _lat0 : lat,
i != 0 ? _lon0 : lon,
273 crossings +=
transit(
i == 0 ? _lon1 : lon,
274 i != 0 ? _lon0 : lon);
281 if ((crossings & 1) != 0)
282 tempsum += (tempsum < 0 ? 1 : -1) * _area0/2;
289 if (tempsum > _area0/2)
291 else if (tempsum <= -_area0/2)
294 if (tempsum >= _area0)
296 else if (tempsum < 0)
329 double perimeter = _perimetersum.
Sum() +
s;
333 double tempsum = _areasum.
Sum();
338 _earth.
Direct(_lat1, _lon1, azi,
false, s, _mask);
347 if ((crossings & 1) != 0)
348 tempsum += (tempsum < 0 ? 1 : -1) * _area0/2;
355 if (tempsum > _area0/2)
357 else if (tempsum <= -_area0/2)
360 if (tempsum >= _area0)
362 else if (tempsum < 0)
static int transit(double lon1, double lon2)
PolygonResult TestPoint(double lat, double lon, boolean reverse, boolean sign)
static final int LONGITUDE
void AddPoint(double lat, double lon)
void g(const string &key, int i)
GeodesicData Direct(double lat1, double lon1, double azi1, double s12)
PolygonResult Compute(boolean reverse, boolean sign)
GeodesicData Inverse(double lat1, double lon1, double lat2, double lon2)
void AddEdge(double azi, double s)
Point3 cross(const Point3 &p, const Point3 &q, OptionalJacobian< 3, 3 > H1, OptionalJacobian< 3, 3 > H2)
cross product
PolygonResult TestEdge(double azi, double s, boolean reverse, boolean sign)
EIGEN_DEVICE_FUNC const SignReturnType sign() const
static final int DISTANCE
void reverse(const MatrixType &m)
static final int LONG_UNROLL
static final int LATITUDE
static int transitdirect(double lon1, double lon2)
static double AngNormalize(double x)
static Pair AngDiff(double x, double y)
PolygonArea(Geodesic earth, boolean polyline)