Refactor selectlist attach feature - #175
Conversation
e55fafe to
fc26169
Compare
fc26169 to
d74b22b
Compare
|
The default parameter Consequence: a bare |
|
Thank you for catching that regression! Addressed and tested in 25871c3 Additionally, when doing a GetFeatureById with empty |
25871c3 to
2b9817e
Compare
|
Have a look at |
65402f6 to
d39196c
Compare
| // Rewrite an embedded-catalog geometry-column desync into a clear diagnostic | ||
| // (shared with the proxy path); any other error passes through unchanged. | ||
| rethrowIdentifiedCatalogDesyncError(error, compiled.geometryProperty.name, input.typename); | ||
| if (compiled.geometryProperty) { |
There was a problem hiding this comment.
compileQueryParts now only populates compiled.geometryProperty inside if (spatialFilter), but buildPropertyName still forces the geometry column into propertyName whenever spatial_extras is non-empty resolving it locally (properties.ts:142) without handing it back. So for a query with spatial_extras and no spatial filter, the column is in the request while this field is undefined, and the rewrite is skipped.
The two names have drifted apart:
compiled.geometryPropertynow means "column used by the spatial filter"catalogDesyncneeds "column injected into the request"
| if (includeGeometry) { | ||
| // ensure that the geometric property exists | ||
| geometryProperty ?? getGeometryProperty(featureType); | ||
| return ""; // return all properties |
There was a problem hiding this comment.
So, there, if select is not there and includeGeometry is true we return "" so no propertyName will appear in the WFS query and every column will be returned. If we were to omit columns from the catalogue we will still return all the WFS columns.
There was a problem hiding this comment.
This commit makes it so that all properties are now explicitly returned and the resulting propertyName is never empty
| ) { | ||
| const shouldIncludeGeometry = (input.spatial_extras ?? []).length > 0; | ||
| select?: string[], | ||
| spatial_extras?: string[], |
There was a problem hiding this comment.
spatial_extras is never read in the body, its only uses are this declaration, the JSDoc, and the
default value of includeGeometry.
buildPropertyNameWithGeometry(ft, select, spatial_extras)
silently ignores its 3rd argument, since it forces includeGeometry: true. Both real callers pass only (featureType, select).
Maybe drop spatial_extras from both signatures and let each caller compute includeGeometry
explicitly at the call site (it already did before this PR).
There was a problem hiding this comment.
I prefer the current design, it avoids duplicating the logic to detect whether or not includeGeometry should be set. That was actually one of the main points of this refactor.
However, I agree that spatial_extras is irrelevant for buildPropertyNameWithGeometry so I removed the spatial_extras argument from buildPropertyNameWithGeometry in 0c810c5
|
|
||
| if (includeGeometry) { | ||
| // ensure that the geometric property exists | ||
| geometryProperty ?? getGeometryProperty(featureType); |
There was a problem hiding this comment.
geometryProperty ?? getGeometryProperty(featureType); is an expression statement whose result is
discarded. It only exists to throw. And the only caller with includeGeometry: true always passes
geometryProperty, so the right-hand side never runs.
There was a problem hiding this comment.
Yes, the result is discarded, it only exists to throw. But no, the right-hand side can run, because includeGeometry can be set on the other caller if spatial_extra is not empty. That would be the case of a GetFeatures call with empty select but non-empty spatial_extra on a geometry-less collection: this is tested in the new tests of this PR at https://github.com/ignfab/geocontext/pull/175/changes#diff-188df1952a07ac03771df78672fa7af090aa35892cbc19c19840fa99b6e3f970R437-R459
There was a problem hiding this comment.
This comment is now false: it promises appending the geometry column "only when spatial_extras needs it", but the return "" above exits before reaching here. A reader concludes main's behavior is preserved.
The comment that carried the why (// Include geometry when spatial_extras needs it to derive bbox/centroid/...) was dropped with no replacement.
Probably a good idea to restore the why on the branch that actually appends (:141), and cut this one down to what the code below really does.
There was a problem hiding this comment.
I move the comment above and slightly reword it.
| * @param geometryProperty Geometry property already resolved for the feature type. | ||
| * @param input Normalized tool input. | ||
| * @param includeGeometry Override boolean to force including the geometry in the return query. | ||
| * @returns The list of property names to expose in the WFS `propertyName` parameter. |
There was a problem hiding this comment.
Will have to be updated based on decisions deriving from other comments
There was a problem hiding this comment.
Nothing to do so far, but keeping this open while we don't have a common conclusion on the issues above.
Co-authored-by: Emmanuel S. <5435148+esgn@users.noreply.github.com>
a6773c0 to
9c906c7
Compare
…sInput Co-authored-by: Emmanuel S. <5435148+esgn@users.noreply.github.com>
…rty is part of the request Co-authored-by: Emmanuel S. <5435148+esgn@users.noreply.github.com>
Co-authored-by: Emmanuel S. <5435148+esgn@users.noreply.github.com>
3ee9384 to
438656e
Compare
… queries) Co-authored-by: Emmanuel S. <5435148+esgn@users.noreply.github.com>
68595e4 to
0c810c5
Compare
Fix two code inconsistencies:
select: one exists for the GpfGetFeatures codepath and another for GpfGetFeatureById, while they should be identical.attachFeatureRefsintopostProcessFeatureCollectionto more accurately reflect that this function handles all the post-processing, and does not only attach feature refs anymore.Pure refactors, no impact on behavior.