Skip to content
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

Introduce AddWmsPanel #267

Merged
merged 8 commits into from Dec 7, 2017
Merged

Introduce AddWmsPanel #267

merged 8 commits into from Dec 7, 2017

Conversation

ahennr
Copy link
Member

@ahennr ahennr commented Dec 5, 2017

  • Container
  • AddWmsPanel -- Panel containing a (checkable) list of AddWmsLayerEntry instances
  • AddWmsLayerEntry -- Visual representation of layer entry parsed from capabilities document.
  • adds an example which parses capabilities document of OWS terrestris

Plz review.

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 work.

I added some notes regarding a CapabilitiesUtil. Please have a look at it.

The other notes are noneblocking.

wmsAttribution: PropTypes.string,
queryable: PropTypes.boolean,
Abstract: PropTypes.string,
Title: 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.

Is uppercase intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this matches to notation in the object parsed by ol WMS Capabilities parser

copyright: props.wmsLayer.wmsAttribution,
queryable: props.wmsLayer.queryable
};
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a componentWillReceiveProps or is it unlikely that the AddWmsLayerEntry will receive props after creation?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMHO it's very unlikely that the AddWmsLayerEntry will receive updated props after creation.

const wmsGetFeatureInfoConfig = get(caps, 'Capability.Request.GetFeatureInfo');

return get(caps,'Capability.Layer.Layer').map(layer => Object.assign(layer, {wmsVersion, wmsAttribution, wmsGetMapConfig, wmsGetFeatureInfoConfig}) );
}).then((wmsLayers) => {
Copy link
Member

Choose a reason for hiding this comment

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

Would be very nice if you could extract this method into small functions in something like a CapabilitiesUtil. We discussed this some days ago.
I think it will be very usefull in many applications.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in 823294f

* parser)
* @type {Array} -- required
*/
wmsLayers: PropTypes.arrayOf(PropTypes.object).isRequired,
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 it would be better to work with instances of OlLayer here. The parser could be in the CapabilitiesUtil described above. I don't like the idea of working with diffrent "layerlike" objects across the framework.
You could then implement an "real" addToMap method wich would call the property method onLayerAddToMap after add. Ofcourse the map should be a required prop.

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 replaced all "custom" objects representing a layer by an instance of OlLayerTile.

Copy link
Member Author

Choose a reason for hiding this comment

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

See c2889cb

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.

Nice work, @ahenn. I have added a couple of remarks, you decide what to do with them. Support for 1.3.0 is essential, IMO.

const abstract = wmsLayer.get('abstract');
const abstractTextSpan = abstract ?
<span>{`${title} - ${abstract}:`}</span> :
<span>{`${title}`}</span>;
Copy link
Member

Choose a reason for hiding this comment

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

Can we have this configurable? with a template or a metjod or ...? What do you think?

testLayer.set('queryable', false);
});

it('doesnt add queryable icon if prop wmsLayer has queryable set to false', () => {
Copy link
Member

Choose a reason for hiding this comment

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

missing apostrophe in doesnt: doesn't

expect(icons.getElement().props.className).toContain('fa-copyright');
});

it('doesnt add copyright icon if prop wmsLayer no has filled attribution', () => {
Copy link
Member

Choose a reason for hiding this comment

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

See above

//

// Please note: CORS headers must be set on server providing capabilities document. Otherwise proxy needed.
const WMS_CAPABILITIES_URL = 'http://ows.terrestris.de/osm/service?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities';
Copy link
Member

Choose a reason for hiding this comment

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

https?

Copy link
Member Author

Choose a reason for hiding this comment

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

---
layout: basic.html
title: AddWmsPanel example
description: This is a example using a AddWmsPanel.
Copy link
Member

Choose a reason for hiding this comment

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

an example ... using the AddWmsPanel

collection: Examples
---

This is a example containing a AddWmsPanel
Copy link
Member

Choose a reason for hiding this comment

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

Same here

.then((data) => {
const wmsCapabilitiesParser = new OlWMSCapabilities();
return wmsCapabilitiesParser.read(data);
});
Copy link
Member

Choose a reason for hiding this comment

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

How are errors handled?

Copy link
Member Author

Choose a reason for hiding this comment

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

These are handled by the method / statement handling Promise returned by parseWmsCapabilities. I've added an example in AddWmsLayerEntry.example.jsx

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 adding a seperate error handler to every promise we use would bei even saver, but we don't do it anywhere. Lets open an issue therefore.

return layersInCapabilities.map((layerObj) => new OlLayerTile({
opacity: 1,
title: get(layerObj, 'Title'),
abstract: get(layerObj, 'Attribution'),
Copy link
Member

Choose a reason for hiding this comment

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

is abstract == attribution?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. Replaced by Abstract. For each layer, the abstract property in service/layer metadata must be provided properly in order to be shown here.

abstract: get(layerObj, 'Attribution'),
getFeatureInfoUrl: getFeatureInfoUrl,
queryable: !!getFeatureInfoUrl,
source: new OlSourceTileWms({
Copy link
Member

Choose a reason for hiding this comment

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

Always tiled?

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've changed this to OlSourceImageWMS. IMHO we should return tiled layers in a further method which parses capabilities of WMTS services.


const layerTitle = 'OpenStreetMap WMS - by terrestris';
const capabilitiesObj = {
version: '1.1.0',
Copy link
Member

Choose a reason for hiding this comment

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

Do we also support 1.3.0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes we do since the OL capabilities parser does. I changed version this in this object used for testing getLayersFromWmsCapabilties.

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.

One other thing: adding the dist folder makes reading the diff hard. Can we agree not to do that?

@ahennr ahennr force-pushed the add-wms-grid branch 2 times, most recently from 7ddda0d to c1304c3 Compare December 6, 2017 12:47
@ahennr
Copy link
Member Author

ahennr commented Dec 6, 2017

@KaiVolland: Do you think this is ok now?

* Container
* AddWmsPanel -- Panel containing a (checkable) list of AddWmsLayerEntry instances
* AddWmsLayerEntry -- Visual representation of layer entry parsed from capabilities document.
* adds an example which parses capabilities document of OWS terrestris
* adds template function for textual representation of layer
* use https and WMS v1.3.0
* enhance description of examples
@ahennr
Copy link
Member Author

ahennr commented Dec 7, 2017

Thx for your reviews. I'll merge as soon as all checks are green.

@ahennr ahennr merged commit 7f4ec0a into terrestris:master Dec 7, 2017
@ahennr ahennr deleted the add-wms-grid branch December 7, 2017 11:07
@KaiVolland KaiVolland mentioned this pull request Jan 25, 2018
56 tasks
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.

None yet

3 participants