GeometryFactory.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/geometry/GeometryFactory.h
22 
23  \brief This is the Geometry factory for TerraLib geometries.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_GEOMETRYFACTORY_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_GEOMETRYFACTORY_H
28 
29 // TerraLib
30 #include "../common/Static.h"
31 #include "Geometry.h"
32 #include "GeometryCollection.h"
33 #include "LineString.h"
34 #include "MultiLineString.h"
35 #include "MultiPoint.h"
36 #include "MultiPolygon.h"
37 #include "Point.h"
38 #include "Polygon.h"
39 #include "PolyhedralSurface.h"
40 #include "TIN.h"
41 #include "Triangle.h"
42 
43 namespace te
44 {
45  namespace gm
46  {
47  /*!
48  \class GeometryFactory
49 
50  \brief This is the Geometry factory for TerraLib geometries.
51 
52  \ingroup geometry
53 
54  \sa Geometry,
55  Point, PointM, PointZ, PointZM,
56  Curve, LineString, LinearRing,
57  Surface, Polygon, Triangle, PolyhedralSurface, TIN,
58  GeometryCollection, MultiCurve, MultiSurface,
59  MultiPoint, MultiLineString, MultiPolygon
60  */
62  {
63  public:
64 
65  /*!
66  \brief It returns an instance according to the informed geometry type.
67 
68  \param t The geometry type to be instantiable.
69  \param srid The geometry spatial reference system.
70 
71  \return A geometry object.
72  */
73  static Geometry* make(GeomType t, int srid);
74  };
75 
77  {
78  switch(t)
79  {
80  case PointType:
81  case PointZType:
82  case PointMType:
83  case PointZMType:
84  return new Point(t, srid, 0);
85 
86  case LineStringType:
87  case LineStringZType:
88  case LineStringMType:
89  case LineStringZMType:
90  return new LineString(t, srid, 0);
91 
92  case PolygonType:
93  case PolygonZType:
94  case PolygonMType:
95  case PolygonZMType:
96  return new Polygon(0, t, srid, 0);
97 
98  case MultiPointType:
99  case MultiPointZType:
100  case MultiPointMType:
101  case MultiPointZMType:
102  return new MultiPoint(0, t, srid, 0);
103 
104  case MultiLineStringType:
108  return new MultiLineString(0, t, srid, 0);
109 
110  case MultiPolygonType:
111  case MultiPolygonZType:
112  case MultiPolygonMType:
113  case MultiPolygonZMType:
114  return new MultiPolygon(0, t, srid, 0);
115 
116  case MultiSurfaceType:
117  case MultiSurfaceZType:
118  case MultiSurfaceMType:
119  case MultiSurfaceZMType:
120  return new MultiSurface(0, t, srid, 0);
121 
126  return new GeometryCollection(0, t, srid, 0);
127 
128  case TriangleType:
129  case TriangleZType:
130  case TriangleMType:
131  case TriangleZMType:
132  return new Triangle(t, srid, 0);
133 
134  case TINType:
135  case TINZType:
136  case TINMType:
137  case TINZMType:
138  return new TIN(0, t, srid, 0);
139 
144  return new PolyhedralSurface(0, t, srid, 0);
145 
146  default:
147  return 0;
148  }
149  }
150 
151  } // end namespace gm
152 } // end namespace te
153 
154 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOMETRYFACTORY_H
155 
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
This is the Geometry factory for TerraLib geometries.
A point with x and y coordinate values.
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
MultiPoint is a GeometryCollection whose elements are restricted to points.
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
Definition: Triangle.h:50
A point with x and y coordinate values.
Definition: Point.h:50
MultiLineString is a MultiCurve whose elements are LineStrings.
URI C++ Library.
MultiPolygon is a MultiSurface whose elements are Polygons.
static Geometry * make(GeomType t, int srid)
It returns an instance according to the informed geometry type.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:74
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
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.
Definition: Polygon.h:50
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:54
LineString is a curve with linear interpolation between points.
It is a collection of other geometric objects.
A base type for static classes.
Definition: Static.h:43
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
It is a collection of other geometric objects.