Package: qgis / 2.4.0-1

0001-Bug-9797-Add-a-precision-setting-for-GetFeatureInfo-.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
From 5add43c24b4dadce9a74038f6697e4915f07438c Mon Sep 17 00:00:00 2001
From: rldhont <rldhont@gmail.com>
Date: Sat, 9 Aug 2014 17:08:21 +0200
Subject: Bug #9797 Add a precision setting for GetFeatureInfo geometry
 attributes
Origin: https://github.com/qgis/QGIS/commit/5add43c24b4dadce9a74038f6697e4915f07438c
Bug: http://hub.qgis.org/issues/9797

Add precision to QgsGeometry method exportToWKT and use it in GetFeatureInfo

--- a/python/core/qgsgeometry.sip
+++ b/python/core/qgsgeometry.sip
@@ -364,10 +364,11 @@ class QgsGeometry
     /** Returns a Geometry representing the points making up this Geometry that do not make up other. */
     QgsGeometry* symDifference( QgsGeometry* geometry ) /Factory/;
 
-    /** Exports the geometry to mWkt
+    /** Exports the geometry to WKT
+     *  @note precision parameter added in 2.4
      *  @return true in case of success and false else
      */
-    QString exportToWkt() const;
+    QString exportToWkt( const int &precision = 17 ) const;
 
     /** Exports the geometry to GeoJSON
      *  @return a QString representing the geometry as GeoJSON
--- a/src/core/qgsgeometry.cpp
+++ b/src/core/qgsgeometry.cpp
@@ -3536,7 +3536,7 @@ bool QgsGeometry::crosses( const QgsGeom
   return geosRelOp( GEOSCrosses, this, geometry );
 }
 
-QString QgsGeometry::exportToWkt() const
+QString QgsGeometry::exportToWkt( const int &precision ) const
 {
   QgsDebugMsg( "entered." );
 
@@ -3566,7 +3566,7 @@ QString QgsGeometry::exportToWkt() const
     {
       double x, y;
       wkbPtr >> x >> y;
-      wkt += "POINT(" + qgsDoubleToString( x ) + " " + qgsDoubleToString( y ) + ")";
+      wkt += "POINT(" + qgsDoubleToString( x, precision ) + " " + qgsDoubleToString( y, precision ) + ")";
       return wkt;
     }
 
@@ -3589,7 +3589,7 @@ QString QgsGeometry::exportToWkt() const
         if ( idx != 0 )
           wkt += ", ";
 
-        wkt += qgsDoubleToString( x ) + " " + qgsDoubleToString( y );
+        wkt += qgsDoubleToString( x, precision ) + " " + qgsDoubleToString( y, precision );
       }
       wkt += ")";
       return wkt;
@@ -3626,7 +3626,7 @@ QString QgsGeometry::exportToWkt() const
           if ( hasZValue )
             wkbPtr += sizeof( double );
 
-          wkt += qgsDoubleToString( x ) + " " + qgsDoubleToString( y );
+          wkt += qgsDoubleToString( x, precision ) + " " + qgsDoubleToString( y, precision );
         }
         wkt += ")";
       }
@@ -3653,7 +3653,7 @@ QString QgsGeometry::exportToWkt() const
         if ( hasZValue )
           wkbPtr += sizeof( double );
 
-        wkt += qgsDoubleToString( x ) + " " + qgsDoubleToString( y );
+        wkt += qgsDoubleToString( x, precision ) + " " + qgsDoubleToString( y, precision );
       }
       wkt += ")";
       return wkt;
@@ -3686,7 +3686,7 @@ QString QgsGeometry::exportToWkt() const
           if ( hasZValue )
             wkbPtr += sizeof( double );
 
-          wkt += qgsDoubleToString( x ) + " " + qgsDoubleToString( y );
+          wkt += qgsDoubleToString( x, precision ) + " " + qgsDoubleToString( y, precision );
         }
         wkt += ")";
       }
@@ -3729,7 +3729,7 @@ QString QgsGeometry::exportToWkt() const
             if ( hasZValue )
               wkbPtr += sizeof( double );
 
-            wkt += qgsDoubleToString( x ) + " " + qgsDoubleToString( y );
+            wkt += qgsDoubleToString( x, precision ) + " " + qgsDoubleToString( y, precision );
           }
           wkt += ")";
         }
--- a/src/core/qgsgeometry.h
+++ b/src/core/qgsgeometry.h
@@ -406,10 +406,11 @@ class CORE_EXPORT QgsGeometry
     /** Returns a Geometry representing the points making up this Geometry that do not make up other. */
     QgsGeometry* symDifference( QgsGeometry* geometry );
 
-    /** Exports the geometry to mWkt
+    /** Exports the geometry to WKT
+     *  @note precision parameter added in 2.4
      *  @return true in case of success and false else
      */
