When you add WFS data to your map, LuciadLightspeed automatically sends a WFS request to the WFS server with a spatial filter that matches the area that you are visualizing. You can also add your own filters to further restrict the data that you want to query and visualize.
To add such a filter, construct an OGC Filter with your filter criteria, and set it on the WFS model.
This example shows how you can add a filter for a US Cities WFS feature type. We want to query only those cities that have a name starting with "New":
// Create a WFS model for the WFS feature type 'cities' provided by the WFS server 'http://sampleservices.luciad.com/wfs'. TLcdWFSProxyModel model = TLcdWFSProxyModel.Builder.newBuilder().server("http://sampleservices.luciad.com/wfs").featureTypeName("cities").build(); // We only want to query cities that have a name starting with "New". // To achieve this, we can rely on the IsLike filter condition, which can compare a property with a value containing a wildcard. TLcdOGCFilter filter = new TLcdOGCFilter(TLcdOGCFilterFactory.like(TLcdOGCFilterFactory.property("CITY"), "New*")); // By setting an explicit filter on the WFS model, all future access to the WFS data will include the filter. model.setFilter(filter);
You can also combine multiple filter conditions. The following example extends the previous example with an additional
filter condition that specifies a search area. To ensure that both conditions are applied together,
they are combined using a boolean filter condition that specifies an
// We only want to query cities that are located within a specific area and that have a name starting with "New". // To achieve this, we first create an IsLike filter condition and a bounding box spatial filter condition. ILcdOGCCondition isLikeCondition = TLcdOGCFilterFactory.like(TLcdOGCFilterFactory.property("CITY"), "New*"); ILcdOGCCondition bboxCondition = TLcdOGCFilterFactory.bbox(new TLcdLonLatBounds(-75, 40, 10, 10), new TLcdGeodeticReference()); // Next, we create a boolean condition that combines both conditions with an 'and' relationship // and use this to create the filter. TLcdOGCFilter filter = new TLcdOGCFilter(TLcdOGCFilterFactory.and(isLikeCondition, bboxCondition));