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
Conversation
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.
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 |
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.
Is uppercase intended?
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.
Yes, this matches to notation in the object parsed by ol WMS Capabilities parser
copyright: props.wmsLayer.wmsAttribution, | ||
queryable: props.wmsLayer.queryable | ||
}; | ||
} |
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.
Do we need a componentWillReceiveProps
or is it unlikely that the AddWmsLayerEntry
will receive props after creation?
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.
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) => { |
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.
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.
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.
Added in 823294f
* parser) | ||
* @type {Array} -- required | ||
*/ | ||
wmsLayers: PropTypes.arrayOf(PropTypes.object).isRequired, |
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.
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.
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.
I replaced all "custom" objects representing a layer by an instance of OlLayerTile
.
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.
See c2889cb
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.
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>; |
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.
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', () => { |
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.
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', () => { |
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.
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'; |
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.
https?
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.
✅
--- | ||
layout: basic.html | ||
title: AddWmsPanel example | ||
description: This is a example using a AddWmsPanel. |
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.
an example ... using the AddWmsPanel
collection: Examples | ||
--- | ||
|
||
This is a example containing a AddWmsPanel |
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.
Same here
.then((data) => { | ||
const wmsCapabilitiesParser = new OlWMSCapabilities(); | ||
return wmsCapabilitiesParser.read(data); | ||
}); |
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.
How are errors handled?
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.
These are handled by the method / statement handling Promise returned by parseWmsCapabilities
. I've added an example in AddWmsLayerEntry.example.jsx
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.
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'), |
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.
is abstract == attribution?
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.
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({ |
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.
Always tiled?
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.
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', |
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.
Do we also support 1.3.0?
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.
Yes we do since the OL capabilities parser does. I changed version this in this object used for testing getLayersFromWmsCapabilties
.
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.
One other thing: adding the dist folder makes reading the diff hard. Can we agree not to do that?
7ddda0d
to
c1304c3
Compare
@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
Thx for your reviews. I'll merge as soon as all checks are green. |
Plz review.