Skip to content
Permalink
Browse files

Precision and 3d

  • Loading branch information
elpaso committed Apr 6, 2019
1 parent 6967a21 commit be8822ed8bea591025d01b68d65d7a7f1bf6ebda
Showing with 82 additions and 70 deletions.
  1. +1 −1 python/core/auto_generated/geometry/qgsabstractgeometry.sip.in
  2. +1 −1 python/core/auto_generated/geometry/qgscircularstring.sip.in
  3. +1 −1 python/core/auto_generated/geometry/qgscompoundcurve.sip.in
  4. +1 −1 python/core/auto_generated/geometry/qgscurvepolygon.sip.in
  5. +1 −1 python/core/auto_generated/geometry/qgsgeometry.sip.in
  6. +1 −1 python/core/auto_generated/geometry/qgsgeometrycollection.sip.in
  7. +1 −1 python/core/auto_generated/geometry/qgslinestring.sip.in
  8. +1 −1 python/core/auto_generated/geometry/qgsmulticurve.sip.in
  9. +1 −1 python/core/auto_generated/geometry/qgsmultilinestring.sip.in
  10. +1 −1 python/core/auto_generated/geometry/qgsmultipoint.sip.in
  11. +1 −1 python/core/auto_generated/geometry/qgsmultipolygon.sip.in
  12. +1 −1 python/core/auto_generated/geometry/qgsmultisurface.sip.in
  13. +1 −1 python/core/auto_generated/geometry/qgspoint.sip.in
  14. +5 −5 python/core/auto_generated/qgsjsonutils.sip.in
  15. +1 −1 src/core/geometry/qgsabstractgeometry.h
  16. +2 −2 src/core/geometry/qgscircularstring.cpp
  17. +1 −1 src/core/geometry/qgscircularstring.h
  18. +2 −2 src/core/geometry/qgscompoundcurve.cpp
  19. +1 −1 src/core/geometry/qgscompoundcurve.h
  20. +3 −3 src/core/geometry/qgscurvepolygon.cpp
  21. +1 −1 src/core/geometry/qgscurvepolygon.h
  22. +2 −2 src/core/geometry/qgsgeometry.cpp
  23. +1 −1 src/core/geometry/qgsgeometry.h
  24. +2 −2 src/core/geometry/qgsgeometrycollection.cpp
  25. +1 −1 src/core/geometry/qgsgeometrycollection.h
  26. +9 −2 src/core/geometry/qgsgeometryutils.cpp
  27. +1 −1 src/core/geometry/qgsgeometryutils.h
  28. +2 −2 src/core/geometry/qgslinestring.cpp
  29. +1 −1 src/core/geometry/qgslinestring.h
  30. +2 −2 src/core/geometry/qgsmulticurve.cpp
  31. +1 −1 src/core/geometry/qgsmulticurve.h
  32. +2 −2 src/core/geometry/qgsmultilinestring.cpp
  33. +1 −1 src/core/geometry/qgsmultilinestring.h
  34. +1 −1 src/core/geometry/qgsmultipoint.cpp
  35. +1 −1 src/core/geometry/qgsmultipoint.h
  36. +3 −3 src/core/geometry/qgsmultipolygon.cpp
  37. +1 −1 src/core/geometry/qgsmultipolygon.h
  38. +3 −3 src/core/geometry/qgsmultisurface.cpp
  39. +1 −1 src/core/geometry/qgsmultisurface.h
  40. +7 −2 src/core/geometry/qgspoint.cpp
  41. +1 −1 src/core/geometry/qgspoint.h
  42. +3 −3 src/core/qgsjsonutils.cpp
  43. +5 −5 src/core/qgsjsonutils.h
  44. +2 −2 tests/src/core/testqgsjsonutils.cpp
@@ -259,7 +259,7 @@ Returns a GeoJSON representation of the geometry.
.. seealso:: :py:func:`asGml3`
%End

virtual QJsonObject asJsonV2( ) const = 0;
virtual QJsonObject asJsonObject( int precision = 17 ) const = 0;
%Docstring
Returns a GeoJSON object of the geometry.

@@ -81,7 +81,7 @@ to ``p2`` will be used (i.e. winding the other way around the circle).

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;

