mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Added fromMultiPoint method to QgsGeometry
git-svn-id: http://svn.osgeo.org/qgis/trunk@8041 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
671a782505
commit
c39d6a90ce
@ -39,6 +39,8 @@ class QgsGeometry
|
|||||||
|
|
||||||
/** construct geometry from a point */
|
/** construct geometry from a point */
|
||||||
static QgsGeometry* fromPoint(const QgsPoint& point) /Factory/;
|
static QgsGeometry* fromPoint(const QgsPoint& point) /Factory/;
|
||||||
|
/** construct geometry from a multipoint */
|
||||||
|
static QgsGeometry* fromMultiPoint(const QgsMultiPoint& multipoint) /Factory/;
|
||||||
/** construct geometry from a polyline */
|
/** construct geometry from a polyline */
|
||||||
static QgsGeometry* fromPolyline(const QgsPolyline& polyline) /Factory/;
|
static QgsGeometry* fromPolyline(const QgsPolyline& polyline) /Factory/;
|
||||||
/** construct geometry from a multipolyline*/
|
/** construct geometry from a multipolyline*/
|
||||||
|
@ -125,6 +125,40 @@ QgsGeometry* QgsGeometry::fromPoint(const QgsPoint& point)
|
|||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QgsGeometry* QgsGeometry::fromMultiPoint(const QgsMultiPoint& multipoint)
|
||||||
|
{
|
||||||
|
std::vector<GEOS_GEOM::Geometry*>* pointVector = new std::vector<GEOS_GEOM::Geometry*>(multipoint.size());
|
||||||
|
GEOS_GEOM::Coordinate currentCoord;
|
||||||
|
|
||||||
|
for(int i = 0; i < multipoint.size(); ++i)
|
||||||
|
{
|
||||||
|
currentCoord.x = multipoint.at(i).x();
|
||||||
|
currentCoord.y = multipoint.at(i).y();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
(*pointVector)[i] = geosGeometryFactory->createPoint(currentCoord);
|
||||||
|
}
|
||||||
|
catch(GEOS_UTIL::GEOSException* e)
|
||||||
|
{
|
||||||
|
delete e; delete pointVector; return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GEOS_GEOM::Geometry* geom = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
geom = geosGeometryFactory->createMultiPoint(pointVector);
|
||||||
|
}
|
||||||
|
catch(GEOS_UTIL::GEOSException* e)
|
||||||
|
{
|
||||||
|
delete e; return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsGeometry* g = new QgsGeometry;
|
||||||
|
g->setGeos(geom);
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
QgsGeometry* QgsGeometry::fromPolyline(const QgsPolyline& polyline)
|
QgsGeometry* QgsGeometry::fromPolyline(const QgsPolyline& polyline)
|
||||||
{
|
{
|
||||||
const GEOS_GEOM::CoordinateSequenceFactory* seqFactory = GEOS_GEOM::COORD_SEQ_FACTORY::instance();
|
const GEOS_GEOM::CoordinateSequenceFactory* seqFactory = GEOS_GEOM::COORD_SEQ_FACTORY::instance();
|
||||||
|
@ -112,6 +112,8 @@ class CORE_EXPORT QgsGeometry {
|
|||||||
|
|
||||||
/** construct geometry from a point */
|
/** construct geometry from a point */
|
||||||
static QgsGeometry* fromPoint(const QgsPoint& point);
|
static QgsGeometry* fromPoint(const QgsPoint& point);
|
||||||
|
/** construct geometry from a multipoint */
|
||||||
|
static QgsGeometry* fromMultiPoint(const QgsMultiPoint& multipoint);
|
||||||
/** construct geometry from a polyline */
|
/** construct geometry from a polyline */
|
||||||
static QgsGeometry* fromPolyline(const QgsPolyline& polyline);
|
static QgsGeometry* fromPolyline(const QgsPolyline& polyline);
|
||||||
/** construct geometry from a multipolyline*/
|
/** construct geometry from a multipolyline*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user