viewer : restrict metadata searches to a specified extent, optionnally set that extent to the current map extent #964

Merged
merged 12 commits into from Apr 29, 2015

Projects

None yet

2 participants

@fphg
Member
fphg commented Apr 23, 2015

No GUI for now, this is admin's choice

fphg added some commits Apr 21, 2015
@fphg fphg geographic filter for csw queries
for now it only handles bbox  specified with CSW_FILTER_SPATIAL
f529fb7
@fphg fphg POC for mapextent-based csw spatial filters c4c0bed
@fphg fphg CSW_FILTER_SPATIAL has two modes : static bbox or dynamic when param …
…is empty
a308f10
@fphg fphg whitespaces cleanup 7e3c500
@fphg fphg restore line removed by mistake
bffcaf4
@fvanderbiest fvanderbiest and 1 other commented on an outdated diff Apr 23, 2015
mapfishapp/src/main/webapp/app/js/GEOR_cswquerier.js
- new OpenLayers.Filter.Logical({
- type: "&&",
- filters: byWords
- })
- ]
- })
- ]
- })
+ // combine all filters alltogether
+ finalFilters.push(byTypes);
+
+ // spatial filter
+ if (GEOR.config.CSW_FILTER_SPATIAL.length!==4) {
+ finalFilters.push(new OpenLayers.Filter.Spatial({
+ type: OpenLayers.Filter.Spatial.BBOX,
+ value: this.map.getExtent().clone()
@fvanderbiest
fvanderbiest Apr 23, 2015 Member

no need to clone extent here IMO

@fphg
fphg Apr 23, 2015 Member

dunno if we'll expand or alter this bbox later

@fvanderbiest fvanderbiest and 1 other commented on an outdated diff Apr 23, 2015
mapfishapp/src/main/webapp/app/js/GEOR_config.js
@@ -229,6 +229,14 @@ GEOR.config = (function() {
]),
/**
+ * Constant: CSW_FILTER_SPATIAL
+ * An optional extent in latlon to restrict metadata search on a specific extent (latlon)
+ * Defaults to [-180,-90,180,90] to cover the world.
+ * If the parameter is not an array of 4, the filter uses the current map extent.
+ */
+ CSW_FILTER_SPATIAL: getCustomParameter("CSW_FILTER_SPATIAL", [-180,-90,180,90]),
@fvanderbiest
fvanderbiest Apr 23, 2015 Member

I would rather make this null by default.

@fphg
fphg Apr 23, 2015 Member

right

@fvanderbiest fvanderbiest commented on an outdated diff Apr 23, 2015
mapfishapp/src/main/webapp/app/js/GEOR_cswquerier.js
- // exact matches
- byIds,
- // word matches
- new OpenLayers.Filter.Logical({
- type: "&&",
- filters: byWords
- })
- ]
- })
- ]
- })
+ // combine all filters alltogether
+ finalFilters.push(byTypes);
+
+ // spatial filter
+ if (GEOR.config.CSW_FILTER_SPATIAL.length!==4) {
@fvanderbiest
fvanderbiest Apr 23, 2015 Member

if null, then ...

@fvanderbiest
Member

Some minor comments to be addressed.

Finally, I think we need to inform the user somehow that his search is/might be restricted on the current bbox.

fphg added some commits Apr 23, 2015
@fphg fphg CSW_FILTER_SPATIAL = null triggers the auto bbox mode and warns user,…
… thk fvdb
601cea9
@fphg fphg better code design
checkbox to disable the auto extent filter
todo : better checkbox positioning
9e57683
@fphg fphg form layout
f30c3fc
@fphg fphg repeated CSW searches trigger the search tooltip only once
69fd046
@fphg
Member
fphg commented Apr 27, 2015

fvanderbiest : now there's a warning in the search result report and a dedicated checkbox to enable/disable the auto bbox feature on the fly. this comes in handy at querying large external catalogs. Repeated queries trigger annoyingly the search tooltip, so PR makes it pop only once. Done for me for this PR unless other wishes & bugs.

@fphg fphg added the enhancement label Apr 27, 2015
@fphg fphg self-assigned this Apr 27, 2015
@fphg fphg added this to the 15.06 milestone Apr 27, 2015
@fvanderbiest fvanderbiest and 1 other commented on an outdated diff Apr 27, 2015
mapfishapp/src/main/webapp/app/js/GEOR_cswquerier.js
+ * m - {OpenLayers.Map} The map instance.
+ */
+ init: function(m) {
+ map = m;
+ },
+
+ /**
+ * APIMethod: getSpatialFilter
+ * Return the search extent to build a csw search filter
+ *
+ * Returns:
+ * {OpenLayers.Filter.Spatial} bbox filter
+ */
+ getSpatialFilter: function() {
+ var f;
+ if (isLimitExtent) {
@fvanderbiest
fvanderbiest Apr 27, 2015 Member

I would factorize this contruct, in order to define the filter only once.
Its value should be set with eg:

var v = isLimitExtent ? 
    map.getExtent().clone().transform(
        map.getProjectionObject(), 
        new OpenLayers.Projection("EPSG:4326")
    ) :
    new OpenLayers.Bounds(
         GEOR.config.CSW_FILTER_SPATIAL
    )
@fphg
fphg Apr 27, 2015 Member

done, thanks for the advice

@fvanderbiest fvanderbiest and 1 other commented on an outdated diff Apr 27, 2015
mapfishapp/src/main/webapp/app/js/GEOR_cswquerier.js
+ * Property: map
+ * {OpenLayers.Map} The map instance.
+ */
+ var map = null;
+
+ /**
+ * Property: isLimitExtent
+ * {Boolean} limit metadata results to map extent
+ */
+ var isLimitExtent = false;
+
+ /**
+ * Property: isTooltip
+ * {Boolean} display search tooltip only once
+ */
+ var isTooltip = true;
@fvanderbiest
fvanderbiest Apr 27, 2015 Member

rather tipDisplayed with a default value to false ?

@fphg
fphg Apr 27, 2015 Member

thanks, renamed isTipDisplayed. don't we want the tip to be displayed on 1st search ?

@fphg fphg less statements same result, thanks fvanderbiest
b7c2bad
@fvanderbiest fvanderbiest commented on an outdated diff Apr 27, 2015
mapfishapp/src/main/webapp/app/js/GEOR_cswquerier.js
@@ -462,6 +485,55 @@ GEOR.cswquerier = (function() {
* Observable object
*/
events: observable,
+
+ /**
+ * APIMethod: init
+ * Initialize this module
+ *
+ * Parameters:
+ * m - {OpenLayers.Map} The map instance.
+ */
+ init: function(m) {
+ map = m;
+ isLimitExtent = (GEOR.config.CSW_FILTER_SPATIAL===null);
@fvanderbiest
fvanderbiest Apr 27, 2015 Member

I would rename it to dynamicSpatialFilter as well

@fvanderbiest fvanderbiest commented on an outdated diff Apr 27, 2015
mapfishapp/src/main/webapp/app/js/GEOR_cswquerier.js
@@ -193,6 +194,24 @@ GEOR.cswquerier = (function() {
* {Array} a cache of csw records for "plan B"
*/
var uuidsToDig = null;
+
+ /**
+ * Property: map
+ * {OpenLayers.Map} The map instance.
+ */
+ var map = null;
+
+ /**
+ * Property: isLimitExtent
+ * {Boolean} limit metadata results to map extent
+ */
+ var isLimitExtent = false;
@fvanderbiest
fvanderbiest Apr 27, 2015 Member

In fact, no need to initialize it to anything, since this is done in init()

@fvanderbiest
Member

Still some minor comments to be addressed.
Otherwise, looks good. Thanks for the contribution :-)

fphg added some commits Apr 27, 2015
@fphg fphg use init() to initialize priv properties
e4447c3
@fphg fphg sed s/isLimitExtent/isDynamicSpatialFilter/
0d25281
@fphg
Member
fphg commented Apr 29, 2015

is it ok now ?

@fvanderbiest fvanderbiest merged commit b0dc986 into master Apr 29, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@fvanderbiest fvanderbiest deleted the csw_filter_extent branch Apr 29, 2015
@fvanderbiest
Member

Yes, thanks again

@fphg fphg added a commit to georchestra/template that referenced this pull request Apr 30, 2015
@fphg fphg CSW_FILTER_SPATIAL see georchestra/georchestra#964 b15e12f
@fvanderbiest
Member

I think this PR is incomplete.
When the user has checked the box, he expects the results to change on map extent changed => #1007

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment