hidsflt2.qry

  Download

More scripts: Style By Script

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# hidsflt2.qry
# This is a sample script for drawing a high-angle dip-slip fault
# line (dashed) 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
# place displacement symbols only at the center of each line
numeric red, green, blue;
numeric scale, height, height8, heightMap;
string fontName$;
numeric cum, offset, width, widthMap, charWidth, dashSize, dashMap, halfDash;
numeric lineCheck;
numeric udDrawn;		# flag to indicate whether displacement letters have been drawn yet
numeric skip, radius, dist, 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$);
	}
# This variable sets the length of the dashes
# DashMap is the desired dash length in mm, assuming vector
# coordinates are in meters:
dashMap = 3;
# This variable controls 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;
if (DrawingLegendView == 1) { # set dimensions for LegendView based on sample size
	dashSize = 0.3 * SampleRect.GetWidth();
	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
	dashSize = dashMap * scale;
	height = heightMap * scale;
	width = widthMap * scale;
	}
# 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;
halfDash = dashSize * 0.5;
charWidth = height * 0.65;		# estimated width of character
height8 = 0.8 * height;
fontName$ = "ARIALBD.TTF";
# get length of line and set check location dashSize less than
# the midpoint; to be used to trigger placement of tick mark
lineCheck = (LineStyleGetDistanceTo(3) * 0.5) - dashSize;
######################## Process ###########################
# Set line color and width and font parameters
LineStyleSetColor(red, green, blue);
LineStyleSetLineWidth(width);
LineStyleSetFont(fontName$);
LineStyleSetTextColor(red, green, blue);
# initialize flag indicating if displacement letters have been drawn yet
udDrawn = 0;
# Draw dashed fault line and U and D letter symbols
LineStyleRollPen(dashSize); # start line with dash
while (LineStyleRoll(halfDash) != 1) { # while not at end of line roll length of half dash
	# draw U/D symbols when absolute position along line (in object units)
	# passes the check location near midpoint and set flag to indicate it has been drawn
	if (LineStyleGetPosition(1) > lineCheck && udDrawn == 0 ) {
		# Draw letter symbols
		LineStyleGetDirection(0, minangle, maxangle);
		LineStyleMoveTo(0, halfDash);
		# vary letter placement depending on the line direction (angle counterclockwise from +X direction)
		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);
		LineStyleSetLineWidth(width);
		# Draw dash between letter symbols
		LineStyleRollPen(dashSize);
		udDrawn = 1;		# flag indicating letters have been drawn
		}
	else {
		LineStyleRollPen(dashSize);
		}
	}