On Wed, Dec 22, 2010 at 6:08 AM, Miles Jordan <[email protected]>wrote:

> Andrea Aime wrote:
> > On Tue, Dec 21, 2010 at 6:57 AM, Miles Jordan
> > <[email protected]> wrote:
> >> Hmm.. trying to use the PropertyExists function and not sure how to
> > reference the feature. I would have thought that it would only take
> > one argument, the propertyName, but the docs say:
> >>
> >> Name - PropertyExists Arguments - f:Feature, propertyName:String
> >> Description - Returns true if f has a property named propertyName
> >>
> >  All functions get the current feature as an implicit argument. I
> > guess the documentation is wrong :-p
> >
> > The function would have to be called like:
> >
> > <ogc:Function name="PropertyExists">
> >   <ogc:Literal>MY_PROPERTY</ogc:Literal>
> > </ogc:Function>
>
> That's what I thought, in fact I tried it, but got a NPE. Digging deeper,
> it works fine by itself but not inside of a boolean operation. i.e. this
> works:
>
> <ogc:Filter>
>  <ogc:PropertyExists>
>     <ogc:Literal>MY_PROPERTY</ogc:Literal>
>   </ogc:PropertyExists>
> </ogc:Filter>
>
> But this does not:
>
> <ogc:Filter>
>        <ogc:And>
>                <ogc:PropertyExists>
>                         <ogc:Literal>MY_PROPERTY</ogc:Literal>
>                 </ogc:PropertyExists>
>                <ogc:PropertyIsEqualTo>
>                        <ogc:PropertyName>MY_PROPERTY</ogc:PropertyName>
>                        <ogc:Literal>1</ogc:Literal>
>                </ogc:PropertyIsEqualTo>
>        </ogc:And>
> </ogc:Filter>
>
> In fact, the Boolean operation will work with other functions, just not
> with PropertyExists. Any final thoughts before I head over to JIRA? I
> haven't tried this on the latest Beta.
>
>
Miles, I'm actually confused. If I look into the Filter specification there
is no such a thing
as a "PropertyExists" filter, so I'm not surprised the above does not work.
Have a look for yourself:
http://schemas.opengis.net/filter/1.0.0/filter.xsd

The proper way to write the same filter would be something like:

<ogc:Filter>
       <ogc:And>
               <ogc:PropertyIsEqualsTo>
                     <ogc:Function name="PropertyExists">
                          <ogc:Literal>MY_PROPERTY</ogc:Literal>
                     </ogc:Function>
                     <ogc:Literal>true</ogc:Literal>
               </ogc:PropertyIsEqualsTo>
               <ogc:PropertyIsEqualTo>
                       <ogc:PropertyName>MY_PROPERTY</ogc:PropertyName>
                       <ogc:Literal>1</ogc:Literal>
               </ogc:PropertyIsEqualTo>
       </ogc:And>
</ogc:Filter>

If anything the parser should throw a bloody exception saying it does not
know
what ogc:PropertyExists is :-)

Cheers
Andrea


-----------------------------------------------------
Ing. Andrea Aime
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584962313
fax:     +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------
------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your 
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to