Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# BeddingQry
# Point CartoScript to draw standard geologic strike/dip
# symbols for outcrop bedding attitudes.
# Script from Using CartoScripts tutorial.
###### Read attributes
# Read strike azimuth and dip value from table.field
azStrike = Bedding.Strike; dip1 = Bedding.Dip;
# Check logical field for overturned bedding. Variable is set
# to 1 if Yes, 0 if No
overturned = Bedding.Overturned;
# Convert dip value to a string and assign it
# to a string variable for use as label
label$ = sprintf("%2d", dip1)
###### General parameters
# 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.
scale = 5000;
###### Symbol parameters
# 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;
strikeLength = strikeLengthMap * scale / 1000;
halfLength = 0.5 * strikeLength;
tickLength = halfLength / 3;
doubTick = tickLength * 2;
lineWidth = lineWidthMap * scale / 1000;
###### Label parameters
# These variables control 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;
height = heightMap * scale / 1000;
fontName$ = "ARIALBD.TTF";
offset = 0.5 * tickLength; # offset of label from symbol
###### Process
# 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;
# 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
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 (overturned == 1) { # 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) {
# Find length of label text for label positioning;
LineStyleTextNextPosition(label$, height, 0, 1, next_x ,next_y, labelLength);
# 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 (overturned == 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);
}
}