[Geoserver-users] PostGIS column names to GML

Hi,

just accidentally stumbled upon this today. I might be missing something really obvious but the GML-based output formats for (none of the versions of) WFS seem to return columns with the names:

- name
- description

while e.g. application/json returns them just fine. Turning up logging to GEOTOOLS_DEVELOPER shows that the query executed for GetFeature in the database is ok for GML outputs too (see end of this e-mail) although the "offending" columns are not returned in output.

So I quess this is simply a GML shortcoming of "thou shalt not use these column names"?

For example on localhost:5432

create table fs (
     oid serial not null,
     geom geometry(point, 4326),
     name text,
     description text,
     f_name text,
     f_description text
);
alter table fs add constraint pk__fs primary key (oid);

and then publishing the layer on GeoServer (2.21.1, using the kartofsa docker image), see basic config for layer at https://drive.google.com/drive/folders/110Py1Od8VZZvPQTtvfECXg_PPfYdRuej?usp=sharing

This will have in DescribeFeatureType (and GetFeature aswell):

a) for "application/json" all as expected:

$ curl -o - "http://localhost:8080/geoserver/fs/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=fs%3Afs&outputFormat=application/json"
{"elementFormDefault":"qualified","targetNamespace":"https://localhost/fs","targetPrefix":"fs","featureTypes":\[\{"typeName":"fs","properties":\[\{"name":"oid","maxOccurs":1,"minOccurs":1,"nillable":false,"type":"xsd:int","localType":"int"\},\{"name":"geom","maxOccurs":1,"minOccurs":0,"nillable":true,"type":"gml:Point","localType":"Point"\},\{"name":"name","maxOccurs":1,"minOccurs":0,"nillable":true,"type":"xsd:string","localType":"string"\},\{"name":"description","maxOccurs":1,"minOccurs":0,"nillable":true,"type":"xsd:string","localType":"string"\},\{"name":"f\_name","maxOccurs":1,"minOccurs":0,"nillable":true,"type":"xsd:string","localType":"string"\},\{"name":"f\_description","maxOccurs":1,"minOccurs":0,"nillable":true,"type":"xsd:string","localType":"string"\}\]\}]}

b) but for "application/gml+xml; version=3.2":

$ curl -o - "http://localhost:8080/geoserver/fs/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=fs%3Afs&outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2"
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns:fs="https://localhost/fs&quot; xmlns:gml="http://www.opengis.net/gml/3.2&quot; xmlns:wfs="http://www.opengis.net/wfs/2.0&quot; elementFormDefault="qualified" targetNamespace="https://localhost/fs&quot;&gt;
   <xsd:import namespace="http://www.opengis.net/gml/3.2&quot; schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.2.1/gml.xsd&quot;/&gt;
   <xsd:complexType name="fsType">
     <xsd:complexContent>
       <xsd:extension base="gml:AbstractFeatureType">
         <xsd:sequence>
           <xsd:element maxOccurs="1" minOccurs="1" name="oid" nillable="false" type="xsd:int"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="geom" nillable="true" type="gml:PointPropertyType"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="f_name" nillable="true" type="xsd:string"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="f_description" nillable="true" type="xsd:string"/>
         </xsd:sequence>
       </xsd:extension>
     </xsd:complexContent>
   </xsd:complexType>
   <xsd:element name="fs" substitutionGroup="gml:AbstractFeature" type="fs:fsType"/>
</xsd:schema>

c) and also for "text/xml; subtype=gml/3.1.1":

$ curl -o - "http://localhost:8080/geoserver/fs/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=fs%3Afs&outputFormat=text/xml;%20subtype=gml/3.1.1&quot;
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns:fs="https://localhost/fs&quot; xmlns:gml="http://www.opengis.net/gml&quot; elementFormDefault="qualified" targetNamespace="https://localhost/fs&quot;&gt;
   <xsd:import namespace="http://www.opengis.net/gml&quot; schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/gml.xsd&quot;/&gt;
   <xsd:complexType name="fsType">
     <xsd:complexContent>
       <xsd:extension base="gml:AbstractFeatureType">
         <xsd:sequence>
           <xsd:element maxOccurs="1" minOccurs="1" name="oid" nillable="false" type="xsd:int"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="geom" nillable="true" type="gml:PointPropertyType"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="f_name" nillable="true" type="xsd:string"/>
           <xsd:element maxOccurs="1" minOccurs="0" name="f_description" nillable="true" type="xsd:string"/>
         </xsd:sequence>
       </xsd:extension>
     </xsd:complexContent>
   </xsd:complexType>
   <xsd:element name="fs" substitutionGroup="gml:_Feature" type="fs:fsType"/>
