Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# hidsflt1.qry
# This is a sample script for drawing a high-angle dip-slip fault
# line (solid) with U and D marking upthrown / downthrown sides of
# the fault. The U 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 and to
# put offset symbols only at the center of each line
numeric red, green, blue;
numeric scale, lineLength, height, height8, heightMap;
string fontName$;
numeric offset, width, widthMap, charWidth;
numeric minangle, maxangle;
numeric shiftU, shiftD;
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;
# 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$);
}
# These variables control the drawing of the U and D
# text characters. HeightMap is the desired height of the
# letters in mm, assuming vector coordinates are in meters.
heightMap = 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.3;
# set final dimensions for drawing
if (DrawingLegendView == 1) { # set dimensions for LegendView based on sample size
height = 0.5 * SampleRect.GetHeight();
width = 0.25 * height;
}
else { # set dimensions for drawing elements in View
scale = scale / 1000; # conversion from meters to millimeters
height = heightMap * scale;
width = widthMap * scale;
}
charWidth = height * 0.65;
height8 = 0.8 * height;
fontName$ = "ARIALBD.TTF";
# This variable controls the offset of the U and D
# text characters on either side of the fault line.
# It is the desired offset between the line and the closest
# corner of the character. Positioning of the anchor point for
# each text label (lower left corner) will be calculated from
# this offset, the local line orientation, and the character
# height.
offset = height * 0.3;
######################## Process ###########################
# Set line color, width, and draw line
LineStyleSetColor(red,green,blue);
LineStyleSetLineWidth(width);
LineStyleDrawLine();
# Draw U and D letter symbols
LineStyleSetFont(fontName$);
LineStyleSetTextColor(red, green, blue);
LineStyleSetPosition(0.5); # move to center of line
LineStyleGetDirection(0, minangle, maxangle);
if (minangle >= 0 and minangle < 90) {
LineStyleMoveTo(180, 0.5 * (charWidth * cosd(minangle) + height8 * sind(minangle)));
LineStyleDropAnchor(1);
shiftU = offset + charWidth * sind(minangle);
shiftD = offset + height8 * cosd(minangle);
}
else if (minangle >= 90 and minangle <= 180) {
LineStyleMoveTo(180, 0.5 * height8 * sind(180 - minangle));
LineStyleMoveTo(0, 0.5 * charWidth * cosd(180 - minangle));
LineStyleDropAnchor(1);
shiftU = offset + charWidth * sind(minangle) - height8 * cosd(minangle);
shiftD = offset;
}
else if (minangle > -180 and minangle < -90) {
LineStyleMoveTo(180, 0.5 * height8 * sind(180 - minangle));
LineStyleMoveTo(0, 0.5 * charWidth * cosd(180 - minangle));
LineStyleDropAnchor(1);
shiftU = offset - height8 * cosd(minangle);
shiftD = offset - charWidth * sind(minangle);
}
else if (minangle >= -90 and minangle < 0) {
LineStyleMoveTo(180, 0.5 * (charWidth * cosd(minangle) + height8 * sind(minangle)));
LineStyleDropAnchor(1);
shiftU = offset;
shiftD = offset - charWidth * sind(minangle) + height8 * cosd(minangle);
}
LineStyleMoveTo(90, shiftU);
LineStyleDrawText("U", height, 0, 1);
LineStyleMoveToAnchor(1);
LineStyleMoveTo(-90, shiftD);
LineStyleDrawText("D", height, 0, 1);