virtual bool isEmpty() const;

@@ -52,7 +52,7 @@ Compound curve geometry type

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;


virtual double length() const;
@@ -56,7 +56,7 @@ Curve polygon geometry type

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2() const;
virtual QJsonObject asJsonObject( int precision = 17 ) const;


virtual double area() const;
@@ -1441,7 +1441,7 @@ Exports the geometry to WKT
Exports the geometry to a GeoJSON string.
%End

QJsonObject asJsonV2( ) const;
QJsonObject asJsonObject( int precision = 17 ) const;
%Docstring
Exports the geometry to a GeoJSON object.
%End
@@ -154,7 +154,7 @@ An IndexError will be raised if no geometry with the specified index exists.

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;


virtual QgsRectangle boundingBox() const;
@@ -414,7 +414,7 @@ segment in the line.

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;


virtual double length() const;
@@ -37,7 +37,7 @@ Multi curve geometry collection.

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;

virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

@@ -36,7 +36,7 @@ Multi line string geometry collection.

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;

virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

@@ -38,7 +38,7 @@ Multi point geometry collection.

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;

virtual int nCoordinates() const;

@@ -35,7 +35,7 @@ Multi polygon geometry collection.

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;

virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

@@ -37,7 +37,7 @@ Multi surface geometry collection.

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;

virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

@@ -357,7 +357,7 @@ M value is preserved.

virtual QString asJson( int precision = 17 ) const;

virtual QJsonObject asJsonV2( ) const;
virtual QJsonObject asJsonObject( int precision ) const;

virtual void draw( QPainter &p ) const;

@@ -231,9 +231,9 @@ Returns a GeoJSON string representation of a feature.
.. seealso:: :py:func:`exportFeatures`
%End

QJsonObject exportFeatureV2( const QgsFeature &feature,
const QVariantMap &extraProperties = QVariantMap(),
const QVariant &id = QVariant() ) const;
QJsonObject exportFeatureToJsonObject( const QgsFeature &feature,
const QVariantMap &extraProperties = QVariantMap(),
const QVariant &id = QVariant() ) const;
%Docstring
Returns a GeoJSON string representation of a feature.

@@ -330,8 +330,8 @@ Exports all attributes from a QgsFeature as a JSON map type.
to speed up exporting the attributes for multiple features from the same layer.
%End

static QJsonObject exportAttributesV2( const QgsFeature &feature, QgsVectorLayer *layer = 0,
const QVector<QVariant> &attributeWidgetCaches = QVector<QVariant>() );
static QJsonObject exportAttributesToJsonObject( const QgsFeature &feature, QgsVectorLayer *layer = 0,
const QVector<QVariant> &attributeWidgetCaches = QVector<QVariant>() );
%Docstring
Exports all attributes from a QgsFeature as a JSON map type.

@@ -287,7 +287,7 @@ class CORE_EXPORT QgsAbstractGeometry
* \see asGml2()
* \see asGml3()
*/
virtual QJsonObject asJsonV2( ) const = 0;
virtual QJsonObject asJsonObject( int precision = 17 ) const = 0;

//render pipeline

@@ -375,11 +375,11 @@ QString QgsCircularString::asJson( int precision ) const
return json;
}

QJsonObject QgsCircularString::asJsonV2() const
QJsonObject QgsCircularString::asJsonObject( int precision ) const
{
// GeoJSON does not support curves
std::unique_ptr< QgsLineString > line( curveToLine() );
return line->asJsonV2( );
return line->asJsonObject( precision );
}

bool QgsCircularString::isEmpty() const
@@ -80,7 +80,7 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QString asJson( int precision = 17 ) const override;
QJsonObject asJsonV2( ) const override;
QJsonObject asJsonObject( int precision ) const override;
bool isEmpty() const override;
int numPoints() const override;

@@ -299,11 +299,11 @@ QString QgsCompoundCurve::asJson( int precision ) const
return json;
}

QJsonObject QgsCompoundCurve::asJsonV2() const
QJsonObject QgsCompoundCurve::asJsonObject( int precision ) const
{
// GeoJSON does not support curves
std::unique_ptr< QgsLineString > line( curveToLine() );
return line->asJsonV2();
return line->asJsonObject( precision );
}

