Skip to content

Commit

Permalink
LIBKML: do not advertize RandomWrite capability (unless on a update l…
Browse files Browse the repository at this point in the history
…ayer, when datasource is created with UPDATE_TARGETHREF creation option) (fixes qgis/QGIS#39087)
  • Loading branch information
rouault committed Sep 29, 2020
1 parent 9943ada commit a2166a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions autotest/ogr/ogr_libkml.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ def ogr_libkml_write(filename):
srs.SetWellKnownGeogCS('WGS72')
lyr = ds.CreateLayer('test_wgs72', srs=srs)

assert lyr.TestCapability(ogr.OLCSequentialWrite) == 1
assert lyr.TestCapability(ogr.OLCRandomWrite) == 0

dst_feat = ogr.Feature(lyr.GetLayerDefn())
dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (2 49)'))
assert lyr.CreateFeature(dst_feat) == 0, 'CreateFeature failed.'
Expand Down Expand Up @@ -1376,10 +1379,11 @@ def test_ogr_libkml_write_update():
with gdaltest.error_handler():
lyr.CreateFeature(feat)
feat.SetFID(10)
lyr.CreateFeature(feat)
assert lyr.CreateFeature(feat) == 0
feat.SetFID(2)
lyr.SetFeature(feat)
lyr.DeleteFeature(3)
assert lyr.TestCapability(ogr.OLCRandomWrite) == 1
assert lyr.SetFeature(feat) == 0
assert lyr.DeleteFeature(3) == 0
ds = None

if i == 0:
Expand Down
2 changes: 1 addition & 1 deletion gdal/ogr/ogrsf_frmts/libkml/ogrlibkmllayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ int OGRLIBKMLLayer::TestCapability( const char *pszCap )
else if( EQUAL( pszCap, OLCSequentialWrite ) )
result = bUpdate;
else if( EQUAL( pszCap, OLCRandomWrite ) )
result = bUpdate;
result = bUpdate && m_poKmlUpdate != nullptr;
else if( EQUAL( pszCap, OLCFastFeatureCount ) )
result = FALSE;
else if( EQUAL( pszCap, OLCFastSetNextByIndex ) )
Expand Down

0 comments on commit a2166a9

Please sign in to comment.