File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ class QgsGeometry
39
39
40
40
/** construct geometry from a point */
41
41
static QgsGeometry* fromPoint(const QgsPoint& point) /Factory/;
42
+ /** construct geometry from a multipoint */
43
+ static QgsGeometry* fromMultiPoint(const QgsMultiPoint& multipoint) /Factory/;
42
44
/** construct geometry from a polyline */
43
45
static QgsGeometry* fromPolyline(const QgsPolyline& polyline) /Factory/;
44
46
/** construct geometry from a multipolyline*/
Original file line number Diff line number Diff line change @@ -125,6 +125,40 @@ QgsGeometry* QgsGeometry::fromPoint(const QgsPoint& point)
125
125
return g;
126
126
}
127
127
128
+ QgsGeometry* QgsGeometry::fromMultiPoint (const QgsMultiPoint& multipoint)
129
+ {
130
+ std::vector<GEOS_GEOM::Geometry*>* pointVector = new std::vector<GEOS_GEOM::Geometry*>(multipoint.size ());
131
+ GEOS_GEOM::Coordinate currentCoord;
132
+
133
+ for (int i = 0 ; i < multipoint.size (); ++i)
134
+ {
135
+ currentCoord.x = multipoint.at (i).x ();
136
+ currentCoord.y = multipoint.at (i).y ();
137
+ try
138
+ {
139
+ (*pointVector)[i] = geosGeometryFactory->createPoint (currentCoord);
140
+ }
141
+ catch (GEOS_UTIL::GEOSException* e)
142
+ {
143
+ delete e; delete pointVector; return 0 ;
144
+ }
145
+ }
146
+
147
+ GEOS_GEOM::Geometry* geom = 0 ;
148
+ try
149
+ {
150
+ geom = geosGeometryFactory->createMultiPoint (pointVector);
151
+ }
152
+ catch (GEOS_UTIL::GEOSException* e)
153
+ {
154
+ delete e; return 0 ;
155
+ }
156
+
157
+ QgsGeometry* g = new QgsGeometry;
158
+ g->setGeos (geom);
159
+ return g;
160
+ }
161
+
128
162
QgsGeometry* QgsGeometry::fromPolyline (const QgsPolyline& polyline)
129
163
{
130
164
const GEOS_GEOM::CoordinateSequenceFactory* seqFactory = GEOS_GEOM::COORD_SEQ_FACTORY::instance ();
Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ class CORE_EXPORT QgsGeometry {
112
112
113
113
/* * construct geometry from a point */
114
114
static QgsGeometry* fromPoint (const QgsPoint& point);
115
+ /* * construct geometry from a multipoint */
116
+ static QgsGeometry* fromMultiPoint (const QgsMultiPoint& multipoint);
115
117
/* * construct geometry from a polyline */
116
118
static QgsGeometry* fromPolyline (const QgsPolyline& polyline);
117
119
/* * construct geometry from a multipolyline*/
You can’t perform that action at this time.
0 commit comments