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);
An exception class for all GeoTess objects.
Manages information about a great circle path that extends from one point to another point,...
const double * getNormal()
An ordered list of points on the surface of a unit sphere that define a closed polygon.
const double * getPoint(int index)
bool getReferencePointIn()
virtual ~GeoTessPolygon()
void setReferencePoint(const double *refPoint, const bool &inside)
const void getReferencePoint(double *u)
void getPoints(vector< double * > &points, const bool &repeatFirstPoint)
vector< GeoTessGreatCircle * > edges
static double getTolerance()
GeoTessPolygon(vector< double * > &points)
GeoTessPolygon(const double *center, double radius, int nEdges)
const double *const getReferencePoint()
void getPoints(vector< double * > &points, const bool &repeatFirstPoint, const double &maxSpacing)
virtual string class_name()
void setReferencePoint(double lat, double lon, bool inside)
string str(const bool &repeatFirstPoint, const bool &latFirst, const double &minLongitude=-180)
bool contains(const double *x)
bool containsAll(const vector< double * > &positions)
int edgeCrossings(GeoTessGreatCircle &gcRef)
GeoTessPolygon(string filename)
bool onBoundary(const double *x)
bool containsAny(const vector< double * > &points)
void setup(vector< double * > &points)
virtual void write(const string &outputFileName)
bool onBoundary(GeoTessGreatCircle &gcRef)