double QgsCompoundCurve::length() const
@@ -51,7 +51,7 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve
QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QString asJson( int precision = 17 ) const override;
QJsonObject asJsonV2( ) const override;
QJsonObject asJsonObject( int precision ) const override;

//curve interface
double length() const override;
@@ -428,23 +428,23 @@ QString QgsCurvePolygon::asJson( int precision ) const
return json;
}

QJsonObject QgsCurvePolygon::asJsonV2() const
QJsonObject QgsCurvePolygon::asJsonObject( int precision ) const
{
QJsonArray coordinates;
if ( exteriorRing() )
{
std::unique_ptr< QgsLineString > exteriorLineString( exteriorRing()->curveToLine() );
QgsPointSequence exteriorPts;
exteriorLineString->points( exteriorPts );
coordinates.append( QgsGeometryUtils::pointsToJsonV2( exteriorPts ) );
coordinates.append( QgsGeometryUtils::pointsToJsonObject( exteriorPts, precision ) );

std::unique_ptr< QgsLineString > interiorLineString;
for ( int i = 0, n = numInteriorRings(); i < n; ++i )
{
interiorLineString.reset( interiorRing( i )->curveToLine() );
QgsPointSequence interiorPts;
interiorLineString->points( interiorPts );
coordinates.append( QgsGeometryUtils::pointsToJsonV2( interiorPts ) );
coordinates.append( QgsGeometryUtils::pointsToJsonObject( interiorPts, precision ) );
}
}
return
@@ -56,7 +56,7 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QString asJson( int precision = 17 ) const override;
QJsonObject asJsonV2() const override;
QJsonObject asJsonObject( int precision = 17 ) const override;

//surface interface
double area() const override;
@@ -1268,13 +1268,13 @@ QString QgsGeometry::asJson( int precision ) const
return d->geometry->asJson( precision );
}

QJsonObject QgsGeometry::asJsonV2() const
QJsonObject QgsGeometry::asJsonObject( int precision ) const
{
if ( !d->geometry )
{
return QJsonObject( );
}
return d->geometry->asJsonV2( );
return d->geometry->asJsonObject( precision );
}

QgsGeometry QgsGeometry::convertToType( QgsWkbTypes::GeometryType destType, bool destMultipart ) const
@@ -1433,7 +1433,7 @@ class CORE_EXPORT QgsGeometry
/**
* Exports the geometry to a GeoJSON object.
*/
QJsonObject asJsonV2( ) const;
QJsonObject asJsonObject( int precision = 17 ) const;

/**
* Try to convert the geometry to the requested type
@@ -431,12 +431,12 @@ QString QgsGeometryCollection::asJson( int precision ) const
return json;
}

QJsonObject QgsGeometryCollection::asJsonV2() const
QJsonObject QgsGeometryCollection::asJsonObject( int precision ) const
{
QJsonArray coordinates;
for ( const QgsAbstractGeometry *geom : qgis::as_const( mGeometries ) )
{
coordinates.append( geom->asJsonV2() );
coordinates.append( geom->asJsonObject() );
}
return
{
@@ -174,7 +174,7 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry
QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QString asJson( int precision = 17 ) const override;
QJsonObject asJsonV2( ) const override;
QJsonObject asJsonObject( int precision ) const override;

QgsRectangle boundingBox() const override;

@@ -1195,12 +1195,19 @@ QString QgsGeometryUtils::pointsToJSON( const QgsPointSequence &points, int prec
return json;
}

QJsonArray QgsGeometryUtils::pointsToJsonV2( const QgsPointSequence &points )
QJsonArray QgsGeometryUtils::pointsToJsonObject( const QgsPointSequence &points, int precision )
{
QJsonArray coordinates;
for ( const QgsPoint &p : points )
{
coordinates.append( QJsonArray( { p.x(), p.y() } ) );
if ( p.is3D() )
{
coordinates.append( QJsonArray( { qgsRound( p.x(), precision ), qgsRound( p.y(), precision ), qgsRound( p.z(), precision ) } ) );
}
else
{
coordinates.append( QJsonArray( { qgsRound( p.x(), precision ), qgsRound( p.y(), precision ) } ) );
}
}
return coordinates;
}
@@ -425,7 +425,7 @@ class CORE_EXPORT QgsGeometryUtils
* Returns a geoJSON coordinates object.
* \note not available in Python bindings
*/
static QJsonArray pointsToJsonV2( const QgsPointSequence &points ) SIP_SKIP;
static QJsonArray pointsToJsonObject( const QgsPointSequence &points, int precision ) SIP_SKIP;

/**
* Ensures that an angle is in the range 0 <= angle < 2 pi.
@@ -419,14 +419,14 @@ QString QgsLineString::asJson( int precision ) const
return "{\"type\": \"LineString\", \"coordinates\": " + QgsGeometryUtils::pointsToJSON( pts, precision ) + '}';
}

QJsonObject QgsLineString::asJsonV2() const
QJsonObject QgsLineString::asJsonObject( int precision ) const
{
QgsPointSequence pts;
points( pts );
return
{
{ QLatin1String( "type" ), QLatin1String( "LineString" ) },
{ QLatin1String( "coordinates" ), QgsGeometryUtils::pointsToJsonV2( pts ) }
{ QLatin1String( "coordinates" ), QgsGeometryUtils::pointsToJsonObject( pts, precision ) }
};
}

@@ -561,7 +561,7 @@ class CORE_EXPORT QgsLineString: public QgsCurve
QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QString asJson( int precision = 17 ) const override;
QJsonObject asJsonV2( ) const override;
QJsonObject asJsonObject( int precision ) const override;

//curve interface
double length() const override;
@@ -131,7 +131,7 @@ QString QgsMultiCurve::asJson( int precision ) const
return json;
}

QJsonObject QgsMultiCurve::asJsonV2() const
QJsonObject QgsMultiCurve::asJsonObject( int precision ) const
{
QJsonArray coordinates;
for ( const QgsAbstractGeometry *geom : qgis::as_const( mGeometries ) )
@@ -141,7 +141,7 @@ QJsonObject QgsMultiCurve::asJsonV2() const
std::unique_ptr< QgsLineString > lineString( static_cast<const QgsCurve *>( geom )->curveToLine() );
QgsPointSequence pts;
lineString->points( pts );
coordinates.append( QgsGeometryUtils::pointsToJsonV2( pts ) );
coordinates.append( QgsGeometryUtils::pointsToJsonObject( pts, precision ) );
}
}
return
@@ -38,7 +38,7 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection
QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QString asJson( int precision = 17 ) const override;
QJsonObject asJsonV2( ) const override;
QJsonObject asJsonObject( int precision ) const override;
bool addGeometry( QgsAbstractGeometry *g SIP_TRANSFER ) override;
bool insertGeometry( QgsAbstractGeometry *g SIP_TRANSFER, int index ) override;

@@ -118,7 +118,7 @@ QString QgsMultiLineString::asJson( int precision ) const
return json;
}

QJsonObject QgsMultiLineString::asJsonV2() const
QJsonObject QgsMultiLineString::asJsonObject( int precision ) const
{
QJsonArray coordinates;
for ( const QgsAbstractGeometry *geom : mGeometries )
@@ -128,7 +128,7 @@ QJsonObject QgsMultiLineString::asJsonV2() const
const QgsLineString *lineString = static_cast<const QgsLineString *>( geom );
QgsPointSequence pts;
lineString->points( pts );
coordinates.append( QgsGeometryUtils::pointsToJsonV2( pts ) );
coordinates.append( QgsGeometryUtils::pointsToJsonObject( pts, precision ) );
}
}
return
@@ -38,7 +38,7 @@ class CORE_EXPORT QgsMultiLineString: public QgsMultiCurve
QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const override;
QString asJson( int precision = 17 ) const override;
QJsonObject asJsonV2( ) const override;
QJsonObject asJsonObject( int precision ) const override;
bool addGeometry( QgsAbstractGeometry *g SIP_TRANSFER ) override;
bool insertGeometry( QgsAbstractGeometry *g SIP_TRANSFER, int index ) override;

0 comments on commit be8822e

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