EPANETlines.qry

  Download

More scripts: Style By Script

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# EPANETlines.qry
# CartoScript to create predefined line symbols for pipe network
# vector object with EPANET attributes.
numeric radius, dofill;	# parameters for drawing shapes
LineStyleSetCoordType(1);	# set coordinate type to mm @ current scale
LineStyleSetColor(0,0,0);
dofill = 1;
numeric startx, endx;
numeric startnode, endnode;
# Draw line for all types; pipe symbol is simply a solid line.
LineStyleDrawLine();
# Add symbol at midpoint of line for pumps and valves
if (`Link Type`.`Link Type` == "Pump")	
	{
	LineStyleSetPosition(0.5);		# move to middle of line
	radius = 2.5;
	LineStyleDrawCircle(radius, dofill);	# draw circle for pump symbol
	startnode = Vect.Line.Internal.StartNode;
	endnode = Vect.Line.Internal.EndNode;
	startx = Vect.Node.Internal[startnode].x;
	endx = Vect.Node.Internal[endnode].x;
	# draw filled rectangle to complete the pump symbol;
	# determine direction of pump symbol based on line direction;
	# rectangle should appear above the line on screen and point
	# toward the end of the line
	if (startx <= endx)
		{
		LineStyleRecordPolygon(1);
		LineStyleLineTo(90, radius);
		LineStyleLineTo(0, radius * 2);
		LineStyleLineTo(-90, radius);
		LineStyleLineTo(180, radius * 2);
		LineStyleDrawPolygon(1);
		}
	else
		{
		LineStyleRecordPolygon(1);
		LineStyleLineTo(-90, radius);
		LineStyleLineTo(0, radius * 2);
		LineStyleLineTo(90, radius);
		LineStyleLineTo(180, radius * 2);
		LineStyleDrawPolygon(1);
		}
	}
else if (`Link Type`.`Link Type` == "Valve")  
	{
	# draw pair of triangles with vertices meeting at the line midpoint
	numeric side = 4;		# set length of triangle sides
	LineStyleSetPosition(0.5);		# move pointer to middle of line
	LineStyleMoveTo(0,0);			# move the pen to the pointer position
	LineStyleRecordPolygon(1);		# record vertex locations for 1st triangle and draw
	LineStyleSideshot(1, 0, 0, -135, side, 135, side);
	LineStyleDrawPolygon(dofill);
	LineStyleRecordPolygon(1);		# record vertex location for 2nd triangle and draw
	LineStyleSideshot(1, 0, 0, 45, side, -45, side);
	LineStyleDrawPolygon(dofill);
	}