1
0
forked from MTSR/mapserver

Compare commits

...

3 Commits

Author SHA1 Message Date
cde8ef4495
suppress shadows of invisible nodes 2024-11-12 11:42:07 +05:00
c45f002f82
tweak trains and trainlines displayed zoom (#412) 2024-11-11 19:51:31 +01:00
e1c9bdb8bd
Show layer selector only if more that one layer (#411)
Co-authored-by: Pierre-Yves Rollo <dev@pyrollo.com>
2024-11-11 19:50:45 +01:00
4 changed files with 26 additions and 7 deletions

View File

@ -36,7 +36,7 @@ const (
EXPECTED_BLOCKS_PER_FLAT_MAPBLOCK = 16 * 16
)
func IsViewBlocking(nodeName string) bool {
func (r *MapBlockRenderer) IsViewBlocking(nodeName string, param2 int) bool {
if nodeName == "" {
return false
}
@ -49,6 +49,12 @@ func IsViewBlocking(nodeName string) bool {
return false
}
c := r.colors.GetColor(nodeName, param2)
if c == nil {
return false
}
return true
}
@ -147,12 +153,14 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *types.MapBlockCoords) (*image.NRGB
if r.enableShadow {
var left, leftAbove, top, topAbove string
var left_param2, leftAbove_param2, top_param2, topAbove_param2 int
if x > 0 {
//same mapblock
left = mb.GetNodeName(x-1, y, z)
if y < 15 {
leftAbove = mb.GetNodeName(x-1, y+1, z)
leftAbove_param2 = mb.GetParam2(x-1, y+1, z)
}
} else {
@ -162,8 +170,10 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *types.MapBlockCoords) (*image.NRGB
if neighbourMapblock != nil && err == nil {
left = neighbourMapblock.GetNodeName(15, y, z)
left_param2 = neighbourMapblock.GetParam2(15, y, z)
if y < 15 {
leftAbove = neighbourMapblock.GetNodeName(15, y+1, z)
leftAbove_param2 = neighbourMapblock.GetParam2(15, y+1, z)
}
}
}
@ -173,6 +183,7 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *types.MapBlockCoords) (*image.NRGB
top = mb.GetNodeName(x, y, z+1)
if y < 15 {
topAbove = mb.GetNodeName(x, y+1, z+1)
topAbove_param2 = mb.GetParam2(x, y+1, z+1)
}
} else {
@ -182,28 +193,30 @@ func (r *MapBlockRenderer) Render(pos1, pos2 *types.MapBlockCoords) (*image.NRGB
if neighbourMapblock != nil && err == nil {
top = neighbourMapblock.GetNodeName(x, y, 0)
top_param2 = neighbourMapblock.GetParam2(x, y, 0)
if y < 15 {
topAbove = neighbourMapblock.GetNodeName(x, y+1, 0)
topAbove_param2 = neighbourMapblock.GetParam2(x, y+1, 0)
}
}
}
if IsViewBlocking(leftAbove) {
if r.IsViewBlocking(leftAbove, leftAbove_param2) {
//add shadow
c = addColorComponent(c, -10)
}
if IsViewBlocking(topAbove) {
if r.IsViewBlocking(topAbove, topAbove_param2) {
//add shadow
c = addColorComponent(c, -10)
}
if !IsViewBlocking(left) {
if !r.IsViewBlocking(left, left_param2) {
//add light
c = addColorComponent(c, 10)
}
if !IsViewBlocking(top) {
if !r.IsViewBlocking(top, top_param2) {
//add light
c = addColorComponent(c, 10)
}

View File

@ -7,9 +7,11 @@ function onchange(e){
m.route.set("/map/:layerId/:zoom/:lon/:lat", params);
}
export default {
view: function(){
// Display layer selector only if there is choice
if (LayerManager.layers.length <= 1)
return null;
const layers = LayerManager.layers.map(layer => m(
"option",

View File

@ -71,7 +71,7 @@ export default L.LayerGroup.extend({
getMaxDisplayedZoom: function(){
return 10;
return 7;
},
createMarker: function(train){

View File

@ -58,6 +58,10 @@ export default AbstractGeoJsonOverlay.extend({
}
});
},
getMaxDisplayedZoom: function(){
return 4;
},
createGeoJson: function(objects){
var self = this;