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 "PointM.h"
39 #include "PointZ.h"
40 #include "PointZM.h"
41 #include "Polygon.h"
42 #include "PolyhedralSurface.h"
43 #include "TIN.h"
44 #include "Triangle.h"
45 
46 namespace te
47 {
48  namespace gm
49  {
50  /*!
51  \class GeometryFactory
52 
53  \brief This is the Geometry factory for TerraLib geometries.
54 
55  \ingroup geometry
56 
57  \sa Geometry,
58  Point, PointM, PointZ, PointZM,
59  Curve, LineString, LinearRing,
60  Surface, Polygon, Triangle, PolyhedralSurface, TIN,
61  GeometryCollection, MultiCurve, MultiSurface,
62  MultiPoint, MultiLineString, MultiPolygon
63  */
65  {
66  public:
67 
68  /*!
69  \brief It returns an instance according to the informed geometry type.
70 
71  \param t The geometry type to be instantiable.
72  \param srid The geometry spatial reference system.
73 
74  \return A geometry object.
75  */
76  static Geometry* make(GeomType t, int srid);
77  };
78 
80  {
81  switch(t)
82  {
83  case PointType:
84  return new Point(srid, 0);
85 
86  case PointZType:
87  return new PointZ(srid, 0);
88 
89  case PointMType:
90  return new PointM(srid, 0);
91 
92  case PointZMType:
93  return new PointZM(srid, 0);
94 
95  case LineStringType:
96  case LineStringZType:
97  case LineStringMType:
98  case LineStringZMType:
99  return new LineString(t, srid, 0);
100 
101  case PolygonType:
102  case PolygonZType:
103  case PolygonMType:
104  case PolygonZMType:
105  return new Polygon(0, t, srid, 0);
106 
107  case MultiPointType:
108  case MultiPointZType:
109  case MultiPointMType:
110  case MultiPointZMType:
111  return new MultiPoint(0, t, srid, 0);
112 
113  case MultiLineStringType:
117  return new MultiLineString(0, t, srid, 0);
118 
119  case MultiPolygonType:
120  case MultiPolygonZType:
121  case MultiPolygonMType:
122  case MultiPolygonZMType:
123  return new MultiPolygon(0, t, srid, 0);
124 
125  case MultiSurfaceType:
126  case MultiSurfaceZType:
127  case MultiSurfaceMType:
128  case MultiSurfaceZMType:
129  return new MultiSurface(0, t, srid, 0);
130 
135  return new GeometryCollection(0, t, srid, 0);
136 
137  case TriangleType:
138  case TriangleZType:
139  case TriangleMType:
140  case TriangleZMType:
141  return new Triangle(t, srid, 0);
142 
143  case TINType:
144  case TINZType:
145  case TINMType:
146  case TINZMType:
147  return new TIN(0, t, srid, 0);
148 
153  return new PolyhedralSurface(0, t, srid, 0);
154 
155  default:
156  return 0;
157  }
158  }
159 
160  } // end namespace gm
161 } // end namespace te
162 
163 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOMETRYFACTORY_H
164 
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.
A point with a z-coordinate value and an associated measurement.
Definition: PointZM.h:51
A point with an associated measure.
Definition: PointM.h:51
#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
A point with z-coordinate value.
Definition: PointZ.h:51
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:73
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 point with z-coordinate value.
A point with a z-coordinate value and an associated measurement.
A point with an associated measure.
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.