OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ossimPolyArea2d Class Reference

#include <ossimPolyArea2d.h>

Inheritance diagram for ossimPolyArea2d:
ossimReferenced

Public Member Functions

 ossimPolyArea2d ()
 
 ossimPolyArea2d (const vector< ossimGpt > &polygon)
 
 ossimPolyArea2d (const vector< ossimDpt > &polygon)
 
 ossimPolyArea2d (const ossimPolygon &shell, const vector< ossimPolygon > &holes)
 
 ossimPolyArea2d (const ossimDpt &p1, const ossimDpt &p2, const ossimDpt &p3, const ossimDpt &p4)
 
 ossimPolyArea2d (const ossimPolyArea2d &rhs)
 
 ossimPolyArea2d (const ossimIrect &rect)
 
 ossimPolyArea2d (const ossimDrect &rect)
 
 ossimPolyArea2d (const ossimPolygon &polygon)
 
 ~ossimPolyArea2d ()
 
void clear ()
 
const ossimPolyArea2doperator= (const ossimPolyArea2d &rhs)
 
const ossimPolyArea2doperator= (const ossimPolygon &rhs)
 
const ossimPolyArea2doperator= (const ossimIrect &rect)
 
const ossimPolyArea2doperator= (const ossimDrect &rect)
 
const ossimPolyArea2doperator= (const vector< ossimGpt > &polygon)
 
const ossimPolyArea2doperator= (const vector< ossimDpt > &polygon)
 
const ossimPolyArea2doperator&= (const ossimPolyArea2d &rhs)
 
ossimPolyArea2d operator& (const ossimPolyArea2d &rhs) const
 
ossimPolyArea2d operator+ (const ossimPolyArea2d &rhs) const
 
const ossimPolyArea2doperator+= (const ossimPolyArea2d &rhs)
 
ossimPolyArea2d operator- (const ossimPolyArea2d &rhs) const
 
const ossimPolyArea2doperator-= (const ossimPolyArea2d &rhs)
 
bool intersects (const ossimPolyArea2d &rhs) const
 
void add (const ossimPolyArea2d &rhs)
 
bool getVisiblePolygons (vector< ossimPolygon > &polyList) const
 
bool getPolygonHoles (vector< ossimPolygon > &polyList) const
 
bool getCompletePolygons (vector< ossimPolyArea2d > &polyList) const
 Gets all of the polygons stored with their holes embedded. More...
 
bool isEmpty () const
 
bool isValid (bool displayValidationError=false) const
 
bool isPointWithin (const ossimDpt &point) const
 
bool isPointWithin (double x, double y) const
 
void getBoundingRect (ossimDrect &rect)
 
std::string toString () const
 Returns the Well Known Text string. More...
 
ossimPolyArea2d getBufferedShape (double distance=FLT_EPSILON) const
 Buffers the ossimPolyArea2d shape and returns a copy. More...
 
ossimPolyArea2dsetToBufferedShape (double distance=FLT_EPSILON)
 
ossimPolyArea2dtoMultiPolygon ()
 
bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

void clearPolygons ()
 
void recurseVisibleGeometries (ossimPolygon::Vector &polyList, const geos::geom::Geometry *geom) const
 
void recurseHoles (ossimPolygon::Vector &polyList, const geos::geom::Geometry *geom) const
 
void recurseCompleteGeometries (std::vector< ossimPolyArea2d > &polyList, const geos::geom::Geometry *geom) const
 Recurses over the Geometry object to load all complete polygons (a shell and any internal holes) into the ossimPolyArea2d. More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

OssimPolyArea2dPrivatem_privateData
 

Friends

class OssimPolyArea2dPrivate
 
OSSIM_DLL std::ostream & operator<< (std::ostream &out, const ossimPolyArea2d &data)
 

Detailed Description

Definition at line 31 of file ossimPolyArea2d.h.

Constructor & Destructor Documentation

◆ ossimPolyArea2d() [1/9]

ossimPolyArea2d::ossimPolyArea2d ( )

Definition at line 303 of file ossimPolyArea2d.cpp.

Referenced by recurseCompleteGeometries().

305 {
306 }
OssimPolyArea2dPrivate * m_privateData

◆ ossimPolyArea2d() [2/9]

ossimPolyArea2d::ossimPolyArea2d ( const vector< ossimGpt > &  polygon)

Definition at line 308 of file ossimPolyArea2d.cpp.

