[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:

https://github.com/geotools/geotools/blob/master/modules/unsupported/ogr/ogr-core/src/main/java/org/geotools/data/ogr/OGRDataStore.java#L188

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 (
https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmts/georss/ogrgeorsslayer.cpp#L2207)
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"):
    os.remove("atom.xml")

ds = ogr.GetDriverByName("GeoRSS").CreateDataSource("atom.xml",
options=["FORMAT=ATOM"])
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"])))

layer.CreateFeature(feature)
feature.Destroy()
ds.Destroy()

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