29 #ifdef TERRALIB_GEOS_ENABLED 
   31 #include "../common/Translator.h" 
   32 #include "Exception.h" 
   43 #include <geos/geom/Coordinate.h> 
   44 #include <geos/geom/CoordinateArraySequence.h> 
   45 #include <geos/geom/GeometryCollection.h> 
   46 #include <geos/geom/LineString.h> 
   47 #include <geos/geom/LinearRing.h> 
   48 #include <geos/geom/MultiLineString.h> 
   49 #include <geos/geom/MultiPoint.h> 
   50 #include <geos/geom/MultiPolygon.h> 
   51 #include <geos/geom/Point.h> 
   52 #include <geos/geom/Polygon.h> 
   61   switch(geom->getGeometryTypeId())
 
   63     case geos::geom::GEOS_POINT:
 
   64       return read(dynamic_cast<const geos::geom::Point*>(geom));
 
   66     case geos::geom::GEOS_LINESTRING:
 
   67       return read(dynamic_cast<const geos::geom::LineString*>(geom));
 
   69     case geos::geom::GEOS_LINEARRING:
 
   70       return read(dynamic_cast<const geos::geom::LinearRing*>(geom));
 
   72     case geos::geom::GEOS_POLYGON:
 
   73       return read(dynamic_cast<const geos::geom::Polygon*>(geom));
 
   75     case geos::geom::GEOS_MULTIPOLYGON:
 
   76       return read(dynamic_cast<const geos::geom::MultiPolygon*>(geom));
 
   78     case geos::geom::GEOS_MULTIPOINT:
 
   79       return read(dynamic_cast<const geos::geom::MultiPoint*>(geom));
 
   81     case geos::geom::GEOS_MULTILINESTRING:
 
   82       return read(dynamic_cast<const geos::geom::MultiLineString*>(geom));
 
   84     case geos::geom::GEOS_GEOMETRYCOLLECTION:
 
   85       return read(dynamic_cast<const geos::geom::GeometryCollection*>(geom));
 
   88       throw Exception(
TE_TR(
"The type of informed geometry can not be converted from GEOS to TerraLib!"));
 
   92 te::gm::Point* te::gm::GEOSReader::read(
const geos::geom::Point* geosPt)
 
   94   assert((geosPt != 0) && (geosPt->getGeometryTypeId() == geos::geom::GEOS_POINT));
 
   96   Point* pt = 
new Point(geosPt->getX(), geosPt->getY(), geosPt->getSRID(), 0);
 
  103   assert((geosLine != 0) && (geosLine->getGeometryTypeId() == geos::geom::GEOS_LINESTRING));
 
  105   const geos::geom::CoordinateSequence* cs = geosLine->getCoordinatesRO();
 
  107   std::size_t size = cs->getSize();
 
  109   LineString* l = 
new LineString(size, 
LineStringType, geosLine->getSRID(), 0);
 
  111   for(std::size_t i = 0; i < size; ++i)
 
  113     l->setX(i, cs->getX(i));
 
  114     l->setY(i, cs->getY(i));
 
  122   assert((geosRing != 0) && (geosRing->getGeometryTypeId() == geos::geom::GEOS_LINEARRING));
 
  124   const geos::geom::CoordinateSequence* cs = geosRing->getCoordinatesRO();
 
  126   std::size_t size = cs->getSize();
 
  128   LinearRing* r = 
new LinearRing(size, 
LineStringType, geosRing->getSRID(), 0);
 
  130   for(std::size_t i = 0; i < size; ++i)
 
  132     r->setX(i, cs->getX(i));
 
  133     r->setY(i, cs->getY(i));
 
  140 te::gm::Polygon* te::gm::GEOSReader::read(
const geos::geom::Polygon* geosPoly)
 
  142   assert((geosPoly != 0) && (geosPoly->getGeometryTypeId() == geos::geom::GEOS_POLYGON));
 
  144   if(geosPoly->isEmpty())
 
  145     return new Polygon(0, 
PolygonType, geosPoly->getSRID());
 
  147   std::size_t holesSize = geosPoly->getNumInteriorRing();
 
  149   Polygon* poly = 
