[gdal-dev] GeoRSS and TestCapability("CreateField")

Jared Erickson jared.erickson at gmail.com
Wed Jan 8 12:23:50 PST 2014

Hi all,

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:


Are we using TestCapability("CreateField") correctly?    Should it be used
when creating new layers or just when adding a field to an existing layer?

I did notice that the GeoRSS driver doesn't seem to explicitly support
CreateField (
it just returns false.

Here is a small Python script that illustrates my question.

from osgeo import ogr
import os

if os.path.exists("atom.xml"):

ds = ogr.GetDriverByName("GeoRSS").CreateDataSource("atom.xml",
layer = ds.CreateLayer("georss")
for cap in ["CreateField","DeleteField"]:
    print "%s = %s" % (cap, layer.TestCapability(cap))

data = [
        {"x": -122.275147, "y": 47.109372, "title": "point", "id": "123"}

layer.CreateField(ogr.FieldDefn("id", ogr.OFTString))
layer.CreateField(ogr.FieldDefn("title", ogr.OFTString))

feature = ogr.Feature(layer.GetLayerDefn())
feature.SetField("title", data[0]["title"])
feature.SetField("id", data[0]["id"])
feature.SetGeometryDirectly(ogr.CreateGeometryFromWkt("POINT (%d %d)" %
(data[0]["x"], data[0]["y"])))


The output I get from running this is:

CreateField = False
Delete Field = False

but the creation of the fields and the GeoRSS file succeeds.

Thank you!
Jared Erickson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140108/f00926ac/attachment.html>

More information about the gdal-dev mailing list