36 for (
int i = 0; i < nGeoms; ++i )
49 for (
int i = 0; i < nGeoms; ++i )
124 int dim = ( *it )->dimension();
138 ( *it )->transform( ct );
147 ( *it )->transform( t );
152 void QgsGeometryCollectionV2::clip(
const QgsRectangle& rect )
157 ( *it )->clip( rect );
181 wkbPtr >> nGeometries;
184 for (
int i = 0; i < nGeometries; ++i )
189 geometryList.
append( geom );
195 for (
int i = 0; i < geometryList.
size(); ++i )
211 int size =
sizeof( char ) +
sizeof( quint32 ) +
sizeof( quint32 );
225 unsigned char* geomPtr =
new unsigned char[binarySize];
228 wkb << static_cast<quint32>(
wkbType() );
235 unsigned char* geomWkb = geom->
asWkb( geomWkbLen );
236 memcpy( wkb, geomWkb, geomWkbLen );
250 if ( dynamic_cast<const QgsPointV2*>( geom ) ||
251 dynamic_cast<const QgsLineStringV2*>( geom ) ||
252 dynamic_cast<const QgsPolygonV2*>( geom ) )
255 childWkt = childWkt.
mid( childWkt.
indexOf(
"(" ) );
257 wkt += childWkt +
",";
274 elemMultiGeometry.
appendChild( elemGeometryMember );
276 return elemMultiGeometry;
286 elemMultiGeometry.
appendChild( elemGeometryMember );
288 return elemMultiGeometry;
293 QString json =
"{\"type\": \"GeometryCollection\", \"geometries\": [";
296 json += geom->
asJSON( precision ) +
", ";
329 ( *geomIt )->coordinateSequence( geomCoords );
331 for ( ; cIt != geomCoords.
constEnd(); ++cIt )
333 coord.push_back( *cIt );
347 id.part = 0;
id.ring = -1;
id.vertex = -1;
359 ++
id.part;
id.ring = -1;
id.vertex = -1;
413 length += ( *geomIt )->length();
424 area += ( *geomIt )->area();
445 bool success =
false;
461 qDeleteAll( subtypes );
465 qDeleteAll( subtypes );
474 if (( *it )->hasCurvedSegments() )
486 if ( !geomCollection )
488 delete geom;
return clone();
494 geomCollection->
addGeometry(( *geomIt )->segmentize() );
496 return geomCollection;
virtual void transform(const QgsCoordinateTransform &ct) override
Transforms the geometry using a coordinate transform.
QgsGeometryCollectionV2()
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
bool fromWkb(const unsigned char *wkb) override
Sets the geometry from a WKB string.
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
A rectangle specified with double values.
static QPair< QgsWKBTypes::Type, QString > wktReadBlock(const QString &wkt)
Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents (...
virtual void coordinateSequence(QList< QList< QList< QgsPointV2 > > > &coord) const override
Retrieves the sequence of geometries, rings and nodes.
QgsGeometryCollectionV2 & operator=(const QgsGeometryCollectionV2 &c)
virtual QgsAbstractGeometryV2 & operator=(const QgsAbstractGeometryV2 &geom)
QDomNode appendChild(const QDomNode &newChild)
void append(const T &value)
Circular string geometry type.
const_iterator constEnd() const
const T & at(int i) const
virtual QString asJSON(int precision=17) const =0
Returns a GeoJSON representation of the geometry.
Abstract base class for all geometries.
virtual ~QgsGeometryCollectionV2()
static QStringList wktGetChildBlocks(const QString &wkt, const QString &defaultType="")
Parses a WKT string and returns of list of blocks contained in the WKT.
static double closestSegmentFromComponents(T &container, componentType ctype, const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon)
virtual bool insertVertex(const QgsVertexId &position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry.
QDomElement createElementNS(const QString &nsURI, const QString &qName)
QString asWkt(int precision=17) const override
Returns a WKT representation of the geometry.
virtual void clear() override
Clears the geometry, ie reset it to a null geometry.
static endian_t endian()
Returns whether this machine uses big or little endian.
QString wktTypeStr() const
Returns the WKT type string of the geometry.
virtual int wkbSize() const =0
Returns the size of the WKB representation of the geometry.
QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML2 representation of the geometry.
bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const override
Returns next vertex id and coordinates.
static Type flatType(Type type)
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
unsigned char * asWkb(int &binarySize) const override
Returns a WKB representation of the geometry.
bool hasCurvedSegments() const override
Returns true if the geometry contains curved segments.
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
void append(const T &value)
QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML3 representation of the geometry.
int wkbSize() const override
Returns the size of the WKB representation of the geometry.
Utility class for identifying a unique vertex within a geometry.
bool isMeasure() const
Returns true if the geometry contains m values.
Line string geometry type.
bool isEmpty() const
Returns true if the geometry is empty.
QgsWKBTypes::Type mWkbType
virtual unsigned char * asWkb(int &binarySize) const =0
Returns a WKB representation of the geometry.
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
virtual QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
Returns a GML3 representation of the geometry.
virtual bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const =0
Returns next vertex id and coordinates.
static QgsAbstractGeometryV2 * geomFromWkbType(QgsWKBTypes::Type t)
return empty geometry from wkb type
virtual double length() const override
Returns the length (or perimeter for area geometries) of the geometry.
QString asJSON(int precision=17) const override
Returns a GeoJSON representation of the geometry.
Compound curve geometry type.
bool fromCollectionWkt(const QString &wkt, const QList< QgsAbstractGeometryV2 * > &subtypes, const QString &defaultChildWkbType=QString())
Reads a collection from a WKT string.
virtual double area() const override
Returns the area of the geometry.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
static QgsAbstractGeometryV2 * geomFromWkb(const unsigned char *wkb)
Construct geometry from a WKB string.
virtual bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
virtual bool deleteVertex(const QgsVertexId &position) override
Deletes a vertex within the geometry.
QVector< QgsAbstractGeometryV2 * > mGeometries
virtual bool deleteVertex(const QgsVertexId &position)=0
Deletes a vertex within the geometry.
int numGeometries() const
Returns the number of geometries within the collection.
const T & at(int i) const
const_iterator constBegin() const
QString mid(int position, int n) const
virtual QgsAbstractGeometryV2 * clone() const override
Clones the geometry by performing a deep copy.
virtual bool addGeometry(QgsAbstractGeometryV2 *g)
Adds a geometry and takes ownership.
virtual void draw(QPainter &p) const override
Draws the geometry using the specified QPainter.
virtual double closestSegment(const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const override
Searches for the closest segment of the geometry to a given point.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
virtual QString geometryType() const override
Returns a unique string representing the geometry type.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
static Type parseType(const QString &wktStr)
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.
virtual QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
Returns a GML2 representation of the geometry.
const_iterator constEnd() const
QgsAbstractGeometryV2 * segmentize() const override
Returns a geometry without curves.
const_iterator constBegin() const
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
virtual bool moveVertex(const QgsVertexId &position, const QgsPointV2 &newPos) override
Moves a vertex within the geometry.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual QgsRectangle calculateBoundingBox() const override
Calculates the minimal bounding box for the geometry.
virtual int dimension() const override
Returns the inherent dimension of the geometry.