39 for (
int i = 0; i < nGeoms; ++i )
52 for (
int i = 0; i < nGeoms; ++i )
139 int dim = ( *it )->dimension();
153 ( *it )->transform( ct, d );
162 ( *it )->transform( t );
167 void QgsGeometryCollectionV2::clip(
const QgsRectangle& rect )
172 ( *it )->clip( rect );
196 wkbPtr >> nGeometries;
199 for (
int i = 0; i < nGeometries; ++i )
204 geometryList.
append( geom );
210 for (
int i = 0; i < geometryList.
size(); ++i )
228 int size =
sizeof( char ) +
sizeof( quint32 ) +
sizeof( quint32 );
242 unsigned char* geomPtr =
new unsigned char[binarySize];
245 wkb << static_cast<quint32>(
wkbType() );
252 unsigned char* geomWkb = geom->
asWkb( geomWkbLen );
253 memcpy( wkb, geomWkb, geomWkbLen );
269 childWkt = childWkt.
mid( childWkt.
indexOf(
"(" ) );
271 wkt += childWkt +
",";
288 elemMultiGeometry.
appendChild( elemGeometryMember );
290 return elemMultiGeometry;
300 elemMultiGeometry.
appendChild( elemGeometryMember );
302 return elemMultiGeometry;
307 QString json =
"{\"type\": \"GeometryCollection\", \"geometries\": [";
310 json += geom->
asJSON( precision ) +
", ";
343 ( *geomIt )->coordinateSequence( geomCoords );
345 for ( ; cIt != geomCoords.
constEnd(); ++cIt )
347 coord.push_back( *cIt );
361 id.part = 0;
id.ring = -1;
id.vertex = -1;
373 ++
id.part;
id.ring = -1;
id.vertex = -1;
384 bool success =
mGeometries[position.
part]->insertVertex( position, vertex );
399 bool success =
mGeometries[position.
part]->moveVertex( position, newPos );
441 length += ( *geomIt )->length();
452 area += ( *geomIt )->area();
463 perimeter += ( *geomIt )->perimeter();
484 bool success =
false;
500 qDeleteAll( subtypes );
504 qDeleteAll( subtypes );
512 hasZ = hasZ || geom->
is3D();
530 if (( *it )->hasCurvedSegments() )
542 if ( !geomCollection )
544 delete geom;
return clone();
550 geomCollection->
addGeometry(( *geomIt )->segmentize() );
552 return geomCollection;
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.
virtual double vertexAngle(const QgsVertexId &vertex) const =0
Returns approximate rotation angle for a vertex.
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.
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)
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.
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.
TransformDirection
Enum used to indicate the direction (forward or inverse) of the transform.
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.
Multi point geometry collection.
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.
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.
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.
double vertexAngle(const QgsVertexId &vertex) const override
Returns approximate rotation angle for a vertex.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
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.
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
QgsWKBTypes::Type mWkbType
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
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 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.
static QgsAbstractGeometryV2 * geomFromWkbType(QgsWKBTypes::Type t)
Return empty geometry from wkb type.
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.
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
virtual bool addMValue(double mValue=0) override
Adds a measure to the geometry, initialized to a preset value.
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.
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.
QgsRectangle mBoundingBox
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)
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
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type.
virtual double perimeter() const override
Returns the perimeter of the geometry.
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.