Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# EPANETpts.qry
# CartoScript to create predefined point symbols for pipe network
# vector object with EPANET attributes.
numeric radius, dofill; # parameters for circle
numeric width, height, angle; # parameters for rectangle
LineStyleSetCoordType(1); # set coordinate type to mm @ current scale
LineStyleSetColor(0,0,0);
radius = 1.5; dofill = 1;
if (`Node Type`.`Node Type` == "Junction")
{
# draw filled circle
LineStyleDrawCircle(radius, dofill);
}
else
{
height = radius * 2.5;
width = height * 2;
angle = 0;
numeric halfwidth = width * 0.5;
numeric halfheight = height * 0.5;
if (`Node Type`.`Node Type` == "Reservoir")
{
# draw filled rectangle centered on point
LineStyleDrawRectangle(width, height, angle, dofill);
LineStyleDropAnchor(1); # anchor at point location
# draw vertical line from top left corner of rectangle
numeric linelength = height * 0.4;
LineStyleMoveTo(180, halfwidth);
LineStyleMoveTo(90, linelength); # pointer at top left corner
LineStyleLineTo(90, linelength);
# draw vertical line from top right corner of rectangle
LineStyleMoveToAnchor(1);
LineStyleMoveTo(0, halfwidth);
LineStyleMoveTo(90, linelength); # pointer at top left corner
LineStyleLineTo(90, linelength);
}
else if (`Node Type`.`Node Type` == "Tank")
{
height = radius * 3;
numeric tankbase = height * 0.75;
# Draw filled square for tank base, midpoint of top edge at point location
LineStyleDropAnchor(1); # drop anchor at point location
LineStyleMoveTo(-90, tankbase * 0.5);
LineStyleDrawRectangle(tankbase, tankbase, angle, dofill);
# Draw tanktop symbol with cutoff corners, midpoint of bottom edge at point location
numeric cutoff = height * 0.15; # size of corner cutouts
LineStyleMoveToAnchor(1); # move to point location
# Make anchor points for vertices of the tanktop polygon
LineStyleMoveTo(180, halfwidth - cutoff); # move to vertex right of lower left corner
LineStyleDropAnchor(2);
LineStyleMoveTo(180, cutoff); # move to lower left corner
LineStyleMoveTo(90, cutoff); # move up to next vertex
LineStyleDropAnchor(3);
LineStyleMoveTo(90, height - cutoff * 2); # move up to next vertex
LineStyleDropAnchor(4);
LineStyleMoveTo(90, cutoff); # move up to upper left corner
LineStyleMoveTo(0, cutoff); # move right to next vertex
LineStyleDropAnchor(5);
LineStyleMoveTo(0, width - cutoff * 2); # move right to next vertex
LineStyleDropAnchor(6);
LineStyleMoveTo(0, cutoff); # move to upper right corner
LineStyleMoveTo(-90, cutoff); # move down to next vertex
LineStyleDropAnchor(7);
LineStyleMoveTo(-90, height - cutoff * 2); # move down to cutoff vertex
LineStyleDropAnchor(8);
LineStyleMoveTo(-90, cutoff); # move to lower right corner
LineStyleMoveTo(180, cutoff); # move left to last vertex
LineStyleDropAnchor(9);
# Draw tanktop polygon
LineStyleRecordPolygon(1);
LineStyleLineToAnchor(2);
LineStyleLineToAnchor(3);
LineStyleLineToAnchor(4);
LineStyleLineToAnchor(5);
LineStyleLineToAnchor(6);
LineStyleLineToAnchor(7);
LineStyleLineToAnchor(8);
LineStyleLineToAnchor(9);
LineStyleDrawPolygon(dofill);
}
}