Changeset 6102


Ignore:
Timestamp:
Mar 4, 2016, 7:01:39 AM (9 years ago)
Author:
ldelgass
Message:

Adding validation to addLayer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/map.tcl

    r6097 r6102  
    531531        error "Layer '$id' already exists"
    532532    }
     533    if { ![info exists _layerTypes($type)] } {
     534        error "Invalid layer type \"$type\": should be one of: [join [array names _layerTypes] {, }]"
     535    }
    533536    set parent [$_tree findchild root "layers"]
    534537    set child [$_tree insert $parent -label $id]
     
    560563            set val $params($key)
    561564            if {$val != ""} {
     565                if {$key eq "coverage" && $type ne "image"} {
     566                    error "Coverage is only valid for layers of type \"image\""
     567                }
     568                if {$key eq "content" || $key eq "priority"} {
     569                    if {$type ne "label"} {
     570                        error "content and priority are only valid in layers of type \"label\""
     571                    }
     572                }
     573                if {$key eq "opacity" && $type eq "elevation"} {
     574                    error  "opacity is not valid for layers of type \"elevation\""
     575                }
    562576                $_tree set $child $key $val
    563577            }
     
    706720                }
    707721            }
     722        }
     723        default {
     724            error "Unknown driver \"$driver\""
    708725        }
    709726    }
Note: See TracChangeset for help on using the changeset viewer.