new Polygon(holesSize + 1, 
PolygonType, geosPoly->getSRID(), 0);
 
  151   LinearRing* r = read(static_cast<const geos::geom::LinearRing*>(geosPoly->getExteriorRing()));
 
  153   poly->setRingN(0, r);
 
  155   for(std::size_t i = 0; i < holesSize; ++i)
 
  157     LinearRing* r = read(static_cast<const geos::geom::LinearRing*>(geosPoly->getInteriorRingN(i)));
 
  159     poly->setRingN(i + 1, r);
 
  167   assert((geosMPoly != 0) && (geosMPoly->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON));
 
  169   const std::size_t size = geosMPoly->getNumGeometries();
 
  171   MultiPolygon* mpoly = 
new MultiPolygon(size, 
MultiPolygonType, geosMPoly->getSRID(), 0);
 
  173   for(std::size_t i = 0; i < size; ++i)
 
  174     mpoly->setGeometryN(i, read(geosMPoly->getGeometryN(i)));
 
  181   assert((geosMLine != 0) && (geosMLine->getGeometryTypeId() == geos::geom::GEOS_MULTILINESTRING));
 
  183   const std::size_t size = geosMLine->getNumGeometries();
 
  185   MultiLineString* mline = 
new MultiLineString(size, 
MultiLineStringType, geosMLine->getSRID(), 0);
 
  187   for(std::size_t i = 0; i < size; ++i)
 
  188     mline->setGeometryN(i, read(geosMLine->getGeometryN(i)));
 
  195   assert((geosMPt != 0) && (geosMPt->getGeometryTypeId() == geos::geom::GEOS_MULTIPOINT));
 
  197   const std::size_t size = geosMPt->getNumGeometries();
 
  199   MultiPoint* mpt = 
new MultiPoint(size,
MultiPointType, geosMPt->getSRID(), 0);
 
  201   for(std::size_t i = 0; i < size; ++i)
 
  202     mpt->setGeometryN(i, read(geosMPt->getGeometryN(i)));
 
  209   assert((geosGeomColl != 0) && (geosGeomColl->getGeometryTypeId() == geos::geom::GEOS_GEOMETRYCOLLECTION));
 
  211   const std::size_t size = geosGeomColl->getNumGeometries();
 
  213   GeometryCollection* geomColl = 
new GeometryCollection(size, 
GeometryCollectionType, geosGeomColl->getSRID(), 0);
 
  215   for(std::size_t i = 0; i < size; ++i)
 
  216     geomColl->setGeometryN(i, read(geosGeomColl->getGeometryN(i)));
 
  221 #endif  // TERRALIB_GEOS_ENABLED 
MultiPolygon is a MultiSurface whose elements are Polygons. 
 
A LinearRing is a LineString that is both closed and simple. 
 
A point with x and y coordinate values. 
 
#define TE_TR(message)
It marks a string in order to get translated. 
 
MultiPoint is a GeometryCollection whose elements are restricted to points. 
 
A LinearRing is a LineString that is both closed and simple. 
 
MultiPoint is a GeometryCollection whose elements are restricted to points. 
 
LineString is a curve with linear interpolation between points. 
 
A point with x and y coordinate values. 
 
MultiLineString is a MultiCurve whose elements are LineStrings. 
 
MultiPolygon is a MultiSurface whose elements are Polygons. 
 
A class that converts a GEOS geometry to a TerraLib geometry. 
 
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards. 
 
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings. 
 
MultiLineString is a MultiCurve whose elements are LineStrings. 
 
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings. 
 
LineString is a curve with linear interpolation between points. 
 
It is a collection of other geometric objects. 
 
It is a collection of other geometric objects.