mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
fix geometry editing:
- store geometry changes to added features - fix GEOS exception handling - fix QgsGeometry::vertexAt() and QgsGeometry::closestVertexWithContext() git-svn-id: http://svn.osgeo.org/qgis/trunk@9304 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
5f760995cc
commit
787c363e5f
@ -38,26 +38,46 @@ email : morb at ozemail dot com dot au
|
||||
class GEOSException
|
||||
{
|
||||
public:
|
||||
GEOSException( const char *theMsg )
|
||||
GEOSException( char *theMsg )
|
||||
{
|
||||
msg = theMsg;
|
||||
if ( strcmp( theMsg, "Unknown exception thrown" ) == 0 && lastMsg )
|
||||
{
|
||||
delete [] theMsg;
|
||||
msg = new char[strlen( lastMsg )+1];
|
||||
strcpy( msg, lastMsg );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = theMsg;
|
||||
lastMsg = msg;
|
||||
}
|
||||
}
|
||||
|
||||
// copy constructor
|
||||
GEOSException( const GEOSException &rhs )
|
||||
{
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
~GEOSException()
|
||||
{
|
||||
if ( lastMsg == msg )
|
||||
lastMsg = NULL;
|
||||
delete [] msg;
|
||||
}
|
||||
|
||||
|
||||
const char *what()
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
|
||||
private:
|
||||
const char *msg;
|
||||
char *msg;
|
||||
static const char *lastMsg;
|
||||
};
|
||||
|
||||
const char *GEOSException::lastMsg = NULL;
|
||||
|
||||
void throwGEOSException( const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
@ -2080,7 +2100,11 @@ QgsPoint QgsGeometry::vertexAt( int atVertex )
|
||||
{
|
||||
try
|
||||
{
|
||||
const GEOSCoordSequence *cs = GEOSGeom_getCoordSeq( mGeos );
|
||||
const GEOSGeometry *g = GEOSGetExteriorRing( mGeos );
|
||||
if ( !g )
|
||||
return QgsPoint( 0, 0 );
|
||||
|
||||
const GEOSCoordSequence *cs = GEOSGeom_getCoordSeq( g );
|
||||
GEOSCoordSeq_getX( cs, atVertex, &x );
|
||||
GEOSCoordSeq_getY( cs, atVertex, &y );
|
||||
return QgsPoint( x, y );
|
||||
@ -2317,7 +2341,11 @@ double QgsGeometry::closestVertexWithContext( const QgsPoint& point, int& atVert
|
||||
// set up the GEOS geometry
|
||||
exportWkbToGeos();
|
||||
|
||||
const GEOSCoordSequence *sequence = GEOSGeom_getCoordSeq( mGeos );
|
||||
const GEOSGeometry *g = GEOSGetExteriorRing( mGeos );
|
||||
if ( g == NULL )
|
||||
return -1;
|
||||
|
||||
const GEOSCoordSequence *sequence = GEOSGeom_getCoordSeq( g );
|
||||
|
||||
unsigned int n;
|
||||
GEOSCoordSeq_getSize( sequence, &n );
|
||||
|
@ -2745,6 +2745,14 @@ bool QgsVectorLayer::commitChanges()
|
||||
//
|
||||
if ( mAddedFeatures.size() > 0 )
|
||||
{
|
||||
for ( QgsFeatureList::iterator iter = mAddedFeatures.begin(); iter != mAddedFeatures.end(); ++iter )
|
||||
{
|
||||
if ( mChangedGeometries.contains( iter->featureId() ) )
|
||||
{
|
||||
iter->setGeometry( mChangedGeometries.take( iter->featureId() ) );
|
||||
}
|
||||
}
|
||||
|
||||
if (( cap & QgsVectorDataProvider::AddFeatures ) && mDataProvider->addFeatures( mAddedFeatures ) )
|
||||
{
|
||||
mCommitErrors << tr( "SUCCESS: %1 features added." ).arg( mAddedFeatures.size() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user