Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# anticln4.qry
# This is a sample script for drawing the geological line symbol
# for an overturned anticline (dashed). Arrow symbols are drawn
# with 0 line width, and arrow stems and other cross elements
# are drawn with width designated for the trace line.
# Symbol is drawn with dip arrows on the right side of the
# line. Use the Spatial Data Editor to reverse the start and
# end of individual lines to achieve correct symbol orientation.
# 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 and to
# put arrow symbols only at the approximate center of each line.
numeric red, green, blue, scale, dashMap, dashSize, halfDash;
numeric widthMap, width, arrowSize, arrowLengthMap;
numeric flipSize, angle, stemSize, radius;
numeric lineCheck;
numeric arrowDrawn; # flag to indicate whether arrow symbol has been drawn
class RVC_GEOREFERENCE vGeoref;
class SR_COORDREFSYS vectCRS;
###################### Set Parameters ##############################
# red, green, blue variables define the color of the line
red = 0; 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 sets the length of the dashes
# DashMap is the desired dash length in mm, assuming vector
# coordinates are in meters:
dashMap = 2;
# This variable controls the width of the lines.
# WidthMap is the desired map width in mm, assuming vector
# coordinates are in meters.
widthMap = 0.25;
# These variables control the length of the arrows
# ArrowLengthMap is the desired arrow length in mm, assuming vector
# coordinates are in meters:
arrowLengthMap = 4;
# 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
dashSize = 0.25 * SampleRect.GetWidth();
width = 0.1 * SampleRect.GetHeight();
arrowSize = 0.5 * SampleRect.GetHeight();
}
else { # set dimensions for drawing elements in View
scale = scale / 1000; # conversion from meters to millimeters
dashSize = dashMap * scale;
width = widthMap * scale;
arrowSize = arrowLengthMap * scale;
}
halfDash = dashSize * 0.5;
radius = dashSize * 0.75; # radius of arc based on half-dash spaces between dashes
# This variable controls the length of the arrow head
flipSize = 0.5 * arrowSize;
# This variable controls the sweep angle of the arrow in degrees
angle = 35; # 35 degree angle
# This variable sets the length of the lines redrawn over the
# arrow stems
stemSize = arrowSize - flipSize * cosd(angle);
# get length of line and set check location dashSize less than
# the midpoint; to be used to trigger placement of tick mark
lineCheck = (LineStyleGetDistanceTo(3) * 0.5) - dashSize;
######################## Process ###########################
# Set line color, width
LineStyleSetColor(red,green,blue);
LineStyleSetLineWidth(width);
# initialize flag indicating if arrow symbol has been drawn yet
arrowDrawn = 0;
# Draw dashed fold line and arrow symbols
LineStyleRollPen(dashSize); # start line with dash
while (LineStyleRoll(halfDash) != 1) { # while not at end of line roll half length of 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 && arrowDrawn == 0 ) {
# Draw dashed line through arrow symbol
LineStyleRollPen(halfDash);
LineStyleDropAnchor(1);
LineStyleRollPen(halfDash);
LineStyleRoll(halfDash);
LineStyleRollPen(halfDash);
LineStyleDropAnchor(2);
LineStyleRollPen(halfDash);
# Draw lines for composite arrow symbol
LineStyleMoveToAnchor(1);
LineStyleLineTo(-90, stemSize);
LineStyleMoveToAnchor(1);
LineStyleDrawArc(0, radius, radius, radius, -180, -180, 0);
LineStyleMoveToAnchor(2);
LineStyleLineTo(-90, stemSize);
LineStyleMoveToAnchor(2);
# Draw arrow symbols
LineStyleSetLineWidth(0);
LineStyleDrawArrow(-90, arrowSize, flipSize, angle, 1);
LineStyleMoveToAnchor(1);
LineStyleDrawArrow(-90, arrowSize, flipSize, angle, 1);
LineStyleSetLineWidth(width);
arrowDrawn = 1;
}
else {
LineStyleRollPen(dashSize);
}
}