</xsd:schema>

If logging is turned up to GEOTOOLS_DEVELOPER the GetFeature request produces this into the logs regardless of outputformat.

10 027 16:27:03 DEBUG [geotools.jdbc] - CREATE CONNECTION
10 027 16:27:03 DEBUG [geotools.jdbc] - SELECT "oid",encode(ST_AsEWKB("geom"), 'base64') as "geom","name","description","f_name","f_description" FROM "public"."fs" LIMIT 1000000
10 027 16:27:03 DEBUG [geotools.jdbc] - CLOSE CONNECTION

So everything is seemingly as it should be :slight_smile:

All the best,
Tõnis

--
@tkardi

This the expected behaviour see https://gis.stackexchange.com/a/388397/79 for more details.

Ian

On Wed, 10 Aug 2022, 18:12 Tõnis Kärdi, <tonis.kardi@anonymised.com> wrote:

Hi,

just accidentally stumbled upon this today. I might be missing something
really obvious but the GML-based output formats for (none of the
versions of) WFS seem to return columns with the names:

  • name
  • description

while e.g. application/json returns them just fine. Turning up logging
to GEOTOOLS_DEVELOPER shows that the query executed for GetFeature in
the database is ok for GML outputs too (see end of this e-mail) although
the “offending” columns are not returned in output.

So I quess this is simply a GML shortcoming of “thou shalt not use these
column names”?

For example on localhost:5432

create table fs (
oid serial not null,
geom geometry(point, 4326),
name text,
description text,
f_name text,
f_description text
);
alter table fs add constraint pk__fs primary key (oid);

and then publishing the layer on GeoServer (2.21.1, using the kartofsa
docker image), see basic config for layer at
https://drive.google.com/drive/folders/110Py1Od8VZZvPQTtvfECXg_PPfYdRuej?usp=sharing

This will have in DescribeFeatureType (and GetFeature aswell):

a) for “application/json” all as expected:

$ curl -o -
http://localhost:8080/geoserver/fs/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=fs%3Afs&outputFormat=application/json
{“elementFormDefault”:“qualified”,“targetNamespace”:“https://localhost/fs”,“targetPrefix”:“fs”,“featureTypes”:[{“typeName”:“fs”,“properties”:[{“name”:“oid”,“maxOccurs”:1,“minOccurs”:1,“nillable”:false,“type”:“xsd:int”,“localType”:“int”},{“name”:“geom”,“maxOccurs”:1,“minOccurs”:0,“nillable”:true,“type”:“gml:Point”,“localType”:“Point”},{“name”:“name”,“maxOccurs”:1,“minOccurs”:0,“nillable”:true,“type”:“xsd:string”,“localType”:“string”},{“name”:“description”,“maxOccurs”:1,“minOccurs”:0,“nillable”:true,“type”:“xsd:string”,“localType”:“string”},{“name”:“f_name”,“maxOccurs”:1,“minOccurs”:0,“nillable”:true,“type”:“xsd:string”,“localType”:“string”},{“name”:“f_description”,“maxOccurs”:1,“minOccurs”:0,“nillable”:true,“type”:“xsd:string”,“localType”:“string”}]}]}

b) but for “application/gml+xml; version=3.2”:

$ curl -o -
http://localhost:8080/geoserver/fs/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=fs%3Afs&outputFormat=application%2Fgml%2Bxml%3B%20version%3D3.2

<?xml version="1.0" encoding="UTF-8"?><xsd:schema

