Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
#raster labeller.sml
#written by: David Friberg
#date: 27 July 2004
#
#Purpose:
# Use this SML Layer to add labels to all raster layers
# in a group. Label used is the name of the raster.
#
#Requirements:
# TNTmips 6.9
# Must be used as an SML layer in the Display process.
#
#To use:
# Add all raster layers to be labeled.
# Add this SML layer.
class GRE_LAYER curLayer = ThisLayer.Group.FirstLayer;
ThisLayer.Name = "Labels";
DrawTextSetColors("red","red");
SetLineWidth(4);
DrawTextSetHeightPixels(13);
while(curLayer != 0) {
if(curLayer.Type == "Raster") {
class RASTER curRast;
DispGetRasterFromLayer(curRast, curLayer);
class GEOREF curGeoref;
curGeoref = GetLastUsedGeorefObject(curRast);
class POINT2D labelPos = ObjectToMap(curRast, 0, 15, curGeoref);
class TRANSPARM trans;
trans.InputCoordRefSys = curGeoref.CoordRefSys;
trans.OutputProjection = ThisLayer.Projection;
labelPos = trans.ConvertPoint2DFwd(labelPos);
MoveTo(labelPos.x, labelPos.y);
DrawTextSimple(sprintf("%s", curLayer.Name));
}
curLayer = curLayer.NextLayer;
}