39 for (
int i = 0; i < nGeoms; ++i )
53 for (
int i = 0; i < nGeoms; ++i )
141 int dim = ( *it )->dimension();
169 void QgsGeometryCollectionV2::clip(
const QgsRectangle& rect )
174 ( *it )->clip( rect );
198 wkbPtr >> nGeometries;
202 for (
int i = 0; i < nGeometries; ++i )
216 qDeleteAll( geometryListBackup );
235 int size =
sizeof( char ) +
sizeof( quint32 ) +
sizeof( quint32 );
249 unsigned char* geomPtr =
new unsigned char[binarySize];
252 wkb << static_cast<quint32>(
wkbType() );
259 unsigned char* geomWkb = geom->
asWkb( geomWkbLen );
260 memcpy( wkb, geomWkb, geomWkbLen );
276 childWkt = childWkt.
mid( childWkt.
indexOf(
'(' ) );
278 wkt += childWkt +
',';
295 elemMultiGeometry.
appendChild( elemGeometryMember );
297 return elemMultiGeometry;
307 elemMultiGeometry.
appendChild( elemGeometryMember );
309 return elemMultiGeometry;
314 QString json =
"{\"type\": \"GeometryCollection\", \"geometries\": [";
317 json += geom->
asJSON( precision ) +
", ";
329 if ( mBoundingBox.
isNull() )
354 if ( !mCoordinateSequence.
isEmpty() )
355 return mCoordinateSequence;
363 for ( ; cIt != geomCoords.
constEnd(); ++cIt )
369 return mCoordinateSequence;
374 if ( !mCoordinateSequence.
isEmpty() )
382 count += ( *geomIt )->nCoordinates();
428 bool success =
mGeometries.
at( position.
part )->insertVertex( position, vertex );
485 length += ( *geomIt )->length();
496 area += ( *geomIt )->area();
507 perimeter += ( *geomIt )->perimeter();
528 bool success =
false;
544 qDeleteAll( subtypes );
548 qDeleteAll( subtypes );
556 hasZ = hasZ || geom->
is3D();
574 if (( *it )->hasCurvedSegments() )
586 if ( !geomCollection )
595 geomCollection->
addGeometry(( *geomIt )->segmentize( tolerance, toleranceType ) );
597 return geomCollection;
QString wktTypeStr() const
Returns the WKT type string of the geometry.
QgsGeometryCollectionV2()
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
A rectangle specified with double values.
int numGeometries() const
Returns the number of geometries within the collection.
virtual QgsAbstractGeometryV2 * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
virtual bool insertVertex(QgsVertexId position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry.
bool isEmpty() const
Returns true if the geometry is empty.
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.
Multi curve geometry collection.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
const_iterator constEnd() const
virtual QString asJSON(int precision=17) const =0
Returns a GeoJSON representation of the geometry.
void insert(int i, const T &value)
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 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.
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 wktOmitChildType() const
Returns whether child type names are omitted from Wkt representations of the collection.
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.
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.
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
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.
Line string geometry type, with support for z-dimension and m-values.
bool isMeasure() const
Returns true if the geometry contains m values.
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.
Multi surface geometry collection.
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 int nCoordinates() const override
Returns the number of nodes contained in the geometry.
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.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
virtual double area() const override
Returns the area of the geometry.
virtual bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
void combineExtentWith(const QgsRectangle &rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
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.
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.
bool fromCollectionWkt(const QString &wkt, const QList< QgsAbstractGeometryV2 *> &subtypes, const QString &defaultChildWkbType=QString())
Reads a collection from a WKT string.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
QString mid(int position, int n) const
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) override
Transforms the geometry using a coordinate transform.
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
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.
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
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.
QgsAbstractGeometryV2 * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
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.
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.
Curve polygon geometry type.
QgsWKBTypes::Type readHeader() const
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
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 void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)=0
Transforms the geometry using a coordinate transform.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
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.