OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
OssimPolyArea2dPrivate Class Reference

Public Types

typedef geos::geom::Geometry * GeometryPtr
 
typedef const geos::geom::Geometry * ConstGeometryPtr
 

Public Member Functions

 OssimPolyArea2dPrivate (GeometryPtr geom=0)
 
 ~OssimPolyArea2dPrivate ()
 
void deleteGeometry ()
 
void setGeometry (const ossimPolygon &polygon, const vector< ossimPolygon > &holes=vector< ossimPolygon >())
 
void setGeometry (GeometryPtr geom)
 
geos::geom::GeometryFactory * geomFactory ()
 

Public Attributes

GeometryPtr m_geometry
 

Static Public Attributes

static ossimRefPtr< ossimGeometryFactoryWrapperm_globalFactory
 

Detailed Description

Definition at line 58 of file ossimPolyArea2d.cpp.

Member Typedef Documentation

◆ ConstGeometryPtr

typedef const geos::geom::Geometry* OssimPolyArea2dPrivate::ConstGeometryPtr

Definition at line 62 of file ossimPolyArea2d.cpp.

◆ GeometryPtr

typedef geos::geom::Geometry* OssimPolyArea2dPrivate::GeometryPtr

Definition at line 61 of file ossimPolyArea2d.cpp.

Constructor & Destructor Documentation

◆ OssimPolyArea2dPrivate()

OssimPolyArea2dPrivate::OssimPolyArea2dPrivate ( GeometryPtr  geom = 0)

Definition at line 77 of file ossimPolyArea2d.cpp.

References m_globalFactory, and ossimRefPtr< T >::valid().

78 :m_geometry(geom)
79 {
80  static std::mutex globalFactoryMutex;
81 
82  {
83  std::lock_guard<std::mutex> lock(globalFactoryMutex);
84  if(!m_globalFactory.valid())
85  {
87  }
88  }
89 }
bool valid() const
Definition: ossimRefPtr.h:75
static ossimRefPtr< ossimGeometryFactoryWrapper > m_globalFactory

◆ ~OssimPolyArea2dPrivate()

OssimPolyArea2dPrivate::~OssimPolyArea2dPrivate ( )

Definition at line 91 of file ossimPolyArea2d.cpp.

References deleteGeometry().

92 {
94 }

Member Function Documentation

◆ deleteGeometry()

void OssimPolyArea2dPrivate::deleteGeometry ( )
inline

Definition at line 67 of file ossimPolyArea2d.cpp.

References m_geometry.

Referenced by ossimPolyArea2d::clearPolygons(), setGeometry(), and ~OssimPolyArea2dPrivate().

67 { if(m_geometry) { delete m_geometry; m_geometry = 0; }}

◆ geomFactory()

geos::geom::GeometryFactory* OssimPolyArea2dPrivate::geomFactory ( )
inline

◆ setGeometry() [1/2]

void OssimPolyArea2dPrivate::setGeometry ( const ossimPolygon polygon,
const vector< ossimPolygon > &  holes = vector<ossimPolygon>() 
)

Definition at line 96 of file ossimPolyArea2d.cpp.

References deleteGeometry(), geomFactory(), ossimPolygon::getVertexList(), m_geometry, n, x, and y.

Referenced by ossimPolyArea2d::add(), ossimPolyArea2d::getBufferedShape(), ossimPolyArea2d::loadState(), ossimPolyArea2d::operator+(), ossimPolyArea2d::operator+=(), ossimPolyArea2d::operator-(), ossimPolyArea2d::operator-=(), ossimPolyArea2d::operator=(), ossimPolyArea2d::ossimPolyArea2d(), ossimPolyArea2d::setToBufferedShape(), and ossimPolyArea2d::toMultiPolygon().

98 {
100 
101  geos::geom::CoordinateArraySequence *cas = new geos::geom::CoordinateArraySequence();
102 
103  const std::vector<ossimDpt>& pts = exteriorRing.getVertexList();
104 
105  int idx = 0;
106  int n = (int)pts.size();
107 
108  if(n > 0)
109  {
110  //fill the exterior ring
111  for (idx = 0; idx < n; idx++)
112  {
113  cas->add(geos::geom::Coordinate(pts[idx].x, pts[idx].y));
114  }
115 
116  //if the original polygon didn't have the first and last point the same, make it so
117  if((pts[0].x != pts[n-1].x) || (pts[0].y!=pts[n-1].y))
118  {
119  cas->add(geos::geom::Coordinate(pts[0].x, pts[0].y));
120  }
121 
122  //fill the interior rings
123  vector<geos::geom::Geometry*> *holes = new vector<geos::geom::Geometry*>();
124  for (ossim_uint32 interiorRingIdx = 0; interiorRingIdx < interiorRings.size(); ++interiorRingIdx)
125  {
126  geos::geom::CoordinateArraySequence *interiorCas =
127  new geos::geom::CoordinateArraySequence();
128  const std::vector<ossimDpt>& vertexPts = interiorRings[interiorRingIdx].getVertexList();
129  for(ossim_uint32 vertexIndex=0; vertexIndex < vertexPts.size(); ++vertexIndex)
130  {
131  interiorCas->add(geos::geom::Coordinate(vertexPts[vertexIndex].x,
132  vertexPts[vertexIndex].y));
133  }
134 
135  //if the original polygon didn't have the first and last point the same, make it so
136  if((vertexPts[0].x != vertexPts[vertexPts.size()-1].x) ||
137  (vertexPts[0].y!=vertexPts[vertexPts.size()-1].y))
138  {
139  interiorCas->add(geos::geom::Coordinate(vertexPts[0].x, vertexPts[0].y));
140  }
141 
142  geos::geom::LinearRing *hole = geomFactory()->createLinearRing(interiorCas);
143  holes->push_back(hole);
144  }
145 
146  geos::geom::LinearRing* shell = geomFactory()->createLinearRing(cas);
147  if ( shell )
148  {
149  m_geometry = geomFactory()->createPolygon(shell, holes);
150  }
151  else
152  {
153  m_geometry = 0;
154  }
155  }
156 }
ossim_uint32 x
ossim_uint32 y
os2<< "> n<< " > nendobj n
unsigned int ossim_uint32
geos::geom::GeometryFactory * geomFactory()

◆ setGeometry() [2/2]

void OssimPolyArea2dPrivate::setGeometry ( GeometryPtr  geom)
inline

Definition at line 69 of file ossimPolyArea2d.cpp.

References deleteGeometry(), and m_geometry.

Member Data Documentation

◆ m_geometry

GeometryPtr OssimPolyArea2dPrivate::m_geometry

◆ m_globalFactory

ossimRefPtr< ossimGeometryFactoryWrapper > OssimPolyArea2dPrivate::m_globalFactory
static

Definition at line 72 of file ossimPolyArea2d.cpp.

Referenced by geomFactory(), and OssimPolyArea2dPrivate().


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