Skip to content

Commit 047d393

Browse files
committedNov 30, 2012
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents 9342a9c + aab08cb commit 047d393

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed
 

‎python/plugins/db_manager/dlg_import_vector.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ def __init__(self, inLayer, outDb, outUri, parent=None):
6363

6464
pk = self.outUri.keyColumn()
6565
self.editPrimaryKey.setText(pk if pk != "" else self.default_pk)
66-
geom = self.outUri.geometryColumn()
67-
self.editGeomColumn.setText(geom if geom != "" else self.default_geom)
66+
if self.inLayer.hasGeometryType():
67+
geom = self.outUri.geometryColumn()
68+
self.editGeomColumn.setText(geom if geom != "" else self.default_geom)
6869

6970
inCrs = self.inLayer.crs()
7071
srid = inCrs.postgisSrid() if inCrs.isValid() else 4236
@@ -76,10 +77,11 @@ def __init__(self, inLayer, outDb, outUri, parent=None):
7677

7778
def checkSupports(self):
7879
allowSpatial = self.db.connector.hasSpatialSupport()
79-
self.chkGeomColumn.setEnabled(allowSpatial and self.inLayer.hasGeometryType())
80-
self.chkSourceSrid.setEnabled(allowSpatial)
81-
self.chkTargetSrid.setEnabled(allowSpatial)
82-
self.chkSpatialIndex.setEnabled(allowSpatial)
80+
hasGeomType = self.inLayer.hasGeometryType()
81+
self.chkGeomColumn.setEnabled(allowSpatial and hasGeomType)
82+
self.chkSourceSrid.setEnabled(allowSpatial and hasGeomType)
83+
self.chkTargetSrid.setEnabled(allowSpatial and hasGeomType)
84+
self.chkSpatialIndex.setEnabled(allowSpatial and hasGeomType)
8385

8486

8587
def populateSchemas(self):
@@ -174,8 +176,11 @@ def importLayer(self):
174176
# get pk and geom field names from the source layer or use the
175177
# ones defined by the user
176178
pk = self.outUri.keyColumn() if not self.chkPrimaryKey.isChecked() else self.editPrimaryKey.text()
177-
geom = self.outUri.geometryColumn() if not self.chkGeomColumn.isChecked() else self.editGeomColumn.text()
178-
geom = geom if geom != "" else self.default_geom
179+
if self.inLayer.hasGeometryType():
180+
geom = self.outUri.geometryColumn() if not self.chkGeomColumn.isChecked() else self.editGeomColumn.text()
181+
geom = geom if geom != "" else self.default_geom
182+
else:
183+
geom = QString()
179184

180185
self.outUri.setDataSource( schema, table, geom, QString(), pk )
181186
uri = self.outUri.uri()

‎src/core/qgsvectorlayerimport.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,12 @@ bool QgsVectorLayerImport::addFeature( QgsFeature& feat )
121121
const QgsAttributeMap &attrs = feat.attributeMap();
122122

123123
QgsFeature newFeat;
124-
newFeat.setGeometry( *feat.geometry() );
124+
if ( feat.geometry() )
125+
newFeat.setGeometry( *feat.geometry() );
125126

126127
for ( QgsAttributeMap::const_iterator it = attrs.begin(); it != attrs.end(); it++ )
127128
{
128-
// add only mapped attributes (un-mapped ones are not present in the
129+
// add only mapped attributes (un-mapped ones will not be present in the
129130
// destination layer)
130131
if ( mOldToNewAttrIdx.contains( it.key() ) )
131132
{

‎src/mapserver/qgswfsserver.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,9 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
11681168
typeName = actionElem.attribute( "typeName" );
11691169
}
11701170

1171+
if ( typeName.contains( ":" ) )
1172+
typeName = typeName.section( ":", 1, 1 );
1173+
11711174
QDomNodeList typeNameList = mDocElem.elementsByTagName( typeName );
11721175
if ( typeNameList.count() == 0 )
11731176
{
@@ -1424,13 +1427,12 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
14241427
}
14251428
// Add the feature to th layer
14261429
// and store it to put it's Feature Id in the response
1427-
layer->addFeature( *f, true );
1428-
inFeatList << *f;
1430+
inFeatList.append( *f );
14291431
}
14301432
}
14311433
}
14321434
// Commit the changes of the insert elements
1433-
if ( !layer->commitChanges() )
1435+
if ( !provider->addFeatures( inFeatList ) )
14341436
{
14351437
QDomElement trElem = doc.createElement( "TransactionResult" );
14361438
QDomElement stElem = doc.createElement( "Status" );
@@ -1444,6 +1446,13 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
14441446
trElem.appendChild( locElem );
14451447

14461448
QDomElement mesElem = doc.createElement( "Message" );
1449+
QStringList mesErrors;
1450+
mesErrors << QString( "ERROR: %n feature(s) not added.").arg(inFeatList.size());
1451+
if ( provider->hasErrors() )
1452+
{
1453+
mesErrors << "\n Provider errors:" << provider->errors();
1454+
provider->clearErrors();
1455+
}
14471456
mesElem.appendChild( doc.createTextNode( layer->commitErrors().join( "\n " ) ) );
14481457
trElem.appendChild( mesElem );
14491458

@@ -1460,16 +1469,14 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
14601469
// Put the Feature Ids of the inserted feature
14611470
if ( insertResults.size() > 0 )
14621471
{
1463-
QDomElement irsElem = doc.createElement( "InsertResults" );
14641472
foreach (const QString &fidStr, insertResults)
14651473
{
14661474
QDomElement irElem = doc.createElement( "InsertResult" );
14671475
QDomElement fiElem = doc.createElement( "ogc:FeatureId" );
14681476
fiElem.setAttribute( "fid", fidStr );
14691477
irElem.appendChild( fiElem );
1470-
irsElem.appendChild( irElem );
1478+
respElem.appendChild( irElem );
14711479
}
1472-
respElem.appendChild( irsElem );
14731480
}
14741481

14751482
// Set the transaction reposne for success

0 commit comments

Comments
 (0)
Please sign in to comment.