Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# crenaxis.qry
# This is a sample script for drawing geologic point symbols
# for trend and plunge of crenulation fold axes (arrow with
# double fold symbol).
# Information required for each point includes the trend
# azimuth (degrees) and plunge value (degrees).
# Each of these values is read from a particular
# field in an attached database table. To use the script you
# will need to edit the statements that include database references
# to conform to your table name and field names.
# Trend angle must be specified as azimuth (0 to 360 degrees
# clockwise from north) of the down-plunge direction.
# Modified for drawing legend samples August 2002.
# Modified to declare all variables October 2005.
# Modified to correct for angle between grid north and true north May 2006.
# Version Dec. 2007
# Requires TNTmips 2007:73 or later.
# Modified to adjust scale based on georeference map units.
numeric azTrend, plunge1, red, green, blue;
numeric scale, arrowLengthMap, lineWidthMap, arrowLength, lineWidth;
numeric headSize, angle, stemLength, halfStem, tickSize, radius, diam;
numeric heightMap, height, halfHeight, offset;
string fontName$, label$;
numeric direction, oppTrend;
numeric next_x ,next_y, labelLength, shift1, shift2;
class RVC_GEOREFERENCE vGeoref;
class SR_COORDREFSYS vectCRS;
numeric northAng;
###################### Set Parameters ##############################
# Read trend azimuth and plunge value from table.field
azTrend = CrenAxis.Trend; ###### change to fit your data
plunge1 = CrenAxis.Plunge; ###### change to fit your data
# This variable defines the denominator of the intended map scale.
# It is used as the basis for defining line width and symbol size.
# Example: for 1:24,000 map scale, Scale = 24000
scale = 24000;
# red, green, blue variables define the color of the symbols and label
red = 0; green = 0; blue = 0;
# These variables define the dimensions and line widths of the
# symbol. ArrowLengthMap is the desired length of the symbol
# in mm, assuming vector coordinates are in meters.
# LineWidthMap is the desired line width in mm.
arrowLengthMap = 6;
lineWidthMap = 0.3;
# This variable controls the drawing of the label text string.
# HeightMap is the desired height of the letters in mm,
# assuming vector coordinates are in meters.
heightMap = 2.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
arrowLength = 0.5 * SampleRect.GetWidth();
lineWidth = 0.1 * arrowLength;
height = 0.7 * SampleRect.GetHeight();
}
else { # set dimensions for drawing elements in view
scale = scale / 1000; # conversion from meters to millimeters
arrowLength = arrowLengthMap * scale;
lineWidth = lineWidthMap * scale;
height = heightMap * scale;
}
# This variable controls the length of the arrow head
headSize = 0.3 * arrowLength;
# 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
stemLength = arrowLength - headSize * cosd(angle);
halfStem = stemLength * 0.5;
# These variables set the size of the double fold symbol
tickSize = stemLength * 0.2;
radius = stemLength * 0.12;
diam = radius * 2;
halfHeight = 0.5 * height;
fontName$ = "ARIALBD.TTF";
offset = arrowLength * 0.1; # offset of label from symbol
######################## Process ###########################
# find angle to north at the current point's map coordinates
class TRANS2D_MAPGEN transObjToMap;
class TRANSMODEL model;
model = vGeoref.GetCalibModel();
vGeoref.GetTransParm(transObjToMap, 0, model);
point.x = Vect.Point.Internal.x; # object coordinates of current point
point.y = Vect.Point.Internal.y;
point = transObjToMap.ConvertPoint2DFwd(point); # convert to map coordinates
northAng = vectCRS.ComputeAngleToNorth(point);
# subtract the angle to north from the stored trend value
azTrend = azTrend - northAng;
# Convert trend azimuth to internal coordinate system.
direction = -(azTrend - 90);
if (direction < 0)
direction = direction + 360;
oppTrend = direction - 180;
# Convert plunge value to a string and assign it to a
# string variable for use as label
label$ = sprintf("%2d", plunge1);
# Find length of label text for label positioning
LineStyleTextNextPosition(label$, height, 0, 1, next_x ,next_y, labelLength);
# Set line color, width, and end type
LineStyleSetColor(red, green, blue); # set symbol color
LineStyleSetLineWidth(lineWidth);
LineStyleSetCapJoinType(1,1); # square ends of lines
# Draw arrow with zero line width, tip of stem at data point
LineStyleDropAnchor(0); # anchor at data point
LineStyleSetLineWidth(0);
LineStyleDrawArrow(direction, arrowLength, headSize, angle, 1);
LineStyleDropAnchor(1); # anchor at tip of arrow
# Draw arrow stem with desired line width
LineStyleMoveToAnchor(0);
LineStyleSetLineWidth(lineWidth);
LineStyleLineTo(direction, stemLength);
# Draw double fold symbol
LineStyleMoveTo(oppTrend, halfStem);
LineStyleDropAnchor(2); # anchor at center of stem
LineStyleDrawArc(direction, radius, radius, radius, oppTrend, -180, 0);
LineStyleDrawArc(oppTrend, radius, radius, radius, oppTrend, 180, 0);
LineStyleMoveTo(direction, diam);
LineStyleLineTo(direction - 90, tickSize);
LineStyleMoveToAnchor(2);
LineStyleMoveTo(oppTrend, diam);
LineStyleLineTo(direction + 90, tickSize);
LineStyleMoveToAnchor(1); # reposition pen at arrow tip
########## Add plunge label
# Set font name and text color
LineStyleSetFont(fontName$);
LineStyleSetTextColor(red, green, blue);
# Compute label shift perpendicular to trend to center label
shift1 = 0.5 * ( height * cosd(direction) - labelLength * sind(direction) );
# Compute label shift in trend direction to avoid overwriting symbol
if (direction >= 0 and direction < 90)
shift2 = offset;
if (direction >= 90 and direction < 180)
shift2 = offset - 0.8 * labelLength * cosd(direction);
if (direction >= 180 and direction < 270)
shift2 = offset - 0.8 * ( labelLength * cosd(direction) + height * sind(direction));
if (direction >= 270 and direction <= 360)
shift2 = offset - 0.8 * height * sind(direction);
# Shift pen position and draw label
if (shift1 <0) {
shift1 = abs(shift1);
LineStyleMoveTo(direction + 90, shift1);
}
else {
LineStyleMoveTo(direction - 90, shift1); }
LineStyleMoveTo(direction, shift2);
LineStyleDrawText(label$, height, 0, 1);