Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# ridge1.qry
# This is a sample script for drawing a double solid line to
# represent a spreading axis (mid-ocean ridge) on a geotectonic map.
# This effect is approximated by drawing a narrower white line
# over a wider colored line. Therefore the space between the
# "two" apparent colored lines is white, not transparent.
# Modified to provide scaling for LegendView samples, August 2002;
# Modified to declare all variables, October 2005;
# Version Dec. 2007
# Requires TNTmips 2007:73 or later.
# Modified to adjust scale based on georeference map units
numeric red, green, blue, scale;
numeric widthMap, width, overlay, lineWidth;
class RVC_GEOREFERENCE vGeoref;
class SR_COORDREFSYS vectCRS;
###################### Set Parameters ##############################
# red, green, blue variables define the color of the line
red = 255; green = 0; blue = 0;
# This variable defines the denominator of the intended map scale.
# It is used as the basis for defining line width and symbol size
# and spacing.
# Example: for 1:24,000 map scale, Scale = 24000
scale = 24000;
# These variables control the width of the line symbol
# WidthMap is the overall desired width in mm, assuming vector
# coordinates are in meters.
widthMap = 1.5;
# Check if vector has geographic coordinates (units of degrees instead of meters)
# and if so adjust scale factor to draw symbols of appropriate size.
Vect.GetDefaultGeoref(vGeoref);
vectCRS = vGeoref.GetCoordRefSys();
if (vectCRS.IsProjected() <> 1) {
if (vectCRS.IsLocal() <> 1) {
scale = scale * 0.000009;
}
}
else { # CRS is projected; check coordinate units to adjust scale
# get coordinate unit from the first axis of the planar coordinate system
coordUnit$ = vectCRS.Coordsys.GetAxis(1).Unit.GetSymbol();
scale = scale * GetUnitConvDist("m", coordUnit$);
}
# set final dimensions for drawing
if (DrawingLegendView == 1) { # set dimensions for LegendView based on sample size
lineWidth = 0.5 * SampleRect.GetHeight();
}
else {
lineWidth = widthMap * scale / 1000; # conversion from meters to millimeters at scale
}
overlay = lineWidth * 0.6; # width of overlaid white line
######################## Process ###########################
# Set line color and width for wide colored line and draw
LineStyleSetColor(red, green, blue);
LineStyleSetLineWidth(lineWidth);
LineStyleSetCapJoinType(1, 1);
LineStyleDrawLine();
# Set line color and width for narrower white line and draw
LineStyleSetColor(255, 255, 255);
LineStyleSetLineWidth(overlay);
LineStyleSetPosition(0); # return to start of line
LineStyleDrawLine();
# Mask ends of lines with white rectangles
LineStyleSetPosition(0); # move to start of line
LineStyleMoveTo(0,0);
LineStyleDrawRectangle(overlay, 1.1 * lineWidth, 0, 1);
LineStyleSetPosition(1); # move to end of line
LineStyleMoveTo(0, 0);
LineStyleDrawRectangle(overlay, 1.1 * lineWidth, 0, 1);