310 {
311  (*this) = polygon;
312 }
OssimPolyArea2dPrivate * m_privateData

◆ ossimPolyArea2d() [3/9]

ossimPolyArea2d::ossimPolyArea2d ( const vector< ossimDpt > &  polygon)

Definition at line 314 of file ossimPolyArea2d.cpp.

316 {
317  (*this) = polygon;
318 }
OssimPolyArea2dPrivate * m_privateData

◆ ossimPolyArea2d() [4/9]

ossimPolyArea2d::ossimPolyArea2d ( const ossimPolygon shell,
const vector< ossimPolygon > &  holes 
)

Definition at line 338 of file ossimPolyArea2d.cpp.

References m_privateData, and OssimPolyArea2dPrivate::setGeometry().

340 {
341  m_privateData->setGeometry(exteriorRing, interiorRings);
342 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())

◆ ossimPolyArea2d() [5/9]

ossimPolyArea2d::ossimPolyArea2d ( const ossimDpt p1,
const ossimDpt p2,
const ossimDpt p3,
const ossimDpt p4 
)

Definition at line 350 of file ossimPolyArea2d.cpp.

354  :
356 {
357  ossimPolygon temp(p1,p2,p3,p4);
358  *this = temp;
359 }
OssimPolyArea2dPrivate * m_privateData

◆ ossimPolyArea2d() [6/9]

ossimPolyArea2d::ossimPolyArea2d ( const ossimPolyArea2d rhs)

Definition at line 344 of file ossimPolyArea2d.cpp.

346 {
347  *this = rhs;
348 }
OssimPolyArea2dPrivate * m_privateData

◆ ossimPolyArea2d() [7/9]

ossimPolyArea2d::ossimPolyArea2d ( const ossimIrect rect)

Definition at line 320 of file ossimPolyArea2d.cpp.

322 {
323  (*this) = rect;
324 }
OssimPolyArea2dPrivate * m_privateData

◆ ossimPolyArea2d() [8/9]

ossimPolyArea2d::ossimPolyArea2d ( const ossimDrect rect)

Definition at line 326 of file ossimPolyArea2d.cpp.

328 {
329  (*this) = rect;
330 }
OssimPolyArea2dPrivate * m_privateData

◆ ossimPolyArea2d() [9/9]

ossimPolyArea2d::ossimPolyArea2d ( const ossimPolygon polygon)

Definition at line 332 of file ossimPolyArea2d.cpp.

334 {
335  (*this) = polygon;
336 }
OssimPolyArea2dPrivate * m_privateData

◆ ~ossimPolyArea2d()

ossimPolyArea2d::~ossimPolyArea2d ( )

Definition at line 361 of file ossimPolyArea2d.cpp.

References m_privateData.

362 {
363  if(m_privateData)
364  {
365  delete m_privateData;
366  m_privateData = 0;
367  }
368 }
OssimPolyArea2dPrivate * m_privateData

Member Function Documentation

◆ add()

void ossimPolyArea2d::add ( const ossimPolyArea2d rhs)

Definition at line 584 of file ossimPolyArea2d.cpp.

References isEmpty(), OssimPolyArea2dPrivate::m_geometry, m_privateData, and OssimPolyArea2dPrivate::setGeometry().

Referenced by ossimImageGeometry::calculatePolyBounds(), ossimImageViewProjectionTransform::getViewSegments(), and ossimImageRenderer::initializeBoundingRects().

585 {
586  if(isEmpty())
587  {
588  *this=rhs;
589  }
590  else
591  {
592  geos::geom::Geometry* geom = m_privateData->m_geometry->Union(rhs.m_privateData->m_geometry);
593  if(geom) m_privateData->setGeometry(geom);
594  }
595 }
OssimPolyArea2dPrivate * m_privateData
bool isEmpty() const
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())

◆ clear()

void ossimPolyArea2d::clear ( )
inline

◆ clearPolygons()

void ossimPolyArea2d::clearPolygons ( )
protected

Definition at line 597 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::deleteGeometry(), and m_privateData.

Referenced by getBufferedShape(), loadState(), operator+(), operator+=(), operator-(), and operator-=().

598 {
600 #if 0
601  clearEngine();
602 #endif
603 }
OssimPolyArea2dPrivate * m_privateData

◆ getBoundingRect()

void ossimPolyArea2d::getBoundingRect ( ossimDrect rect)

Definition at line 706 of file ossimPolyArea2d.cpp.

