<p dir="ltr">Hi all,</p>
<p dir="ltr">I am working with the GeoTools developers on their OGR module in order to add OGR support for GeoScript and I have a question about what exactly Layer.TestCapability means.  In GeoTools (which is written in Java), when creating a new Layer we call Layer.TestCapability("CreateField") to see if we can create a new field.  For most drivers this works fine.  For GeoRSS and GPX testing for CreateField returns false even though if we comment out the TestCapability("CreateField") check creating the fields succeeds.  Here is the GeoTools code in question:</p>

<p dir="ltr"><a href="https://github.com/geotools/geotools/blob/master/modules/unsupported/ogr/ogr-core/src/main/java/org/geotools/data/ogr/OGRDataStore.java#L188">https://github.com/geotools/geotools/blob/master/modules/unsupported/ogr/ogr-core/src/main/java/org/geotools/data/ogr/OGRDataStore.java#L188</a></p>

<p dir="ltr">Are we using TestCapability("CreateField") correctly?    Should it be used when creating new layers or just when adding a field to an existing layer?</p>
<p dir="ltr">I did notice that the GeoRSS driver doesn't seem to explicitly support CreateField (<a href="https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmts/georss/ogrgeorsslayer.cpp#L2207">https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmts/georss/ogrgeorsslayer.cpp#L2207</a>) it just returns false.</p>

<p dir="ltr">Here is a small Python script that illustrates my question.</p>
<p dir="ltr">from osgeo import ogr<br>
import os</p>
<p dir="ltr">if os.path.exists("atom.xml"):<br>
    os.remove("atom.xml")</p>
<p dir="ltr">ds = ogr.GetDriverByName("GeoRSS").CreateDataSource("atom.xml", options=["FORMAT=ATOM"])<br>
layer = ds.CreateLayer("georss")<br>
for cap in ["CreateField","DeleteField"]:<br>
    print "%s = %s" % (cap, layer.TestCapability(cap))</p>
<p dir="ltr">data = [<br>
        {"x": -122.275147, "y": 47.109372, "title": "point", "id": "123"}<br>
]</p>
<p dir="ltr">layer.CreateField(ogr.FieldDefn("id", ogr.OFTString))<br>
layer.CreateField(ogr.FieldDefn("title", ogr.OFTString))</p>
<p dir="ltr">feature = ogr.Feature(layer.GetLayerDefn())<br>
feature.SetField("title", data[0]["title"])<br>
feature.SetField("id", data[0]["id"])<br>
feature.SetGeometryDirectly(ogr.CreateGeometryFromWkt("POINT (%d %d)" % (data[0]["x"], data[0]["y"])))</p>
<p dir="ltr">layer.CreateFeature(feature)<br>
feature.Destroy()<br>
ds.Destroy()</p>
<p dir="ltr">The output I get from running this is:</p>
<p dir="ltr">CreateField = False<br>
Delete Field = False</p>
<p dir="ltr">but the creation of the fields and the GeoRSS file succeeds.</p>
<p dir="ltr">Thank you!<br>
Jared Erickson<br>
</p>