All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeometryFactory.h
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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 
129  return new GeometryCollection(0, t, srid, 0);
130 
131  case TriangleType:
132  case TriangleZType:
133  case TriangleMType:
134  case TriangleZMType:
135  return new Triangle(t, srid, 0);
136 
137  case TINType:
138  case TINZType:
139  case TINMType:
140  case TINZMType:
141  return new TIN(0, t, srid, 0);
142 
147  return new PolyhedralSurface(0, t, srid, 0);
148 
149  default:
150  return 0;
151  }
152  }
153 
154  } // end namespace gm
155 } // end namespace te
156 
157 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOMETRYFACTORY_H
158 
MultiLineString is a MultiCurve whose elements are LineStrings.
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:114
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
A point with z-coordinate value.
Definition: PointZ.h:51
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
Definition: TIN.h:50
It is a collection of other geometric objects.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A point with z-coordinate value.
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
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
A point with x and y coordinate values.
This is the Geometry factory for TerraLib geometries.
LineString is a curve with linear interpolation between points.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
A point with x and y coordinate values.
Definition: Point.h:50
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
A point with an associated measure.
Definition: PointM.h:51
A point with a z-coordinate value and an associated measurement.
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
It is a collection of other geometric objects.
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
MultiPolygon is a MultiSurface whose elements are Polygons.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
Definition: Triangle.h:50
A base type for static classes.
Definition: Static.h:43
A point with an associated measure.
MultiLineString is a MultiCurve whose elements are LineStrings.
static Geometry * make(GeomType t, int srid)
It returns an instance according to the informed geometry type.