[Geoserver-devel] Referencing App-Schema defined feature types properties in styles (SLD)

Hi all,

Consider the following extract of an App-Schema defined feature type:

(…)
<st:Station gml:id=“st.1”>
st:namestation1</st:name>
st:position
st:location
<gml:Point srsDimension=“2” srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>
gml:pos-1.0 1.0</gml:pos>
</gml:Point>
</st:location>
st:nameEurope</st:name>
</st:position>
st:measurements
<ms:Measurement gml:id=“ms.1”>
ms:nametemperature</ms:name>
</ms:Measurement>
</st:measurements>
(…)

Since the geometry is in a sub element it will not be recognized as the default geometry and we need
to specify in the SLD the geometry XPath. My first try was to use the following XPath:

ogc:PropertyNamest:Station**/**st:position/st:location</ogc:PropertyName>

To my surprise this didn’t work, after debugging the code it looks like the root feature type should not
be provided at the start of the XPath, so this is what should be used:

ogc:PropertyNamest:position/st:location</ogc:PropertyName>

Consider the following valid SLD, note the filter usage:

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

<StyledLayerDescriptor version=“1.0.0”
xmlns=“http://www.opengis.net/sld”
xmlns:gml=“http://www.opengis.net/gml/3.2”
xmlns:ms=“http://www.measurements.org/1.0”
xmlns:ogc=“http://www.opengis.net/ogc”
xmlns:sld=“http://www.opengis.net/sld”
xmlns:st=“http://www.stations.org/1.0”
xmlns:xlink=“http://www.w3.org/1999/xlink”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://www.opengis.net/sld StyledLayerDescriptor.xsd”>

stations



stations
ogc:Filter

st:measurements/ms:Measurement/ms:name
wind

</ogc:Filter>

sld:Geometry
ogc:PropertyNamest:position/st:location</ogc:PropertyName>
</sld:Geometry>


square

#FF0000


6






The same filter in a WFS GetFeature request will needs to be encoded like this:

<wfs:GetFeature outputFormat=“gml3” service=“WFS” version=“1.1.0”
xmlns:ms=“http://www.measurements.org/1.0”
xmlns:ogc=“http://www.opengis.net/ogc”
xmlns:st=“http://www.stations.org/1.0”
xmlns:topp=“http://www.openplans.org/topp”
xmlns:wfs=“http://www.opengis.net/wfs”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/WFS-basic.xsd”>
<wfs:Query typeName=“st:Station”>
ogc:Filter
ogc:PropertyIsEqualTo
ogc:PropertyName
st:Station/st:measurements/ms:Measurement/ms:name
</ogc:PropertyName>
ogc:Literalwind</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

In this case the root feature type name needs to be provided at the beginning of the XPath.

Conclusion, the way of referencing properties of App-Schema defined feature types is different
in WFS and WMS (at least for GetFeatrue and SLDs).

In my opinion the WFS GetFeature full XPath path is the most natural one and both WFS and
WMS should use \ accept the same XPath.

I propose to allow the use of the full XPath in WMS (equal to WFS) but keep accepting the shorten
one in WMS for compatibility reasons, opinions ?

My plan is to store as user data the target root name and root type name here:
https://github.com/nmco/geotools/blob/22ab45c198130388c7774d8d43b051fc7a7402e6/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/config/AppSchemaDataAccessConfigurator.java#L297

and then in the feature accessor remove the root element from the XPath id needed (based on the user data):
https://github.com/nmco/geotools/blob/66a9c89239d7a7ae6526399b57eb28649b5620c2/modules/extension/complex/src/main/java/org/geotools/filter/expression/FeaturePropertyAccessorFactory.java#L257-L285

This is the best way I found to do it … better idea ?

Cheers,

Nuno Oliveira

···
-- 
Regards,
Nuno Oliveira
==
GeoServer Professional Services from the experts! Visit [http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:      +39 0584 1660272

[http://www.geo-solutions.it](http://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.
 
The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.

Nuno,

that seems like a sensible solution, and backwards compatibility is maintained.

Kind regards,
Ben.

On 24/12/17 10:06, Nuno Oliveira wrote:

Hi all,

Consider the following extract of an App-Schema defined feature type:

\(\.\.\.\)
&lt;st:Station gml:id=&quot;st\.1&quot;&gt;
&lt;st:name&gt;station1&lt;/st:name&gt;
&lt;st:position&gt;
\*&lt;st:location&gt;\*\*
\*\*        &lt;gml:Point srsDimension=&quot;2&quot; srsName=&quot;http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;\*\*
\*\*            &lt;gml:pos&gt;\-1\.0 1\.0&lt;/gml:pos&gt;\*\*
\*\*        &lt;/gml:Point&gt;\*\*
\*\*    &lt;/st:location&gt;\*
&lt;st:name&gt;Europe&lt;/st:name&gt;
&lt;/st:position&gt;
&lt;st:measurements&gt;
&lt;ms:Measurement gml:id=&quot;ms\.1&quot;&gt;
&lt;ms:name&gt;temperature&lt;/ms:name&gt;
&lt;/ms:Measurement&gt;
&lt;/st:measurements&gt;
\(\.\.\.\)

Since the geometry is in a sub element it will not be recognized as the default geometry and we need
to specify in the SLD the geometry XPath. My first try was to use the following XPath:

    <ogc:PropertyName>*st:Station**/*st:position/st:location</ogc:PropertyName>

