152 void setup(vector<double*>& points);
225 if (isNotReferenced())
228 os << endl <<
"ERROR in Polygon::removeReference" << endl
229 <<
"Reference count (" << refCount <<
") is already zero." << endl;
271 return referencePoint;
282 u[0] = referencePoint[0];
283 u[1] = referencePoint[1];
284 u[2] = referencePoint[2];
302 referenceIn = !referenceIn;
319 if (referencePoint == NULL)
320 referencePoint =
new double[3];
322 referencePoint[0] = refPoint[0];
323 referencePoint[1] = refPoint[1];
324 referencePoint[2] = refPoint[2];
325 referenceIn = inside;
340 GeoTessUtils::getVectorDegrees(lat, lon, r);
341 setReferencePoint(r, inside);
354 for (
int i=0; i<(int)points.size(); ++i)
355 if (contains(points[i]))
368 for (
int i=0; i<(int)positions.size(); ++i)
369 if (!contains(positions[i]))
382 if (global || GeoTessUtils::dot(referencePoint, x) > cos(TOLERANCE))
387 return onBoundary(gcRef) || ((edgeCrossings(gcRef) % 2 == 0) == referenceIn);
400 for (
int i=0; i<(int)edges.size(); ++i)
403 if (GeoTessUtils::dot(gcRef.
getLast(), edges[i]->getFirst()) >= cos(TOLERANCE))
409 if (abs(GeoTessUtils::dot(gcRef.
getNormal(), edges[i]->getNormal())) >= cos(TOLERANCE)
410 && edges[i]->getDistance(gcRef.
getLast()) <= edges[i]->getDistance())
426 return onBoundary(gc);
443 void getPoints(vector<double*> &points,
const bool &repeatFirstPoint)
445 points.reserve(points.size()+edges.size()+1);
447 for (
int i = 0; i < (int)edges.size(); ++i)
449 double* point =
new double[3];
450 point[0] = edges[i]->getFirst()[0];
451 point[1] = edges[i]->getFirst()[1];
452 point[2] = edges[i]->getFirst()[2];
453 points.push_back(point);
456 if (repeatFirstPoint)
458 double* point =
new double[3];
459 point[0] = edges[0]->getFirst()[0];
460 point[1] = edges[0]->getFirst()[1];
461 point[2] = edges[0]->getFirst()[2];
462 points.push_back(point);
481 void getPoints(vector<double*> &points,
const bool &repeatFirstPoint,
const double &maxSpacing)
483 points.reserve(points.size()+edges.size()+1);
487 for (
int i = 0; i < (int)edges.size(); ++i)
489 n = (int)ceil(edges[i]->getDistance()/maxSpacing);
490 dx = edges[i]->getDistance()/n;
491 for (
int j=0; j<n; ++j)
492 points.push_back(edges[i]->getPoint(j*dx));
495 if (repeatFirstPoint)
497 double* point =
new double[3];
498 point[0] = edges[0]->getFirst()[0];
499 point[1] = edges[0]->getFirst()[1];
500 point[2] = edges[0]->getFirst()[2];
501 points.push_back(point);
514 return edges[index]->getFirst();
535 for (
int i=0; i<(int)edges.size(); ++i)
548 area -= (edges.size()-2)*PI;
563 double area = getArea();
564 return area <= 2*PI ? area : 4*PI-area;
578 double area = getArea();
579 return area >= 2*PI ? area : 4*PI-area;
600 string str(
const bool& repeatFirstPoint,
const bool& latFirst,
601 const double& minLongitude = -180);
603 virtual void write(
const string& outputFileName);
607 virtual void loadAscii(vector<string>& records);
bool isNotReferenced()
Returns true if reference count is zero.
Definition: GeoTessPolygon.h:239
void addReference()
Add reference count;.
Definition: GeoTessPolygon.h:218
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Definition: GeoTessPolygon.h:111
int size()
Returns the number of edges that define the polygon.
Definition: GeoTessPolygon.h:250
void setReferencePoint(double lat, double lon, bool inside)
Specify the reference point for this polygon and whether or not the specified point is inside or outs...
Definition: GeoTessPolygon.h:337
static double TOLERANCE
Tolerance value in radians used when comparing locations of two points.
Definition: GeoTessPolygon.h:136
const double * getPoint(int index)
Retrieve a reference to one point on the polygon boundary.
Definition: GeoTessPolygon.h:512
Definition: ArrayReuse.h:55
const double *const getReferencePoint()
Retrieve a reference to the referencePoint.
Definition: GeoTessPolygon.h:269
void setReferencePoint(const double *refPoint, const bool &inside)
Specify the reference point for this polygon and whether or not the specified point is inside or outs...
Definition: GeoTessPolygon.h:317
void * attachment
Some unspecified information that applications can attach to this polygon.
Definition: GeoTessPolygon.h:169
vector< GeoTessGreatCircle * > edges
A GreatCircle object for each edge of the polygon.
Definition: GeoTessPolygon.h:118
double * getFirst()
Retrieve a reference to the first unit vector on this GreatCircle.
Definition: GeoTessGreatCircle.h:482
int getRefCount()
Definition: GeoTessPolygon.h:241
double getAreaLarge()
Retrieve the area of this polygon.
Definition: GeoTessPolygon.h:576
const void getReferencePoint(double *u)
Retrieve a copy to the referencePoint.
Definition: GeoTessPolygon.h:280
static double getTolerance()
Retrieve the tolerance value in radians used when comparing locations of two points.
Definition: GeoTessPolygon.h:258
double * referencePoint
A point on the surface of the unit sphere that is used as a reference point.
Definition: GeoTessPolygon.h:126
Manages information about a great circle path that extends from one point to another point...
Definition: GeoTessGreatCircle.h:168
bool contains(const double *x)
return true if point x is located inside the polygon
Definition: GeoTessPolygon.h:380
bool onBoundary(const double *x)
Return true if evaluation point is very close to being on the boundary of the polygon.
Definition: GeoTessPolygon.h:423
void getPoints(vector< double * > &points, const bool &repeatFirstPoint)
Retrieve a deep copy of the points on the polygon.
Definition: GeoTessPolygon.h:443
bool referenceIn
true if the referencePoint is inside the polygon.
Definition: GeoTessPolygon.h:131
An exception class for all GeoTess objects.
Definition: GeoTessException.h:65
bool onBoundary(GeoTessGreatCircle &gcRef)
Return true if evaluation point is very close to being on the boundary of the polygon.
Definition: GeoTessPolygon.h:397
int refCount
Reference count.
Definition: GeoTessPolygon.h:159
double getArea()
Retrieve the area of this polygon.
Definition: GeoTessPolygon.h:529
bool containsAll(const vector< double * > &positions)
Returns true if this Polygon contains all of the supplied unit vectors.
Definition: GeoTessPolygon.h:366
bool containsAny(const vector< double * > &points)
Returns true if this Polygon contains any of the supplied unit vectors.
Definition: GeoTessPolygon.h:352
bool global
If global is true this polygon encompasses the entire Earth and method contains() will always return ...
Definition: GeoTessPolygon.h:142
const double * getNormal()
Retrieve a reference to the unit vector that is normal to the plane of this great circle (firstPoint ...
Definition: GeoTessGreatCircle.h:508
void invert()
Invert the current polygon.
Definition: GeoTessPolygon.h:300
bool getReferencePointIn()
Retrieve the value of referenceIn which indicates whether or not the referencePoint is inside or outs...
Definition: GeoTessPolygon.h:291
double getAreaSmall()
Retrieve the area of this polygon.
Definition: GeoTessPolygon.h:561
double * getLast()
Retrieve a reference to the last unit vector on this GreatCircle.
Definition: GeoTessGreatCircle.h:494
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
bool lonFirst
When reading/writing lat,lon data, should order be lat,lon or lon,lat.
Definition: GeoTessPolygon.h:147
virtual string class_name()
Returns the class name.
Definition: GeoTessPolygon.h:213
void getPoints(vector< double * > &points, const bool &repeatFirstPoint, const double &maxSpacing)
Retrieve a deep copy of the points on the polygon.
Definition: GeoTessPolygon.h:481
void removeReference()
Remove reference count;.
Definition: GeoTessPolygon.h:223