References isEmpty(), OssimPolyArea2dPrivate::m_geometry, m_privateData, and ossimDrect::makeNan().

Referenced by ATP::AtpGenerator::initialize().

707 {
708  rect.makeNan();
709 
710  if(!isEmpty())
711  {
712  const geos::geom::Envelope* envelope = m_privateData->m_geometry->getEnvelopeInternal();
713 
714  rect = ossimDrect(envelope->getMinX(), envelope->getMinY(), envelope->getMaxX(), envelope->getMaxY());
715  }
716 }
void makeNan()
Definition: ossimDrect.h:388
OssimPolyArea2dPrivate * m_privateData
bool isEmpty() const

◆ getBufferedShape()

ossimPolyArea2d ossimPolyArea2d::getBufferedShape ( double  distance = FLT_EPSILON) const

Buffers the ossimPolyArea2d shape and returns a copy.

This method does not alter polygon.

Parameters
distanceis the distance to buffer the shape by. Positive values will expand the shape, and negative values will shrink the shape.
Returns
A shape that is a buffered (expanded/contracted) version of this shape

Definition at line 730 of file ossimPolyArea2d.cpp.

References clearPolygons(), distance(), OssimPolyArea2dPrivate::m_geometry, m_privateData, ossimNotify(), ossimNotifyLevel_DEBUG, and OssimPolyArea2dPrivate::setGeometry().

730  {
731  ossimPolyArea2d result;
732  try{
733  geos::operation::buffer::BufferOp buffer_operation(m_privateData->m_geometry);
734  result.m_privateData->setGeometry( buffer_operation.getResultGeometry(distance));
735  }catch( const std::exception& e ){
737  << "ossimPolyArea2d::getBufferedShape Caught exception: " << e.what() << std::endl;
738  result.clearPolygons();
739  }catch( ... ){
741  << "ossimPolyArea2d::getBufferedShape Caught exception!" << std::endl;
742  result.clearPolygons();
743  }
744  return result;
745 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
float distance(double lat1, double lon1, double lat2, double lon2, int units)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getCompletePolygons()

bool ossimPolyArea2d::getCompletePolygons ( vector< ossimPolyArea2d > &  polyList) const

Gets all of the polygons stored with their holes embedded.

This may be useful if an operation was performed on the original ossimPolyArea2d that caused multiple polygons to be created internally.

For example, if a rectangle is intersected with a U shape, the two top portions of the U would be their own separate polygon. It's also possible for these polygons to contain their own holes. This function will return the two top polygons as separate ossimPolyArea2d objects (with any of their holes embedded inside them).


........ .........
. . . .

-.---—.--------—.----—.— . . . . . ............. . . . ............................

Parameters
polylistan empty vector of ossimPolyArea2d that will be filled
Returns
returns true if it successfully places polygons in the input vector

Definition at line 631 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, m_privateData, and recurseCompleteGeometries().

632 {
633  bool foundPolys = false;
635  ossim_uint32 sizeBefore = (ossim_uint32)polyList.size();
637  foundPolys = (sizeBefore != polyList.size());
638  }
639  return foundPolys;
640 }
OssimPolyArea2dPrivate * m_privateData
void recurseCompleteGeometries(std::vector< ossimPolyArea2d > &polyList, const geos::geom::Geometry *geom) const
Recurses over the Geometry object to load all complete polygons (a shell and any internal holes) into...
unsigned int ossim_uint32

◆ getPolygonHoles()

bool ossimPolyArea2d::getPolygonHoles ( vector< ossimPolygon > &  polyList) const

Definition at line 618 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, m_privateData, and recurseHoles().

619 {
620  bool foundPolys = false;
622  {
623  ossim_uint32 sizeBefore = (ossim_uint32)polyList.size();
625  foundPolys = (sizeBefore != polyList.size());
626  }
627 
628  return foundPolys;
629 }
OssimPolyArea2dPrivate * m_privateData
unsigned int ossim_uint32
void recurseHoles(ossimPolygon::Vector &polyList, const geos::geom::Geometry *geom) const

◆ getVisiblePolygons()

bool ossimPolyArea2d::getVisiblePolygons ( vector< ossimPolygon > &  polyList) const

Definition at line 605 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, m_privateData, and recurseVisibleGeometries().

Referenced by ossimPolygon::clipToRect(), ossimImageDataHelper::copyInputToThis(), ossimImageDataHelper::fill(), and ATP::AtpGenerator::initialize().

