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

Introduces WfsSearch #563

Merged
merged 3 commits into from
Apr 11, 2018
Merged

Introduces WfsSearch #563

merged 3 commits into from
Apr 11, 2018

Conversation

KaiVolland
Copy link
Member

FEATURE

Description:

This introduces the WfsSearch.

@KaiVolland KaiVolland changed the title [WIP] Introduces WfsSearch Introduces WfsSearch Apr 9, 2018
@KaiVolland KaiVolland changed the title Introduces WfsSearch Introduces WfsSearch Apr 9, 2018
@KaiVolland KaiVolland mentioned this pull request Apr 9, 2018
Copy link
Member

@annarieger annarieger left a 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 🍍

*/
srsName: PropTypes.string,
/**
* Ther output format of the response.
Copy link
Member

Choose a reason for hiding this comment

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

Typo Ther -> The

baseUrl: PropTypes.string.isRequired,
/**
* The Property which should be shown in the inputfield when a selection was
* made.
Copy link
Member

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

* @return {AutoComplete.Option} The AutoComplete.Option that will be
* rendered for each feature.
*/
renderOption: (feature) => {
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

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

olMap param missing


/**
* This function gets called when the nomintim fetch returns an error.
* It logs the error to the console.
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

😎 👍

Copy link
Member

@ahennr ahennr left a 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));
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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.

filter: this.createFilter()
};

const wfsFormat = new OlFormatWFS();
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

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

Copy link
Member Author

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),
Copy link
Member

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, ..?

Copy link
Member Author

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.

Copy link
Member Author

@KaiVolland KaiVolland Apr 11, 2018

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.

* The base URL.
* @type {String}
*/
baseUrl: PropTypes.string.isRequired,
Copy link
Member

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?

Copy link
Member Author

@KaiVolland KaiVolland Apr 10, 2018

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.

Copy link
Member

@marcjansen marcjansen left a 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,
Copy link
Member

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?

Copy link
Member Author

@KaiVolland KaiVolland Apr 11, 2018

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?

Copy link
Member

Choose a reason for hiding this comment

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

Here you are: #567

* made.
* @type {String}
*/
displayField: PropTypes.string,
Copy link
Member

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.

Copy link
Member Author

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,
Copy link
Member

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

Copy link
Member Author

@KaiVolland KaiVolland Apr 11, 2018

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?

Copy link
Member

Choose a reason for hiding this comment

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

Here you are: #567

*
* @type {Object}
*/
map: PropTypes.instanceOf(OlMap).isRequired,
Copy link
Member

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 => {
Copy link
Member

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.

Copy link
Member Author

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
});
Copy link
Member

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?

Copy link
Member Author

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.


if (value) {
this.setState({
searchTerm: value || ''
Copy link
Member

Choose a reason for hiding this comment

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

|| '' seems unneeded

filter: this.createFilter()
};

const wfsFormat = new OlFormatWFS();
Copy link
Member

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));
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

is this actually tested?

Copy link
Member Author

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.

@KaiVolland KaiVolland merged commit e7907ca into terrestris:master Apr 11, 2018
@KaiVolland KaiVolland deleted the wfs-search branch April 11, 2018 11:14
@KaiVolland KaiVolland restored the wfs-search branch November 22, 2019 09:00
hblitza pushed a commit that referenced this pull request Oct 19, 2022
…-jest-27.4.5

Bump babel-jest from 27.4.4 to 27.4.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants