[Geoserver-devel] Questions about namespaces/prefixes in WFS responses

Hello all,

So I started down a simple path. I was getting responses to my WFS queries against geoserver SVN-HEAD <--> ArcSDE that looked like this:

<gml:featureMember>
  <gml:GISDATA.TOWNS_POLY fid="GISDATA.TOWNS_POLY.3">
     <gml:OBJECTID>3</gml:OBJECTID>
     <gml:TOWNS_ID>3</gml:TOWNS_ID>
     <gml:SHAPE>
        <gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#26986&quot;&gt;
    ...
       </gml:MultiPolygon>
     </gml:SHAPE>
   </gml:GISDATA.TOWNS_POLY>
</gml:featureMember>

I thought this was a bit odd, as my GISDATA.TOWNS_POLY featureType isn't in the gml namespace at all, and isn't defined as such in any part of my configuration.

So I dug in a bit, and here's a brief recap of what I found.

Inside FeatureResponse.java.execute(), the real meat of the action happens. The running geoserver catalog is interrogated to find out all about the featureType information for the queried featureType (in my case - GISDATA.TOWNS_POLY). See line 246 or so for this sequence:

Data catalog = request.getWFS().getData();
...
meta = catalog.getFeatureTypeInfo(query.getTypeName());

Lots of debugging later, this looks gorgeous. No problems at all. My featureType is correctly decoded from the catalog, with the right namespace and all.

Then we actually do the query. See line 325 or so

FeatureResults features = source.getFeatures(query.toDataQuery(
                             maxFeatures));

The metadata is fused to the results:

results.addFeatures(meta, features);

All's good so far.

We go and prepare our delegate (I happen to know it's a GML2FeatureResponseDelegate). The delegate sets up all of our namespaces just fine (using that very same metadata pulled from the catalog earlier).

See around line 135 of GML2FeatureResponseDelegate.java:

ftNames.declareNamespace(features.getSchema(),
                 namespace.getPrefix(), uri);

Still running smoothly.

Finally, we go and actually writeTo our response. FeatureResponse.writeTo() invokes our GML2FeatureResponseDelegate.encode(), which in turn invokes our well set up FeatureTransformer.FeatureTranslator.

Well, I think it does...that part is a bit occluded because of the javax.xml.tranform stuff that's in the way.

So on we go, and our FeatureTransformer.FeatureTranslator goes to actually handle a Feature. And on line 592 of FeatureTransformer,java we try to figure out the currentPrefix for the given namespace:

currentPrefix = getNamespaceSupport().getPrefix(f.getFeatureType() .getNamespace().toString());

Unfortunately, this doesn't return the correct namespace for this feature. In fact, as far as the SDE DataStore is concerned, it will allways return the GML namespace for every feature.

This is because in the SDE DataStore code, we go and re-generate the featureType for each featureType we run across, starting on line 540 of ArcSDEDataStore.java.

The newly generated featuretype is very very similar to the featuretype that is pulled out of geoserver's catalog, but it's missing a couple of things...notably it's missing the namespace (which defaults to GML).

All of this is a long run-up to the questions I have:

1) Does this affect other datastores besides the ArcSDEDataStore? If not, how is the geoserver catalog "passed" or "communicated" to the geotools-specific FeatureReader generation code, so that each feature can have it's correct namespaces set?

2) It seems odd to me that there's a great infrastructure for looking all these various namespaces up, and that it's just the last teeny-tiny part of the featureReader that's screwy...has anyone else run across this?

3) I notice that three or four lines later there's fallback code:

if (currentPrefix == null) {
   currentPrefix = types.findPrefix(f.getFeatureType());
}

This code SHOULD fix exactly my problem...is this a problem with the ArcSDE DataStore such that when the SDEDataStore.getFeatureReader is discovering types, it should set their namespaces to null, rather than to the default GML namespace?

I have to think it's probably #3...

Anyone seen this before?

Sorry to be so long-winded.

thanks,
--saul

Hi Saul,

I hope you enjoyed your trip down the rabbit hole :).

I did some looking into this myself and I beleive the problem lies with the sde datastore. The namespace of the datastore is passed in as one of the connection parameters, but from what I can tell is never set on feature types created by the datastore.

