synclnAsym2.qry

  Download

More scripts: Style By Script

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# synclnAsym2.qry
# This is a sample script for drawing the geological line symbol
# for an asymmetric syncline (dashed, no arrow stems). Fold symbols
# are placed at the center of each line.  The steeper limb of the
# fold is assumed to be on the left side of the fold line; use the
# Spatial Editor to reverse line directions if necessary. 
# Version March 2008
# Requires TNTmips 2006:72 or later.
numeric red, green, blue, scale, dashMap, dashSize, halfDash;
numeric widthMap, width, arrowSize, arrowLengthMap;
numeric halfSize, wingSize, angle, stemSize, dist;
numeric arrowDrawn;		# 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 = 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
# and spacing.
# Example: for 1:24,000 map scale, Scale = 24000
scale = 24000;
# This variable sets the length of the dashes
# DashMap is the desired dash length in mm, assuming vector
# coordinates are in meters:
dashMap = 2;
# This variable controls the width of the lines.
# WidthMap is the desired map width in mm, assuming vector
# coordinates are in meters.
widthMap = 0.75;
# This variable controls the size of the arrows
# ArrowLengthMap is the desired arrowhead length in mm, assuming vector
# coordinates are in meters:
arrowLengthMap = 3;
# This variable controls the sweep angle of the arrow in degrees
angle = 80;			 # 80 degree angle
#######################  Compute Derived Values ########################
# Check if vector has geographic coordinates (units of degrees instead of meters)
# and if so automatically 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
	dashSize = 0.25 * SampleRect.GetWidth();
	width = 0.1 * SampleRect.GetHeight();
	arrowSize = 0.4 * SampleRect.GetHeight();
	}
else {	# set dimensions for drawing elements in view
	scale = scale / 1000;	# conversion from meters to millimeters
	dashSize = dashMap * scale;
	width = widthMap * scale;
	arrowSize = arrowLengthMap * scale;
	}
halfDash = dashSize * 0.5;
# This variable controls the length of the arrow head
wingSize = arrowSize / cosd(angle * 0.5);
# 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;
############################ Draw ###############################
# Set line color, width, and draw fold line.
LineStyleSetColor(red,green,blue);
LineStyleSetLineWidth(width);
# initialize flag indicating if arrow symbol has been drawn yet
arrowDrawn = 0;
# Draw dashed fold line and arrow symbols
LineStyleRollPen(dashSize); # start line with dash
while (LineStyleRoll(halfDash) != 1)  # while not at end of line roll length of half dash
	{
	# draw arrow symbol when position passes middle of line and set
	# flag to indicate it has been drawn
	if ( LineStyleGetPosition(1) > lineCheck && arrowDrawn == 0 ) 
		{
		# Draw dash with anchor point in center
		LineStyleRollPen(halfDash);
		LineStyleDropAnchor(1);
		LineStyleRollPen(halfDash);
		LineStyleSetLineWidth(0);			# set 0 width for drawing arrow heads
		# Draw arrow heads
		LineStyleMoveToAnchor(1);
		LineStyleMoveTo(90, arrowSize);
		LineStyleDrawArrow(-90, arrowSize, wingSize, angle, 1);	# arrowhead on left
		LineStyleMoveToAnchor(1);
		LineStyleMoveTo(-90, arrowSize);
		LineStyleDrawArrow(90, arrowSize, wingSize, angle, 1);	# arrowhead on right
		LineStyleMoveToAnchor(1);
		LineStyleMoveTo(90, arrowSize * 2);
		LineStyleDrawArrow(-90, arrowSize, wingSize, angle, 1);	# draw extra arrowhead on left
		LineStyleSetLineWidth(width);			# reset line width after drawing arrows
		arrowDrawn = 1;
		}
		else 	LineStyleRollPen(dashSize);
	}