606 {
607  bool foundPolys = false;
609  {
610  ossim_uint32 sizeBefore = (ossim_uint32)polyList.size();
612  foundPolys = (sizeBefore != polyList.size());
613  }
614 
615  return foundPolys;
616 }
void recurseVisibleGeometries(ossimPolygon::Vector &polyList, const geos::geom::Geometry *geom) const
OssimPolyArea2dPrivate * m_privateData
unsigned int ossim_uint32

◆ intersects()

bool ossimPolyArea2d::intersects ( const ossimPolyArea2d rhs) const

Definition at line 417 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, and m_privateData.

Referenced by ossimImageRenderer::recursiveResample().

418 {
419  bool result = false;
420 
422  {
423  result = m_privateData->m_geometry->intersects(rhs.m_privateData->m_geometry);
424  }
425 
426  return result;
427 }
OssimPolyArea2dPrivate * m_privateData

◆ isEmpty()

bool ossimPolyArea2d::isEmpty ( ) const

Definition at line 642 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, and m_privateData.

Referenced by add(), getBoundingRect(), isPointWithin(), and saveState().

643 {
644  bool result = true;
646  {
647  result = m_privateData->m_geometry->isEmpty();
648  }
649 
650  return result;
651 }
OssimPolyArea2dPrivate * m_privateData

◆ isPointWithin() [1/2]

bool ossimPolyArea2d::isPointWithin ( const ossimDpt point) const

Definition at line 684 of file ossimPolyArea2d.cpp.

References ossimDpt::x, and ossimDpt::y.

685 {
686  return isPointWithin(point.x, point.y);
687 }
bool isPointWithin(const ossimDpt &point) const
double y
Definition: ossimDpt.h:165
double x
Definition: ossimDpt.h:164

◆ isPointWithin() [2/2]

bool ossimPolyArea2d::isPointWithin ( double  x,
double  y 
) const

Definition at line 689 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::geomFactory(), isEmpty(), OssimPolyArea2dPrivate::m_geometry, m_privateData, x, and y.

690 {
691  bool result = false;
692 
693  if(!isEmpty())
694  {
695  geos::geom::Coordinate c(x,y);
696  geos::geom::Geometry* geom = m_privateData->geomFactory()->createPoint(c);
697 
698  result = m_privateData->m_geometry->intersects(geom);
699 
700  delete geom;
701  }
702 
703  return result;
704 }
ossim_uint32 x
ossim_uint32 y
OssimPolyArea2dPrivate * m_privateData
bool isEmpty() const
geos::geom::GeometryFactory * geomFactory()

◆ isValid()

bool ossimPolyArea2d::isValid ( bool  displayValidationError = false) const

Definition at line 653 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, m_privateData, ossimNotify(), and ossimNotifyLevel_INFO.

Referenced by ossimImageGeometry::calculatePolyBounds().

654 {
655  bool result = false;
656 
658  {
659  if(displayValidationError)
660  {
661  geos::operation::valid::IsValidOp validityCheck(m_privateData->m_geometry);
662  geos::operation::valid::TopologyValidationError*
663  topologyValidationError(validityCheck.getValidationError());
664  // if(topologyValidationError == nullptr)
665  if(topologyValidationError == 0)
666  {
667  result = true;
668  }
669  else
670  {
672  << "ossimPolyArea2d::isValid: " << topologyValidationError->toString() << std::endl;
673  }
674  }
675  else
676  {
677  result = m_privateData->m_geometry->isValid();
678  }
679  }
680 
681  return result;
682 }
OssimPolyArea2dPrivate * m_privateData
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ loadState()

bool ossimPolyArea2d::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)

Definition at line 833 of file ossimPolyArea2d.cpp.

References ossimString::c_str(), clearPolygons(), ossimString::empty(), ossimKeywordlist::find(), OssimPolyArea2dPrivate::geomFactory(), m_privateData, ossimNotify(), ossimNotifyLevel_DEBUG, and OssimPolyArea2dPrivate::setGeometry().

