Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# bedding.qry
# This is a sample script for drawing geologic point
# symbols for strike and dip of bedding, including
# special cases of horizontal, vertical, overturned bedding.
# The dip value is shown as a text label, except in the
# cases of horizontal and vertical bedding.
# Information required for each point includes the strike
# value (degrees), dip value (degrees), and whether the bed is
# overturned. 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.
# Strike angle must be specified as azimuth (0 to 360 degrees
# clockwise from north). Dip direction is defined by the
# strike azimuth using the right hand rule: of the two possible
# azimuths for a given strike line, choose the azimuth the
# strike line points toward with the dip direction on the right hand
# side of the strike line. (For overturned beds, substitute facing
# direction [stratigraphic top] for dip direction in the rule).
# The script assumes that the database field for overturned
# bedding is a Logical field, with Yes indicating overturned bed
# and No (default value) indicating upright bedding.
# Modified for 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 azStrike, dip1, overturned1, red, green, blue;
numeric scale, strikeLengthMap, lineWidthMap, strikeLength, lineWidth;
numeric halfLength, tickLength, doubTick, heightMap, height, offset;
string fontName$, label$;
numeric direction, oppStrike, dipDir, oppDip;
numeric next_x ,next_y, labelLength, shift1, shift2;
class RVC_GEOREFERENCE vGeoref;
class SR_COORDREFSYS vectCRS;
numeric northAng;
class POINT2D point;
string coordUnit$;
##################### Set Parameters ##############################
# Read strike azimuth and dip value from table.field
azStrike = Bedding.Strike - northAng; ####### change to fit your data
dip1 = Bedding.Dip; ####### change to fit your data
# Check logical field for overturned bedding. Variable is set to
# 1 if Yes, 0 if No
overturned1 = Bedding.Overturned;
# red, green, blue variables define the color of the symbols and label
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.
# Example: for 1:24,000 map scale, Scale = 24000
scale = 24000;
# These variables define the dimensions and line widths of the
# symbol. StrikeLengthMap is the desired length of the symbol
# strike line in mm, assuming vector coordinates are in meters.
# LineWidthMap is the desired line width in mm.
strikeLengthMap = 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
strikeLength = 0.5 * SampleRect.GetWidth();
lineWidth = 0.08 * strikeLength;
height = 0.7 * SampleRect.GetHeight();
}
else { # set dimensions for drawing elements in view
scale = scale / 1000; # conversion from meters to millimeters
strikeLength = strikeLengthMap * scale;
lineWidth = lineWidthMap * scale;
height = heightMap * scale;
}
halfLength = 0.5 * strikeLength;
tickLength = halfLength / 3;
doubTick = tickLength * 2;
fontName$ = "ARIALBD.TTF";
offset = 0.5 * tickLength; # 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 angle to north from stored strike value for display
azStrike = azStrike - northAng;
# Convert strike azimuth to internal coordinate system.
direction = -(azStrike - 90);
if (direction < 0) then
direction = direction + 360;
oppStrike = direction -180;
dipDir = direction - 90;
oppDip = dipDir - 180;
# Convert dip value to a string and assign it
# to a string variable for use as label
label$ = sprintf("%2d", dip1);
# 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 symbol
# Special symbol for horizontal bedding (cross in circle)
if (dip1 == 0){
LineStyleDropAnchor(0);
LineStyleDrawCircle(halfLength);
LineStyleMoveTo(90, halfLength);
LineStyleLineTo(-90, strikeLength);
LineStyleMoveToAnchor(0);
LineStyleMoveTo(0, halfLength);
LineStyleLineTo(180, strikeLength);
}
else {
# For nonzero dip, draw strike line with center at point
# but move down first for Legend sample
if (DrawingSample == 1) then
LineStyleMoveTo(-90, 1);
LineStyleDropAnchor(0);
LineStyleMoveTo(direction, halfLength);
LineStyleLineTo(oppStrike, strikeLength);
LineStyleMoveToAnchor(0);
# Draw appropriate symbol for dip direction
if (dip1 == 90) { # crossbar for vertical bed
LineStyleMoveTo(dipDir, tickLength);
LineStyleLineTo(oppDip, doubTick);
}
else {
if (Bedding.Overturned) { # dip symbol for overturned beds
LineStyleDrawArc(0, 0, tickLength, tickLength, direction, -180, 0);
LineStyleMoveTo(direction, tickLength);
LineStyleLineTo(oppDip, doubTick);
}
else { # dip direction tick mark
LineStyleLineTo(dipDir, tickLength);
}
}
}
########## Add dip label if bedding is not horizontal or vertical
if (dip1 > 0 and dip1 < 90) {
# Set font name and text color
LineStyleSetFont(fontName$);
LineStyleSetTextColor(red, green, blue);
# Compute label shift parallel to strike to center label
shift1 = 0.5 * ( labelLength * cosd(direction) + height * sind(direction) );
if (shift1 <0) {
shift1 = abs(shift1);
LineStyleMoveTo(direction, shift1);
}
else {
LineStyleMoveTo(oppStrike, shift1);
}
# Compute label shift in dip direction to avoid overwriting symbol
if (overturned1 == 1) {
if (direction >= 0 and direction < 90) then
shift2 = offset + 0.8 * labelLength * cosd(dipDir);
else if (direction >= 90 and direction < 180) then
shift2 = offset + 0.8 * (labelLength * cosd(dipDir) + height * sind(dipDir));
else if (direction >= 180 and direction < 270) then
shift2 = offset + 0.8 * height * sind(dipDir);
else if (direction >= 270 and direction <= 360) then
shift2 = offset;
LineStyleMoveTo(direction + 90, shift2);
LineStyleDrawText(label$, height, 0, 1);
}
else { # place label for upright bedding
if (direction >= 0 and direction < 90) then
shift2 = offset - 0.8 * height * sind(dipDir);
else if (direction >= 90 and direction < 180) then
shift2 = offset;
else if (direction >= 180 and direction < 270) then
shift2 = offset - 0.8 * labelLength * cosd(dipDir);
else if (direction >= 270 and direction <= 360) then
shift2 = offset - 0.8 * ((labelLength * cosd(dipDir)) + (height * sind(dipDir)));
LineStyleMoveTo(dipDir, shift2);
LineStyleDrawText(label$, height, 0, 1);
}
}