24QString QgsExtentFromLayerAlgorithm::name()
 const 
   26  return QStringLiteral( 
"polygonfromlayerextent" );
 
   29QString QgsExtentFromLayerAlgorithm::displayName()
 const 
   31  return QObject::tr( 
"Extract layer extent" );
 
   34QStringList QgsExtentFromLayerAlgorithm::tags()
 const 
   36  return QObject::tr( 
"polygon,vector,raster,extent,envelope,bounds,bounding,boundary,layer,round,rounded" ).split( 
',' );
 
   39QString QgsExtentFromLayerAlgorithm::group()
 const 
   41  return QObject::tr( 
"Layer tools" );
 
   44QString QgsExtentFromLayerAlgorithm::groupId()
 const 
   46  return QStringLiteral( 
"layertools" );
 
   49QString QgsExtentFromLayerAlgorithm::shortHelpString()
 const 
   51  return QObject::tr( 
"This algorithm takes a map layer and generates a new vector " 
   52                      "layer with the minimum bounding box (rectangle polygon with " 
   53                      "N-S orientation) that covers the input layer. Optionally, the " 
   54                      "extent can be enlarged to a rounded value." );
 
   57QString QgsExtentFromLayerAlgorithm::shortDescription()
 const 
   59  return QObject::tr( 
"Generates a vector layer with the minimum bounding box that covers the input layer." );
 
   62QString QgsExtentFromLayerAlgorithm::svgIconPath()
 const 
   67QIcon QgsExtentFromLayerAlgorithm::icon()
 const 
   72QgsExtentFromLayerAlgorithm *QgsExtentFromLayerAlgorithm::createInstance()
 const 
   74  return new QgsExtentFromLayerAlgorithm();
 
   77void QgsExtentFromLayerAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   81  auto roundParam = std::make_unique<QgsProcessingParameterDistance>( QStringLiteral( 
"ROUND_TO" ), QObject::tr( 
"Round values to" ), 0, QStringLiteral( 
"INPUT" ), 0 );
 
   83  addParameter( roundParam.release() );
 
   90  QgsMapLayer *layer = parameterAsLayer( parameters, QStringLiteral( 
"INPUT" ), context );
 
   95  const double roundTo = parameterAsDouble( parameters, QStringLiteral( 
"ROUND_TO" ), context );
 
   98  fields.
append( 
QgsField( QStringLiteral( 
"MINX" ), QMetaType::Type::Double ) );
 
   99  fields.
append( 
QgsField( QStringLiteral( 
"MINY" ), QMetaType::Type::Double ) );
 
  100  fields.
append( 
QgsField( QStringLiteral( 
"MAXX" ), QMetaType::Type::Double ) );
 
  101  fields.
append( 
QgsField( QStringLiteral( 
"MAXY" ), QMetaType::Type::Double ) );
 
  102  fields.
append( 
QgsField( QStringLiteral( 
"CNTX" ), QMetaType::Type::Double ) );
 
  103  fields.
append( 
QgsField( QStringLiteral( 
"CNTY" ), QMetaType::Type::Double ) );
 
  104  fields.
append( 
QgsField( QStringLiteral( 
"AREA" ), QMetaType::Type::Double ) );
 
  105  fields.
append( 
QgsField( QStringLiteral( 
"PERIM" ), QMetaType::Type::Double ) );
 
  106  fields.
append( 
QgsField( QStringLiteral( 
"HEIGHT" ), QMetaType::Type::Double ) );
 
  107  fields.
append( 
QgsField( QStringLiteral( 
"WIDTH" ), QMetaType::Type::Double ) );
 
  110  std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, QStringLiteral( 
"OUTPUT" ), context, dest, fields, 
Qgis::WkbType::Polygon, layer->
crs() ) );
 
  114  if ( 
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer ) )
 
  131  const double minX = rect.
xMinimum();
 
  132  const double maxX = rect.
xMaximum();
 
  133  const double minY = rect.
yMinimum();
 
  134  const double maxY = rect.
yMaximum();
 
  135  const double height = rect.
height();
 
  136  const double width = rect.
width();
 
  137  const double cntX = minX + width / 2.0;
 
  138  const double cntY = minY + height / 2.0;
 
  139  const double area = width * height;
 
  140  const double perim = 2 * width + 2 * height;
 
  151  outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
@ VectorPolygon
Vector polygon layers.
 
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
 
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
 
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
 
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
 
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
 
Encapsulate a field in an attribute table or data source.
 
Container of fields for a vector layer.
 
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
 
A geometry is the spatial representation of a feature.
 
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
 
Base class for all map layer types.
 
virtual QgsRectangle extent() const
Returns the extent of the layer.
 
QgsCoordinateReferenceSystem crs
 
Contains information about the context in which a processing algorithm is executed.
 
Custom exception class for processing related exceptions.
 
Base class for providing feedback from a processing algorithm.
 
A feature sink output for processing algorithms.
 
A map layer parameter for processing algorithms.
 
A rectangle specified with double values.
 
void setYMinimum(double y)
Set the minimum y value.
 
void setXMinimum(double x)
Set the minimum x value.
 
void setYMaximum(double y)
Set the maximum y value.
 
void setXMaximum(double x)
Set the maximum x value.
 
Represents a vector layer which manages a vector based dataset.