-
Notifications
You must be signed in to change notification settings - Fork 35
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
[Datahub] Wfs pagination in data fetcher #1126
Conversation
Affected libs:
|
8586ef2
to
b37add0
Compare
📷 Screenshots are here! |
ed85830
to
255637d
Compare
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.
This looks really good! I'd like to test this first but I think your implementation makes a lot of sense, thanks!
return this.getData().then( | ||
(result) => | ||
({ | ||
itemsCount: result.items.length, | ||
}) as DatasetInfo | ||
) |
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 think this is supposed to be the total amount of items in the featureType, you should be able to get this information using ogc-client:
const count = (await this.endpoint.getFeatureTypeFull(featureTypeName)).objectCount
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.
Right! i have updated the code like you have suggested.
if (Array.isArray(this.sort) && this.sort.length > 0) { | ||
const finalUrl = new URL(url) | ||
const sorts = this.sort | ||
.map( | ||
(fieldSort) => `${fieldSort[1]}+${fieldSort[0] === 'asc' ? 'A' : 'D'}` | ||
) | ||
.join(',') | ||
|
||
finalUrl.searchParams.append('sortBy', sorts) | ||
url = finalUrl.toString() | ||
} |
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.
looking good! would be great to have this in ogc-client :)
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.
FYI i now set the params directly on the url string as searchParams is encoding the "+"
16b04f7
to
66a24b2
Compare
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.
This looks great, thank you! I added a few comments for things that could be clarified/simplified. I tried this reader with #1120 and it seems to work OK.
return this.getDownloadUrlsFromWfs(link.url.toString(), link.name).pipe( | ||
switchMap((urls) => { |
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.
You can probably just call openDataset
right away:
return this.getDownloadUrlsFromWfs(link.url.toString(), link.name).pipe( | |
switchMap((urls) => { | |
return from(openDataset(wfsUrlEndpoint, 'wfs', { | |
wfsUrlEndpoint, | |
featureType: link.name, | |
}) |
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.
Thanks, code updated
url: string, | ||
wfsUrlEndpoint: 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.
I'm not sure I understand why you need both of these. Only using url
everywhere would make it much simpler 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.
in the getDownloadUrlsFromWfs()
the url Endpoint is proxified, this is why i have a wfsUrlEndpoint
. Should i ignore the proxified url then? Agree it would be simpler.
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.
Ok i have removed one, now there is only one wfsUrlEndpoint
) | ||
.join(',') | ||
|
||
finalUrl.searchParams.append('sortBy', sorts) |
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.
finalUrl.searchParams.append('sortBy', sorts) | |
finalUrl.searchParams.append('SORTBY', sorts) |
to comply with the WFS spec :)
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.
updated, thx
options?: { | ||
namespace?: string | ||
wfsVersion?: WfsVersion | ||
wfsUrlEndpoint?: 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.
wfsUrlEndpoint?: string | |
wfsFeatureType?: string |
This would be more appropriate/explicit instead of reusing namespace
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.
ok done, i kept namespace for gml and added wfsFeatureType for wfs, is that what you have in mind?
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.
exactly!
reader = await WfsReader.createReader( | ||
url, | ||
options.wfsUrlEndpoint, | ||
options.namespace |
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.
options.namespace | |
options.wfsFeatureType |
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.
done
@@ -5,7 +5,7 @@ export function parseHeaders(httpHeaders: Headers): DatasetHeaders { | |||
if (httpHeaders.has('Content-Type')) { | |||
result.mimeType = httpHeaders.get('Content-Type').split(';')[0] | |||
const supported = | |||
SupportedTypes.filter( | |||
SupportedTypes.filter((type) => type !== 'wfs').filter( |
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.
Maybe add a comment here? just to make sure that someone encountering this code understands what's going on. Thanks!
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.
done
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.
Looking good, thank you for the work!
The e2e failures do not seem related, but that's a lot of failing tests :/ |
299471e
to
445fa3f
Compare
Merging this PR as the failure is similar as the one on main |
Description
This PR introduces pagination when reading data through a WFS service. This feature is implemented in a new reader: the
WfsReader
.If the service supports pagination, the WfsReader will handle pagination, fetching api at each read(). If service version is lower than 2.0.0 (does not handle pagination) the WfsReader returns GeoJsonReader or GmlReader (works as previously).
Architectural changes
Added a new WfsReader.
Screenshots
None
Quality Assurance Checklist
breaking change
labelbackport <release branch>
label