forked from keplergl/kepler.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support WMS layer #24
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f6e2d37
feat: add wms layer
06ce460
feat: wms layer fix
30488f6
Merge remote-tracking branch 'origin/v2.5.5-master' into wms-layer
32cab77
feat: improvement wms layer
8263c42
small fixes wms layer
0461aa5
refactor: tile layer & update wms url
88cd5be
fix: wms loading
bc472f1
ci: bump version
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 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 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 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
@imec-int:registry=https://npm.pkg.github.com |
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -35,5 +35,6 @@ export const LAYER_TYPES = keyMirror({ | |
trip: null, | ||
s2: null, | ||
tile: null, | ||
wms: null, | ||
graph: null | ||
}); |
This file contains 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2022 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
import React, {Component} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Base from 'components/common/icons/base'; | ||
|
||
class TileLayerIcon extends Component { | ||
static propTypes = { | ||
/** Set the height of the icon, ex. '16px' */ | ||
height: PropTypes.string, | ||
colors: PropTypes.arrayOf(PropTypes.string) | ||
}; | ||
|
||
static defaultProps = { | ||
height: '16px', | ||
predefinedClassName: 'tile-layer-icon', | ||
totalColor: 1 | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Base {...this.props}> | ||
<path | ||
d="M512 288c0 35.35-21.49 64-48 64c-32.43 0-31.72-32-55.64-32C394.9 320 384 330.9 384 344.4V480c0 17.67-14.33 32-32 32h-71.64C266.9 512 256 501.1 256 487.6C256 463.1 288 464.4 288 432c0-26.51-28.65-48-64-48s-64 21.49-64 48c0 32.43 32 31.72 32 55.64C192 501.1 181.1 512 167.6 512H32c-17.67 0-32-14.33-32-32v-135.6C0 330.9 10.91 320 24.36 320C48.05 320 47.6 352 80 352C106.5 352 128 323.3 128 288S106.5 223.1 80 223.1c-32.43 0-31.72 32-55.64 32C10.91 255.1 0 245.1 0 231.6v-71.64c0-17.67 14.33-31.1 32-31.1h135.6C181.1 127.1 192 117.1 192 103.6c0-23.69-32-23.24-32-55.64c0-26.51 28.65-47.1 64-47.1s64 21.49 64 47.1c0 32.43-32 31.72-32 55.64c0 13.45 10.91 24.36 24.36 24.36H352c17.67 0 32 14.33 32 31.1v71.64c0 13.45 10.91 24.36 24.36 24.36c23.69 0 23.24-32 55.64-32C490.5 223.1 512 252.7 512 288z" | ||
className="cr2" | ||
/> | ||
</Base> | ||
); | ||
} | ||
} | ||
|
||
export default TileLayerIcon; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import Layer from '../base-layer'; | ||
import {TileLayer as DeckGLTileLayer} from '@deck.gl/geo-layers'; | ||
import {BitmapLayer} from '@deck.gl/layers'; | ||
import WMSLayerIcon from './wms-layer-icon'; | ||
import {load} from '@loaders.gl/core'; | ||
|
||
export const WMSLayerVisConfigs = { | ||
opacity: 'opacity', | ||
thickness: 'thickness', | ||
colorRange: 'colorRange', | ||
sizeRange: 'strokeWidthRange', | ||
targetColor: 'targetColor' | ||
}; | ||
|
||
export default class WMSLayer extends Layer { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.registerVisConfig(WMSLayerVisConfigs); | ||
} | ||
|
||
get type() { | ||
return 'wms'; | ||
} | ||
|
||
get layerIcon() { | ||
return WMSLayerIcon; | ||
} | ||
|
||
formatLayerData(datasets, oldLayerData) { | ||
if (this.config.dataId === null) { | ||
return {}; | ||
} | ||
const {dataContainer} = datasets[this.config.dataId]; | ||
// extract URL from row 0 column 0 | ||
const newUrl = dataContainer.valueAt(0, 0); | ||
const styles = dataContainer.valueAt(0, 2); | ||
const crs = dataContainer.valueAt(0, 1); | ||
const oldUrl = oldLayerData ? oldLayerData.url : undefined; | ||
let url = oldUrl; | ||
if (oldUrl !== newUrl) { | ||
url = newUrl; | ||
} | ||
const accessors = this.getAttributeAccessors({ | ||
dataAccessor: dc => d => d, | ||
dataContainer | ||
}); | ||
return { | ||
url, | ||
styles, | ||
crs, | ||
...accessors | ||
}; | ||
} | ||
|
||
shouldRenderLayer() { | ||
return typeof this.type === 'string' && this.config.isVisible && this.hasAllColumns(); | ||
} | ||
|
||
renderLayer(opts) { | ||
const {data} = opts; | ||
const {url, crs, styles} = data; | ||
|
||
// Create new deck.gl WMS Layer with Bitmap sublayers | ||
return [ | ||
new DeckGLTileLayer({ | ||
data: url, | ||
minZoom: 0, | ||
maxZoom: 19, | ||
tileSize: 512, | ||
|
||
getTileData(tile) { | ||
const wmsUrl = url; | ||
const {bbox} = tile; | ||
const {east, north, south, west} = bbox; | ||
const urlQueryStringParams = { | ||
bbox: [west, south, east, north].join(','), | ||
format: 'image/png', | ||
height: 512, | ||
request: 'GetMap', | ||
service: 'WMS', | ||
srs: crs ? crs : 'EPSG:4326', | ||
styles: styles ? styles : '', | ||
version: '1.1.1', | ||
width: 512, | ||
transparent: 'true' | ||
}; | ||
const urlQueryString = Object.keys(urlQueryStringParams) | ||
.map(key => `${key}=${urlQueryStringParams[key]}`) | ||
.join('&'); | ||
|
||
return load(`${wmsUrl}&${urlQueryString}`); | ||
}, | ||
|
||
renderSubLayers: props => { | ||
const { | ||
bbox: {west, south, east, north} | ||
} = props.tile; | ||
|
||
return new BitmapLayer(props, { | ||
data: null, | ||
image: props.data, | ||
bounds: [west, south, east, north] | ||
}); | ||
}, | ||
onTileError: () => { | ||
return; | ||
} | ||
}) | ||
]; | ||
} | ||
} |
This file contains 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
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 method is not creating any layers once the map is loaded. It works once you select the layer type :/
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.
Fixed!
config: { version: 'v1' }
was required and added initial state for wms in types