rtTransPres1c.qry

  Download

More scripts: Style By Script

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# rtTransPres1c.qry
# This is a sample script for drawing a solid line symbol for a
# right-lateral transpressional fault.  Triangle symbols are 
# drawn on the upthrown (left) side of the fault line.
# If this is the wrong side for an individual line, use
# the Spatial Data Editor to reverse its start and end points.
# Strike-slip arrows are drawn centered between the pair of
# triangles nearest to the center of the line.
# Version March 2008
# Requires TNTmips 2006:72 or later.
# Version 30 April 2008
# Improved drawing of displacement arrows so they look better for
# wider line widths.  Arrow offset determined from line width.
# Procedures defined for drawing triangles and displacement arrows.
# Special drawing instructions added for LegendView.
numeric red, green, blue;
numeric triMap, triWidth, halfTri, heightFac, height, spacing, halfSpacing, dist;
numeric arrowLengthMap, arrowSize, wingSizeFac, wingSize, angle, offsetFac, arrowOffset;
numeric triInt;
numeric arrowsDrawn;		# flag to indicate whether arrow symbol has been drawn
numeric lineCheck;
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;
# This variable sets the dimensions of the triangle symbols.
# TriMap is the desired triangle width in mm, assuming vector
# coordinates are in meters:
triMap = 3;
heightFac = 0.6;		# height of triangle as fraction of width
# This variable sets the interval between triangles as multiple of triangle width
triInt = 4;
# This variable controls the width of the lines.
# WidthMap is the desired map width in mm, assuming vector
# coordinates are in meters.
widthMap = 0.6;
# This variable sets the length of the arrows
# ArrowLengthMap is the desired arrow length in mm, assuming vector 
# coordinates are in meters:
arrowLengthMap = 6;
# This variable controls the sweep angle of the arrow in degrees
angle = 30;	 # 30 degree angle
# This variable sets the length of the side of the arrowhead as a
# fraction of the arrow length
wingSizeFac = 0.4;
# This variable controls how far from the base line to draw arrows
# as a multiple of line width
offsetFac = 2.5;
#######################  Compute Derived Values ########################
# 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
	triWidth = 0.15 * SampleRect.GetWidth();
	width = 0.1 * SampleRect.GetHeight();
	arrowSize = 0.4 * SampleRect.GetWidth();
	}
else {		# set dimensions for drawing elements in View using scale
	scale = scale / 1000;	# conversion from meters to millimeters
	triWidth = triMap * scale;
	width = widthMap * scale;
	arrowSize = arrowLengthMap * scale;
	}
# Compute final triangle dimensions
height = heightFac * triWidth;	# height of triangle as a fraction of width
halfTri = triWidth * 0.5;
# Compute spacing between triangles as a multiple of width.
spacing = triWidth * triInt;
# Distance derived from spacing to use as origin for drawing displacement arrows
halfSpacing = (spacing * 0.5) - (arrowSize * 0.5);
# Compute final dimensions of the arrow head
wingSize = wingSizeFac * arrowSize;
headBase = wingSize * sind(angle);	# length of base of half arrow head
# Compute arrow offset from the base line
arrowOffset = offsetFac * width;
# get length of line in meters and set a check location 1 "spacing" distance
# before the line center (length * 0.5) to trigger drawing displacement
# arrows midway between adjacent triangles that are closest to the line center
lineCheck = (LineStyleGetDistanceTo(3) * 0.5) - spacing;
##########################  Procedures  #######################
### procedure to draw triangle along line
proc drawTriangle ()
	{
	LineStyleDropAnchor(1);			# anchor at left corner of triangle
	LineStyleRoll(halfTri);			# roll to midpoint of triangle base
	LineStyleMoveTo(0,0);			# move pen to current line position
	LineStyleMoveTo(90, height);	# move pen to top corner of triangle
	LineStyleDropAnchor(2);			# drop anchor at top corner
	LineStyleRoll(-halfTri);		# roll line pointer back along line to left corner
	LineStyleRecordPolygon();		# set up to record vertex positions for triangle polygon
	LineStyleRollPen(triWidth);	# draw complete base of triangle (to right corner)
	LineStyleLineToAnchor(2);		# line to top corner anchor
	LineStyleLineToAnchor(1);		# line from top to left corner anchor
	LineStyleDrawPolygon(1);		# fill the polygon
	}
### procedure to draw right-lateral displacement arrows along line
proc drawArrows ()
	{
	# Draw first half-arrow forward on left side of line
	LineStyleMoveTo(90, arrowOffset);
	LineStyleDropAnchor(3);				# anchor at base of arrow shaft
	LineStyleMoveTo(0, arrowSize);	# move forward to tip of arrow
	LineStyleDropAnchor(4);				# anchor at tip of arrow
	LineStyleRecordPolygon(1);			# start recording vertices for arrow head polygon
	LineStyleLineTo(180 - angle, wingSize);	# draw arrowhead side
	LineStyleLineTo(-90, headBase);				# draw arrowhead base
	LineStyleDropAnchor(5);
	LineStyleLineToAnchor(4);
	LineStyleDrawPolygon(1);				# fill polygon
	LineStyleMoveToAnchor(5);
	LineStyleLineToAnchor(3);				# draw arrow shaft back to base
	LineStyleMoveToAnchor(4);
	# Draw other half-arrow backward on right side of line
	LineStyleMoveTo(-90, 2 * arrowOffset);	# offset to other side of line
	LineStyleDropAnchor(6);					# anchor at base of arrow
	LineStyleMoveTo(180, arrowSize);		# move backward to tip of arrow
	LineStyleDropAnchor(7);					# anchor at tip of arrow
	LineStyleRecordPolygon(1);			# start recording vertices for arrow head polygon
	LineStyleLineTo(-angle, wingSize);
	LineStyleLineTo(90, headBase);
	LineStyleDropAnchor(8);
	LineStyleLineToAnchor(7);
	LineStyleDrawPolygon(1);
	LineStyleMoveToAnchor(8);
	LineStyleLineToAnchor(6);				# draw arrow shaft back to base
	}
############################### Draw ###########################
# Set line color and width and draw solid fault line
LineStyleSetColor(red, green, blue);
LineStyleSetLineWidth(width);
LineStyleSetCapJoinType(0,0);
LineStyleDrawLine();				# draw the solid line
# initialize flag indicating if arrow symbols have been drawn yet
arrowsDrawn = 0;
# special drawing instructions for LegendView
if (DrawingLegendView)
	{
	LineStyleRoll(triWidth);
	drawTriangle();
	LineStyleRoll(triWidth);
	drawArrows();
	}
else 
	{
	# Draw triangles at specified spacing along line
	while (LineStyleRoll(spacing) != 1) 	# while not at end of line, roll spacing distance
		{
		dist = LineStyleGetDistanceTo(3);		# distance to end of line
		if (dist > triWidth) {
			drawTriangle();
	
			# draw displacement arrows when line position passes the check point
			# and set flag to indicate they have been drawn
			if (LineStyleGetPosition(1) > lineCheck && arrowsDrawn == 0)
				{
				LineStyleRoll(halfSpacing);	# move pointer along line halfway to next triangle;
				drawArrows();
				LineStyleRoll(-halfSpacing);		# roll pointer back along line to end of previous
															# triangle for next triangle iteration to preserve spacing
				arrowsDrawn = 1;						# set flag to indicate arrows have been drawn
				}
			}
		}
	}