Skip to content
Permalink
Browse files

Merge pull request #5719 from nyalldawson/translate_z

geometries: translate Z/M
  • Loading branch information
nyalldawson committed Nov 24, 2017
2 parents 97f749e + b786ed0 commit 14531964a81ecf3d52b3540f7d54d8f7a5369fde
Showing with 611 additions and 193 deletions.
  1. +6 −3 python/core/geometry/qgsabstractgeometry.sip
  2. +1 −1 python/core/geometry/qgscircularstring.sip
  3. +1 −1 python/core/geometry/qgscompoundcurve.sip
  4. +1 −1 python/core/geometry/qgscurvepolygon.sip
  5. +8 −4 python/core/geometry/qgsgeometry.sip
  6. +1 −1 python/core/geometry/qgsgeometrycollection.sip
  7. +1 −1 python/core/geometry/qgslinestring.sip
  8. +1 −1 python/core/geometry/qgspoint.sip
  9. +0 −2 python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
  10. +0 −76 python/plugins/processing/algs/qgis/Translate.py
  11. +32 −0 python/plugins/processing/tests/testdata/expected/buffer_polys.gfs
  12. +16 −0 python/plugins/processing/tests/testdata/expected/gridify_lines.gfs
  13. +32 −0 python/plugins/processing/tests/testdata/expected/gridify_polys.gfs
  14. +16 −0 python/plugins/processing/tests/testdata/expected/lines_bounds.gfs
  15. +16 −0 python/plugins/processing/tests/testdata/expected/multiline_offset.gfs
  16. BIN python/plugins/processing/tests/testdata/expected/translate_z_m.dbf
  17. +77 −0 python/plugins/processing/tests/testdata/expected/translate_z_m.gml
  18. +1 −0 python/plugins/processing/tests/testdata/expected/translate_z_m.prj
  19. +1 −0 python/plugins/processing/tests/testdata/expected/translate_z_m.qpj
  20. BIN python/plugins/processing/tests/testdata/expected/translate_z_m.shp
  21. BIN python/plugins/processing/tests/testdata/expected/translate_z_m.shx
  22. +37 −0 python/plugins/processing/tests/testdata/expected/translate_z_m.xsd
  23. +31 −0 python/plugins/processing/tests/testdata/expected/variable_buffer_points.gfs
  24. +16 −1 python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
  25. +1 −0 src/analysis/CMakeLists.txt
  26. +114 −0 src/analysis/processing/qgsalgorithmtranslate.cpp
  27. +65 −0 src/analysis/processing/qgsalgorithmtranslate.h
  28. +2 −1 src/analysis/processing/qgsnativealgorithms.cpp
  29. +6 −3 src/core/geometry/qgsabstractgeometry.h
  30. +11 −1 src/core/geometry/qgscircularstring.cpp
  31. +1 −1 src/core/geometry/qgscircularstring.h
  32. +2 −2 src/core/geometry/qgscompoundcurve.cpp
  33. +1 −1 src/core/geometry/qgscompoundcurve.h
  34. +3 −3 src/core/geometry/qgscurvepolygon.cpp
  35. +1 −1 src/core/geometry/qgscurvepolygon.h
  36. +4 −4 src/core/geometry/qgsgeometry.cpp
  37. +8 −4 src/core/geometry/qgsgeometry.h
  38. +2 −2 src/core/geometry/qgsgeometrycollection.cpp
  39. +1 −1 src/core/geometry/qgsgeometrycollection.h
  40. +11 −1 src/core/geometry/qgslinestring.cpp
  41. +1 −1 src/core/geometry/qgslinestring.h
  42. +10 −1 src/core/geometry/qgspoint.cpp
  43. +1 −1 src/core/geometry/qgspoint.h
  44. +19 −30 src/gui/qgsmaptoolidentify.cpp
  45. +0 −5 src/gui/qgsmaptoolidentify.h
  46. +52 −38 tests/src/core/testqgsgeometry.cpp
@@ -234,10 +234,13 @@ class QgsAbstractGeometry
transform.
%End

virtual void transform( const QTransform &t ) = 0;
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0,
double mTranslate = 0.0, double mScale = 1.0 ) = 0;
%Docstring
Transforms the geometry using a QTransform object
\param t QTransform transformation
Transforms the x and y components of the geometry using a QTransform object ``t``.

Optionally, the geometry's z values can be scaled via ``zScale`` and translated via ``zTranslate``.
Similarly, m-values can be scaled via ``mScale`` and translated via ``mTranslate``.
%End

virtual void draw( QPainter &p ) const = 0;
@@ -87,7 +87,7 @@ class QgsCircularString: QgsCurve

virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QTransform &t );
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );

virtual void addToPainterPath( QPainterPath &path ) const;

@@ -112,7 +112,7 @@ class QgsCompoundCurve: QgsCurve

virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QTransform &t );
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );

virtual void addToPainterPath( QPainterPath &path ) const;

@@ -131,7 +131,7 @@ Adds an interior ring to the geometry (takes ownership)

virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QTransform &t );
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );


virtual bool insertVertex( QgsVertexId position, const QgsPoint &vertex );
@@ -566,9 +566,9 @@ Returns true if WKB of the geometry is of WKBMulti* type
:rtype: QgsGeometry
%End

OperationResult translate( double dx, double dy );
OperationResult translate( double dx, double dy, double dz = 0.0, double dm = 0.0 );
%Docstring
Translates this geometry by dx, dy
Translates this geometry by dx, dy, dz and dm.
:return: OperationResult a result code: success or reason of failure
:rtype: OperationResult
%End
@@ -580,9 +580,13 @@ Returns true if WKB of the geometry is of WKBMulti* type
:rtype: OperationResult
%End