xmlns:xsd=“http://www.w3.org/2001/XMLSchema
xmlns:fs=“https://localhost/fs
xmlns:gml=“http://www.opengis.net/gml/3.2
xmlns:wfs=“http://www.opengis.net/wfs/2.0
elementFormDefault=“qualified” targetNamespace=“https://localhost/fs”>
<xsd:import namespace=“http://www.opengis.net/gml/3.2
schemaLocation=“http://localhost:8080/geoserver/schemas/gml/3.2.1/gml.xsd”/>
<xsd:complexType name=“fsType”>
xsd:complexContent
<xsd:extension base=“gml:AbstractFeatureType”>
xsd:sequence
<xsd:element maxOccurs=“1” minOccurs=“1” name=“oid”
nillable=“false” type=“xsd:int”/>
<xsd:element maxOccurs=“1” minOccurs=“0” name=“geom”
nillable=“true” type=“gml:PointPropertyType”/>
<xsd:element maxOccurs=“1” minOccurs=“0” name=“f_name”
nillable=“true” type=“xsd:string”/>
<xsd:element maxOccurs=“1” minOccurs=“0” name=“f_description”
nillable=“true” type=“xsd:string”/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name=“fs” substitutionGroup=“gml:AbstractFeature”
type=“fs:fsType”/>
</xsd:schema>

c) and also for “text/xml; subtype=gml/3.1.1”:

$ curl -o -
http://localhost:8080/geoserver/fs/ows?service=WFS&version=2.0.0&request=DescribeFeatureType&typeName=fs%3Afs&outputFormat=text/xml;%20subtype=gml/3.1.1

<?xml version="1.0" encoding="UTF-8"?><xsd:schema

xmlns:xsd=“http://www.w3.org/2001/XMLSchema
xmlns:fs=“https://localhost/fs” xmlns:gml=“http://www.opengis.net/gml
elementFormDefault=“qualified” targetNamespace=“https://localhost/fs”>
<xsd:import namespace=“http://www.opengis.net/gml
schemaLocation=“http://localhost:8080/geoserver/schemas/gml/3.1.1/base/gml.xsd”/>
<xsd:complexType name=“fsType”>
xsd:complexContent
<xsd:extension base=“gml:AbstractFeatureType”>
xsd:sequence
<xsd:element maxOccurs=“1” minOccurs=“1” name=“oid”
nillable=“false” type=“xsd:int”/>
<xsd:element maxOccurs=“1” minOccurs=“0” name=“geom”
nillable=“true” type=“gml:PointPropertyType”/>
<xsd:element maxOccurs=“1” minOccurs=“0” name=“f_name”
nillable=“true” type=“xsd:string”/>
<xsd:element maxOccurs=“1” minOccurs=“0” name=“f_description”
nillable=“true” type=“xsd:string”/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name=“fs” substitutionGroup=“gml:_Feature”
type=“fs:fsType”/>
</xsd:schema>

If logging is turned up to GEOTOOLS_DEVELOPER the GetFeature request
produces this into the logs regardless of outputformat.

10 027 16:27:03 DEBUG [geotools.jdbc] - CREATE CONNECTION
10 027 16:27:03 DEBUG [geotools.jdbc] - SELECT
“oid”,encode(ST_AsEWKB(“geom”), ‘base64’) as
“geom”,“name”,“description”,“f_name”,“f_description” FROM “public”.“fs”
LIMIT 1000000
10 027 16:27:03 DEBUG [geotools.jdbc] - CLOSE CONNECTION

So everything is seemingly as it should be :slight_smile:

All the best,
Tõnis


@tkardi


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Thanks for the quick answer, Ian. Exactly what I was supposed to look for but was unable to formulate my question.

All the best,
Tõnis

On 10.08.22 20:35, Ian Turton wrote:

This the expected behaviour see https://gis.stackexchange.com/a/388397/79 for more details.

Ian

On Wed, 10 Aug 2022, 18:12 Tõnis Kärdi, <tonis.kardi@anonymised.com <mailto:tonis.kardi@anonymised.com>> wrote:

    Hi,

    just accidentally stumbled upon this today. I might be missing
    something
    really obvious but the GML-based output formats for (none of the
    versions of) WFS seem to return columns with the names:

    - name
    - description

    while e.g. application/json returns them just fine. Turning up logging
    to GEOTOOLS_DEVELOPER shows that the query executed for GetFeature in
    the database is ok for GML outputs too (see end of this e-mail)
    although
    the "offending" columns are not returned in output.

    So I quess this is simply a GML shortcoming of "thou shalt not use
    these
    column names"?

...

--
@tkardi
skype: tonis.kardi