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

Fix #1392 added viewport into spatial filter list #1822

Merged
merged 3 commits into from
May 15, 2017
Merged
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions web/client/actions/queryform.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const CHANGE_CASCADING_VALUE = 'CHANGE_CASCADING_VALUE';
const EXPAND_ATTRIBUTE_PANEL = 'EXPAND_ATTRIBUTE_PANEL';
const EXPAND_SPATIAL_PANEL = 'EXPAND_SPATIAL_PANEL';
const SELECT_SPATIAL_METHOD = 'SELECT_SPATIAL_METHOD';
const SELECT_VIEWPORT_SPATIAL_METHOD = 'SELECT_VIEWPORT_SPATIAL_METHOD';
const UPDATE_GEOMETRY = 'UPDATE_GEOMETRY';
const SELECT_SPATIAL_OPERATION = 'SELECT_SPATIAL_OPERATION';
const CHANGE_SPATIAL_ATTRIBUTE = 'CHANGE_SPATIAL_ATTRIBUTE';
const REMOVE_SPATIAL_SELECT = 'REMOVE_SPATIAL_SELECT';
Expand Down Expand Up @@ -126,6 +128,18 @@ function selectSpatialMethod(method, fieldName) {
};
}

function selectViewportSM() {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't be shy, selectViewportSpatialMethod

return {
type: SELECT_VIEWPORT_SPATIAL_METHOD
};
}
function updateGeometrySpatialField(geometry) {
return {
type: UPDATE_GEOMETRY,
geometry
};
}