OperationResult transform( const QTransform &ct );
OperationResult transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
%Docstring
Transforms this geometry as described by QTransform ct
Transforms the x and y components of the geometry using a QTransform object ``t``.

Optionally, the geometry's z values can be scaled via ``zScale`` and translated via ``zTranslate``.
Similarly, m-values can be scaled via ``mScale`` and translated via ``mTranslate``.

:return: OperationResult a result code: success or reason of failure
:rtype: OperationResult
%End
@@ -83,7 +83,7 @@ Adds a geometry and takes ownership. Returns true in case of success.

virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QTransform &t );
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );


virtual void draw( QPainter &p ) const;
@@ -225,7 +225,7 @@ Closes the line string by appending the first point to the end of the line, if i

virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QTransform &t );
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );


virtual void addToPainterPath( QPainterPath &path ) const;
@@ -359,7 +359,7 @@ class QgsPoint: QgsAbstractGeometry

virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QTransform &t );
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );

virtual QgsCoordinateSequence coordinateSequence() const;

@@ -143,7 +143,6 @@
from .TextToFloat import TextToFloat
from .TinInterpolation import TinInterpolation
from .TopoColors import TopoColor
from .Translate import Translate
from .TruncateTable import TruncateTable
from .Union import Union
from .UniqueValues import UniqueValues
@@ -268,7 +267,6 @@ def getAlgs(self):
TextToFloat(),
TinInterpolation(),
TopoColor(),
Translate(),
TruncateTable(),
Union(),
UniqueValues(),

This file was deleted.

@@ -0,0 +1,32 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>buffer_polys</Name>
<ElementPath>buffer_polys</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>6</FeatureCount>
<ExtentXMin>-1.50000</ExtentXMin>
<ExtentXMax>10.50000</ExtentXMax>
<ExtentYMin>-3.50000</ExtentYMin>
<ExtentYMax>6.50000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>name</Name>
<ElementPath>name</ElementPath>
<Type>String</Type>
<Width>5</Width>
</PropertyDefn>
<PropertyDefn>
<Name>intval</Name>
<ElementPath>intval</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>floatval</Name>
<ElementPath>floatval</ElementPath>
<Type>Real</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,16 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>gridify_lines</Name>
<ElementPath>gridify_lines</ElementPath>
<!--LINESTRING-->
<GeometryType>2</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>7</FeatureCount>
<ExtentXMin>-2.00000</ExtentXMin>
<ExtentXMax>12.00000</ExtentXMax>
<ExtentYMin>-4.00000</ExtentYMin>
<ExtentYMax>6.00000</ExtentYMax>
</DatasetSpecificInfo>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,32 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>gridify_polys</Name>
<ElementPath>gridify_polys</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>6</FeatureCount>
<ExtentXMin>-2.00000</ExtentXMin>
<ExtentXMax>10.00000</ExtentXMax>
<ExtentYMin>-4.00000</ExtentYMin>
<ExtentYMax>6.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>name</Name>
<ElementPath>name</ElementPath>
<Type>String</Type>
<Width>5</Width>
</PropertyDefn>
<PropertyDefn>
<Name>intval</Name>
<ElementPath>intval</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>floatval</Name>
<ElementPath>floatval</ElementPath>
<Type>Real</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,16 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>lines_bounds</Name>
<ElementPath>lines_bounds</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>7</FeatureCount>
<ExtentXMin>-1.00000</ExtentXMin>
<ExtentXMax>11.00000</ExtentXMax>
<ExtentYMin>-3.00000</ExtentYMin>
<ExtentYMax>5.00000</ExtentYMax>
</DatasetSpecificInfo>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,16 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>multiline_offset</Name>
<ElementPath>multiline_offset</ElementPath>
<!--MULTILINESTRING-->
<GeometryType>5</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>4</FeatureCount>
<ExtentXMin>-1.00000</ExtentXMin>
<ExtentXMax>6.02404</ExtentXMax>
<ExtentYMin>0.00000</ExtentYMin>
<ExtentYMax>5.11935</ExtentYMax>
</DatasetSpecificInfo>
</GMLFeatureClass>
</GMLFeatureClassList>
Binary file not shown.
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ translate_z_m.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0</gml:X><gml:Y>-5</gml:Y><gml:Z>8</gml:Z></gml:coord>
<gml:coord><gml:X>8</gml:X><gml:Y>3</gml:Y><gml:Z>8</gml:Z></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:translate_z_m fid="points.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
<gml:featureMember>
<ogr:translate_z_m fid="points.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3,3,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>2</ogr:id>
<ogr:id2>1</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
<gml:featureMember>
<ogr:translate_z_m fid="points.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,2,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>3</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
<gml:featureMember>
<ogr:translate_z_m fid="points.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5,2,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
<gml:featureMember>
<ogr:translate_z_m fid="points.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4,1,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:id2>1</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
<gml:featureMember>
<ogr:translate_z_m fid="points.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-5,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>6</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
<gml:featureMember>
<ogr:translate_z_m fid="points.6">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>8,-1,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>7</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
<gml:featureMember>
<ogr:translate_z_m fid="points.7">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7,-1,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>8</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
<gml:featureMember>
<ogr:translate_z_m fid="points.8">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-1,8</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:id>9</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:translate_z_m>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
@@ -0,0 +1 @@
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]
Binary file not shown.
Binary file not shown.

0 comments on commit 1453196

Please sign in to comment.
You can’t perform that action at this time.