23QString QgsFindProjectionAlgorithm::name()
 const 
   25  return QStringLiteral( 
"findprojection" );
 
   28QString QgsFindProjectionAlgorithm::displayName()
 const 
   30  return QObject::tr( 
"Find projection" );
 
   33QStringList QgsFindProjectionAlgorithm::tags()
 const 
   35  return QObject::tr( 
"crs,srs,coordinate,reference,system,guess,estimate,finder,determine" ).split( 
',' );
 
   38QString QgsFindProjectionAlgorithm::group()
 const 
   40  return QObject::tr( 
"Vector general" );
 
   43QString QgsFindProjectionAlgorithm::groupId()
 const 
   45  return QStringLiteral( 
"vectorgeneral" );
 
   48QString QgsFindProjectionAlgorithm::shortHelpString()
 const 
   50  return QObject::tr( 
"Creates a list of possible candidate coordinate reference systems for a layer " 
   51                      "with an unknown projection.\n\n" 
   52                      "The expected area which the layer should reside in must be specified via the " 
   53                      "target area parameter.\n\n" 
   54                      "The algorithm operates by testing the layer's extent in every known reference " 
   55                      "system and listing any in which the bounds would fall within the target area if " 
   56                      "the layer was in this projection." );
 
   59QString QgsFindProjectionAlgorithm::shortDescription()
 const 
   61  return QObject::tr( 
"Creates a list of possible candidate coordinate reference systems for a layer with an unknown projection." );
 
   64QgsFindProjectionAlgorithm *QgsFindProjectionAlgorithm::createInstance()
 const 
   66  return new QgsFindProjectionAlgorithm();
 
   69void QgsFindProjectionAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   75  auto crsParam = std::make_unique<QgsProcessingParameterCrs>( QStringLiteral( 
"TARGET_AREA_CRS" ), QObject::tr( 
"Target area CRS" ), QVariant(), 
true );
 
   77  addParameter( crsParam.release() );
 
   84  std::unique_ptr<QgsProcessingFeatureSource> source( parameterAsSource( parameters, QStringLiteral( 
"INPUT" ), context ) );
 
   88  const QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral( 
"TARGET_AREA" ), context );
 
   90  if ( parameters.contains( QStringLiteral( 
"TARGET_AREA_CRS" ) ) )
 
  112  engine->prepareGeometry();
 
  117  double step = crsesToCheck.count() > 0 ? 100.0 / crsesToCheck.count() : 0;
 
  118  long foundResults = 0;
 
  123  for ( 
long srsId : crsesToCheck )
 
  155      if ( engine->intersects( transformedBounds.
constGet() ) )
 
  157        feedback->
pushInfo( QObject::tr( 
"Found candidate CRS: %1." ).arg( candidateCrs.
authid() ) );
 
  173  if ( foundResults == 0 )
 
  175    feedback->
reportError( QObject::tr( 
"No matching projections found." ) );
 
  181  outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
 
@ Success
Operation succeeded.
 
@ Hidden
Parameter is hidden and should not be shown to users.
 
Represents a coordinate reference system (CRS).
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
 
static QList< long > validSrsIds()
Returns a list of all valid SRS IDs present in the CRS database.
 
static QgsCoordinateReferenceSystem fromSrsId(long srsId)
Creates a CRS from a specified QGIS SRS ID.
 
Contains information about the context in which a coordinate transform is executed.
 
Custom exception class for Coordinate Reference System related exceptions.
 
@ 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.
 
bool isCanceled() const
Tells whether the operation has been canceled already.
 
void setProgress(double progress)
Sets the current progress for the feedback object.
 
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.
 
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
 
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
 
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlag::SkipEmptyInteriorRings)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
 
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.
 
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
 
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
 
A rectangular map extent parameter for processing algorithms.
 
A feature sink output for processing algorithms.
 
An input feature source (such as vector layers) parameter for processing algorithms.
 
A rectangle specified with double values.
 
const QgsCoordinateReferenceSystem & crs