28 #include <QProgressDialog>
31 const QString& shapefileName,
33 bool onlySelectedFeatures,
54 if ( onlySelectedFeatures )
60 p->setMaximum( selection.size() );
63 int processedFeatures = 0;
64 QgsFeatureIds::const_iterator it = selection.constBegin();
65 for ( ; it != selection.constEnd(); ++it )
69 p->setValue( processedFeatures );
72 if ( p && p->wasCanceled() )
86 p->setValue( selection.size() );
97 p->setMaximum( featureCount );
99 int processedFeatures = 0;
105 p->setValue( processedFeatures );
107 if ( p && p->wasCanceled() )
116 p->setValue( featureCount );
128 if ( !featureGeometry )
133 tmpGeometry = featureGeometry->
simplify( tolerance );
147 bool onlySelectedFeatures, QProgressDialog* p )
158 QgsDebugMsg(
"No data provider for layer passed to centroids" );
169 if ( onlySelectedFeatures )
175 p->setMaximum( selection.size() );
178 int processedFeatures = 0;
179 QgsFeatureIds::const_iterator it = selection.constBegin();
180 for ( ; it != selection.constEnd(); ++it )
184 p->setValue( processedFeatures );
187 if ( p && p->wasCanceled() )
201 p->setValue( selection.size() );
212 p->setMaximum( featureCount );
214 int processedFeatures = 0;
220 p->setValue( processedFeatures );
222 if ( p && p->wasCanceled() )
231 p->setValue( featureCount );
244 if ( !featureGeometry )
249 tmpGeometry = featureGeometry->
centroid();
263 const QString& shapefileName,
264 bool onlySelectedFeatures,
289 fields.
append(
QgsField( QString(
"PERIM" ), QVariant::Double ) );
290 fields.
append(
QgsField( QString(
"HEIGHT" ), QVariant::Double ) );
291 fields.
append(
QgsField( QString(
"WIDTH" ), QVariant::Double ) );
296 if ( onlySelectedFeatures )
306 double miny = rect.yMinimum();
307 double maxx = rect.xMaximum();
308 double maxy = rect.yMaximum();
309 double height = rect.height();
310 double width = rect.width();
311 double cntx = minx + ( width / 2.0 );
312 double cnty = miny + ( height / 2.0 );
313 double area = width * height;
314 double perim = ( 2 * width ) + ( 2 * height );
318 attrs[0] = QVariant( minx );
319 attrs[1] = QVariant( miny );
320 attrs[2] = QVariant( maxx );
321 attrs[3] = QVariant( maxy );
322 attrs[4] = QVariant( cntx );
323 attrs[5] = QVariant( cnty );
324 attrs[6] = QVariant( area );
325 attrs[7] = QVariant( perim );
326 attrs[8] = QVariant( height );
327 attrs[9] = QVariant( width );
330 vWriter.addFeature( feat );
341 list.append( pt.
x() );
342 list.append( pt.
y() );
347 list.append( measure.
measure( mpGeometry ) );
351 list.append( perim );
363 QgsMultiPolygon::iterator it;
364 QgsPolygon::iterator jt;
365 for ( it = poly.begin(); it != poly.end(); ++it )
367 for ( jt = it->begin(); jt != it->end(); ++jt )
375 QgsPolygon::iterator jt;
377 for ( jt = poly.begin(); jt != poly.end(); ++jt )
386 bool onlySelectedFeatures,
int uniqueIdField, QProgressDialog* p )
397 bool useField =
false;
398 if ( uniqueIdField == -1 )
409 fields.
append(
QgsField( QString(
"PERIM" ), QVariant::Double ) );
417 QMultiMap<QString, QgsFeatureId> map;
419 if ( onlySelectedFeatures )
423 QgsFeatureIds::const_iterator it = selection.constBegin();
424 for ( ; it != selection.constEnd(); ++it )
429 p->setValue( processedFeatures );
431 if ( p && p->wasCanceled() )
441 map.insert( currentFeature.attribute( uniqueIdField ).toString(), currentFeature.id() );
452 p->setValue( processedFeatures );
454 if ( p && p->wasCanceled() )
460 map.insert( currentFeature.attribute( uniqueIdField ).toString(), currentFeature.id() );
464 QMultiMap<QString, QgsFeatureId>::const_iterator jt = map.constBegin();
465 while ( jt != map.constEnd() )
467 QString currentKey = jt.key();
468 int processedFeatures = 0;
470 if ( onlySelectedFeatures )
476 p->setMaximum( selection.size() );
478 processedFeatures = 0;
479 while ( jt != map.constEnd() && ( jt.key() == currentKey || !useField ) )
481 if ( p && p->wasCanceled() )
485 if ( selection.contains( jt.value() ) )
489 p->setValue( processedFeatures );
495 convexFeature( currentFeature, processedFeatures, &dissolveGeometry );
500 QList<double> values;
501 if ( !dissolveGeometry )
503 QgsDebugMsg(
"no dissolved geometry - should not happen" );
506 dissolveGeometry = dissolveGeometry->
convexHull();
509 attributes[0] = QVariant( currentKey );
510 attributes[1] = values[ 0 ];
511 attributes[2] = values[ 1 ];
515 vWriter.addFeature( dissolveFeature );
523 p->setMaximum( featureCount );
525 processedFeatures = 0;
526 while ( jt != map.constEnd() && ( jt.key() == currentKey || !useField ) )
530 p->setValue( processedFeatures );
533 if ( p && p->wasCanceled() )
541 convexFeature( currentFeature, processedFeatures, &dissolveGeometry );
545 QList<double> values;
547 if ( !dissolveGeometry )
549 QgsDebugMsg(
"no dissolved geometry - should not happen" );
552 dissolveGeometry = dissolveGeometry->
convexHull();
556 attributes[0] = QVariant( currentKey );
557 attributes[1] = QVariant( values[ 0 ] );
558 attributes[2] = QVariant( values[ 1 ] );
562 vWriter.addFeature( dissolveFeature );
575 if ( !featureGeometry )
580 convexGeometry = featureGeometry->
convexHull();
582 if ( nProcessedFeatures == 0 )
584 *dissolveGeometry = convexGeometry;
588 tmpGeometry = *dissolveGeometry;
589 *dissolveGeometry = ( *dissolveGeometry )->
combine( convexGeometry );
591 delete convexGeometry;
596 bool onlySelectedFeatures,
int uniqueIdField, QProgressDialog* p )
607 bool useField =
false;
608 if ( uniqueIdField == -1 )
622 QMultiMap<QString, QgsFeatureId> map;
624 if ( onlySelectedFeatures )
628 QgsFeatureIds::const_iterator it = selection.constBegin();
629 for ( ; it != selection.constEnd(); ++it )
635 map.insert( currentFeature.attribute( uniqueIdField ).toString(), currentFeature.id() );
643 map.insert( currentFeature.attribute( uniqueIdField ).toString(), currentFeature.id() );
648 QMultiMap<QString, QgsFeatureId>::const_iterator jt = map.constBegin();
650 while ( jt != map.constEnd() )
652 QString currentKey = jt.key();
653 int processedFeatures = 0;
656 if ( onlySelectedFeatures )
662 p->setMaximum( selection.size() );
664 while ( jt != map.constEnd() && ( jt.key() == currentKey || !useField ) )
666 if ( p && p->wasCanceled() )
670 if ( selection.contains( jt.value() ) )
674 p->setValue( processedFeatures );
685 dissolveFeature( currentFeature, processedFeatures, &dissolveGeometry );
697 p->setMaximum( featureCount );
699 while ( jt != map.constEnd() && ( jt.key() == currentKey || !useField ) )
703 p->setValue( processedFeatures );
706 if ( p && p->wasCanceled() )
718 dissolveFeature( currentFeature, processedFeatures, &dissolveGeometry );
724 vWriter.addFeature( outputFeature );
733 if ( !featureGeometry )
738 if ( nProcessedFeatures == 0 )
740 size_t geomSize = featureGeometry->
wkbSize();
742 unsigned char* wkb =
new unsigned char[geomSize];
743 memcpy( wkb, featureGeometry->
asWkb(), geomSize );
744 ( *dissolveGeometry )->fromWkb( wkb, geomSize );
748 *dissolveGeometry = ( *dissolveGeometry )->
combine( featureGeometry );
753 bool onlySelectedFeatures,
bool dissolve,
int bufferDistanceField, QProgressDialog* p )
778 if ( onlySelectedFeatures )
784 p->setMaximum( selection.size() );
787 int processedFeatures = 0;
788 QgsFeatureIds::const_iterator it = selection.constBegin();
789 for ( ; it != selection.constEnd(); ++it )
793 p->setValue( processedFeatures );
796 if ( p && p->wasCanceled() )
804 bufferFeature( currentFeature, processedFeatures, &vWriter, dissolve, &dissolveGeometry, bufferDistance, bufferDistanceField );
810 p->setValue( selection.size() );
821 p->setMaximum( featureCount );
823 int processedFeatures = 0;
829 p->setValue( processedFeatures );
831 if ( p && p->wasCanceled() )
835 bufferFeature( currentFeature, processedFeatures, &vWriter, dissolve, &dissolveGeometry, bufferDistance, bufferDistanceField );
840 p->setValue( featureCount );
847 if ( !dissolveGeometry )
849 QgsDebugMsg(
"no dissolved geometry - should not happen" );
853 vWriter.addFeature( dissolveFeature );
859 QgsGeometry** dissolveGeometry,
double bufferDistance,
int bufferDistanceField )
861 double currentBufferDistance;
866 if ( !featureGeometry )
872 if ( bufferDistanceField == -1 )
874 currentBufferDistance = bufferDistance;
878 currentBufferDistance = f.
attribute( bufferDistanceField ).toDouble();
880 bufferGeometry = featureGeometry->
buffer( currentBufferDistance, 5 );
884 if ( nProcessedFeatures == 0 )
886 *dissolveGeometry = bufferGeometry;
890 tmpGeometry = *dissolveGeometry;
891 *dissolveGeometry = ( *dissolveGeometry )->
combine( bufferGeometry );
893 delete bufferGeometry;
911 const QString& outputFormat,
int locationField1,
int locationField2,
int offsetField,
double offsetScale,
914 if ( !lineLayer || !eventLayer || !lineLayer->
isValid() || !eventLayer->
isValid() )
920 QMultiHash< QString, QgsFeature > lineLayerIdMap;
925 lineLayerIdMap.insert( fet.
attribute( lineField ).toString(), fet );
931 if ( !memoryProvider )
934 if ( locationField2 == -1 )
946 &( lineLayer->
crs() ),
957 double measure1, measure2 = 0.0;
960 int featureCounter = 0;
961 int nOutputFeatures = 0;
964 p->setWindowModality( Qt::WindowModal );
966 p->setMaximum( nEventFeatures );
977 if ( p->wasCanceled() )
981 p->setValue( featureCounter );
985 measure1 = fet.
attribute( locationField1 ).toDouble();
986 if ( locationField2 != -1 )
988 measure2 = fet.
attribute( locationField2 ).toDouble();
995 QList<QgsFeature> featureIdList = lineLayerIdMap.values( fet.
attribute( eventField ).toString() );
996 QList<QgsFeature>::const_iterator featureIdIt = featureIdList.constBegin();
997 for ( ; featureIdIt != featureIdList.constEnd(); ++featureIdIt )
999 if ( locationField2 == -1 )
1011 addEventLayerFeature( fet, lrsGeom, featureIdIt->geometry(), fileWriter, memoryProviderFeatures, offsetField, offsetScale, forceSingleGeometry );
1014 if ( nOutputFeatures < 1 )
1016 unlocatedFeatureIds.insert( fet.
id() );
1022 p->setValue( nEventFeatures );
1025 if ( memoryProvider )
1027 memoryProvider->
addFeatures( memoryProviderFeatures );
1034 int offsetField,
double offsetScale,
bool forceSingleType )
1041 QList<QgsGeometry*> geomList;
1042 if ( forceSingleType )
1048 geomList.push_back( geom );
1051 QList<QgsGeometry*>::iterator geomIt = geomList.begin();
1052 for ( ; geomIt != geomList.end(); ++geomIt )
1055 if ( offsetField >= 0 )
1057 double offsetVal = feature.
attribute( offsetField ).toDouble();
1058 offsetVal *= offsetScale;
1073 memoryFeatures << feature;
1077 if ( forceSingleType )
1085 if ( !geom || !lineGeom )
1090 QList<QgsGeometry*> inputGeomList;
1098 inputGeomList.push_back( geom );
1101 QList<GEOSGeometry*> outputGeomList;
1102 QList<QgsGeometry*>::const_iterator inputGeomIt = inputGeomList.constBegin();
1103 for ( ; inputGeomIt != inputGeomList.constEnd(); ++inputGeomIt )
1108 #if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
1109 ((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
1110 GEOSGeometry* offsetGeom = GEOSOffsetCurve(( *inputGeomIt )->asGeos(), -offset, 8 , 0 , 5.0 );
1111 if ( !offsetGeom || !GEOSisValid( offsetGeom ) )
1115 if ( !GEOSisValid( offsetGeom ) || GEOSGeomTypeId( offsetGeom ) != GEOS_LINESTRING || GEOSGeomGetNumPoints( offsetGeom ) < 1 )
1117 GEOSGeom_destroy( offsetGeom );
1120 outputGeomList.push_back( offsetGeom );
1122 outputGeomList.push_back( GEOSGeom_clone(( *inputGeomIt )->asGeos() ) );
1127 QgsPoint p = ( *inputGeomIt )->asPoint();
1129 GEOSCoordSequence* ptSeq = GEOSCoordSeq_create( 1, 2 );
1130 GEOSCoordSeq_setX( ptSeq, 0, p.
x() );
1131 GEOSCoordSeq_setY( ptSeq, 0, p.
y() );
1132 GEOSGeometry* geosPt = GEOSGeom_createPoint( ptSeq );
1133 outputGeomList.push_back( geosPt );
1139 GEOSGeometry* outputGeom = outputGeomList.at( 0 );
1147 GEOSGeometry** geomArray =
new GEOSGeometry*[outputGeomList.size()];
1148 for (
int i = 0; i < outputGeomList.size(); ++i )
1150 geomArray[i] = outputGeomList.at( i );
1152 GEOSGeometry* collection = 0;
1155 collection = GEOSGeom_createCollection( GEOS_MULTIPOINT, geomArray, outputGeomList.size() );
1159 collection = GEOSGeom_createCollection( GEOS_MULTILINESTRING, geomArray, outputGeomList.size() );
1174 int beforeVertexNr = afterVertexNr - 1;
1179 double dx = afterVertex.
x() - beforeVertex.
x();
1180 double dy = afterVertex.
y() - beforeVertex.
y();
1181 double normalX = -dy;
1182 double normalY = dx;
1183 double normalLength = sqrt( normalX * normalX + normalY * normalY );
1184 normalX *= ( dist / normalLength );
1185 normalY *= ( dist / normalLength );
1187 double debugLength = sqrt( normalX * normalX + normalY * normalY );
1188 Q_UNUSED( debugLength );
1189 return QgsPoint( x - normalX, y - normalY );
1202 const unsigned char* lineWkb = lineGeom->
asWkb();
1204 const unsigned char* ptr = lineWkb + 1;
1206 memcpy( &wkbType, ptr,
sizeof( wkbType ) );
1207 ptr +=
sizeof( wkbType );
1220 int* nLines = (
int* )ptr;
1221 ptr +=
sizeof( int );
1222 for (
int i = 0; i < *nLines; ++i )
1224 ptr += ( 1 +
sizeof( wkbType ) );
1229 if ( resultGeom.size() < 1 )
1246 const unsigned char* lineWkb = lineGeom->
asWkb();
1248 const unsigned char* ptr = lineWkb + 1;
1250 memcpy( &wkbType, ptr,
sizeof( wkbType ) );
1251 ptr +=
sizeof( wkbType );
1264 int* nLines = (
int* )ptr;
1265 ptr +=
sizeof( int );
1266 for (
int i = 0; i < *nLines; ++i )
1268 ptr += ( 1 +
sizeof( wkbType ) );
1273 if ( resultGeom.size() < 1 )
1282 int* nPoints = (
int* ) ptr;
1283 ptr +=
sizeof( int );
1284 double prevx = 0.0, prevy = 0.0, prevz = 0.0;
1289 bool measureInSegment;
1290 bool secondPointClipped;
1293 for (
int i = 0; i < *nPoints; ++i )
1296 ptr +=
sizeof( double );
1298 ptr +=
sizeof( double );
1299 z = (
double* ) ptr;
1300 ptr +=
sizeof( double );
1304 measureInSegment =
clipSegmentByRange( prevx, prevy, prevz, *x, *y, *z, fromMeasure, toMeasure, pt1, pt2, secondPointClipped );
1305 if ( measureInSegment )
1307 if ( currentLine.size() < 1 )
1309 currentLine.append( pt1 );
1314 currentLine.append( pt2 );
1317 if ( secondPointClipped || i == *nPoints - 1 )
1319 if ( currentLine.size() > 1 )
1321 result.append( currentLine );
1323 currentLine.clear();
1327 prevx = *x; prevy = *y; prevz = *z;
1334 int* nPoints = (
int* ) ptr;
1335 ptr +=
sizeof( int );
1336 double prevx = 0.0, prevy = 0.0, prevz = 0.0;
1342 for (
int i = 0; i < *nPoints; ++i )
1345 ptr +=
sizeof( double );
1347 ptr +=
sizeof( double );
1348 z = (
double* ) ptr;
1349 ptr +=
sizeof( double );
1353 locateAlongSegment( prevx, prevy, prevz, *x, *y, *z, measure, pt1Ok, pt1, pt2Ok, pt2 );
1356 result.append( pt1 );
1358 if ( pt2Ok && ( i == ( *nPoints - 1 ) ) )
1360 result.append( pt2 );
1363 prevx = *x; prevy = *y; prevz = *z;
1369 QgsPoint& pt2,
bool& secondPointClipped )
1371 bool reversed = m1 > m2;
1391 if ( range1 > range2 )
1399 if ( m2 < range1 || m1 > range2 )
1405 if ( m2 <= range2 && m1 >= range1 )
1417 secondPointClipped =
false;
1422 if ( m1 >= range1 && m1 <= range2 )
1425 double dist = ( range2 - m1 ) / ( m2 - m1 );
1426 pt2.
setX( x1 + ( x2 - x1 ) * dist );
1427 pt2.
setY( y1 + ( y2 - y1 ) * dist );
1428 secondPointClipped = !reversed;
1432 if ( m2 >= range1 && m2 <= range2 )
1435 double dist = ( m2 - range1 ) / ( m2 - m1 );
1436 pt1.
setX( x2 - ( x2 - x1 ) * dist );
1437 pt1.
setY( y2 - ( y2 - y1 ) * dist );
1438 secondPointClipped = reversed;
1442 if ( range1 >= m1 && range2 <= m2 )
1444 double dist1 = ( range1 - m1 ) / ( m2 - m1 );
1445 double dist2 = ( range2 - m1 ) / ( m2 - m1 );
1446 pt1.
setX( x1 + ( x2 - x1 ) * dist1 );
1447 pt1.
setY( y1 + ( y2 - y1 ) * dist1 );
1448 pt2.
setX( x1 + ( x2 - x1 ) * dist2 );
1449 pt2.
setY( y1 + ( y2 - y1 ) * dist2 );
1450 secondPointClipped =
true;
1463 void QgsGeometryAnalyzer::locateAlongSegment(
double x1,
double y1,
double m1,
double x2,
double y2,
double m2,
double measure,
bool& pt1Ok,
QgsPoint& pt1,
bool& pt2Ok,
QgsPoint& pt2 )
1465 bool reversed =
false;
1468 double tolerance = 0.000001;
1479 if (( m1 - measure ) > tolerance || ( measure - m2 ) > tolerance )
1517 if ( pt1Ok || pt2Ok )
1530 double dist = ( measure - m1 ) / ( m2 - m1 );
1536 pt1.
setX( x1 + dist * ( x2 - x1 ) );
1537 pt1.
setY( y1 + dist * ( y2 - y1 ) );
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
QgsFeatureId id() const
Get the feature id for this feature.
Wrapper for iterator of features from vector data provider or vector layer.
void addEventLayerFeature(QgsFeature &feature, QgsGeometry *geom, QgsGeometry *lineGeom, QgsVectorFileWriter *fileWriter, QgsFeatureList &memoryFeatures, int offsetField=-1, double offsetScale=1.0, bool forceSingleType=false)
bool eventLayer(QgsVectorLayer *lineLayer, QgsVectorLayer *eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds, const QString &outputLayer, const QString &outputFormat, int locationField1, int locationField2=-1, int offsetField=-1, double offsetScale=1.0, bool forceSingleGeometry=false, QgsVectorDataProvider *memoryProvider=0, QProgressDialog *p=0)
Creates an event layer (multipoint or multiline) by locating features from a (non-spatial) event tabl...
A rectangle specified with double values.
virtual bool addAttributes(const QList< QgsField > &attributes)
Adds new attributes.
static bool clipSegmentByRange(double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPoint &pt1, QgsPoint &pt2, bool &secondPointClipped)
static void locateAlongSegment(double x1, double y1, double m1, double x2, double y2, double m2, double measure, bool &pt1Ok, QgsPoint &pt1, bool &pt2Ok, QgsPoint &pt2)
QgsGeometry * combine(QgsGeometry *geometry)
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
bool dissolve(QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, int uniqueIdField=-1, QProgressDialog *p=0)
Dissolve a vector layer and write it to a new shape file.
size_t wkbSize() const
Returns the size of the WKB in asWkb().
QSet< QgsFeatureId > QgsFeatureIds
bool isMultipart()
Returns true if wkb of the geometry is of WKBMulti* type.
QList< QgsFeature > QgsFeatureList
QList< double > simpleMeasure(QgsGeometry *geometry)
const unsigned char * locateAlongWkbString(const unsigned char *ptr, QgsMultiPoint &result, double measure)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
bool extent(QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, QProgressDialog *p=0)
Create a polygon based on the extent of all (selected) features and write it to a new shape file...
QgsPolygon asPolygon() const
return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list ...
QList< QgsGeometry * > asGeometryCollection() const
return contents of the geometry as a list of geometries
double closestSegmentWithContext(const QgsPoint &point, QgsPoint &minDistPoint, int &afterVertex, double *leftOf=0, double epsilon=DEFAULT_SEGMENT_EPSILON)
Searches for the closest segment of geometry to the given point.
QGis::GeometryType type()
Returns type of the vector.
QgsGeometry * locateAlongMeasure(double measure, QgsGeometry *lineGeom)
Returns linear reference geometry.
Container of fields for a vector layer.
void setAttributes(const QgsAttributes &attrs)
WkbType
Used for symbology operations.
A convenience class for writing vector files to disk.
void bufferFeature(QgsFeature &f, int nProcessedFeatures, QgsVectorFileWriter *vfw, bool dissolve, QgsGeometry **dissolveGeometry, double bufferDistance, int bufferDistanceField)
Helper function to buffer an individual feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsPoint vertexAt(int atVertex)
Returns coordinates of a vertex.
virtual bool addFeatures(QgsFeatureList &flist)
Adds a list of features.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
QgsGeometry * centroid()
Returns the center of mass of a geometry.
QgsMultiPolygon asMultiPolygon() const
return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
QgsRectangle extent()
Return the extent of the layer as a QRect.
QString encoding() const
Get encoding which is used for accessing data.
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object (deep copy)
QgsGeometry * buffer(double distance, int segments)
Returns a buffer region around this geometry having the given width and with a specified number of se...
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
bool buffer(QgsVectorLayer *layer, const QString &shapefileName, double bufferDistance, bool onlySelectedFeatures=false, bool dissolve=false, int bufferDistanceField=-1, QProgressDialog *p=0)
Create buffers for a vector layer and write it to a new shape file.
double measure(QgsGeometry *geometry)
general measurement (line distance or polygon area)
QgsGeometry * convexHull()
Returns the smallest convex polygon that contains all the points in the geometry. ...
QgsGeometry * simplify(double tolerance)
Returns a simplified version of this geometry using a specified tolerance value.
QgsPoint createPointOffset(double x, double y, double dist, QgsGeometry *lineGeom) const
void centroidFeature(QgsFeature &f, QgsVectorFileWriter *vfw)
Helper function to get the cetroid of an individual feature.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QVector< QgsPolygon > QgsMultiPolygon
a collection of QgsPolygons that share a common collection of attributes
int pendingFeatureCount()
returns feature count after commit
QList< int > QgsAttributeList
QVector< QgsPoint > QgsMultiPoint
a collection of QgsPoints that share a common collection of attributes
void fromGeos(GEOSGeometry *geos)
Set the geometry, feeding in a geometry in GEOS format.
const QgsAttributes & attributes() const
bool addFeature(QgsFeature &feature, QgsFeatureRendererV2 *renderer=0, QGis::UnitType outputUnit=QGis::Meters)
add feature to the currently opened shapefile
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Append a field. The field must have unique name, otherwise it is rejected (returns false) ...
QGis::WkbType wkbType() const
Returns type of wkb (point / linestring / polygon etc.)
Encapsulate a field in an attribute table or data source.
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
void convexFeature(QgsFeature &f, int nProcessedFeatures, QgsGeometry **dissolveGeometry)
Helper function to get the convex hull of feature(s)
virtual QGis::WkbType geometryType() const =0
Get feature type.
A class to represent a point geometry.
void dissolveFeature(QgsFeature &f, int nProcessedFeatures, QgsGeometry **dissolveGeometry)
Helper function to dissolve feature(s)
const unsigned char * locateBetweenWkbString(const unsigned char *ptr, QgsMultiPolyline &result, double fromMeasure, double toMeasure)
QVector< QgsPolyline > QgsMultiPolyline
a collection of QgsPolylines that share a common collection of attributes
void simplifyFeature(QgsFeature &f, QgsVectorFileWriter *vfw, double tolerance)
Helper function to simplify an individual feature.
static QgsGeometry * fromMultiPolyline(const QgsMultiPolyline &multiline)
construct geometry from a multipolyline
bool createOffsetGeometry(QgsGeometry *geom, QgsGeometry *lineGeom, double offset)
Create geometry offset relative to line geometry.
General purpose distance and area calculator.
double perimeterMeasure(QgsGeometry *geometry, QgsDistanceArea &measure)
virtual long featureCount() const
Number of features in the layer.
bool centroids(QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, QProgressDialog *p=0)
Calculate the true centroids, or 'center of mass' for a vector layer and write it to a new shape file...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QVector< QVariant > QgsAttributes
Class for storing a coordinate reference system (CRS)
bool simplify(QgsVectorLayer *layer, const QString &shapefileName, double tolerance, bool onlySelectedFeatures=false, QProgressDialog *p=0)
Simplify vector layer using (a modified) Douglas-Peucker algorithm and write it to a new shape file...
static QgsGeometry * fromRect(const QgsRectangle &rect)
construct geometry from a rectangle
static QgsGeometry * fromMultiPoint(const QgsMultiPoint &multipoint)
construct geometry from a multipoint
static QgsGeometry * fromPolyline(const QgsPolyline &polyline)
construct geometry from a polyline
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QgsVectorDataProvider * dataProvider()
Returns the data provider.
bool nextFeature(QgsFeature &f)
This is the base class for vector data providers.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QgsPoint asPoint() const
return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
Represents a vector layer which manages a vector based data sets.
QgsGeometry * locateBetweenMeasures(double fromMeasure, double toMeasure, QgsGeometry *lineGeom)
Returns linear reference geometry as a multiline (or 0 if no match).
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.
double xMinimum() const
Get the x minimum value (left side of rectangle)
bool convexHull(QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures=false, int uniqueIdField=-1, QProgressDialog *p=0)
Create convex hull(s) of a vector layer and write it to a new shape file.
QgsRectangle boundingBoxOfSelected()
Returns the bounding box of the selected features.