synQryLgn.qry

  Download

More scripts: Style By Script

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# SynQryLgn
# This is a sample CartoScript for drawing the geological line
# symbols for a syncline with different scaling for map
# and for the LegendView sample.
# Script from the Using CartoScripts tutorial.
###################### Set Parameters ##############################
# Read a logical database field (Yes/No) to check if syncline is 
# overturned.  Numeric variable is set to 1 if yes, 0 if no
Overturned1 = Syncline.Overturned; 
# red, green, blue variables define the color of the line
red = 228;	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 = 5000;
# These variables place the arrow symbols at the midpoint of each line.
LineLength = LineStyleGetDistanceTo(3);
Spacing = LineLength / 2;
# These variables control the width of the lines.
# WidthMap is the desired map width in mm, assuming vector
# coordinates are in meters.
WidthMap = 0.4;
Width = WidthMap * Scale / 1000;
# These variables control the length of the arrows
# ArrowLengthMap is the desired arrow length in mm, assuming vector 
# coordinates are in meters:
if (DrawingLegendView == 1) {
	ArrowSize = 0.5 * ( SampleRect.GetHeight() );
}
else {
	ArrowLengthMap = 4;
	ArrowSize = ArrowLengthMap * Scale / 1000;
}
HalfSize = ArrowSize * 0.5
# This variable controls the length of the arrow head
FlipSize = 0.5 * ArrowSize;
# This variable controls the sweep angle of the arrow in degrees
Angle = 35 # 35 degree angle;
# This variable sets the length of the lines redrawn over the
# arrow stems
StemSize = ArrowSize - FlipSize * cosd(Angle);
######################## Process ###########################
# Set line color, width, and draw fold line.
LineStyleSetColor(red,green,blue);
LineStyleSetLineWidth(Width);
LineStyleDrawLine();
# Draw arrow symbols
while (LineStyleRoll(Spacing) != 1) {
	Dist = LineStyleGetDistanceTo(3);
	if (Dist >= Spacing) {
		if ( Overturned1 == 1 ) {
			# Draw arrows with 0 line width
			LineStyleMoveTo(180, HalfSize); # back up half the width of symbol
			LineStyleDropAnchor(1);
			LineStyleSetLineWidth(0);
			LineStyleMoveTo(-90, ArrowSize);
			LineStyleDropAnchor(2);
			LineStyleDrawArrow(90, ArrowSize, FlipSize, Angle, 1);
			LineStyleMoveTo(0, ArrowSize);
			LineStyleMoveTo(-90, ArrowSize);
			LineStyleDropAnchor(3);
			LineStyleDrawArrow(90, ArrowSize, FlipSize, Angle, 1);
			# Draw arrow stems and arc with linewidth = Width
			LineStyleSetLineWidth(Width);
			LineStyleMoveToAnchor(2);
			LineStyleLineTo(90, StemSize);
			LineStyleMoveToAnchor(1);
			LineStyleDrawArc(0, HalfSize, HalfSize, HalfSize, -180, -180, 0);
			LineStyleMoveToAnchor(3);
			LineStyleLineTo(90, StemSize);
			}
		else {
			# Draw arrows with 0 line width
			LineStyleDropAnchor(1);
			LineStyleSetLineWidth(0);
			LineStyleMoveTo(90, ArrowSize);
			LineStyleDropAnchor(2);
			LineStyleDrawArrow(-90, ArrowSize, FlipSize, Angle, 1);
			LineStyleMoveToAnchor(1);
			LineStyleMoveTo(-90, ArrowSize);
			LineStyleDropAnchor(3);
			LineStyleDrawArrow(90, ArrowSize, FlipSize, Angle, 1);
			# Redraw arrow stems
			LineStyleMoveToAnchor(2);
			LineStyleSetLineWidth(Width);
			LineStyleLineTo(-90, StemSize);
			LineStyleMoveToAnchor(3);
			LineStyleLineTo(90, StemSize);
			}
		}
	}