Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# ssfltlf2.qry
# This is a sample script to draw a right-lateral strike slip
# fault line symbol (dashed) with solid half-arrows.
# Modified for legend 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 and to
# place displacement symbols only at the center of the lines
numeric red, green, blue;
numeric scale, widthMap, width, dashMap, dashSize, halfDash, arrowLengthMap, arrowSize;
numeric flipSize, angle, headBase, offset, lineCheck;
numeric symbDrawn; # flag to indicate whether arrow symbol has been drawn
class RVC_GEOREFERENCE vGeoref;
class SR_COORDREFSYS vectCRS;
class STRING coordUnit$;
###################### 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;
# This variable controls the width of the lines.
# WidthMap is the desired map width in mm, assuming vector
# coordinates are in meters.
widthMap = 0.3;
# This variable sets the length of the dashes
# DashMap is the desired dash length in mm, assuming vector
# coordinates are in meters:
dashMap = 3;
# These variables control the length of the arrows
# ArrowLengthMap is the desired arrow length in mm, assuming vector
# coordinates are in meters:
arrowLengthMap = 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
width = 0.1 * SampleRect.GetHeight();
dashSize = 0.3 * SampleRect.GetHeight();
arrowSize = 0.5 * SampleRect.GetWidth();
}
else { # set dimensions for drawing elements in view
scale = scale / 1000; # conversion from meters to millimeters
width = widthMap * scale;
dashSize = dashMap * scale;
arrowSize = arrowLengthMap * scale;
}
halfDash = dashSize * 0.5;
# This variable controls the length of the arrow head
flipSize = 0.4 * arrowSize;
# This variable controls the sweep angle of the arrow in degrees
angle = 30; # 30 degree angle
headBase = flipSize * sind(angle);
# This variable controls how far from the base line to draw arrows
offset = 0.2 * arrowSize;
# get length of line and set check location dashSize less than
# the midpoint; to be used to trigger placement of arrow symbols
lineCheck = (LineStyleGetDistanceTo(3) * 0.5) - dashSize;
######################## Process ###########################
# Set line color, width, and draw fault line.
LineStyleSetColor(red,green,blue);
LineStyleSetLineWidth(width);
# initialize flag indicating if arrow symbols have been drawn
symbDrawn = 0;
# draw dashed fault line with arrow symbols near middle
LineStyleRollPen(dashSize); # start line with dash
while (LineStyleRoll(halfDash) != 1) { # while not at end of line roll length of half dash
# draw arrow symbol when absolute position along line (in object units)
# passes the check location near midpoint and set flag to indicate it has been drawn
if (LineStyleGetPosition(1) > lineCheck && symbDrawn == 0 ) {
# Draw dash between arrows
LineStyleRollPen(halfDash);
LineStyleDropAnchor(0); # anchor at center of dash for centering arrows
LineStyleRollPen(halfDash);
# Draw first half-arrow
LineStyleMoveToAnchor(0);
LineStyleMoveTo(90, offset);
LineStyleMoveTo(0, arrowSize * 0.5); # move forward parallel to line to center arrows
LineStyleRecordPolygon(1); # start recording polygon vertices for arrow head
LineStyleLineTo(180, arrowSize); # draw arrow shaft backward parallel to line
LineStyleDropAnchor(1);
LineStyleMoveTo(angle, flipSize); # arrowhead side
LineStyleMoveTo(-90, headBase); # arrowhead base
LineStyleDrawPolygon(1); # draw filled polygon
# draw the other half-arrow
LineStyleMoveToAnchor(1);
LineStyleMoveTo(-90, 2 * offset); # offset to other side of line
LineStyleRecordPolygon(1);
LineStyleLineTo(0, arrowSize); # draw arrow shaft forward parallel to line
LineStyleMoveTo(180 + angle, flipSize);
LineStyleMoveTo(90, headBase);
LineStyleDrawPolygon(1);
symbDrawn = 1;
}
else { # draw dash along line
LineStyleRollPen(dashSize);
}
}