835 {
836  if(m_privateData)
837  {
838  ossimString wkt = kwl.find(prefix, "wkt");
839 
840  if(!wkt.empty())
841  {
842  geos::io::WKTReader reader(m_privateData->geomFactory());
843  try
844  {
845  m_privateData->setGeometry(reader.read(wkt.c_str()));
846  }
847  catch( const std::exception& e )
848  {
850  << "ossimPolyArea2d::loadState Caught exception: " << e.what() << std::endl;
851  this->clearPolygons();
852  }
853  catch(...)
854  {
856  << "ossimPolyArea2d::loadState Caught exception!" << std::endl;
857  this->clearPolygons();
858  }
859  }
860  }
861  return true;
862 }
const char * find(const char *key) const
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool empty() const
Definition: ossimString.h:411
geos::geom::GeometryFactory * geomFactory()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator&()

ossimPolyArea2d ossimPolyArea2d::operator & ( const ossimPolyArea2d rhs) const

◆ operator&=()

const ossimPolyArea2d& ossimPolyArea2d::operator &= ( const ossimPolyArea2d rhs)

◆ operator+()

ossimPolyArea2d ossimPolyArea2d::operator+ ( const ossimPolyArea2d rhs) const

Definition at line 456 of file ossimPolyArea2d.cpp.

References clearPolygons(), OssimPolyArea2dPrivate::m_geometry, m_privateData, ossimNotify(), ossimNotifyLevel_DEBUG, and OssimPolyArea2dPrivate::setGeometry().

457 {
458  if((this!=&rhs) && m_privateData->m_geometry && rhs.m_privateData->m_geometry)
459  {
460  ossimPolyArea2d result;
461  try // GEOS code throws exceptions...
462  {
464  rhs.m_privateData->m_geometry));
465  }
466  catch( const std::exception& e )
467  {
469  << "ossimPolyArea2d::operator+ Caught exception: " << e.what() << std::endl;
470  result.clearPolygons();
471  }
472  catch( ... )
473  {
475  << "ossimPolyArea2d::operator+ Caught exception!" << std::endl;
476  result.clearPolygons();
477  }
478  return result;
479  }
480  return *this;
481 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator+=()

const ossimPolyArea2d & ossimPolyArea2d::operator+= ( const ossimPolyArea2d rhs)

Definition at line 534 of file ossimPolyArea2d.cpp.

References clearPolygons(), OssimPolyArea2dPrivate::m_geometry, m_privateData, ossimNotify(), ossimNotifyLevel_DEBUG, and OssimPolyArea2dPrivate::setGeometry().

535 {
536  if((this!=&rhs) && m_privateData->m_geometry && rhs.m_privateData->m_geometry)
537  {
538  try // GEOS code throws exceptions...
539  {
541  rhs.m_privateData->m_geometry));
542  }
543  catch( const std::exception& e )
544  {
546  << "ossimPolyArea2d::operator+= Caught exception: " << e.what() << std::endl;
547  this->clearPolygons();
548  }
549  catch( ... )
550  {
552  << "ossimPolyArea2d::operator+= Caught exception!" << std::endl;
553  this->clearPolygons();
554  }
555  }
556  return *this;
557 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator-()

ossimPolyArea2d ossimPolyArea2d::operator- ( const ossimPolyArea2d rhs) const

Definition at line 482 of file ossimPolyArea2d.cpp.

References clearPolygons(), OssimPolyArea2dPrivate::m_geometry, m_privateData, ossimNotify(), ossimNotifyLevel_DEBUG, and OssimPolyArea2dPrivate::setGeometry().

483 {
484  if((this!=&rhs) && m_privateData->m_geometry && rhs.m_privateData->m_geometry)
485  {
486  ossimPolyArea2d result;
487  try // GEOS code throws exceptions...
488  {
489  result.m_privateData->setGeometry(m_privateData->m_geometry->difference(
490  rhs.m_privateData->m_geometry));
491  }
492  catch( const std::exception& e )
493  {
495  << "ossimPolyArea2d::operator- Caught exception: " << e.what() << std::endl;
496  result.clearPolygons();
497  }
498  catch( ... )
499  {
501  << "ossimPolyArea2d::operator- Caught exception!" << std::endl;
502  result.clearPolygons();
503  }
504  return result;
505  }
506  return *this;
507 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator-=()

const ossimPolyArea2d & ossimPolyArea2d::operator-= ( const ossimPolyArea2d rhs)

Definition at line 559 of file ossimPolyArea2d.cpp.

References clearPolygons(), OssimPolyArea2dPrivate::m_geometry, m_privateData, ossimNotify(), ossimNotifyLevel_DEBUG, and OssimPolyArea2dPrivate::setGeometry().

560 {
561  if((this!=&rhs) && m_privateData->m_geometry && rhs.m_privateData->m_geometry)
562  {
563  try // GEOS code throws exceptions...
564  {
566  rhs.m_privateData->m_geometry));
567  }
568  catch( const std::exception& e )
569  {
571  << "ossimPolyArea2d::operator-= Caught exception: " << e.what() << std::endl;
572  this->clearPolygons();
573  }
574  catch( ... )
575  {
577  << "ossimPolyArea2d::operator-= Caught exception!" << std::endl;
578  this->clearPolygons();
579  }
580  }
581  return *this;
582 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator=() [1/6]

