Skip to content

Comments

Coordinate reference system combo#244

Merged
ahennr merged 9 commits intoterrestris:masterfrom
ahennr:coordinate-reference-system-combo
Nov 29, 2017
Merged

Coordinate reference system combo#244
ahennr merged 9 commits intoterrestris:masterfrom
ahennr:coordinate-reference-system-combo

Conversation

@ahennr
Copy link
Member

@ahennr ahennr commented Nov 28, 2017

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 an AutoComplete field 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, proj4 has been added as dependency. In addition, aProjectionUtil has been added as well.

Plz review.

@ahennr ahennr mentioned this pull request Nov 28, 2017
56 tasks
@ahennr ahennr force-pushed the coordinate-reference-system-combo branch from 43f51d2 to afd4333 Compare November 28, 2017 16:44
Copy link
Member

@marcjansen marcjansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a space

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 77710ba

import { Logger, UrlUtil } from '../../index.js';

/**
* Class representating a combo to choose coordinate projection system via a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

representing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 77710ba

@@ -0,0 +1,3 @@
.react-geo-crs-combo {
width: 200px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have a fixed width in the library?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed less file in 77710ba. Style can be passed as prop now.

limit,
countrycodes,
map,
onSelect,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh? is this ok here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is mistake… plz revert.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where these variables are used in render function?!

Copy link
Member

@KaiVolland KaiVolland Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted in 0e724b2

*/
static proj4CrsDefinitions() {
return {
'EPSG:25832': '+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not in in the proj database? Or am I misunderstanding stuff here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no version needed, ol is enough

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎩

Copy link
Member

@KaiVolland KaiVolland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The propertyname could be more general like crsApiUrl.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in 3cc756f

* CRS) and code (e.g. EPSG-code of CRS) property
* @type {Array}
*/
predefinedCrsDefinitions: PropTypes.arrayOf(PropTypes.shape({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

q: searchVal
};

fetch(`${epsgIoBaseUrl}?${UrlUtil.objectToRequestString(queryParameters)}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in 3cc756f

}

if (!predefinedCrsDefinitions) {
this.fetchCrs(value, crsDefinitions => this.setState({ crsDefinitions, value })) ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in 3cc756f

limit,
countrycodes,
map,
onSelect,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is mistake… plz revert.

*
* @class
*/
export class ProjectionUtil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, crs Mappings and definitions are passed to init functions of util, see 059eaa3

@ahennr ahennr force-pushed the coordinate-reference-system-combo branch from afd4333 to 059eaa3 Compare November 29, 2017 10:12
Copy link
Member

@KaiVolland KaiVolland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 })))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 149

Copy link
Member Author

@ahennr ahennr Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in 645f3d9

@ahennr ahennr force-pushed the coordinate-reference-system-combo branch from 17775ed to 645f3d9 Compare November 29, 2017 12:31
@KaiVolland
Copy link
Member

Great job. Plz merge.

@ahennr ahennr merged commit 190c852 into terrestris:master Nov 29, 2017
@ahennr ahennr deleted the coordinate-reference-system-combo branch November 29, 2017 13:14
hblitza pushed a commit that referenced this pull request Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants