Skip to content

Commit d4d5e9f

Browse files
MV88offtherailz
authored andcommitted
Added srsName param to the spatial filter configuration (#2449)
1 parent 4c2737b commit d4d5e9f

5 files changed

Lines changed: 15 additions & 12 deletions

File tree

web/client/components/data/query/SpatialFilter.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,11 @@ class SpatialFilter extends React.Component {
173173
const selectedMethod = this.getMethodFromId(this.props.spatialField.method);
174174
return (<Panel>
175175
<div className="container-fluid">
176-
<Row className="filter-field-row">
177-
<Col xs={5}>
176+
<Row className="filter-field-row filter-field-fixed-row">
177+
<Col xs={6}>
178178
<span>{this.props.spatialField.method}</span>
179179
</Col>
180-
<Col xs={7}>
181-
<div style={{width: "140px"}}>
180+
<Col xs={6}>
182181
<AutocompleteWFSCombobox
183182
autocompleteStreamFactory={createWFSFetchStream}
184183
valueField={selectedMethod && selectedMethod.filterProps && selectedMethod.filterProps.valueField}
@@ -188,8 +187,6 @@ class SpatialFilter extends React.Component {
188187
onChangeDrawingStatus={this.props.actions.onChangeDrawingStatus}
189188
filterProps={selectedMethod && selectedMethod.filterProps}
190189
/>
191-
</div>
192-
193190
</Col>
194191
</Row>
195192
</div>

web/client/components/misc/AutocompleteWFSCombobox.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const streamEnhancer = mapPropsStream(props$ => {
2424
data: isArray(data && data.fetchedData && data.fetchedData.values) ? data.fetchedData.values : [],
2525
features: isArray(data && data.fetchedData && data.fetchedData.features) ? data.fetchedData.features : [],
2626
valuesCount: data && data.fetchedData && data.fetchedData.size,
27+
srsName: data && data.fetchedData && data.fetchedData.crs,
2728
busy: data.busy
2829
}));
2930
});
@@ -32,13 +33,13 @@ const streamEnhancer = mapPropsStream(props$ => {
3233
const PagedWFSComboboxEnhanced = streamEnhancer(
3334
({ open, toggle, select, focus, change, value, valuesCount, onChangeDrawingStatus,
3435
loadNextPage, loadPrevPage, maxFeatures, currentPage, itemComponent, features,
35-
busy, data, loading = false, valueField, textField, filter }) => {
36+
busy, data, loading = false, valueField, textField, filter, srsName }) => {
3637
const numberOfPages = Math.ceil(valuesCount / maxFeatures);
3738
// for understanding "numberOfPages <= currentPage" see https://osgeo-org.atlassian.net/browse/GEOS-7233. can be removed when fixed
3839
// sometimes on the last page it returns a wrong totalFeatures number
3940
return (<PagedComboboxWithFeatures
4041
pagination={{firstPage: currentPage === 1, lastPage: numberOfPages <= currentPage, paginated: true, loadPrevPage, loadNextPage, currentPage}}
41-
busy={busy} dropUp={false} data={data} open={open} onChangeDrawingStatus={onChangeDrawingStatus}
42+
srsName={srsName} busy={busy} dropUp={false} data={data} open={open} onChangeDrawingStatus={onChangeDrawingStatus}
4243
valueField={valueField} textField={textField} itemComponent={itemComponent} filter={filter}
4344
onFocus={focus} onToggle={toggle} onChange={change} onSelect={select} features={features}
4445
selectedValue={value} loading={loading}/>);

web/client/components/misc/combobox/PagedComboboxWithFeatures.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class PagedCombobox extends React.Component {
4949
nextPageIcon: PropTypes.string,
5050
prevPageIcon: PropTypes.string,
5151
selectedValue: PropTypes.string,
52+
srsName: PropTypes.string,
5253
textField: PropTypes.string,
5354
tooltip: PropTypes.object,
5455
valueField: PropTypes.string
@@ -79,6 +80,7 @@ class PagedCombobox extends React.Component {
7980
onChange: () => {},
8081
onChangeDrawingStatus: () => {},
8182
onSelect: () => {},
83+
srsName: "EPSG:4326",
8284
textField: "label",
8385
tooltip: {
8486
customizedTooltip: undefined,
@@ -155,7 +157,7 @@ class PagedCombobox extends React.Component {
155157
const feature = head(this.props.features.filter(f => f.properties[this.props.valueField].toLowerCase() === v[this.props.valueField].toLowerCase()));
156158
this.props.onSelect(v, feature);
157159
if (feature) {
158-
this.props.onChangeDrawingStatus('drawOrEdit', feature.geometry.type, "queryform", [feature], {editEnabled: false, stopAfterDrawing: true, updateSpatialField: true});
160+
this.props.onChangeDrawingStatus('drawOrEdit', feature.geometry.type, "queryform", [feature], {editEnabled: false, stopAfterDrawing: true, updateSpatialField: true, featureProjection: this.props.srsName});
159161
}
160162
}}
161163
onToggle={(v) => {
@@ -165,7 +167,7 @@ class PagedCombobox extends React.Component {
165167
this.props.onToggle(v, feature, this.props.pagination.currentPage);
166168
// if when closing the menu it finds a feature with the text inserted, then update the spatial field
167169
if (feature && !v) {
168-
this.props.onChangeDrawingStatus('drawOrEdit', feature.geometry.type, "queryform", [feature], {editEnabled: false, stopAfterDrawing: true, updateSpatialField: true});
170+
this.props.onChangeDrawingStatus('drawOrEdit', feature.geometry.type, "queryform", [feature], {editEnabled: false, stopAfterDrawing: true, updateSpatialField: true, featureProjection: this.props.srsName});
169171
}
170172
// if when closing the menu it does not find a feature, then clean all
171173
// it conflicts with change page which trigger the on toggle twice, one for closing and one for opening

web/client/observables/autocomplete.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ const createWFSFetchStream = (props$) => props$
9090
item: {},
9191
timeout: 60000,
9292
headers: {'Accept': 'application/json', 'Content-Type': 'application/xml'},
93+
srsName: p.filterProps && p.filterProps.srsName || "EPSG:4326",
9394
...parsed.query
9495
});
9596
return Rx.Observable.fromPromise((API.Utils.getService("wfs")(p.value, serviceOptions)
9697
.then( data => {
97-
return {fetchedData: { values: data.features.map(f => f.properties), size: data.totalFeatures, features: data.features}, busy: false};
98+
return {fetchedData: { values: data.features.map(f => f.properties), size: data.totalFeatures, features: data.features, crs: p.filterProps && p.filterProps.srsName || "EPSG:4326"}, busy: false};
9899
}))).catch(() => {
99100
return Rx.Observable.of({fetchedData: {values: [], size: 0, features: []}, busy: false});
100101
}).startWith({busy: true});

web/client/plugins/QueryPanel.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class QueryPanel extends React.Component {
301301
* - queriableAttributes {string[]} list of attributes to query on.
302302
* - typeName {string} the workspace + layer name on geosever
303303
* - valueField {string} the attribute from features properties used as value/label in the autocomplete list
304+
* - srsName {string} The projection of the requested features fetched via wfs
304305
*
305306
* @prop {object[]} cfg.spatialOperations: The list of geometric operations use to create the spatial filter.<br/>
306307
*
@@ -329,7 +330,8 @@ class QueryPanel extends React.Component {
329330
* "predicate": "LIKE",
330331
* "queriableAttributes": ["ATTRIBUTE_X"],
331332
* "typeName": "workspace:typeName",
332-
* "valueField": "ATTRIBUTE_Y"
333+
* "valueField": "ATTRIBUTE_Y",
334+
+ * "srsName": "ESPG:3857"
333335
* },
334336
* "customItemClassName": "customItemClassName"
335337
* }

0 commit comments

Comments
 (0)