39 for (
int i = 0; i < nGeoms; ++i )
53 for (
int i = 0; i < nGeoms; ++i )
137 int dim = ( *it )->dimension();
165 void QgsGeometryCollectionV2::clip(
const QgsRectangle& rect )
170 ( *it )->clip( rect );
194 wkbPtr >> nGeometries;
197 for (
int i = 0; i < nGeometries; ++i )
202 geometryList.
append( geom );
208 for (
int i = 0; i < geometryList.
size(); ++i )
227 int size =
sizeof( char ) +
sizeof( quint32 ) +
sizeof( quint32 );
241 unsigned char* geomPtr =
new unsigned char[binarySize];
244 wkb << static_cast<quint32>(
wkbType() );
251 unsigned char* geomWkb = geom->
asWkb( geomWkbLen );
252 memcpy( wkb, geomWkb, geomWkbLen );
268 childWkt = childWkt.
mid( childWkt.
indexOf(
'(' ) );
270 wkt += childWkt +
',';
287 elemMultiGeometry.
appendChild( elemGeometryMember );
289 return elemMultiGeometry;
299 elemMultiGeometry.
appendChild( elemGeometryMember );
301 return elemMultiGeometry;
306 QString json =
"{\"type\": \"GeometryCollection\", \"geometries\": [";
309 json += geom->
asJSON( precision ) +
", ";
321 if ( mBoundingBox.
isNull() )
346 if ( !mCoordinateSequence.
isEmpty() )
347 return mCoordinateSequence;
355 for ( ; cIt != geomCoords.
constEnd(); ++cIt )
361 return mCoordinateSequence;
400 bool success =
mGeometries.
at( position.
part )->insertVertex( position, vertex );
457 length += ( *geomIt )->length();
468 area += ( *geomIt )->area();
479 perimeter += ( *geomIt )->perimeter();
500 bool success =
false;
516 qDeleteAll( subtypes );
520 qDeleteAll( subtypes );
528 hasZ = hasZ || geom->
is3D();
546 if (( *it )->hasCurvedSegments() )
558 if ( !geomCollection )
567 geomCollection->
addGeometry(( *geomIt )->segmentize() );
569 return geomCollection;
QgsGeometryCollectionV2()
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
A rectangle specified with double values.
virtual bool insertVertex(QgsVertexId position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
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 bool insertGeometry(QgsAbstractGeometryV2 *g, int index)
Inserts a geometry before a specified index and takes ownership.
QgsGeometryCollectionV2 & operator=(const QgsGeometryCollectionV2 &c)
virtual QgsAbstractGeometryV2 & operator=(const QgsAbstractGeometryV2 &geom)
QDomNode appendChild(const QDomNode &newChild)
virtual QgsCoordinateSequenceV2 coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
void append(const T &value)
void push_back(const T &value)
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
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.
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void insert(int i, const T &value)
Abstract base class for all geometries.
virtual ~QgsGeometryCollectionV2()
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform) override
Transforms the geometry using a coordinate transform.
static QStringList wktGetChildBlocks(const QString &wkt, const QString &defaultType="")
Parses a WKT string and returns of list of blocks contained in the WKT.
virtual bool wktOmitChildType() const
Returns whether child type names are omitted from Wkt representations of the collection.
static double closestSegmentFromComponents(T &container, componentType ctype, const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon)
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
Multi point geometry collection.
QDomElement createElementNS(const QString &nsURI, const QString &qName)
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
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 QgsAbstractGeometryV2 * geomFromWkb(QgsConstWkbPtr wkb)
Construct geometry from a WKB string.
static endian_t endian()
Returns whether this machine uses big or little endian.
Multi line string geometry collection.
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.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const override
Returns next vertex id and coordinates.
QgsWKBTypes::Type readHeader() const
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)
static Type dropZ(Type type)
Drops the z dimension (if present) for a WKB type and returns the new type.
QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML3 representation of the geometry.
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type.
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, with support for z-dimension and m-values.
bool isEmpty() const
Returns true if the geometry is empty.
Point geometry type, with support for z-dimension and m-values.
QgsWKBTypes::Type mWkbType
double vertexAngle(QgsVertexId vertex) const override
Returns approximate rotation angle for a vertex.
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 void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform)=0
Transforms the geometry using a coordinate transform.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
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.
virtual bool dropMValue() override
Drops any measure values which exist in the geometry.
static QgsAbstractGeometryV2 * geomFromWkbType(QgsWKBTypes::Type t)
Return empty geometry from wkb type.
virtual bool dropZValue() override
Drops any z-dimensions which exist in the geometry.
virtual double length() const override
Returns the length of the geometry.
QString asJSON(int precision=17) const override
Returns a GeoJSON representation of the geometry.
Compound curve geometry type.
virtual bool moveVertex(QgsVertexId position, const QgsPointV2 &newPos) override
Moves a vertex within the geometry.
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.
virtual bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
virtual bool deleteVertex(QgsVertexId position) override
Deletes a vertex within the geometry.
QVector< QgsAbstractGeometryV2 * > mGeometries
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
static Type dropM(Type type)
Drops the m dimension (if present) for a WKB type and returns the new type.
virtual void clearCache() const override
Clears any cached parameters associated with the geometry, eg bounding boxes.
int numGeometries() const
Returns the number of geometries within the collection.
const T & at(int i) const
const_iterator constBegin() const
virtual bool addMValue(double mValue=0) override
Adds a measure to the geometry, initialized to a preset value.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
QString mid(int position, int n) const
virtual QgsGeometryCollectionV2 * 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.
virtual QgsRectangle boundingBox() const override
Returns the minimal bounding box for 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.
bool fromWkb(QgsConstWkbPtr wkb) override
Sets the geometry from a WKB string.
static Type flatType(Type type)
Returns the flat type for a WKB type.
Multi polygon geometry collection.
virtual bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
static Type parseType(const QString &wktStr)
Attempts to extract the WKB type from a WKT string.
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.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual double perimeter() const override
Returns the perimeter of the geometry.
virtual QgsRectangle calculateBoundingBox() const override
Default calculator for the minimal bounding box for the geometry.
virtual int dimension() const override
Returns the inherent dimension of the geometry.