To my surprise this didn't work, after debugging the code it looks like the root feature type should not
be provided at the start of the XPath, so this is what should be used:

&lt;ogc:PropertyName&gt;\*st:position/st:location\*&lt;/ogc:PropertyName&gt;

Consider the following valid SLD, note the filter usage:

&lt;?xml version=&quot;1\.0&quot; encoding=&quot;UTF\-8&quot;?&gt;
&lt;StyledLayerDescriptor version=&quot;1\.0\.0&quot;
xmlns=&quot;http://www.opengis.net/sld&quot;
xmlns:gml=&quot;http://www.opengis.net/gml/3.2&quot;
xmlns:ms=&quot;http://www.measurements.org/1.0&quot;
xmlns:ogc=&quot;http://www.opengis.net/ogc&quot;
xmlns:sld=&quot;http://www.opengis.net/sld&quot;
xmlns:st=&quot;http://www.stations.org/1.0&quot;
xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://www.opengis.net/sld StyledLayerDescriptor\.xsd&quot;&gt;
&lt;NamedLayer&gt;
&lt;Name&gt;stations&lt;/Name&gt;
&lt;UserStyle&gt;
&lt;FeatureTypeStyle&gt;
&lt;Rule&gt;
&lt;Name&gt;stations&lt;/Name&gt;
&lt;ogc:Filter&gt;
&lt;PropertyIsEqualTo&gt;
&lt;PropertyName&gt;\*st:measurements/ms:Measurement/ms:name\*&lt;/PropertyName&gt;
&lt;Literal&gt;wind&lt;/Literal&gt;
&lt;/PropertyIsEqualTo&gt;
&lt;/ogc:Filter&gt;
&lt;PointSymbolizer&gt;
&lt;sld:Geometry&gt;
&lt;ogc:PropertyName&gt;\*st:position/st:location\*&lt;/ogc:PropertyName&gt;
&lt;/sld:Geometry&gt;
&lt;Graphic&gt;
&lt;Mark&gt;
&lt;WellKnownName&gt;square&lt;/WellKnownName&gt;
&lt;Fill&gt;
&lt;CssParameter name=&quot;fill&quot;&gt;\#FF0000&lt;/CssParameter&gt;
&lt;/Fill&gt;
&lt;/Mark&gt;
&lt;Size&gt;6&lt;/Size&gt;
&lt;/Graphic&gt;
&lt;/PointSymbolizer&gt;
&lt;/Rule&gt;
&lt;/FeatureTypeStyle&gt;
&lt;/UserStyle&gt;
&lt;/NamedLayer&gt;
&lt;/StyledLayerDescriptor&gt;

The same filter in a WFS GetFeature request will needs to be encoded like this:

<wfs:GetFeature outputFormat="gml3" service="WFS" version="1.1.0"
xmlns:ms="http://www.measurements.org/1.0&quot;
xmlns:ogc="http://www.opengis.net/ogc&quot;
xmlns:st="http://www.stations.org/1.0&quot;
xmlns:topp="http://www.openplans.org/topp&quot;
xmlns:wfs="http://www.opengis.net/wfs&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/WFS-basic.xsd&quot;&gt;
<wfs:Query typeName="st:Station">
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>
*st:Station/st:measurements/ms:Measurement/ms:name*
</ogc:PropertyName>
<ogc:Literal>wind</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

In this case the root feature type name needs to be provided at the beginning of the XPath.

Conclusion, the way of referencing properties of App-Schema defined feature types is different
in WFS and WMS (at least for GetFeatrue and SLDs).

In my opinion the WFS GetFeature full XPath path is the most natural one and both WFS and
WMS should use \ accept the same XPath.

I propose to allow the use of the full XPath in WMS (equal to WFS) but keep accepting the shorten
one in WMS for compatibility reasons, opinions ?

My plan is to store as user data the target root name and root type name here:
https://github.com/nmco/geotools/blob/22ab45c198130388c7774d8d43b051fc7a7402e6/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/config/AppSchemaDataAccessConfigurator.java#L297

and then in the feature accessor remove the root element from the XPath id needed (based on the user data):
https://github.com/nmco/geotools/blob/66a9c89239d7a7ae6526399b57eb28649b5620c2/modules/extension/complex/src/main/java/org/geotools/filter/expression/FeaturePropertyAccessorFactory.java#L257-L285

