foliatn.qry

  Download

More scripts: Style By Script

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# foliation.qry
# This is a sample script for drawing geologic point
# symbols for strike and dip of foliation, including
# the special case of vertical foliation.
# The dip value is shown as a text label, except in the
# cases of vertical foliation.
# Information required for each point includes the strike
# value (degrees) and dip value (degrees).
# Each of these values is read from a particular
# field in an attached database table.  To use the script you
# will need to edit the statements that include database references
# to conform to your table name and field names.
# Strike angle must be specified as azimuth (0 to 360 degrees
# clockwise from north).  Dip direction is defined by the
# strike azimuth using the right hand rule: of the two possible
# azimuths for a given strike line, choose the azimuth the
# strike line points toward with the dip direction on the right hand
# side of the strike line.
# Modified for legend samples August 2002
# Modified to declare all variables October 2005
# Modified to correct for angle between grid north and true north May 2006.
# Version Dec. 2007
# Requires TNTmips 2007:73 or later.
# Modified to adjust scale based on georeference map units.
numeric azStrike, dip1, red, green, blue;
numeric scale, strikeLengthMap, lineWidthMap, strikeLength, lineWidth;
numeric halfLength, triBase, triHeight, heightMap, height, halfHeight;
string fontName$, label$;
numeric offset, direction, oppStrike, dipDir, oppDip;
numeric next_x ,next_y, labelLength, shift1, shift2;
class RVC_GEOREFERENCE vGeoref;
class SR_COORDREFSYS vectCRS;
numeric northAng;
class POINT2D point;
string coordUnit$;
###################### Set Parameters ##############################
# Read strike azimuth and dip value from table.field
azStrike = Foliation.Strike - northAng;		##### change to fit your data
dip1 = Foliation.Dip;								##### change to fit your data
# This variable defines the denominator of the intended map scale.
# It is used as the basis for defining line width and symbol size.
# Example: for 1:24,000 map scale, Scale = 24000
scale = 24000;
# red, green, blue variables define the color of the symbols and label
red = 0;			green = 0;			blue = 255;
# 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;
# This variable controls 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;
# 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
	strikeLength = 0.5 * SampleRect.GetWidth();
	lineWidth = 0.08 * strikeLength;
	height = 0.7 * SampleRect.GetHeight();
	}
else {	# set dimensions for drawing elements in view
	scale = scale / 1000;	# conversion from meters to millimeters
	strikeLength = strikeLengthMap * scale;
	lineWidth = lineWidthMap * scale;
	height = heightMap * scale;
	}
halfLength = 0.5 * strikeLength;
triBase = strikeLength * 0.15;		# Half length of base of triangle
triHeight = strikeLength * 0.25;		# Height of triangle symbol
halfHeight = 0.5 * height;
fontName$ = "ARIALBD.TTF";
offset = triHeight * 1.5; 		# offset of label from symbol
####################### Process #######################
# find angle to north at the current point's map coordinates 
class TRANS2D_MAPGEN transObjToMap;
class TRANSMODEL model;
model = vGeoref.GetCalibModel();
vGeoref.GetTransParm(transObjToMap, 0, model);
point.x = Vect.Point.Internal.x;		# object coordinates of current point
point.y = Vect.Point.Internal.y;
point = transObjToMap.ConvertPoint2DFwd(point);		# convert to map coordinates
northAng = vectCRS.ComputeAngleToNorth(point);
# subtract angle to north from stored strike value for display
azStrike = azStrike - northAng;
# 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;
# Convert dip value to a string and assign it to a
# string variable for use as label
label$ = sprintf("%2d", dip1);
# Find length of label text for label positioning
LineStyleTextNextPosition(label$, height, 0, 1, next_x ,next_y, labelLength);
# Set line color, width, and end type
LineStyleSetColor(red, green, blue);		# set symbol color
LineStyleSetLineWidth(lineWidth);
LineStyleSetCapJoinType(1,1); 	# square ends of lines
# Draw strike line with center at point
# but move down first for Legend
if (DrawingSample == 1) then
	LineStyleMoveTo(-90,5);
LineStyleDropAnchor(0);
LineStyleMoveTo(direction, halfLength);
LineStyleLineTo(oppStrike, strikeLength);
LineStyleMoveToAnchor(0);
# Draw appropriate symbol for dip direction
if (dip1 == 90) {			# draw double triangle for vertical dip
	LineStyleRecordPolygon(1);
	LineStyleSideshot(0,dipDir,triHeight,direction,triBase,
		oppDip,triHeight,oppStrike,triBase);
	LineStyleDrawPolygon(1);
	}
else {					# single triangle for dip direction
	LineStyleRecordPolygon(1);
	LineStyleSideshot(0,dipDir,triHeight,direction,triBase,
		oppStrike,triBase);
	LineStyleDrawPolygon(1);
	}
# Add dip label if foliation is not vertical
if (dip1 < 90) {
	# 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) );
	# Compute label shift in dip direction to avoid overwriting symbol
	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)));
	# Shift pen position and draw label
	if (shift1 <0) {
		shift1 = abs(shift1);
		LineStyleMoveTo(direction, shift1);
		}
		else {
		LineStyleMoveTo(oppStrike, shift1);
		}
	LineStyleMoveTo(dipDir, shift2);
	LineStyleDrawText(label$, height, 0, 1);
	}