-
Notifications
You must be signed in to change notification settings - Fork 58
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
Introduces WfsSearch #563
Introduces WfsSearch #563
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I've added some mostly minor notes regarding to docs.
Please merge at will and thanks 🍍
src/Field/WfsSearch/WfsSearch.jsx
Outdated
*/ | ||
srsName: PropTypes.string, | ||
/** | ||
* Ther output format of the response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo Ther
-> The
src/Field/WfsSearch/WfsSearch.jsx
Outdated
baseUrl: PropTypes.string.isRequired, | ||
/** | ||
* The Property which should be shown in the inputfield when a selection was | ||
* made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor: here and by some further props below @type
annotation is missing
src/Field/WfsSearch/WfsSearch.jsx
Outdated
* @return {AutoComplete.Option} The AutoComplete.Option that will be | ||
* rendered for each feature. | ||
*/ | ||
renderOption: (feature) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor: ()
around the argument can be ommited
* The default onSelect method if no onSelect prop is given. It zooms to the | ||
* selected item. | ||
* | ||
* @param {object} feature The selected feature as returned by the server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
olMap
param missing
src/Field/WfsSearch/WfsSearch.jsx
Outdated
|
||
/** | ||
* This function gets called when the nomintim fetch returns an error. | ||
* It logs the error to the console. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adapt method description
setTimeout(() => { | ||
expect(map.getView().getCenter()).toEqual([25, 25]); | ||
expect(map.getView().getZoom()).toEqual(2); | ||
}, 501); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 nice work @KaiVolland
Added some remarks you might want to tackle.
} = this.props; | ||
|
||
const propertyFilters = searchAttributes.map(attribute => | ||
OlFormatFilter.like(attribute, `*${searchTerm}*`, '*', '.', '!', false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens here if numerical / boolean attributes are filtered / queried here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uff i don't know. I think this depends on the WFS-Server. Either it throws an error or it just won't match... Anything we can do about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for geoserver we can cast e.g. by using a string function like concatenate with an empty string, which will accept any input (according to the docs). this should be configurable defaulting to false probably.
src/Field/WfsSearch/WfsSearch.jsx
Outdated
filter: this.createFilter() | ||
}; | ||
|
||
const wfsFormat = new OlFormatWFS(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default OlFormatWFS
supports WFS version 1.1. Please make the used WFS version configurable (see e.g. here).
WFS 2.0.x is not supported, or am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ol.format.WFS
does not support WFS 2.0.0, is it really necessary to support WFS 1.0.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for 1.0.0 IMO. 2.0.0 would be nice, but is not a must have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since WFS 1.0.0 will be generated simply by using another GML format in OlFormatWFS
I would make this configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 👒 this done in 638c12d
credentials: additionalFetchOptions.credentials | ||
? additionalFetchOptions.credentials | ||
: 'same-origin', | ||
body: new XMLSerializer().serializeToString(featureRequest), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've in mind that there existed some problems using XMLSerializer
in Firefox.
Did you check this also other browsers like FF, Edge, ..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No i didn't nice hint. I'll check this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a quick check, it works as aspected in FireFox and Internet-Explorer.
src/Field/WfsSearch/WfsSearch.jsx
Outdated
* The base URL. | ||
* @type {String} | ||
*/ | ||
baseUrl: PropTypes.string.isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must CORS headers be set by the WFS server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i think so. I'll add it to the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. please take from my comments what you think is appropriate.
* The list of attributes that should be searched through. | ||
* @type {String[]} | ||
*/ | ||
searchAttributes: PropTypes.arrayOf(PropTypes.string).isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get a utility to get these from a DescribeFeatureType
? Posibbly first fetching these and filtering to those usable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds very useful. Can you open an issue for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are: #567
src/Field/WfsSearch/WfsSearch.jsx
Outdated
* made. | ||
* @type {String} | ||
*/ | ||
displayField: PropTypes.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this to be a template or a function, so I can show multiple fields and arbitrary text? Also it would be super nice if we could somehow mark the matched textpart in the property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After having a look at the code i found out, that this prop is never used. I'll remove it. All what you expect should be realized in the renderOption
prop.
* Geometry name to use in a BBOX filter. | ||
* @type {string} | ||
*/ | ||
geometryName: PropTypes.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A utility to get this from a DescribeFeatureType would be nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds very useful. Can you open an issue for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are: #567
src/Field/WfsSearch/WfsSearch.jsx
Outdated
* | ||
* @type {Object} | ||
*/ | ||
map: PropTypes.instanceOf(OlMap).isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this required? we can search without a map I guess?
* @return {AutoComplete.Option} The AutoComplete.Option that will be | ||
* rendered for each feature. | ||
*/ | ||
renderOption: feature => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user can provide this, we should list actual requirements, if any. I am thinking of the id property, e.g.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll enhance the docs at the property.
if (geometry) { | ||
olView.fit(geometry, { | ||
duration: 500 | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These options might be a good candidate for configuration, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it's just in the default of the onSelect
property this doesn't need to be configurable. You can just provide a complete new function if you want a different duration.
src/Field/WfsSearch/WfsSearch.jsx
Outdated
|
||
if (value) { | ||
this.setState({ | ||
searchTerm: value || '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| ''
seems unneeded
src/Field/WfsSearch/WfsSearch.jsx
Outdated
filter: this.createFilter() | ||
}; | ||
|
||
const wfsFormat = new OlFormatWFS(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for 1.0.0 IMO. 2.0.0 would be nice, but is not a must have.
} = this.props; | ||
|
||
const propertyFilters = searchAttributes.map(attribute => | ||
OlFormatFilter.like(attribute, `*${searchTerm}*`, '*', '.', '!', false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for geoserver we can cast e.g. by using a string function like concatenate with an empty string, which will accept any input (according to the docs). this should be configurable defaulting to false probably.
expect(fitSpy).toHaveBeenCalled(); | ||
setTimeout(() => { | ||
expect(map.getView().getCenter()).toEqual([25, 25]); | ||
expect(map.getView().getZoom()).toEqual(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this actually tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect.assertions
is missing. I'll add it.
…-jest-27.4.5 Bump babel-jest from 27.4.4 to 27.4.5
FEATURE
Description:
This introduces the
WfsSearch
.