function selectSpatialOperation(operation, fieldName) {
return {
type: SELECT_SPATIAL_OPERATION,
Expand Down Expand Up @@ -322,6 +336,10 @@ module.exports = {
ADD_SIMPLE_FILTER_FIELD,
REMOVE_SIMPLE_FILTER_FIELD,
REMOVE_ALL_SIMPLE_FILTER_FIELDS,
SELECT_VIEWPORT_SPATIAL_METHOD,
UPDATE_GEOMETRY,
updateGeometrySpatialField,
selectViewportSM,
resetZones,
zoneChange,
// openMenu,
Expand Down
39 changes: 14 additions & 25 deletions web/client/actions/wfsquery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
Expand Down Expand Up @@ -103,12 +103,11 @@ function createQuery(searchUrl, filterObj) {
};
}

function query(searchUrl, filterObj, retry) {
function query(searchUrl, filterObj) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is retry not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, it's been removed in getFeatures method of DockerFeatureGrid component

return {
type: QUERY,
searchUrl,
filterObj,
retry
filterObj
};
}

Expand Down Expand Up @@ -147,28 +146,18 @@ function closeResponse() {
}

module.exports = {
FEATURE_TYPE_SELECTED,
FEATURE_TYPE_LOADED,
FEATURE_TYPE_SELECTED, featureTypeSelected,
FEATURE_TYPE_LOADED, featureTypeLoaded,
FEATURE_TYPE_ERROR, featureTypeError,
FEATURE_ERROR, featureError,
FEATURE_CLOSE, featureClose,
QUERY_CREATE, createQuery,
QUERY_RESULT, querySearchResponse,
QUERY_ERROR, queryError,
RESET_QUERY, resetQuery,
QUERY, query,
FEATURE_LOADED,
FEATURE_TYPE_ERROR,
FEATURE_ERROR,
FEATURE_CLOSE,
QUERY_CREATE,
QUERY_RESULT,
QUERY_ERROR,
RESET_QUERY,
QUERY,
featureTypeSelected,
featureTypeLoaded,
featureTypeError,
featureError,
loadFeature,
createQuery,
query,
featureClose,
resetQuery,
toggleQueryPanel,
closeResponse,
queryError,
querySearchResponse
closeResponse
};
1 change: 1 addition & 0 deletions web/client/components/data/query/QueryBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const QueryBuilder = React.createClass({
onChangeDrawingStatus: () => {},
onRemoveSpatialSelection: () => {},
onShowSpatialSelectionDetails: () => {},
onSelectViewportSM: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

don't be shy

onEndDrawing: () => {},
onChangeDwithinValue: () => {}
},
Expand Down
18 changes: 14 additions & 4 deletions web/client/components/data/query/SpatialFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const SpatialFilter = React.createClass({
showDetailsPanel: false,
withContainer: true,
spatialMethodOptions: [
{id: "Viewport", name: "queryform.spatialfilter.methods.viewport"},
{id: "BBOX", name: "queryform.spatialfilter.methods.box"},
{id: "Circle", name: "queryform.spatialfilter.methods.circle"},
{id: "Polygon", name: "queryform.spatialfilter.methods.poly"}
Expand All @@ -57,6 +58,7 @@ const SpatialFilter = React.createClass({
onRemoveSpatialSelection: () => {},
onShowSpatialSelectionDetails: () => {},
onEndDrawing: () => {},
onSelectViewportSM: () => {},
onChangeDwithinValue: () => {},
zoneFilter: () => {},
zoneSearch: () => {},
Expand Down Expand Up @@ -314,10 +316,18 @@ const SpatialFilter = React.createClass({

this.props.actions.onSelectSpatialMethod(method, name);

if (method !== "ZONE") {
this.changeDrawingStatus('start', method, "queryform", []);
} else {
this.changeDrawingStatus('clean', null, "queryform", []);
switch (method) {
case "ZONE": {
this.changeDrawingStatus('clean', null, "queryform", []); break;
}
case "Viewport": {
this.changeDrawingStatus('clean', null, "queryform", []);
this.props.actions.onSelectViewportSM();
break;
}
default: {
this.changeDrawingStatus('start', method, "queryform", []);
}
}
},
updateSpatialOperation(id, name, value) {
Expand Down
33 changes: 31 additions & 2 deletions web/client/epics/wfsquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

const Rx = require('rxjs');
const axios = require('../libs/ajax');
const {changeSpatialAttribute} = require('../actions/queryform');
const {changeSpatialAttribute, SELECT_VIEWPORT_SPATIAL_METHOD, updateGeometrySpatialField} = require('../actions/queryform');
const {CHANGE_MAP_VIEW} = require('../actions/map');
const {FEATURE_TYPE_SELECTED, QUERY, featureTypeLoaded, featureTypeError, createQuery, querySearchResponse, queryError, featureClose} = require('../actions/wfsquery');
const FilterUtils = require('../utils/FilterUtils');
const assign = require('object-assign');
Expand Down Expand Up @@ -227,6 +228,33 @@ const closeFeatureEpic = action$ =>
return action.control && action.control === 'drawer' ? Rx.Observable.of(featureClose()) : Rx.Observable.empty();
});

function validateExtent(extent) {
if (extent[0] <= -180.0 || extent[2] >= 180.0) {
extent[0] = -180.0;
extent[2] = 180.0;
}
return extent;
}
const viewportSelectedEpic = (action$, store) =>
action$.ofType(SELECT_VIEWPORT_SPATIAL_METHOD, CHANGE_MAP_VIEW)
.switchMap((action) => {
// calculate new geometry from map properties
const map = action.type === CHANGE_MAP_VIEW ? action : store.getState().map.present;
Copy link
Contributor

Choose a reason for hiding this comment

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

are you updating the geometry also if the spatial filter is not Viewport?

const bounds = Object.keys(map.bbox.bounds).reduce((p, c) => {
return assign({}, p, {[c]: parseFloat(map.bbox.bounds[c])});
}, {});
const extent = validateExtent([bounds.minx, bounds.miny, bounds.maxx, bounds.maxy]);
const center = [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];
const start = [extent[0], extent[1]];
const end = [extent[2], extent[3]];
const coordinates = [[start, [start[0], end[1]], end, [end[0], start[1]], start]];
let geometry = {
type: "Polygon", radius: 0, projection: "EPSG:4326",
extent, center, coordinates
};
return Rx.Observable.of(updateGeometrySpatialField(geometry));
});

/**
* Epics for WFS query requests
* @name epics.wfsquery
Expand All @@ -236,5 +264,6 @@ const closeFeatureEpic = action$ =>
module.exports = {
featureTypeSelectedEpic,
wfsQueryEpic,
closeFeatureEpic
closeFeatureEpic,
viewportSelectedEpic
};
6 changes: 4 additions & 2 deletions web/client/plugins/QueryPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const LayersUtils = require('../utils/LayersUtils');
// include application component
const QueryBuilder = require('../components/data/query/QueryBuilder');

const {featureTypeSelectedEpic, wfsQueryEpic, closeFeatureEpic} = require('../epics/wfsquery');
const {featureTypeSelectedEpic, wfsQueryEpic, closeFeatureEpic, viewportSelectedEpic} = require('../epics/wfsquery');

const {bindActionCreators} = require('redux');
const {
Expand All @@ -40,6 +40,7 @@ const {
expandAttributeFilterPanel,
expandSpatialFilterPanel,
selectSpatialMethod,
selectViewportSM,
selectSpatialOperation,
removeSpatialSelection,
showSpatialSelectionDetails,
Expand Down Expand Up @@ -95,6 +96,7 @@ const SmartQueryForm = connect((state) => {
spatialFilterActions: bindActionCreators({
onExpandSpatialFilterPanel: expandSpatialFilterPanel,
onSelectSpatialMethod: selectSpatialMethod,
onSelectViewportSM: selectViewportSM,
onSelectSpatialOperation: selectSpatialOperation,
onChangeDrawingStatus: changeDrawingStatus,
onRemoveSpatialSelection: removeSpatialSelection,
Expand Down Expand Up @@ -237,5 +239,5 @@ module.exports = {
queryform: require('../reducers/queryform'),
query: require('../reducers/query')
},
epics: {featureTypeSelectedEpic, wfsQueryEpic, closeFeatureEpic}
epics: {featureTypeSelectedEpic, wfsQueryEpic, closeFeatureEpic, viewportSelectedEpic}
};
2 changes: 2 additions & 0 deletions web/client/plugins/TOC.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const {
expandAttributeFilterPanel,
expandSpatialFilterPanel,
selectSpatialMethod,
selectViewportSM,
selectSpatialOperation,
removeSpatialSelection,
showSpatialSelectionDetails,
Expand Down Expand Up @@ -105,6 +106,7 @@ const SmartQueryForm = connect((state) => {
spatialFilterActions: bindActionCreators({
onExpandSpatialFilterPanel: expandSpatialFilterPanel,
onSelectSpatialMethod: selectSpatialMethod,
onSelectViewportSM: selectViewportSM,
onSelectSpatialOperation: selectSpatialOperation,
onChangeDrawingStatus: changeDrawingStatus,
onRemoveSpatialSelection: removeSpatialSelection,
Expand Down
4 changes: 4 additions & 0 deletions web/client/reducers/queryform.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {
CHANGE_DWITHIN_VALUE,
ZONE_FILTER,
ZONE_SEARCH,
UPDATE_GEOMETRY,
// OPEN_MENU,
ZONE_CHANGE,
ZONES_RESET,
Expand Down Expand Up @@ -165,6 +166,9 @@ function queryform(state = initialState, action) {
case SELECT_SPATIAL_METHOD: {
return assign({}, state, {spatialField: assign({}, state.spatialField, {[action.fieldName]: action.method, geometry: null})});
}
case UPDATE_GEOMETRY: {
return assign({}, state, {spatialField: assign({}, state.spatialField, {geometry: action.geometry})}, {toolbarEnabled: true});
}
case SELECT_SPATIAL_OPERATION: {
return assign({}, state, {spatialField: assign({}, state.spatialField, {[action.fieldName]: action.operation})});
}
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.de-DE
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
},
"methods": {
"zone": "Zone",
"viewport": "Viewport",
"box": "BoundingBox",
"buffer": "Buffer",
"circle": "Kreis",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.en-US
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
},
"methods": {
"zone": "Zone",
"viewport": "Viewport",
"box": "BoundingBox",
"buffer": "Buffer",
"circle": "Circle",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.fr-FR
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@
},
"methods": {
"zone": "Zone",
"viewport": "Viewport",
"box": "Cadre d'objet",
"buffer": "Zone tampon",
"circle": "Cercle",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.it-IT
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
},
"methods": {
"zone": "Zona",
"viewport": "Viewport",
"box": "BoundingBox",
"buffer": "Buffer",
"circle": "Cerchio",
Expand Down