About the feature type implementations defaulting to the gml namespace, i am little unsure what the correct action is. On one hand having a default can be nice, and the gml namespace makes sense. On the other hand application code has no way of telling if the namespace is set or not as you showed before.

I looked at some of the other datastores (postgis) and the correct behaviour is acheived.

I would be happy to patch the datastore however without a database to test with i would feel a bit shakey. I beleive Gabriel is the arcsde module maintainer, he may be able to help.

-Justin

Saul Farber wrote:

Hello all,

So I started down a simple path. I was getting responses to my WFS queries against geoserver SVN-HEAD <--> ArcSDE that looked like this:

<gml:featureMember>
<gml:GISDATA.TOWNS_POLY fid="GISDATA.TOWNS_POLY.3">
    <gml:OBJECTID>3</gml:OBJECTID>
    <gml:TOWNS_ID>3</gml:TOWNS_ID>
    <gml:SHAPE>
       <gml:MultiPolygon srsName="http://www.opengis.net/gml/srs/epsg.xml#26986&quot;&gt;
        ...
      </gml:MultiPolygon>
    </gml:SHAPE>
  </gml:GISDATA.TOWNS_POLY>
</gml:featureMember>

I thought this was a bit odd, as my GISDATA.TOWNS_POLY featureType isn't in the gml namespace at all, and isn't defined as such in any part of my configuration.

So I dug in a bit, and here's a brief recap of what I found.

Inside FeatureResponse.java.execute(), the real meat of the action happens. The running geoserver catalog is interrogated to find out all about the featureType information for the queried featureType (in my case - GISDATA.TOWNS_POLY). See line 246 or so for this sequence:

Data catalog = request.getWFS().getData();
...
meta = catalog.getFeatureTypeInfo(query.getTypeName());

Lots of debugging later, this looks gorgeous. No problems at all. My featureType is correctly decoded from the catalog, with the right namespace and all.

Then we actually do the query. See line 325 or so

FeatureResults features = source.getFeatures(query.toDataQuery(
                            maxFeatures));

The metadata is fused to the results:

results.addFeatures(meta, features);

All's good so far.

We go and prepare our delegate (I happen to know it's a GML2FeatureResponseDelegate). The delegate sets up all of our namespaces just fine (using that very same metadata pulled from the catalog earlier).

See around line 135 of GML2FeatureResponseDelegate.java:

ftNames.declareNamespace(features.getSchema(),
                namespace.getPrefix(), uri);

Still running smoothly.

Finally, we go and actually writeTo our response. FeatureResponse.writeTo() invokes our GML2FeatureResponseDelegate.encode(), which in turn invokes our well set up FeatureTransformer.FeatureTranslator.

Well, I think it does...that part is a bit occluded because of the javax.xml.tranform stuff that's in the way.

So on we go, and our FeatureTransformer.FeatureTranslator goes to actually handle a Feature. And on line 592 of FeatureTransformer,java we try to figure out the currentPrefix for the given namespace:

currentPrefix = getNamespaceSupport().getPrefix(f.getFeatureType() .getNamespace().toString());

Unfortunately, this doesn't return the correct namespace for this feature. In fact, as far as the SDE DataStore is concerned, it will allways return the GML namespace for every feature.

This is because in the SDE DataStore code, we go and re-generate the featureType for each featureType we run across, starting on line 540 of ArcSDEDataStore.java.

The newly generated featuretype is very very similar to the featuretype that is pulled out of geoserver's catalog, but it's missing a couple of things...notably it's missing the namespace (which defaults to GML).

All of this is a long run-up to the questions I have:

1) Does this affect other datastores besides the ArcSDEDataStore? If not, how is the geoserver catalog "passed" or "communicated" to the geotools-specific FeatureReader generation code, so that each feature can have it's correct namespaces set?

2) It seems odd to me that there's a great infrastructure for looking all these various namespaces up, and that it's just the last teeny-tiny part of the featureReader that's screwy...has anyone else run across this?

3) I notice that three or four lines later there's fallback code:

if (currentPrefix == null) {
  currentPrefix = types.findPrefix(f.getFeatureType());
}

This code SHOULD fix exactly my problem...is this a problem with the ArcSDE DataStore such that when the SDEDataStore.getFeatureReader is discovering types, it should set their namespaces to null, rather than to the default GML namespace?

I have to think it's probably #3...

Anyone seen this before?

Sorry to be so long-winded.

thanks,
--saul

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org

Justin,

Thanks for the reply.

I'll take a look at the datastore creation parameters, as you suggest.

I did get it to work yesterday by changing the ArcSDEDataStore code to generate an empty-string namespace for the created featuretype (passing in null again defaulted to the gml namespace).

I think this is actually a combination of geoserver and geotools configuration mis-connections. Geoserver expects the ArcSDE DataStore to use geoserver's configuration details (e.g. featuretypes) but ArcSDE has no way of knowing about them and simply generates its own.

Perhaps the real fix is to allow the ArcSDEDataStore code to have its featureType cache "injected" with any already-present featuretypes. I'll look into adding this code and I'll coordinate with Gabriel.

Thanks again justin!

--saul

Justin Deoliveira wrote:

Hi Saul,

I hope you enjoyed your trip down the rabbit hole :).

I did some looking into this myself and I beleive the problem lies with the sde datastore. The namespace of the datastore is passed in as one of the connection parameters, but from what I can tell is never set on feature types created by the datastore.

About the feature type implementations defaulting to the gml namespace, i am little unsure what the correct action is. On one hand having a default can be nice, and the gml namespace makes sense. On the other hand application code has no way of telling if the namespace is set or not as you showed before.

I looked at some of the other datastores (postgis) and the correct behaviour is acheived.

I would be happy to patch the datastore however without a database to test with i would feel a bit shakey. I beleive Gabriel is the arcsde module maintainer, he may be able to help.

-Justin

Saul Farber wrote:

Hi Saul,

thanks a lot for the extensive review and finding the bug.
I'm pretty sure the problem is ArcSDEDataStore not respecting the "namespace"
parameter GeoServer passes on the parameters Map.

I'll fix this tonight at home and let you know as soon as possible.

sorry I didn't attend quicker, was really bussy.

best regards and sorry for forcing you to so much debugging.

Gabriel.

On Friday 20 January 2006 18:52, Saul Farber wrote:

Justin,

Thanks for the reply.

I'll take a look at the datastore creation parameters, as you suggest.

I did get it to work yesterday by changing the ArcSDEDataStore code to
generate an empty-string namespace for the created featuretype (passing
in null again defaulted to the gml namespace).

I think this is actually a combination of geoserver and geotools
configuration mis-connections. Geoserver expects the ArcSDE DataStore
to use geoserver's configuration details (e.g. featuretypes) but ArcSDE
has no way of knowing about them and simply generates its own.

Perhaps the real fix is to allow the ArcSDEDataStore code to have its
featureType cache "injected" with any already-present featuretypes.
I'll look into adding this code and I'll coordinate with Gabriel.

Thanks again justin!

--saul

Justin Deoliveira wrote:
> Hi Saul,
>
> I hope you enjoyed your trip down the rabbit hole :).
>
> I did some looking into this myself and I beleive the problem lies with
> the sde datastore. The namespace of the datastore is passed in as one of
> the connection parameters, but from what I can tell is never set on
> feature types created by the datastore.
>
> About the feature type implementations defaulting to the gml namespace,
> i am little unsure what the correct action is. On one hand having a
> default can be nice, and the gml namespace makes sense. On the other
> hand application code has no way of telling if the namespace is set or
> not as you showed before.
>
> I looked at some of the other datastores (postgis) and the correct
> behaviour is acheived.
>
> I would be happy to patch the datastore however without a database to
> test with i would feel a bit shakey. I beleive Gabriel is the arcsde
> module maintainer, he may be able to help.
>
> -Justin
>
> Saul Farber wrote:

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Gabriel Roldán (groldan@anonymised.com)
Axios Engineering (http://www.axios.es)
Tel. +34 944 41 63 84
Fax. +34 944 41 64 90