[OpenLayers-Dev] [OpenLayers-Users] Help to create FeatureId filter & OpenLayers.Filter.Logical.NOT

Ivan Grcic ivan.grcic at geofoto.hr
Sun Dec 13 14:18:46 EST 2009


>From the Filter Impl. Specs:

The XML encoding for the logical operators AND, OR and NOT is defined
by the following XML Schema fragment:

    <element name="And" type="ogc:BinaryLogicOpType"
substitutionGroup="ogc:logicOps"/>
    <element name="Or" type="ogc:BinaryLogicOpType"
substitutionGroup="ogc:logicOps"/>
    <element name="Not" type="ogc:UnaryLogicOpType"
substitutionGroup="ogc:logicOps"/>
    <element name="logicOps" type="ogc:LogicOpsType" abstract="true"/>
    <complexType name="LogicOpsType" abstract="true"/>
    <complexType name="BinaryLogicOpType">
        <complexContent>
            <extension base="ogc:LogicOpsType">
                <choice minOccurs="2" maxOccurs="unbounded">
                    <element ref="ogc:comparisonOps"/>
                    <element ref="ogc:spatialOps"/>
                    <element ref="ogc:logicOps"/>
                </choice>
            </extension>
        </complexContent>
    </complexType>
    <complexType name="UnaryLogicOpType">
        <complexContent>
            <extension base="ogc:LogicOpsType">
                <sequence>
                    <choice>
                        <element ref="ogc:comparisonOps"/>
                        <element ref="ogc:spatialOps"/>
                        <element ref="ogc:logicOps"/>
                    </choice>
                </sequence>
            </extension>
        </complexContent>
    </complexType>


It doesnt have FeatureIdType choice. And putting filter manually into
geoserver expectedly throws:

Your .SLD file does not conform to the SLD Schema
cvc-complex-type.2.4.a: Invalid content starting with element
'ogc:FeatureId'. One of '{"http://www.opengis.net/ogc":comparisonOps,
"http://www.opengis.net/ogc":spatialOps,
"http://www.opengis.net/ogc":logicOps}' is expected

But creating filter in OL and making request DOES return all the
features but listed ones. So geoserver does support it.

Does anyone know what would be the correct (compliant) way then to
make filter that will fetch all the features except the ones in
FeatureIds ?

Cheers

On Sun, Dec 13, 2009 at 2:38 PM, Eric Lemoine
<eric.lemoine at camptocamp.com> wrote:
> On Thursday, December 10, 2009, Ivan Grcic <ivan.grcic at geofoto.hr> wrote:
>> Hi devs,
>>
>> before opening ticket i want to confirm that im right about this issue
>>
>> Currently its not possible to make filter like this:
>> <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
>> <And>
>> <Not><ogc:FeatureId fid="Feature.1"/></Not>
>> <Not><ogc:FeatureId fid="Feature.2"/></Not>
>> </And>
>> </Filter>
>>
>> I trace the source of it, in Format/Filter/v1.js writers&readers for
>> AND,OR, NOT do not handle FeatureIds seperatly as root "Filter" does.
>>
>> line: 296
>>
>>             "Not": function(filter) {
>>                 var node = this.createElementNSPlus("ogc:Not");
>>                 var childFilter = filter.filters[0];
>>                 this.writeNode(
>>                     this.getFilterType(childFilter), childFilter, node
>>                 );
>>                 return node;
>>             },
>>
>> That happens because FeatureId doesnt have type and getFilterType
>> method throws "Filter writing not supported for rule type: undefined"
>> if we try to encapsulate FeatureId with Logical.Not
>>
>> Its neccesary to check if filter is of FeatureId type and treat it
>> differently, like the root Filter element does
>>
>>             "Not": function(filter) {
>>                 var node = this.createElementNSPlus("ogc:Not");
>>                 var childFilter = filter.filters[0];
>>
>>                 var sub = childFilter.CLASS_NAME.split(".").pop();
>>                 if(sub === "FeatureId") {
>>                     for(var i=0; i<childFilter.fids.length; ++i) {
>>                         this.writeNode("FeatureId", childFilter.fids[i], node);
>>                     }
>>                 } else {
>>                     this.writeNode(
>>                         this.getFilterType(childFilter), childFilter, node
>>                     );
>>                 }
>>                 return node;
>>             }
>>
>> Please can anyone confirm this?
>
> Hi. I don't know the specs but they allow FeatureID filters within NOT
> filters then I agree there's a bug in the library. And I think the
> problem exists for AND and OR as well, no?
>
> Cheers,
>
> --
> Eric Lemoine
>
> Camptocamp France SAS
> Savoie Technolac, BP 352
> 73377 Le Bourget du Lac, Cedex
>
> Tel : 00 33 4 79 44 44 96
> Mail : eric.lemoine at camptocamp.com
> http://www.camptocamp.com
>



-- 
Ivan Grcic



More information about the Dev mailing list