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

Removed additional '?' in WFS request #2048

Merged
merged 5 commits into from
Aug 1, 2017
Merged
Changes from 3 commits
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
15 changes: 12 additions & 3 deletions web/client/epics/wfsquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

const Rx = require('rxjs');
const axios = require('../libs/ajax');
const Url = require('url');
const {changeSpatialAttribute, SELECT_VIEWPORT_SPATIAL_METHOD, updateGeometrySpatialField} = require('../actions/queryform');
const {CHANGE_MAP_VIEW} = require('../actions/map');
const {FEATURE_TYPE_SELECTED, QUERY, featureTypeLoaded, featureTypeError, querySearchResponse, queryError, featureClose} = require('../actions/wfsquery');
const FilterUtils = require('../utils/FilterUtils');
const assign = require('object-assign');
const {isString} = require('lodash');
const {isString, isObject} = require('lodash');
const {TOGGLE_CONTROL, setControlProperty} = require('../actions/controls');
const querystring = require('querystring');
Copy link
Member

Choose a reason for hiding this comment

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

what's this? I think is missing in package.json


const types = {
// string
Expand Down Expand Up @@ -122,8 +124,16 @@ const getWFSFilterData = (filterObj) => {

const getWFSFeature = (searchUrl, filterObj) => {
const data = getWFSFilterData(filterObj);

const urlParsedObj = Url.parse(searchUrl, true);
const parsedUrl = urlParsedObj.protocol + '//' + urlParsedObj.host + urlParsedObj.pathname + '?';
let params = isObject(urlParsedObj.query) ? urlParsedObj.query : {};
params.service = 'WFS';
params.outputFormat = 'json';
const paramsString = querystring.stringify(params);
Copy link
Member

Choose a reason for hiding this comment

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

You don't need other libraries. You can do all with Url.format.
Create a new object from urlParsedObj modifying the query object and call Url.format with the new object.


return Rx.Observable.defer( () =>
axios.post(searchUrl + '?service=WFS&outputFormat=json', data, {
axios.post(parsedUrl + paramsString, data, {
timeout: 60000,
headers: {'Accept': 'application/json', 'Content-Type': 'application/json'}
}));
Expand Down Expand Up @@ -197,7 +207,6 @@ const featureTypeSelectedEpic = action$ =>
const wfsQueryEpic = (action$, store) =>
action$.ofType(QUERY)
.switchMap(action => {

return Rx.Observable.merge(
Rx.Observable.of(setControlProperty('drawer', 'enabled', false)),
getWFSFeature(action.searchUrl, action.filterObj)
Expand Down