Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# ridge2.qry
# This is a sample script for drawing a double dashed line to
# represent a spreading axis (mid-ocean ridge) on a geotectonic map.
# Modified to provide scaling for LegendView 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, scale;
numeric dashMap, dashSize, widthMap, width, offset, double, doubOffset, dist;
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 controls the length of the dashes.
# DashMap is the desired size in mm, assuming vector
# coordinates are in meters:
dashMap = 3;
# This variable controls the width of the line and tick marks.
# 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.25 * 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;
}
double = 2 * dashSize;
offset = dashSize * 0.15; # offset of dashes to left and right of line
doubOffset = 2 * offset;
######################## Process ###########################
# Set line color and width
LineStyleSetColor(red, green, blue);
LineStyleSetLineWidth(width);
# Draw first double dash at start of line line
LineStyleMoveTo(90, offset); # offset pen left
LineStyleLineTo(0, dashSize); # draw dash forward
LineStyleMoveTo(-90, doubOffset); # offset pen to other side of line
LineStyleLineTo(180, dashSize); # draw dash backward, leaving pen at start of twin dash
while (LineStyleRoll(double) != 1) { # while not at end of line, roll pen forward two dash lengths (last dash + space)
dist = LineStyleGetDistanceTo(3); # distance to end of line
if (dist > dashSize) {
LineStyleMoveTo(90, offset); # draw double dash symbol
LineStyleLineTo(0, dashSize);
LineStyleMoveTo(-90, doubOffset);
LineStyleLineTo(180, dashSize);
}
}