Skip to content
Permalink
Browse files

Bug #9797 Add a precision setting for GetFeatureInfo geometry attributes

Add precision to QgsGeometry method exportToWKT and use it in GetFeatureInfo
  • Loading branch information
rldhont committed Aug 9, 2014
1 parent 27ebd96 commit 5add43c24b4dadce9a74038f6697e4915f07438c
Showing with 28 additions and 26 deletions.
  1. +3 −2 python/core/qgsgeometry.sip
  2. +7 −7 src/core/qgsgeometry.cpp
  3. +3 −2 src/core/qgsgeometry.h
  4. +15 −15 src/mapserver/qgswmsserver.cpp
@@ -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
@@ -3536,7 +3536,7 @@ bool QgsGeometry::crosses( const QgsGeometry* geometry ) const
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 += ")";
}
@@ -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
@@ -1282,11 +1282,11 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
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( QDomDocument& result, QString version )
{
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::featureInfoFromVectorLayer( QgsVectorLayer* layer,
{
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::featureInfoFromVectorLayer( QgsVectorLayer* layer,
}
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::createFeatureGML(
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::createFeatureGML(
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() )

0 comments on commit 5add43c

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