QGIS API Documentation 3.99.0-Master (09f76ad7019)
Loading...
Searching...
No Matches
qgsalgorithmsplitlineantimeridian.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmsplitlineantimeridian.cpp
3 -------------------------------------
4 begin : January 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7
8 ***************************************************************************/
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include "qgscircularstring.h"
21#include "qgscompoundcurve.h"
22#include "qgscurve.h"
24#include "qgslinestring.h"
25
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
31
32QString QgsSplitGeometryAtAntimeridianAlgorithm::name() const
33{
34 return u"antimeridiansplit"_s;
35}
36
37QString QgsSplitGeometryAtAntimeridianAlgorithm::displayName() const
38{
39 return QObject::tr( "Geodesic line split at antimeridian" );
40}
41
42QStringList QgsSplitGeometryAtAntimeridianAlgorithm::tags() const
43{
44 return QObject::tr( "break,cut,dateline,180,-180,longitude,geographic,ellipsoid" ).split( ',' );
45}
46
47QString QgsSplitGeometryAtAntimeridianAlgorithm::group() const
48{
49 return QObject::tr( "Vector geometry" );
50}
51
52QString QgsSplitGeometryAtAntimeridianAlgorithm::groupId() const
53{
54 return u"vectorgeometry"_s;
55}
56
57QString QgsSplitGeometryAtAntimeridianAlgorithm::shortDescription() const
58{
59 return QObject::tr( "Splits lines into multiple geodesic segments when the line crosses the antimeridian (±180 degrees longitude)." );
60}
61
62QString QgsSplitGeometryAtAntimeridianAlgorithm::shortHelpString() const
63{
64 return QObject::tr( "This algorithm splits a line into multiple geodesic segments, whenever the line crosses the antimeridian (±180 degrees longitude).\n\n"
65 "Splitting at the antimeridian helps the visual display of the lines in some projections. The returned "
66 "geometry will always be a multi-part geometry.\n\n"
67 "Whenever line segments in the input geometry cross the antimeridian, they will be "
68 "split into two segments, with the latitude of the breakpoint being determined using a geodesic "
69 "line connecting the points either side of this segment. The current project ellipsoid setting will "
70 "be used when calculating this breakpoint.\n\n"
71 "If the input geometry contains M or Z values, these will be linearly interpolated for the new vertices "
72 "created at the antimeridian." );
73}
74
75Qgis::ProcessingAlgorithmDocumentationFlags QgsSplitGeometryAtAntimeridianAlgorithm::documentationFlags() const
76{
78}
79
80QList<int> QgsSplitGeometryAtAntimeridianAlgorithm::inputLayerTypes() const
81{
82 return QList<int>() << static_cast<int>( Qgis::ProcessingSourceType::VectorLine );
83}
84
85Qgis::ProcessingSourceType QgsSplitGeometryAtAntimeridianAlgorithm::outputLayerType() const
86{
88}
89
90QgsSplitGeometryAtAntimeridianAlgorithm *QgsSplitGeometryAtAntimeridianAlgorithm::createInstance() const
91{
92 return new QgsSplitGeometryAtAntimeridianAlgorithm();
93}
94
95QString QgsSplitGeometryAtAntimeridianAlgorithm::outputName() const
96{
97 return QObject::tr( "Split" );
98}
99
100Qgis::WkbType QgsSplitGeometryAtAntimeridianAlgorithm::outputWkbType( Qgis::WkbType inputWkbType ) const
101{
102 return QgsWkbTypes::multiType( inputWkbType );
103}
104
105QgsCoordinateReferenceSystem QgsSplitGeometryAtAntimeridianAlgorithm::outputCrs( const QgsCoordinateReferenceSystem &inputCrs ) const
106{
107 mDa.setSourceCrs( inputCrs, mTransformContext );
108 return inputCrs;
109}
110
111bool QgsSplitGeometryAtAntimeridianAlgorithm::prepareAlgorithm( const QVariantMap &, QgsProcessingContext &context, QgsProcessingFeedback * )
112{
113 mDa.setEllipsoid( context.ellipsoid() );
114 mTransformContext = context.transformContext();
115 return true;
116}
117
118QgsFeatureList QgsSplitGeometryAtAntimeridianAlgorithm::processFeature( const QgsFeature &f, QgsProcessingContext &, QgsProcessingFeedback * )
119{
120 if ( !f.hasGeometry() )
121 {
122 return QgsFeatureList() << f;
123 }
124 else
125 {
126 QgsFeature feat = f;
127 feat.setGeometry( mDa.splitGeometryAtAntimeridian( f.geometry() ) );
128 return QgsFeatureList() << feat;
129 }
130}
131
132
ProcessingSourceType
Processing data source types.
Definition qgis.h:3602
@ VectorLine
Vector line layers.
Definition qgis.h:3606
@ RespectsEllipsoid
Algorithm respects the context's ellipsoid settings, and uses ellipsoidal based measurements.
Definition qgis.h:3692
QFlags< ProcessingAlgorithmDocumentationFlag > ProcessingAlgorithmDocumentationFlags
Flags describing algorithm behavior for documentation purposes.
Definition qgis.h:3701
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:280
Represents a coordinate reference system (CRS).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
QgsGeometry geometry
Definition qgsfeature.h:71
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Contains information about the context in which a processing algorithm is executed.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QString ellipsoid() const
Returns the ellipsoid to use for distance and area calculations.
Base class for providing feedback from a processing algorithm.
static Qgis::WkbType multiType(Qgis::WkbType type)
Returns the multi type for a WKB type.
QList< QgsFeature > QgsFeatureList