Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to Cross-Layer Filtering #1262

Merged
merged 2 commits into from
Nov 11, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions web/client/utils/FilterUtils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const FilterUtils = {
"ogc": {startTag: "<ogc:PropertyName>", endTag: "</ogc:PropertyName>"},
"fes": {startTag: "<fes:ValueReference>", endTag: "</fes:ValueReference>"}
},
toOGCFilter: function(ftName, json, version, sortOptions = null, hits = false, format = null) {
toOGCFilter: function(ftName, json, version, sortOptions = null, hits = false, format = null, propertyNames = null) {
try {
this.objFilter = (json instanceof Object) ? json : JSON.parse(json);
} catch(e) {
Expand Down Expand Up @@ -87,6 +87,14 @@ const FilterUtils = {
spatialFilter = this.processOGCSpatialFilter(versionOGC);
filters.push(spatialFilter);
}
if (this.objFilter.crossLayerFilter) {
let crossLayerFilter = this.objFilter.crossLayerFilter;
if (Array.isArray()) {
crossLayerFilter.forEach( f => filters.push(this.processOGCCrossLayerFilter(f)));
} else {
filters.push(this.processOGCCrossLayerFilter(crossLayerFilter));
}
}

let filter = "<" + this.nsplaceholder + ":Filter>";

Expand All @@ -104,7 +112,12 @@ const FilterUtils = {

ogcFilter += '<wfs:Query ' + (versionOGC === "2.0" ? "typeNames" : "typeName") + '="' + ftName + '" srsName="EPSG:4326">';
ogcFilter += filter;

if (propertyNames) {
ogcFilter += propertyNames.map( name => (
this.propertyTagReference[this.nsplaceholder].startTag +
name +
this.propertyTagReference[this.nsplaceholder].endTag )).join("");
}
if (sortOptions && sortOptions.sortBy && sortOptions.sortOrder) {
ogcFilter +=
"<" + this.nsplaceholder + ":SortBy>" +
Expand Down Expand Up @@ -475,6 +488,41 @@ const FilterUtils = {
ogc += this.ogcSpatialOperator[this.objFilter.spatialField.operation].endTag;
return ogc;
},
processOGCCrossLayerFilter: function(crossLayerFilter) {
let ogc = this.ogcSpatialOperator[crossLayerFilter.operation].startTag;
ogc +=
this.propertyTagReference[this.nsplaceholder].startTag +
crossLayerFilter.attribute +
this.propertyTagReference[this.nsplaceholder].endTag;

switch (crossLayerFilter.operation) {
case "INTERSECTS":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simply do this for ANY operation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

case "DWITHIN":
case "WITHIN":
case "CONTAINS": {
if (crossLayerFilter.collectGeometries) {
ogc += `<ogc:Function name="collectGeometries">
<ogc:Function name="queryCollection">
<ogc:Literal>${crossLayerFilter.collectGeometries.queryCollection.typeName}</ogc:Literal>
<ogc:Literal>${crossLayerFilter.collectGeometries.queryCollection.geometryName}</ogc:Literal>
<ogc:Literal>${crossLayerFilter.collectGeometries.queryCollection.cqlFilter}</ogc:Literal>
</ogc:Function>
</ogc:Function>`;
}

if (crossLayerFilter.operation === "DWITHIN") {
ogc += '<' + this.nsplaceholder + ':Distance units="m">' + (crossLayerFilter.distance || 0) + '</' + this.nsplaceholder + ':Distance>';
}

break;
}
default:
break;
}

ogc += this.ogcSpatialOperator[this.objFilter.spatialField.operation].endTag;
return ogc;
},
getGmlPointElement: function(coordinates, srsName, version) {
let gmlPoint = '<gml:Point srsDimension="2"';

Expand Down