take into account style min/max scale in legend (#4601)

the mapscript and template code calling these updated functions
are hardcoded to do scale-independant legend rendering to remain
backwards compatible.