const ossimPolyArea2d & ossimPolyArea2d::operator= ( const ossimPolyArea2d rhs)

Definition at line 370 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, m_privateData, and OssimPolyArea2dPrivate::setGeometry().

371 {
372  if(this != &rhs)
373  {
374  if(rhs.m_privateData->m_geometry)
375  {
377  }
378  }
379  return *this;
380 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())

◆ operator=() [2/6]

const ossimPolyArea2d & ossimPolyArea2d::operator= ( const ossimPolygon rhs)

Definition at line 382 of file ossimPolyArea2d.cpp.

References m_privateData, and OssimPolyArea2dPrivate::setGeometry().

383 {
384  m_privateData->setGeometry(polygon);
385 
386  return *this;
387 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())

◆ operator=() [3/6]

const ossimPolyArea2d & ossimPolyArea2d::operator= ( const ossimIrect rect)

Definition at line 389 of file ossimPolyArea2d.cpp.

390 {
391  return (*this = ossimPolygon(rect));
392 }

◆ operator=() [4/6]

const ossimPolyArea2d & ossimPolyArea2d::operator= ( const ossimDrect rect)

Definition at line 394 of file ossimPolyArea2d.cpp.

395 {
396  return (*this = ossimPolygon(rect));
397 }

◆ operator=() [5/6]

const ossimPolyArea2d & ossimPolyArea2d::operator= ( const vector< ossimGpt > &  polygon)

Definition at line 399 of file ossimPolyArea2d.cpp.

References n.

400 {
401  std::vector<ossimDpt> pts;
402  int idx = 0;
403  int n = (int)polygon.size();
404  for(idx = 0; idx < n;++idx)
405  {
406  pts.push_back(polygon[idx]);
407  }
408 
409  return (*this = ossimPolygon(pts));
410 }
os2<< "> n<< " > nendobj n

◆ operator=() [6/6]

const ossimPolyArea2d & ossimPolyArea2d::operator= ( const vector< ossimDpt > &  polygon)

Definition at line 412 of file ossimPolyArea2d.cpp.

413 {
414  return (*this = ossimPolygon(polygon));
415 }

◆ recurseCompleteGeometries()

void ossimPolyArea2d::recurseCompleteGeometries ( std::vector< ossimPolyArea2d > &  polyList,
const geos::geom::Geometry *  geom 
) const
protected

Recurses over the Geometry object to load all complete polygons (a shell and any internal holes) into the ossimPolyArea2d.

Definition at line 240 of file ossimPolyArea2d.cpp.

References ossimPolygon::addPoint(), and ossimPolyArea2d().

Referenced by getCompletePolygons().

242 {
243  int nGeoms = (int)geom->getNumGeometries();
244  if(nGeoms < 2 )
245  {
246  const geos::geom::Polygon* poly = dynamic_cast<const geos::geom::Polygon*> (geom);
247 
248  if (poly)
249  {
250  //get exterior shell for the geometry
251  ossimPolygon shell;
252  const geos::geom::LineString* lineString =
253  dynamic_cast<const geos::geom::LineString*> (poly->getExteriorRing());
254  if (lineString)
255  {
256  int nPoints = (int)lineString->getNumPoints();
257  for (int idx = 0; idx<nPoints; idx++)
258  {
259  std::auto_ptr<const geos::geom::Point> point(lineString->getPointN(idx));
260  shell.addPoint(point->getX(), point->getY());
261  }
262  }
263 
264  // Get interior rings for the geometry.
265  std::size_t nInteriorRings = poly->getNumInteriorRing();
266  vector<ossimPolygon> holes(nInteriorRings);
267  for(std::size_t holeIdx = 0; holeIdx < nInteriorRings; ++holeIdx)
268  {
269  const geos::geom::LineString* lineString = poly->getInteriorRingN(holeIdx);
270  if (lineString)
271  {
272  std::size_t nPoints = lineString->getNumPoints();
273  for (std::size_t idx = 0; idx<nPoints; ++idx)
274  {
275  std::auto_ptr<const geos::geom::Point> point(lineString->getPointN(idx));
276  holes[holeIdx].addPoint(point->getX(), point->getY());
277  }
278  }
279  }
280  polyList.push_back(ossimPolyArea2d(shell, holes));
281  }
282  }
283  else
284  {
285  int idx = 0;
286 
287  for (idx=0; idx < nGeoms; idx++)
288  {
289  recurseCompleteGeometries(polyList, geom->getGeometryN(idx));
290  }
291  }
292 }
void addPoint(const ossimDpt &pt)
void recurseCompleteGeometries(std::vector< ossimPolyArea2d > &polyList, const geos::geom::Geometry *geom) const
Recurses over the Geometry object to load all complete polygons (a shell and any internal holes) into...

