-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing spatial filter selection area when FeatureGrid is open (#2906)
- Loading branch information
1 parent
bb3c1c5
commit 73cece8
Showing
8 changed files
with
170 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,53 @@ | ||
const {get} = require('lodash'); | ||
const {createSelector} = require('reselect'); | ||
const {reprojectGeoJson} = require('../utils/CoordinatesUtils'); | ||
|
||
const selectedFeatures = (state) => get(state, state && state.highlight && state.highlight.featuresPath || "highlight.emptyFeatures"); | ||
const filteredspatialObject = (state) => get(state, state && state.featuregrid.open && state.featuregrid.showFilteredObject && "query.filterObj.spatialField" || "emptyObject"); | ||
const filteredGeometry = (state) => filteredspatialObject(state) && filteredspatialObject(state).geometry; | ||
const filteredspatialObjectType = (state) => filteredGeometry(state) && filteredGeometry(state).type || "Polygon"; | ||
const filteredspatialObjectCoord = (state) => filteredGeometry(state) && filteredGeometry(state).coordinates || []; | ||
const filteredSpatialObjectCrs = (state) => filteredGeometry(state) && filteredGeometry(state).projection || "EPSG:3857"; | ||
const filteredSpatialObjectId = (state) => filteredGeometry(state) && filteredGeometry(state).id || "spatial_object"; | ||
const filteredFeatures = createSelector( | ||
[ | ||
filteredspatialObjectCoord, | ||
filteredspatialObjectType, | ||
filteredSpatialObjectId, | ||
filteredSpatialObjectCrs | ||
], | ||
( geometryCoordinates, geometryType, geometryId, geometryCrs) => { | ||
let geometry = { | ||
type: "FeatureCollection", | ||
features: [ | ||
{ | ||
type: "Feature", | ||
geometry: { | ||
type: geometryType, | ||
coordinates: geometryCoordinates | ||
}, | ||
style: { | ||
fillColor: 'rgba(255, 255, 255, 0.2)', | ||
color: '#ffcc33' | ||
}, | ||
id: geometryId | ||
} | ||
] | ||
}; | ||
return geometryCoordinates.length > 0 && geometryType ? reprojectGeoJson(geometry, geometryCrs, 'EPSG:4326').features : []; | ||
} | ||
|
||
module.exports = { | ||
selectedFeatures: (state) => get(state, state && state.highlight && state.highlight.featuresPath || "highlight.emptyFeatures") | ||
); | ||
|
||
const highlighedFeatures = createSelector( | ||
[ | ||
filteredFeatures, | ||
selectedFeatures | ||
], | ||
(featuresFiltered, featuresSelected) => [ ...featuresSelected, ...featuresFiltered] | ||
); | ||
|
||
module.exports = { | ||
selectedFeatures, filteredFeatures, filteredSpatialObjectId, filteredSpatialObjectCrs, filteredspatialObjectCoord, | ||
filteredspatialObjectType, filteredGeometry, filteredspatialObject, highlighedFeatures | ||
}; |