This is the best way I found to do it ... better idea ?

Cheers,

Nuno Oliveira

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <https://transient.nz/&gt;
New Zealand

On Sat, Dec 23, 2017 at 10:06 PM, Nuno Oliveira <
nuno.oliveira@anonymised.com> wrote:

Since the geometry is in a sub element it will not be recognized as the
default geometry and we need
to specify in the SLD the geometry XPath. My first try was to use the
following XPath:

<ogc:PropertyName>*st:Station**/*st:position/st:location</ogc:
PropertyName>

To my surprise this didn't work, after debugging the code it looks like
the root feature type should not
be provided at the start of the XPath, so this is what should be used:

<ogc:PropertyName>*st:position/st:location*</ogc:PropertyName>

Yep, that makes it consistent with simple features, where the full path is
never used.

Conclusion, the way of referencing properties of App-Schema defined
feature types is different
in WFS and WMS (at least for GetFeatrue and SLDs).

In my opinion the WFS GetFeature full XPath path is the most natural one
and both WFS and
WMS should use \ accept the same XPath.

I would never have thought of using the full path, but I don't play with
complex features, so that
probably explains it :-p

I propose to allow the use of the full XPath in WMS (equal to WFS) but
keep accepting the shorten
one in WMS for compatibility reasons, opinions ?

And also keep it for consistency with simple features and common usage in
SLD: check SLD cookbook,
but also the SLD specification, all of the examples use single unqualified
names.

Ideally, it would be best if one could use short relative paths or full
qualified paths in both cases,
simple features and complex features, to have a good overall consistency
(e.g., someone using
mostly complex features might end up using full path for simple ones as
well).
It's likely already handled as a fallback by the XmlXPathPropertyAcessor,
but does not
hurt checking.

Cheers
Andrea

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

Hi Ben and Andrea,

Thanks for the feedback !

I should have read OGC filter specification [1] more carefully before sending this mail … sorry about that :frowning:

Long story short … according to the relevant specification [1] (and my understanding of it) both relative,
full paths, qualified or unqualified paths should be accepted:

(…) In addition, property names may be qualified with a namespace prefix in which case the name
must conform to the Namespaces In XML [9] specification. (…)

(…)Notice that in this instance, each relative location path begins with the root element of the
feature property being referenced. This simply corresponds to the name of the feature
property. Optionally, each XML element within the description may be referenced with
the relative location path beginning with root element of the feature (i.e. the name of the
feature type). Thus the lastName property could be reference as Person/lastName, the
City element could be referenced as Person/mailAddress/Address/city and so on.(…)

The full description of PropertyName element is available in reference [1] in section 6 Properties starting
at page 4 (page 14 in the PDF reader).

Let’s see if I can find time next week to take a look at GeoServer \ GeoTools and check how difficult it will
be to support this behavior and what is the current behavior of XmlXPathPropertyAcessor :slight_smile:

Cheers,

Nuno Oliveira

[1] http://portal.opengeospatial.org/files/?artifact_id=8340

···

On 12/28/2017 10:17 AM, Andrea Aime wrote:

On Sat, Dec 23, 2017 at 10:06 PM, Nuno Oliveira <nuno.oliveira@…1268…> wrote:

Since the geometry is in a sub element it will not be recognized as the default geometry and we need
to specify in the SLD the geometry XPath. My first try was to use the following XPath:

ogc:PropertyNamest:Station**/**st:position/st:location</ogc:PropertyName>

To my surprise this didn’t work, after debugging the code it looks like the root feature type should not
be provided at the start of the XPath, so this is what should be used:

ogc:PropertyNamest:position/st:location</ogc:PropertyName>

Yep, that makes it consistent with simple features, where the full path is never used.

Conclusion, the way of referencing properties of App-Schema defined feature types is different
in WFS and WMS (at least for GetFeatrue and SLDs).

In my opinion the WFS GetFeature full XPath path is the most natural one and both WFS and
WMS should use \ accept the same XPath.

I would never have thought of using the full path, but I don’t play with complex features, so that
probably explains it :-p

I propose to allow the use of the full XPath in WMS (equal to WFS) but keep accepting the shorten
one in WMS for compatibility reasons, opinions ?

And also keep it for consistency with simple features and common usage in SLD: check SLD cookbook,
but also the SLD specification, all of the examples use single unqualified names.

Ideally, it would be best if one could use short relative paths or full qualified paths in both cases,
simple features and complex features, to have a good overall consistency (e.g., someone using
mostly complex features might end up using full path for simple ones as well).
It’s likely already handled as a fallback by the XmlXPathPropertyAcessor, but does not
hurt checking.

Cheers
Andrea

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.

-- 
Regards,
Nuno Oliveira
==
GeoServer Professional Services from the experts! Visit [http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:      +39 0584 1660272

[http://www.geo-solutions.it](http://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.
 
The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.