Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# thrsflt1.qry
# This is a sample script for drawing a thrust fault line (solid)
# with triangles marking the upthrown side of the fault.
# The triangle symbol is drawn on the left side of the line.
# If this is the wrong side for an individual line, use
# the Spatial Data Editor to reverse its start and end points.
# 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
# Version Sep 2013
# Modified to
# - draw triangles with center of base at drawing location
# - draw legend samples with a single triangle at the center of the sample line
# - use a user-defined procedure to draw triangles
numeric red, green, blue;
numeric scale, widthMap, width;
numeric triMap, triWidth, halfTri, height, spacing, dist;
class STRING coordUnit$;
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;
# This variable sets the dimensions of the triangle symbols.
# TriMap is the desired triangle width in mm, assuming vector
# coordinates are in meters:
triMap = 3;
# This variable controls the width of the lines.
# WidthMap is the desired map width in mm, assuming vector
# coordinates are in meters.
widthMap = 0.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
triWidth = 0.15 * SampleRect.GetWidth();
width = 0.1 * SampleRect.GetHeight();
}
else { # set dimensions for drawing elements in View using scale
scale = scale / 1000; # conversion from meters to millimeters
triWidth = triMap * scale;
width = widthMap * scale;
}
halfTri = triWidth * 0.5;
height = 0.8 * triWidth; # height of triangle
# This variable controls spacing between triangles.
spacing = triWidth * 4;
# user-defined procedure to draw a triangle with center of base at designated drawing point
proc drawTriangle()
{
LineStyleMoveTo(0,0); # set drawing point at current line location
LineStyleMoveTo(90, height); # move to top of triangle
LineStyleDropAnchor(1);
LineStyleRoll(-halfTri); # roll line pointer back to left corner of triangle
LineStyleDropAnchor(2);
LineStyleRecordPolygon(); # start recording vertices for polygon
LineStyleRoll(triWidth); # roll line pointer to right corner of triangle
LineStyleMoveTo(0,0); # move drawing point to current line location at right corner
LineStyleLineToAnchor(1); # line to top of triangle
LineStyleLineToAnchor(2); # line from top to lower left corner
LineStyleDrawPolygon(1); # draw filled polygon
}
######################## Process ###########################
# Set line color and width and draw solid fault line
LineStyleSetColor(red, green, blue);
LineStyleSetLineWidth(width);
LineStyleSetCapJoinType(0,0); # set to draw rounded ends for lines and line segments
LineStyleDrawLine();
# Draw triangles
if (DrawingSample == 1) # for sample in sidebar and on map, draw single triangle symbol at center of line
{
LineStyleSetPosition(0.5); # move to center of line
drawTriangle(); # call user-defined procedure to draw triangle
}
else # for map lines, draw triangles at designated spacing along each line
{
while (LineStyleRoll(spacing) != 1) { # while not at end of line roll spacing distance
dist = LineStyleGetDistanceTo(3); # distance to end of line
if (dist > triWidth)
{
drawTriangle(); # call user-defined procedure to draw triangle
}
}
}