◆ recurseHoles()

void ossimPolyArea2d::recurseHoles ( ossimPolygon::Vector polyList,
const geos::geom::Geometry *  geom 
) const
protected

Definition at line 195 of file ossimPolyArea2d.cpp.

Referenced by getPolygonHoles().

197 {
198  int nGeoms = (int)geom->getNumGeometries();
199 
200  if(nGeoms < 2 )
201  {
202  const geos::geom::Polygon* poly = dynamic_cast<const geos::geom::Polygon*> (geom);
203 
204  if (poly)
205  {
206  ossim_uint32 nInteriorRings = (ossim_uint32)poly->getNumInteriorRing();
207  ossim_uint32 idx = 0;
208 
209  for(idx = 0; idx < nInteriorRings; ++idx)
210  {
211  const geos::geom::LineString* lineString = poly->getInteriorRingN(idx);
212  if (lineString)
213  {
214  int currentPolyIdx = (int)polyList.size();
215  int nPoints = (int)lineString->getNumPoints();
216  int idx = 0;
217 
218  polyList.push_back(ossimPolygon());
219 
220  for (idx=0; idx<nPoints; idx++)
221  {
222  std::auto_ptr<const geos::geom::Point> point(lineString->getPointN(idx));
223  polyList[currentPolyIdx].addPoint(point->getX(), point->getY());
224  }
225  }
226  }
227  }
228  }
229  else
230  {
231  int idx = 0;
232 
233  for (idx=0; idx < nGeoms; idx++)
234  {
235  recurseHoles(polyList, geom->getGeometryN(idx));
236  }
237  }
238 }
unsigned int ossim_uint32
void recurseHoles(ossimPolygon::Vector &polyList, const geos::geom::Geometry *geom) const

◆ recurseVisibleGeometries()

void ossimPolyArea2d::recurseVisibleGeometries ( ossimPolygon::Vector polyList,
const geos::geom::Geometry *  geom 
) const
protected

Definition at line 158 of file ossimPolyArea2d.cpp.

Referenced by getVisiblePolygons().

160 {
161  int nGeoms = (int)geom->getNumGeometries();
162 
163  if(nGeoms < 2 )
164  {
165  const geos::geom::Polygon* poly = dynamic_cast<const geos::geom::Polygon*> (geom);
166 
167  if (poly)
168  {
169  const geos::geom::LineString* lineString = dynamic_cast<const geos::geom::LineString*> (poly->getExteriorRing());
170  if (lineString)
171  {
172  int currentPolyIdx = (int)polyList.size();
173  int nPoints = (int)lineString->getNumPoints();
174  int idx = 0;
175 
176  polyList.push_back(ossimPolygon());
177 
178  for (idx=0; idx<nPoints; idx++)
179  {
180  std::auto_ptr<const geos::geom::Point> point(lineString->getPointN(idx));
181  polyList[currentPolyIdx].addPoint(point->getX(), point->getY());
182  }
183  }
184  }
185  }
186  else
187  {
188  for (int idx=0; idx < nGeoms; ++idx)
189  {
190  recurseVisibleGeometries(polyList, geom->getGeometryN(idx));
191  }
192  }
193 }
void recurseVisibleGeometries(ossimPolygon::Vector &polyList, const geos::geom::Geometry *geom) const

◆ saveState()

bool ossimPolyArea2d::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const

Definition at line 808 of file ossimPolyArea2d.cpp.

