Coordinate reference system combo#244
Conversation
43f51d2 to
afd4333
Compare
marcjansen
left a comment
There was a problem hiding this comment.
Thanks, Rö.
Only minor comments, please merge once adressed
| @@ -0,0 +1,228 @@ | |||
| import React from 'react'; | |||
| import PropTypes from 'prop-types'; | |||
| import {AutoComplete } from 'antd'; | |||
| import { Logger, UrlUtil } from '../../index.js'; | ||
|
|
||
| /** | ||
| * Class representating a combo to choose coordinate projection system via a |
| @@ -0,0 +1,3 @@ | |||
| .react-geo-crs-combo { | |||
| width: 200px; | |||
There was a problem hiding this comment.
why do we have a fixed width in the library?
There was a problem hiding this comment.
removed less file in 77710ba. Style can be passed as prop now.
| limit, | ||
| countrycodes, | ||
| map, | ||
| onSelect, |
There was a problem hiding this comment.
I think this is mistake… plz revert.
There was a problem hiding this comment.
I don't see where these variables are used in render function?!
There was a problem hiding this comment.
They are not used but you have to extract them from the passThroughProps as these props would be all passed to antds AutoComplete which does not accept them.
I know this looks somewhat strange but it's needed.
| */ | ||
| static proj4CrsDefinitions() { | ||
| return { | ||
| 'EPSG:25832': '+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs' |
There was a problem hiding this comment.
This is not in in the proj database? Or am I misunderstanding stuff here
There was a problem hiding this comment.
Is this because we get back the urn-whatever identifiers? is there some way to look these up as well?
| /** | ||
| * FeatureCollections returned by the GeoServer may be associated with | ||
| * crs identifiers (e.g. "urn:ogc:def:crs:EPSG::25832") that aren't | ||
| * supported by proj4 and/or ol3 per default. Add appropriate |
There was a problem hiding this comment.
no version needed, ol is enough
There was a problem hiding this comment.
Nice new feature @ahennr ! 😍
Some remarks inline and:
I'd prefer the classname CrsCombo just like in the className private.
If you want to stay with CoordinateReferenceSystemCombo plz change the private to react-geo-coordinatereferencesystemcombo
Current pattern should be `react-geo-${this.className.toLowerCase()}` <-- maybe this could really work.
| * default: http://epsg.io | ||
| * @type {String} | ||
| */ | ||
| epsgIoBaseUrl: PropTypes.string, |
There was a problem hiding this comment.
The propertyname could be more general like crsApiUrl.
| * CRS) and code (e.g. EPSG-code of CRS) property | ||
| * @type {Array} | ||
| */ | ||
| predefinedCrsDefinitions: PropTypes.arrayOf(PropTypes.shape({ |
| q: searchVal | ||
| }; | ||
|
|
||
| fetch(`${epsgIoBaseUrl}?${UrlUtil.objectToRequestString(queryParameters)}`) |
There was a problem hiding this comment.
I'd prefer to return the fetch result and work with the result where it is called. This keeps this function cleaner. #cohesion
return fetch(`${epsgIoBaseUrl}?${UrlUtil.objectToRequestString(queryParameters)}`)
.then(response => response.json());See below for the changes to handleSearch.
| } | ||
|
|
||
| if (!predefinedCrsDefinitions) { | ||
| this.fetchCrs(value, crsDefinitions => this.setState({ crsDefinitions, value })) ; |
There was a problem hiding this comment.
The changes to fetchCrs would lead to further changes here... (see above)
this.fetchCrs(value)
.then(this.transformResults) // to be extracted from onFetchSucess
.then(crsDefinitions => this.setState({ crsDefinitions, value })) // could be the new onFetchSucces
.catch(Logger.error(`Error while requesting in CoordinateReferenceSystemCombo: ${error}`)); // could stay in onFetchError| limit, | ||
| countrycodes, | ||
| map, | ||
| onSelect, |
There was a problem hiding this comment.
I think this is mistake… plz revert.
| * | ||
| * @class | ||
| */ | ||
| export class ProjectionUtil { |
There was a problem hiding this comment.
This util seems to be projectspecific. If we still want it in react-geo proj4CrsDefinitions and proj4CrsMappings should be removed and instead be passed to the init functions.
There was a problem hiding this comment.
Now, crs Mappings and definitions are passed to init functions of util, see 059eaa3
afd4333 to
059eaa3
Compare
KaiVolland
left a comment
There was a problem hiding this comment.
I'm sry to bother you but one more remark: 💌
| if (!predefinedCrsDefinitions) { | ||
| this.fetchCrs(value) | ||
| .then(this.transformResults) | ||
| .then(this.runViaCallback.bind(this, crsDefinitions => this.setState({ crsDefinitions, value }))) |
There was a problem hiding this comment.
I don't get the sense in the runViaCallback method.
.then(this.runViaCallback.bind(this, crsDefinitions => this.setState({ crsDefinitions, value })))…should be…
.then(crsDefinitions => this.setState({crsDefinitions})) // value is already set in line 14917775ed to
645f3d9
Compare
|
Great job. Plz merge. |
This PR introduces a Combobox where uses can choose a coordinate reference system. If no object with predefined CRS definitions (
predefinedCrsDefinitions) is given in props, the CRS combo can be uses as anAutoCompletefield querying epsg.io - API for CRS definitions.An example shows the usage both, using an array containing predefined values as well as fetching CRS defintions.
In order to handle projections / transformations,
proj4has been added as dependency. In addition, aProjectionUtilhas been added as well.Plz review.