thrsflt2.qry

  Download

More scripts: Style By Script

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# thrsflt2.qry
# This is a sample script for drawing a thrust fault line (dashed)
# with triangles marking the upthrown side of the fault.
# The triangle 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
numeric red, green, blue;
numeric scale, widthMap, width;
numeric dashMap, dashSize, halfDash, triWidth, halfTri;
numeric height, spacing, dist, cum;
class STRING coordUnit$;
class RVC_GEOREFERENCE vGeoref;
class SR_COORDREFSYS vectCRS;
###################### 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 length of the dashes
# DashMap is the desired dash length in mm, assuming vector
# coordinates are in meters:
dashMap = 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;
# 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
	dashSize = 0.2 * SampleRect.GetWidth();
	width = 0.1 * SampleRect.GetHeight();
	}
else {		# set dimensions for drawing elements in View
	scale = scale / 1000;	# conversion from meters to millimeters
	dashSize = dashMap * scale;
	width = widthMap * scale;
	}
halfDash = dashSize * 0.5;
triWidth = dashSize;
halfTri = triWidth * 0.5;
height = 0.8 * triWidth;	# height of triangle
# This variable controls spacing between triangles.
spacing = triWidth * 4;
######################## Process ###########################
# Set line color and width
LineStyleSetColor(red, green, blue);
LineStyleSetLineWidth(width);
# Initialize variable to control placement of triangles
cum = 0;
# Draw triangles
while (LineStyleRoll(halfDash) != 1) {	# while not at end of line roll halfDash
	dist = LineStyleGetDistanceTo(3);		# distance to end of line
	cum = cum + dashSize;
	if (dist > triWidth && cum >= spacing) {
		LineStyleDropAnchor(1);
		LineStyleRoll(halfTri);
		LineStyleMoveTo(0,0);
		LineStyleMoveTo(90, height);
		LineStyleDropAnchor(2);
		LineStyleRoll(-halfTri);
		LineStyleRecordPolygon();
		LineStyleRollPen(triWidth);
		LineStyleMoveTo(0,0);
		LineStyleLineToAnchor(2);
		LineStyleLineToAnchor(1);
		LineStyleDrawPolygon(1);
		cum = 0;
		}
	else {
		LineStyleRollPen(dashSize);
		cum = cum + dashSize;
		}
	}