References ossimKeywordlist::add(), isEmpty(), OssimPolyArea2dPrivate::m_geometry, m_privateData, and ossimKeywordNames::TYPE_KW.

810 {
811  kwl.add(prefix,
813  "ossimPolyArea2d",
814  true);
815 
816  if(!isEmpty())
817  {
818  geos::io::WKTWriter writer;
819 
820  kwl.add(prefix,
821  "wkt",
822  writer.write(m_privateData->m_geometry).c_str(),
823  true);
824  }
825  // else
826  // {
827  //
828  // }
829 
830  return true;
831 }
OssimPolyArea2dPrivate * m_privateData
bool isEmpty() const
static const char * TYPE_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)

◆ setToBufferedShape()

ossimPolyArea2d & ossimPolyArea2d::setToBufferedShape ( double  distance = FLT_EPSILON)

Definition at line 746 of file ossimPolyArea2d.cpp.

References distance(), OssimPolyArea2dPrivate::m_geometry, m_privateData, ossimNotify(), ossimNotifyLevel_DEBUG, and OssimPolyArea2dPrivate::setGeometry().

Referenced by ossimImageGeometry::calculatePolyBounds().

747 {
748  try{
749  geos::operation::buffer::BufferOp buffer_operation(m_privateData->m_geometry);
750  m_privateData->setGeometry( buffer_operation.getResultGeometry(distance));
751  }catch( const std::exception& e ){
753  << "ossimPolyArea2d::getBufferedShape Caught exception: " << e.what() << std::endl;
754  }catch( ... ){
756  << "ossimPolyArea2d::getBufferedShape Caught exception!" << std::endl;
757  }
758  return *this;
759 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
float distance(double lat1, double lon1, double lat2, double lon2, int units)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ toMultiPolygon()

ossimPolyArea2d & ossimPolyArea2d::toMultiPolygon ( )

Definition at line 761 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, m_privateData, ossimNotify(), ossimNotifyLevel_WARN, and OssimPolyArea2dPrivate::setGeometry().

762 {
763 
764 
765  try{
767  {
768  switch(m_privateData->m_geometry->getGeometryTypeId())
769  {
770  case geos::geom::GEOS_POLYGON:
771  {
772  std::vector<geos::geom::Geometry*> values;
773  values.push_back(m_privateData->m_geometry->clone());
774 
775  m_privateData->setGeometry(m_privateData->m_geometry->getFactory()->createMultiPolygon(values));
776  break;
777  }
778  case geos::geom::GEOS_MULTIPOLYGON:
779  {
780  // intentionally left blank
781  break;
782  }
783  default:
784  {
785  // might need an error at a later date
787  << "ossimPolyArea2d::toMultiPolygon Geometry type can not be converted to a multi polygon: " <<m_privateData->m_geometry->getGeometryType()<< std::endl;
788 
789  break;
790  }
791  }
792  }
793  }
794  catch(const std::exception& e)
795  {
797  << "ossimPolyArea2d::toMultiPolygon Caught exception: " << e.what() << std::endl;
798  }
799  catch(...)
800  {
802  << "ossimPolyArea2d::toMultiPolygon Caught exception!" << std::endl;
803  }
804 
805  return *this;
806 }
OssimPolyArea2dPrivate * m_privateData
void setGeometry(const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ toString()

std::string ossimPolyArea2d::toString ( ) const

Returns the Well Known Text string.

Definition at line 718 of file ossimPolyArea2d.cpp.

References OssimPolyArea2dPrivate::m_geometry, and m_privateData.

719 {
720  std::string result = "";
721 
723  {
724  result = m_privateData->m_geometry->toString();
725  }
726 
727  return result;
728 }
OssimPolyArea2dPrivate * m_privateData

Friends And Related Function Documentation

◆ operator<<

OSSIM_DLL std::ostream& operator<< ( std::ostream &  out,
const ossimPolyArea2d data 
)
friend

Definition at line 294 of file ossimPolyArea2d.cpp.

295 {
296  if(rhs.m_privateData->m_geometry)
297  {
298  out << rhs.m_privateData->m_geometry->toString();
299  }
300  return out;
301 }

◆ OssimPolyArea2dPrivate

friend class OssimPolyArea2dPrivate
friend

Definition at line 34 of file ossimPolyArea2d.h.

Member Data Documentation

◆ m_privateData

OssimPolyArea2dPrivate* ossimPolyArea2d::m_privateData
protected

The documentation for this class was generated from the following files: