mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Fix loading of curved multitypes
This commit is contained in:
parent
4c1ba46d10
commit
0e55b3bf0f
@ -112,4 +112,8 @@ class QgsAbstractGeometryV2
|
||||
/**Length for linear geometries,perimeter for area geometries*/
|
||||
virtual double length() const;
|
||||
virtual double area() const;
|
||||
|
||||
virtual bool hasCurvedSegments() const;
|
||||
/**Returns a geometry without curves. Caller takes ownership*/
|
||||
virtual QgsAbstractGeometryV2* segmentize() const /Factory/;
|
||||
};
|
||||
|
@ -52,4 +52,5 @@ class QgsCircularStringV2: public QgsCurveV2
|
||||
bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const;
|
||||
|
||||
void sumUpArea( double& sum ) const;
|
||||
bool hasCurvedSegments() const;
|
||||
};
|
||||
|
@ -58,4 +58,6 @@ class QgsCompoundCurveV2: public QgsCurveV2
|
||||
bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const;
|
||||
|
||||
void sumUpArea( double& sum ) const;
|
||||
|
||||
bool hasCurvedSegments() const;
|
||||
};
|
||||
|
@ -59,4 +59,7 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
|
||||
virtual void coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord /Out/ ) const;
|
||||
double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const;
|
||||
bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const;
|
||||
|
||||
bool hasCurvedSegments() const;
|
||||
QgsAbstractGeometryV2* segmentize() const /Factory/;
|
||||
};
|
||||
|
@ -23,4 +23,7 @@ class QgsCurveV2: public QgsAbstractGeometryV2
|
||||
virtual void coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord /Out/ ) const;
|
||||
virtual bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const;
|
||||
virtual bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const = 0;
|
||||
|
||||
/**Returns a geometry without curves. Caller takes ownership*/
|
||||
QgsAbstractGeometryV2* segmentize() const /Factory/;
|
||||
};
|
||||
|
@ -49,4 +49,6 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
|
||||
|
||||
virtual double length() const;
|
||||
virtual double area() const;
|
||||
|
||||
bool hasCurvedSegments() const;
|
||||
};
|
||||
|
@ -20,4 +20,6 @@ class QgsMultiCurveV2: public QgsGeometryCollectionV2
|
||||
|
||||
/**Adds a geometry and takes ownership. Returns true in case of success*/
|
||||
virtual bool addGeometry( QgsAbstractGeometryV2* g );
|
||||
/**Returns a geometry without curves. Caller takes ownership*/
|
||||
QgsAbstractGeometryV2* segmentize() const /Factory/;
|
||||
};
|
||||
|
@ -19,4 +19,7 @@ class QgsMultiSurfaceV2: public QgsGeometryCollectionV2
|
||||
|
||||
/**Adds a geometry and takes ownership. Returns true in case of success*/
|
||||
virtual bool addGeometry( QgsAbstractGeometryV2* g );
|
||||
|
||||
/**Returns a geometry without curves. Caller takes ownership*/
|
||||
QgsAbstractGeometryV2* segmentize() const /Factory/;
|
||||
};
|
||||
|
@ -131,6 +131,9 @@ class CORE_EXPORT QgsAbstractGeometryV2
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
virtual bool hasCurvedSegments() const { return false; }
|
||||
/**Returns a geometry without curves. Caller takes ownership*/
|
||||
virtual QgsAbstractGeometryV2* segmentize() const { return clone(); }
|
||||
|
||||
protected:
|
||||
QgsWKBTypes::Type mWkbType;
|
||||
|
@ -72,6 +72,8 @@ class CORE_EXPORT QgsCircularStringV2: public QgsCurveV2
|
||||
|
||||
void sumUpArea( double& sum ) const override;
|
||||
|
||||
bool hasCurvedSegments() const override { return true; }
|
||||
|
||||
private:
|
||||
QVector<double> mX;
|
||||
QVector<double> mY;
|
||||
|
@ -333,24 +333,7 @@ QgsLineStringV2* QgsCompoundCurveV2::curveToLine() const
|
||||
line->append( currentLine );
|
||||
delete currentLine;
|
||||
}
|
||||
#if 0
|
||||
if ( curveIt == mCurves.constBegin() )
|
||||
{
|
||||
line = ( *curveIt )->curveToLine();
|
||||
if ( !line )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLine = ( *curveIt )->curveToLine();
|
||||
line->append( currentLine );
|
||||
delete currentLine;
|
||||
}
|
||||
}
|
||||
#endif //0
|
||||
return line;
|
||||
return line;
|
||||
}
|
||||
|
||||
const QgsCurveV2* QgsCompoundCurveV2::curveAt( int i ) const
|
||||
@ -568,3 +551,16 @@ void QgsCompoundCurveV2::close()
|
||||
addVertex( startPoint() );
|
||||
}
|
||||
|
||||
bool QgsCompoundCurveV2::hasCurvedSegments() const
|
||||
{
|
||||
QList< QgsCurveV2* >::const_iterator curveIt = mCurves.constBegin();
|
||||
for ( ; curveIt != mCurves.constEnd(); ++curveIt )
|
||||
{
|
||||
if (( *curveIt )->hasCurvedSegments() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,8 @@ class CORE_EXPORT QgsCompoundCurveV2: public QgsCurveV2
|
||||
/**Appends first point if not already closed*/
|
||||
void close();
|
||||
|
||||
bool hasCurvedSegments() const override;
|
||||
|
||||
private:
|
||||
QList< QgsCurveV2* > mCurves;
|
||||
/**Turns a vertex id for the compound curve into one or more ids for the subcurves
|
||||
|
@ -636,3 +636,26 @@ bool QgsCurvePolygonV2::deleteVertex( const QgsVertexId& vId )
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool QgsCurvePolygonV2::hasCurvedSegments() const
|
||||
{
|
||||
if ( mExteriorRing && mExteriorRing->hasCurvedSegments() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<QgsCurveV2*>::const_iterator it = mInteriorRings.constBegin();
|
||||
for ( ; it != mInteriorRings.constEnd(); ++it )
|
||||
{
|
||||
if (( *it )->hasCurvedSegments() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsAbstractGeometryV2* QgsCurvePolygonV2::segmentize() const
|
||||
{
|
||||
return toPolygon();
|
||||
}
|
||||
|
@ -80,6 +80,9 @@ class CORE_EXPORT QgsCurvePolygonV2: public QgsSurfaceV2
|
||||
double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const override;
|
||||
bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const override;
|
||||
|
||||
bool hasCurvedSegments() const override;
|
||||
QgsAbstractGeometryV2* segmentize() const override;
|
||||
|
||||
protected:
|
||||
|
||||
QgsCurveV2* mExteriorRing;
|
||||
|
@ -16,6 +16,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgscurvev2.h"
|
||||
#include "qgslinestringv2.h"
|
||||
|
||||
QgsCurveV2::QgsCurveV2(): QgsAbstractGeometryV2()
|
||||
{}
|
||||
@ -79,3 +80,8 @@ double QgsCurveV2::area() const
|
||||
sumUpArea( area );
|
||||
return qAbs( area );
|
||||
}
|
||||
|
||||
QgsAbstractGeometryV2* QgsCurveV2::segmentize() const
|
||||
{
|
||||
return curveToLine();
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ class CORE_EXPORT QgsCurveV2: public QgsAbstractGeometryV2
|
||||
virtual void coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord ) const override;
|
||||
virtual bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const override;
|
||||
virtual bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const = 0;
|
||||
|
||||
/**Returns a geometry without curves. Caller takes ownership*/
|
||||
QgsAbstractGeometryV2* segmentize() const override;
|
||||
};
|
||||
|
||||
#endif // QGSCURVEV2_H
|
||||
|
@ -1485,42 +1485,10 @@ void QgsGeometry::convertToStraightSegment()
|
||||
}
|
||||
|
||||
detach();
|
||||
QgsWKBTypes::Type flatGeomType = QgsWKBTypes::flatType( d->geometry->wkbType() );
|
||||
if ( flatGeomType == QgsWKBTypes::CompoundCurve || flatGeomType == QgsWKBTypes::CircularString )
|
||||
{
|
||||
QgsCurveV2* curve = dynamic_cast<QgsCurveV2*>( d->geometry );
|
||||
if ( !curve )
|
||||
{
|
||||
return ;
|
||||
}
|
||||
d->geometry = curve->curveToLine();
|
||||
removeWkbGeos();
|
||||
delete curve;
|
||||
}
|
||||
else if ( flatGeomType == QgsWKBTypes::CurvePolygon )
|
||||
{
|
||||
QgsCurvePolygonV2* curvePolygon = dynamic_cast<QgsCurvePolygonV2*>( d->geometry );
|
||||
if ( !curvePolygon )
|
||||
{
|
||||
return;
|
||||
}
|
||||
d->geometry = curvePolygon->toPolygon();
|
||||
removeWkbGeos();
|
||||
delete curvePolygon;
|
||||
}
|
||||
else //no segmentation needed
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//compoundcurve / circularstring /multicurve ?
|
||||
|
||||
//curve polygon / multisurface?
|
||||
delete[] mWkb;
|
||||
mWkb = 0;
|
||||
mWkbSize = 0;
|
||||
GEOSGeom_destroy( mGeos );
|
||||
mGeos = 0;
|
||||
QgsAbstractGeometryV2* straightGeom = d->geometry->segmentize();
|
||||
delete d->geometry;
|
||||
d->geometry = straightGeom;
|
||||
removeWkbGeos();
|
||||
}
|
||||
|
||||
bool QgsGeometry::requiresConversionToStraightSegments() const
|
||||
@ -1530,9 +1498,7 @@ bool QgsGeometry::requiresConversionToStraightSegments() const
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsWKBTypes::Type flatGeomType = QgsWKBTypes::flatType( d->geometry->wkbType() );
|
||||
return ( flatGeomType == QgsWKBTypes::CompoundCurve || flatGeomType == QgsWKBTypes::CircularString
|
||||
|| flatGeomType == QgsWKBTypes::CurvePolygon );
|
||||
return d->geometry->hasCurvedSegments();
|
||||
}
|
||||
|
||||
int QgsGeometry::transform( const QgsCoordinateTransform& ct )
|
||||
|
@ -446,3 +446,16 @@ bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList
|
||||
qDeleteAll( subtypes );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsGeometryCollectionV2::hasCurvedSegments() const
|
||||
{
|
||||
QVector< QgsAbstractGeometryV2* >::const_iterator it = mGeometries.constBegin();
|
||||
for ( ; it != mGeometries.constEnd(); ++it )
|
||||
{
|
||||
if (( *it )->hasCurvedSegments() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2
|
||||
virtual double length() const override;
|
||||
virtual double area() const override;
|
||||
|
||||
bool hasCurvedSegments() const override;
|
||||
|
||||
protected:
|
||||
QVector< QgsAbstractGeometryV2* > mGeometries;
|
||||
void removeGeometries();
|
||||
|
@ -106,3 +106,14 @@ bool QgsMultiCurveV2::addGeometry( QgsAbstractGeometryV2* g )
|
||||
setZMTypeFromSubGeometry( g, QgsWKBTypes::MultiCurve );
|
||||
return QgsGeometryCollectionV2::addGeometry( g );
|
||||
}
|
||||
|
||||
QgsAbstractGeometryV2* QgsMultiCurveV2::segmentize() const
|
||||
{
|
||||
QgsMultiCurveV2* c = new QgsMultiCurveV2();
|
||||
QVector< QgsAbstractGeometryV2* >::const_iterator geomIt = mGeometries.constBegin();
|
||||
for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
|
||||
{
|
||||
c->addGeometry(( *geomIt )->segmentize() );
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ class CORE_EXPORT QgsMultiCurveV2: public QgsGeometryCollectionV2
|
||||
|
||||
/**Adds a geometry and takes ownership. Returns true in case of success*/
|
||||
virtual bool addGeometry( QgsAbstractGeometryV2* g ) override;
|
||||
/**Returns a geometry without curves. Caller takes ownership*/
|
||||
QgsAbstractGeometryV2* segmentize() const override;
|
||||
};
|
||||
|
||||
#endif // QGSMULTICURVEV2_H
|
||||
|
@ -126,3 +126,14 @@ bool QgsMultiSurfaceV2::addGeometry( QgsAbstractGeometryV2* g )
|
||||
setZMTypeFromSubGeometry( g, QgsWKBTypes::MultiSurface );
|
||||
return QgsGeometryCollectionV2::addGeometry( g );
|
||||
}
|
||||
|
||||
QgsAbstractGeometryV2* QgsMultiSurfaceV2::segmentize() const
|
||||
{
|
||||
QgsMultiSurfaceV2* c = new QgsMultiSurfaceV2();
|
||||
QVector< QgsAbstractGeometryV2* >::const_iterator geomIt = mGeometries.constBegin();
|
||||
for ( ; geomIt != mGeometries.constEnd(); ++geomIt )
|
||||
{
|
||||
c->addGeometry(( *geomIt )->segmentize() );
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ class CORE_EXPORT QgsMultiSurfaceV2: public QgsGeometryCollectionV2
|
||||
|
||||
/**Adds a geometry and takes ownership. Returns true in case of success*/
|
||||
virtual bool addGeometry( QgsAbstractGeometryV2* g ) override;
|
||||
|
||||
/**Returns a geometry without curves. Caller takes ownership*/
|
||||
QgsAbstractGeometryV2* segmentize() const override;
|
||||
};
|
||||
|
||||
#endif // QGSMULTISURFACEV2_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user