27 #include <QPainterPath>
103 int currentCurveSize = 0;
104 for (
int i = 0; i < nRings; ++i )
109 wkbPtr -= ( 1 +
sizeof( int ) );
128 currentCurve->
fromWkb( wkbPtr );
129 currentCurveSize = currentCurve->
wkbSize();
138 wkbPtr += currentCurveSize;
193 int size =
sizeof( char ) +
sizeof( quint32 ) +
sizeof( quint32 );
208 unsigned char* geomPtr =
new unsigned char[binarySize];
211 wkb << static_cast<quint32>(
wkbType() );
217 memcpy( wkb, ringWkb, curveWkbLen );
223 unsigned char* ringWkb = curve->
asWkb( curveWkbLen );
224 memcpy( wkb, ringWkb, curveWkbLen );
239 childWkt = childWkt.
mid( childWkt.
indexOf(
"(" ) );
241 wkt += childWkt +
",";
246 if ( dynamic_cast<const QgsLineStringV2*>( curve ) )
249 childWkt = childWkt.
mid( childWkt.
indexOf(
"(" ) );
251 wkt += childWkt +
",";
267 elemOuterBoundaryIs.
appendChild( exteriorLineString->
asGML2( doc, precision, ns ) );
268 delete exteriorLineString;
274 elemInnerBoundaryIs.
appendChild( interiorLineString->
asGML2( doc, precision, ns ) );
275 delete interiorLineString;
293 return elemCurvePolygon;
299 QString json =
"{\"type\": \"Polygon\", \"coordinates\": [";
303 exteriorLineString->
points( exteriorPts );
305 delete exteriorLineString;
311 interiorLineString->
points( interiorPts );
313 delete interiorLineString;
334 area -= ( *ringIt )->area();
346 length += ( *ringIt )->length();
388 rings.
push_back(( *it )->curveToLine() );
471 ( *it )->addToPainterPath( path );
487 ( *it )->transform( ct );
501 ( *it )->transform( t );
514 coordinates.
append( ringCoords );
520 ( *it )->points( ringCoords );
521 coordinates.
append( ringCoords );
523 coord.append( coordinates );
586 else if ( vId.
vertex == n )
601 bool success = ring->
moveVertex( vId, newPos );
607 else if ( vId.
vertex == n - 1 )
633 else if ( vId.
vertex == n - 1 )
650 if (( *it )->hasCurvedSegments() )
const QgsCurveV2 * exteriorRing() const
bool removeInteriorRing(int nr)
Removes ring.
bool hasCurvedSegments() const override
Returns true if the geometry contains curved segments.
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 deleteVertex(const QgsVertexId &position) override
Deletes a vertex within the geometry.
QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML2 representation of 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 moveVertex(const QgsVertexId &position, const QgsPointV2 &newPos) override
Moves a vertex within the geometry.
QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML2 representation of the geometry.
virtual QgsRectangle calculateBoundingBox() const override
Calculates the minimal bounding box for the geometry.
virtual QgsAbstractGeometryV2 & operator=(const QgsAbstractGeometryV2 &geom)
QDomNode appendChild(const QDomNode &newChild)
void addInteriorRing(QgsCurveV2 *ring)
Adds an interior ring to the geometry (takes ownership)
void transform(const QgsCoordinateTransform &ct) override
Transforms the geometry using a coordinate transform.
void push_back(const T &value)
void clear() override
Clears the geometry, ie reset it to a null geometry.
void points(QList< QgsPointV2 > &pt) const override
Returns a list of points within the curve.
virtual bool moveVertex(const QgsVertexId &position, const QgsPointV2 &newPos)=0
Moves a vertex within the geometry.
Circular string geometry type.
virtual double length() const
Returns the length (or perimeter for area geometries) of the geometry.
QgsPolygonV2 * surfaceToPolygon() const override
virtual void points(QList< QgsPointV2 > &pt) const =0
Returns a list of points within the curve.
const T & at(int i) const
static QString pointsToJSON(const QList< QgsPointV2 > &points, int precision)
Returns a geoJSON coordinates string.
virtual void addToPainterPath(QPainterPath &path) const =0
Adds a curve to a painter path.
Abstract base class for all geometries.
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)
QDomElement createElementNS(const QString &nsURI, const QString &qName)
QgsPointV2 vertexAt(const QgsVertexId &id) const
Returns the point corresponding to a specified vertex id.
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.
virtual double length() const override
Returns the length (or perimeter for area geometries) of the geometry.
virtual void coordinateSequence(QList< QList< QList< QgsPointV2 > > > &coord) const override
Retrieves the sequence of geometries, rings and nodes.
virtual bool insertVertex(const QgsVertexId &position, const QgsPointV2 &vertex)=0
Inserts a vertex into the geometry.
virtual QgsAbstractGeometryV2 * clone() const override
Clones the geometry by performing a deep copy.
virtual int numPoints() const =0
Returns the number of points in the curve.
QgsWKBTypes::Type readHeader() const
int wkbSize() const override
Returns the size of the WKB representation of the geometry.
static Type flatType(Type type)
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
void append(const T &value)
virtual bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
virtual QString geometryType() const override
Returns a unique string representing the geometry type.
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.
virtual QgsRectangle calculateBoundingBox() const
Calculates the minimal bounding box for the geometry.
virtual bool fromWkb(const unsigned char *wkb)=0
Sets the geometry from a WKB string.
QgsWKBTypes::Type mWkbType
QString asWkt(int precision=17) const override
Returns a WKT representation of the geometry.
QgsCurvePolygonV2 & operator=(const QgsCurvePolygonV2 &p)
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
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 QgsPolygonV2 * toPolygon() const
void setZMTypeFromSubGeometry(const QgsAbstractGeometryV2 *subggeom, QgsWKBTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
virtual 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.
virtual void draw(QPainter &p) const override
Draws the geometry using the specified QPainter.
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.
Compound curve geometry type.
const QgsCurveV2 * interiorRing(int i) const
virtual bool fromWkb(const unsigned char *wkb) override
Sets the geometry from a WKB string.
bool nextVertex(QgsVertexId &id, QgsPointV2 &vertex) const override
Returns next vertex id and coordinates.
virtual bool deleteVertex(const QgsVertexId &position)=0
Deletes a vertex within the geometry.
QList< QgsCurveV2 * > mInteriorRings
virtual QgsLineStringV2 * curveToLine() const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
QString asJSON(int precision=17) const override
Returns a GeoJSON representation of the geometry.
QString mid(int position, int n) const
void drawPath(const QPainterPath &path)
void setExteriorRing(QgsCurveV2 *ring)
Sets exterior ring (takes ownership)
QgsPointV2 pointOnSurface() const override
virtual double area() const override
Returns the area of the geometry.
virtual void transform(const QgsCoordinateTransform &ct)=0
Transforms the geometry using a coordinate transform.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
QgsRectangle mBoundingBox
QgsPointV2 centroid() const override
virtual void drawAsPolygon(QPainter &p) const =0
Draws the curve as a polygon on the specified QPainter.
static Type parseType(const QString &wktStr)
QgsAbstractGeometryV2 * segmentize() const override
Returns a version of the geometry without curves.
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.
virtual bool insertVertex(const QgsVertexId &position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry.
const_iterator constEnd() const
int numInteriorRings() const
const_iterator constBegin() const
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
Abstract base class for curved geometry type.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML3 representation of the geometry.
virtual double area() const override
Returns the area of the geometry.
void setInteriorRings(QList< QgsCurveV2 * > rings)
Sets all interior rings (takes ownership)
QgsCurveV2 * mExteriorRing