-
Notifications
You must be signed in to change notification settings - Fork 445
[Backport 2024.01.xx]: #10136: Search for Map CRS coordinates (#10220, #10305) #10317
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
Merged
tdipisa
merged 2 commits into
geosolutions-it:2024.01.xx
from
mahmoudadel54:porting_10136_2024.01.xx
May 14, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import Message from "../../I18N/Message"; | |
| import CoordinateEntry from "../../misc/coordinateeditors/CoordinateEntry"; | ||
| import DropdownToolbarOptions from "../../misc/toolbar/DropdownToolbarOptions"; | ||
| import { zoomAndAddPoint, changeCoord } from '../../../actions/search'; | ||
| import { reproject} from '../../../utils/CoordinatesUtils'; | ||
|
|
||
| /** | ||
| * CoordinateOptions for Search bar | ||
|
|
@@ -26,10 +27,14 @@ import { zoomAndAddPoint, changeCoord } from '../../../actions/search'; | |
| export const CoordinateOptions = ({ | ||
| clearCoordinates: (onClearCoordinatesSearch, onChangeCoord) =>{ | ||
| onClearCoordinatesSearch({owner: "search"}); | ||
| onChangeCoord("lat", ""); | ||
| onChangeCoord("lon", ""); | ||
| const clearedFields = ["lat", "lon", "xCoord", "yCoord", "currentMapXYCRS"]; | ||
| const resetVal = ''; | ||
| clearedFields.forEach(field => onChangeCoord(field, resetVal)); | ||
| }, | ||
| areValidCoordinates: (coordinate) => { | ||
| if (!coordinate) return false; | ||
| return isNumber(coordinate?.lon) && isNumber(coordinate?.lat); | ||
| }, | ||
| areValidCoordinates: (coordinate) => isNumber(coordinate?.lon) && isNumber(coordinate?.lat), | ||
| zoomToPoint: (onZoomToPoint, coordinate, defaultZoomLevel = 12) => { | ||
| onZoomToPoint({ | ||
| x: parseFloat(coordinate.lon), | ||
|
|
@@ -63,19 +68,31 @@ export const CoordinateOptions = ({ | |
| coordinate, | ||
| onClearCoordinatesSearch, | ||
| onChangeCoord) =>({ | ||
| visible: activeTool === "coordinatesSearch" && (isNumber(coordinate.lon) || isNumber(coordinate.lat)), | ||
| visible: (['coordinatesSearch', 'mapCRSCoordinatesSearch'].includes(activeTool)) && (isNumber(coordinate.lon) || isNumber(coordinate.lat) || isNumber(coordinate.xCoord) || isNumber(coordinate.yCoord)), | ||
| onClick: () => CoordinateOptions.clearCoordinates(onClearCoordinatesSearch, onChangeCoord) | ||
| }), | ||
| searchIcon: (activeTool, coordinate, onZoomToPoint, defaultZoomLevel) => ({ | ||
| visible: activeTool === "coordinatesSearch", | ||
| visible: ["coordinatesSearch", "mapCRSCoordinatesSearch"].includes(activeTool), | ||
| onClick: () => { | ||
| if (activeTool === "coordinatesSearch" && CoordinateOptions.areValidCoordinates(coordinate)) { | ||
| if ((['coordinatesSearch', 'mapCRSCoordinatesSearch'].includes(activeTool)) && CoordinateOptions.areValidCoordinates(coordinate)) { | ||
| CoordinateOptions.zoomToPoint(onZoomToPoint, coordinate, defaultZoomLevel); | ||
| } | ||
| } | ||
| }), | ||
| coordinatesMenuItem: ({activeTool, searchText, clearSearch, onChangeActiveSearchTool, onClearBookmarkSearch}) =>( | ||
| <MenuItem active={activeTool === "coordinatesSearch"} onClick={() => { | ||
| coordinatesMenuItem: ({activeTool, searchText, clearSearch, onChangeActiveSearchTool, onClearBookmarkSearch, currentMapCRS, onChangeFormat}) =>{ | ||
| if (currentMapCRS === 'EPSG:4326') { | ||
| return (<MenuItem active={activeTool === "coordinatesSearch"} onClick={() => { | ||
| if (searchText !== undefined && searchText !== "") { | ||
| clearSearch(); | ||
| } | ||
| onClearBookmarkSearch("selected"); | ||
| onChangeActiveSearchTool("coordinatesSearch"); | ||
| document.dispatchEvent(new MouseEvent('click')); | ||
| }}> | ||
| <Glyphicon glyph={"search-coords"}/> <Message msgId="search.coordinatesSearch"/> | ||
| </MenuItem>); | ||
| } | ||
| return (<><MenuItem active={activeTool === "coordinatesSearch"} onClick={() => { | ||
| if (searchText !== undefined && searchText !== "") { | ||
| clearSearch(); | ||
| } | ||
|
|
@@ -85,7 +102,21 @@ export const CoordinateOptions = ({ | |
| }}> | ||
| <Glyphicon glyph={"search-coords"}/> <Message msgId="search.coordinatesSearch"/> | ||
| </MenuItem> | ||
| ) | ||
| <MenuItem active={activeTool === "mapCRSCoordinatesSearch"} onClick={() => { | ||
| if (searchText !== undefined && searchText !== "") { | ||
| clearSearch(); | ||
| } | ||
| onClearBookmarkSearch("selected"); | ||
| onChangeActiveSearchTool("mapCRSCoordinatesSearch"); | ||
| onChangeFormat("decimal"); | ||
| document.dispatchEvent(new MouseEvent('click')); | ||
| }}> | ||
| <span style={{marginLeft: 20}}> | ||
| <Glyphicon glyph={"search-coords"}/> <Message msgId="search.currentMapCRS"/> | ||
| </span> | ||
| </MenuItem> | ||
| </>); | ||
| } | ||
| }); | ||
|
|
||
|
|
||
|
|
@@ -108,6 +139,7 @@ const CoordinatesSearch = ({ | |
| onZoomToPoint, | ||
| onChangeCoord, | ||
| defaultZoomLevel, | ||
| currentMapCRS, | ||
| aeronauticalOptions = { | ||
| seconds: { | ||
| decimals: 4, | ||
|
|
@@ -131,9 +163,30 @@ const CoordinatesSearch = ({ | |
|
|
||
| const changeCoordinates = (coord, value) => { | ||
| onChangeCoord(coord, parseFloat(value)); | ||
| // set current map crs to coordinate object | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| if (coordinate?.currentMapXYCRS !== currentMapCRS && currentMapCRS !== "EPSG:4326") onChangeCoord('currentMapXYCRS', currentMapCRS); | ||
| if (!areValidCoordinates()) { | ||
| onClearCoordinatesSearch({owner: "search"}); | ||
| } | ||
| // if there is mapCRS available --> calculate X/Y values by reproject to display in case switch to MapCRS | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| if (currentMapCRS !== 'EPSG:4326') { | ||
| // if there are lat, lon values --> reproject the point and get xCoord and yCoord for map CRS | ||
| const latNumVal = coord === 'lat' ? parseFloat(value) : coordinate.lat; | ||
| const lonNumVal = coord === 'lon' ? parseFloat(value) : coordinate.lon; | ||
| const isLatNumberVal = isNumber(latNumVal) && !isNaN(latNumVal); | ||
| const isLonNumberVal = isNumber(lonNumVal) && !isNaN(lonNumVal); | ||
| if (isLatNumberVal && isLonNumberVal) { | ||
| const reprojectedValue = reproject([lonNumVal, latNumVal], 'EPSG:4326', currentMapCRS, true); | ||
| const parsedXCoord = parseFloat((reprojectedValue?.x)); | ||
| const parsedYCoord = parseFloat((reprojectedValue?.y)); | ||
| onChangeCoord('xCoord', parsedXCoord); | ||
| onChangeCoord('yCoord', parsedYCoord); | ||
|
|
||
| return; | ||
| } | ||
| coordinate.xCoord && onChangeCoord('xCoord', ''); | ||
| coordinate.yCoord && onChangeCoord('yCoord', ''); | ||
| } | ||
| }; | ||
|
|
||
| const onZoom = () => { | ||
|
|
@@ -147,6 +200,7 @@ const CoordinatesSearch = ({ | |
| <InputGroup > | ||
| <InputGroup.Addon style={{minWidth: 45}}><Message msgId="search.latitude"/></InputGroup.Addon> | ||
| <CoordinateEntry | ||
| owner="search" | ||
| format={format} | ||
| aeronauticalOptions={aeronauticalOptions} | ||
| coordinate="lat" | ||
|
|
@@ -168,6 +222,7 @@ const CoordinatesSearch = ({ | |
| <InputGroup> | ||
| <InputGroup.Addon style={{minWidth: 45}}><Message msgId="search.longitude"/></InputGroup.Addon> | ||
| <CoordinateEntry | ||
| owner="search" | ||
| format={format} | ||
| aeronauticalOptions={aeronauticalOptions} | ||
| coordinate="lon" | ||
|
|
@@ -194,7 +249,8 @@ CoordinatesSearch.propTypes = { | |
| onClearCoordinatesSearch: PropTypes.func, | ||
| onZoomToPoint: PropTypes.func, | ||
| onChangeCoord: PropTypes.func, | ||
| defaultZoomLevel: PropTypes.number | ||
| defaultZoomLevel: PropTypes.number, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| currentMapCRS: PropTypes.string | ||
| }; | ||
|
|
||
| export default connect((state)=>{ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems to be missing in
https://github.com/geosolutions-it/MapStore2/pull/10220/files#diff-455b07539c76115f6dce6c982a88461c05ae2ab7cb8a2a3fac5a2a6ad58ba9cc