-    QString exportToWkt() const;
+    QString exportToWkt( const int &precision = 17 ) const;
 
     /** Exports the geometry to GeoJSON
      *  @return a QString representing the geometry as GeoJSON
--- a/src/mapserver/qgswmsserver.cpp
+++ b/src/mapserver/qgswmsserver.cpp
@@ -1282,11 +1282,11 @@ int QgsWMSServer::getFeatureInfo( QDomDo
       int gmlVersion = infoFormat.startsWith( "application/vnd.ogc.gml/3" ) ? 3 : 2;
       if ( gmlVersion < 3 )
       {
-        boxElem = QgsOgcUtils::rectangleToGMLBox( featuresRect, result );
+        boxElem = QgsOgcUtils::rectangleToGMLBox( featuresRect, result, 8 );
       }
       else
       {
-        boxElem = QgsOgcUtils::rectangleToGMLEnvelope( featuresRect, result );
+        boxElem = QgsOgcUtils::rectangleToGMLEnvelope( featuresRect, result, 8 );
       }
 
       QgsCoordinateReferenceSystem crs = mMapRenderer->destinationCrs();
@@ -1301,10 +1301,10 @@ int QgsWMSServer::getFeatureInfo( QDomDo
     {
       QDomElement bBoxElem = result.createElement( "BoundingBox" );
       bBoxElem.setAttribute( "CRS", mMapRenderer->destinationCrs().authid() );
-      bBoxElem.setAttribute( "minx", QString::number( featuresRect->xMinimum() ) );
-      bBoxElem.setAttribute( "maxx", QString::number( featuresRect->xMaximum() ) );
-      bBoxElem.setAttribute( "miny", QString::number( featuresRect->yMinimum() ) );
-      bBoxElem.setAttribute( "maxy", QString::number( featuresRect->yMaximum() ) );
+      bBoxElem.setAttribute( "minx", qgsDoubleToString( featuresRect->xMinimum(), 8 ) );
+      bBoxElem.setAttribute( "maxx", qgsDoubleToString( featuresRect->xMaximum(), 8 ) );
+      bBoxElem.setAttribute( "miny", qgsDoubleToString( featuresRect->yMinimum(), 8 ) );
+      bBoxElem.setAttribute( "maxy", qgsDoubleToString( featuresRect->yMaximum(), 8 ) );
       getFeatureInfoElement.insertBefore( bBoxElem, QDomNode() ); //insert as first child
     }
   }
@@ -1823,10 +1823,10 @@ int QgsWMSServer::featureInfoFromVectorL
       {
         QDomElement bBoxElem = infoDocument.createElement( "BoundingBox" );
         bBoxElem.setAttribute( version == "1.1.1" ? "SRS" : "CRS", outputCrs.authid() );
-        bBoxElem.setAttribute( "minx", QString::number( box.xMinimum() ) );
-        bBoxElem.setAttribute( "maxx", QString::number( box.xMaximum() ) );
-        bBoxElem.setAttribute( "miny", QString::number( box.yMinimum() ) );
-        bBoxElem.setAttribute( "maxy", QString::number( box.yMaximum() ) );
+        bBoxElem.setAttribute( "minx", qgsDoubleToString( box.xMinimum(), 8 ) );
+        bBoxElem.setAttribute( "maxx", qgsDoubleToString( box.xMaximum(), 8 ) );
+        bBoxElem.setAttribute( "miny", qgsDoubleToString( box.yMinimum(), 8 ) );
+        bBoxElem.setAttribute( "maxy", qgsDoubleToString( box.yMaximum(), 8 ) );
         featureElement.appendChild( bBoxElem );
       }
 
@@ -1844,7 +1844,7 @@ int QgsWMSServer::featureInfoFromVectorL
         }
         QDomElement geometryElement = infoDocument.createElement( "Attribute" );
         geometryElement.setAttribute( "name", "geometry" );
-        geometryElement.setAttribute( "value", geom->exportToWkt() );
+        geometryElement.setAttribute( "value", geom->exportToWkt( 8 ) );
         geometryElement.setAttribute( "type", "derived" );
         featureElement.appendChild( geometryElement );
       }
@@ -2830,11 +2830,11 @@ QDomElement QgsWMSServer::createFeatureG
     QDomElement boxElem;
     if ( version < 3 )
     {
-      boxElem = QgsOgcUtils::rectangleToGMLBox( &box, doc );
+      boxElem = QgsOgcUtils::rectangleToGMLBox( &box, doc, 8 );
     }
     else
     {
-      boxElem = QgsOgcUtils::rectangleToGMLEnvelope( &box, doc );
+      boxElem = QgsOgcUtils::rectangleToGMLEnvelope( &box, doc, 8 );
     }
 
     if ( crs.isValid() )
@@ -2858,11 +2858,11 @@ QDomElement QgsWMSServer::createFeatureG
     QDomElement gmlElem;
     if ( version < 3 )
     {
-      gmlElem = QgsOgcUtils::geometryToGML( geom, doc );
+      gmlElem = QgsOgcUtils::geometryToGML( geom, doc, 8 );
     }
     else
     {
-      gmlElem = QgsOgcUtils::geometryToGML( geom, doc, "GML3" );
+      gmlElem = QgsOgcUtils::geometryToGML( geom, doc, "GML3", 8 );
     }
 
     if ( !gmlElem.isNull() )