public function PlotTrace():Polygon
{
firingPosX = parseInt(fpFirePoint.toString().substr(0,6));
firingPosY = parseInt(fpFirePoint.toString().substr(6,6));
//if a min range has been set, set up the slip bearings to change the plotting of the trace
if (minRange > 0)
{
//plot a slipped trace
}
if (hefLength > 0 && stdTraceLength == 0)
{
//plot a hef trace
}
else
{
myTrace = new Polygon();
myTrace.addRing(createFFAFiringPoint());
}
return myTrace;
}
myTrace com.esri.ags.geometry.Polygon (@106b9b79) [inherited] defaultSymbol com.esri.ags.symbol.SimpleFillSymbol (@10599d29) extent <exception thrown by getter> rings Array (@abb0ee9) [0] Array (@1070d901) [0] flash.geom.Point (@10580629) length 717464.8361703869 x 382415 [0x5d5cf] y 607054 [0x9434e] [1] flash.geom.Point (@1055ce71) length 717308.4317941585 x 382020.11968464445 y 607117.7929192365 [2] flash.geom.Point (@1065e629) length 717425.8993229957 x 381281.23903104366 y 607720.7728738267 [3] flash.geom.Point (@10782fb1) length 717649.1139426031 x 381252.6866894122 y 608002.1707483521 [4] flash.geom.Point (@10782fd9) length 718632.3713444908 x 383550.0679880897 y 607718.5454554912 [5] flash.geom.Point (@10782241) length 717728.7598126691 x 382810.00481118547 y 607117.0174510777 [6] flash.geom.Point (@10580629) length 717464.8361703869 x 382415 [0x5d5cf] y 607054 [0x9434e] length 7 type "esriGeometryPolygon"
private function PlotTrace(piTraceType:String):void
{
switch (piTraceType)
{
case ("FirePoint"):
{ if (vwHefStd.selectedChild.id=="StdTemplate")
{
var FPClass:FiringPointTrace = new FiringPointTrace(parseInt(txtFPCoord.text), parseInt(txtFPLeft.text), parseInt(txtFPRight.text), parseInt(txtStdLength.text),parseInt(txtStdWidth.text), parseInt(txtStdBSD.text), chkHT.selected,0,0,0,0,parseInt(txtStdAimErr.text), parseInt(txtFPMinRange.text))
var polyGeometry:Geometry = new Geometry() as Polygon;
polyGeometry = FPClass.PlotTrace();
graphic = new Graphic(polyGeometry,sfs_dashedoutline);
gfxTemplates.add(graphic);
}
//else do hef template
{
}
}
//case 2
//case 3
}
}
private function createFFAFiringPoint():Array
{
var point:MapPoint;
var i:int;
var common:CommonRoutines = new CommonRoutines();
var spatRef:SpatialReference = new SpatialReference(27700);
try
{
//plot a standard trace
//first of all adjust the left and right of arc figures to cater for aim error and run through the routine that ensures bearings
//are kept within the range of 6400mils (360 degs).
arcLeft = common.MODO((arcLeft - aimError), 6400);
arcRight = common.MODO((arcRight + aimError), 6400);
//calculate points on polygon to generate trace shape (there are always 6 points excluding firing position on standard ffa trace)
//we can't do a simple loop because although the method of calculating the point is always the same, the values we pass to the method
//vary depending on which point of the polygon we need to calculate:
//plot origin and push to array
point = new MapPoint(firingPosX, firingPosY, spatRef);
arrPoints = new Array;
arrPoints.push(point);
//Point 1
point = common.CalculatePoint((stdTraceWidth * -1), common.Distance1(stdTraceWidth), arcLeft, firingPosX, firingPosY);
[etc.....]
return arrPoints;
public function CalculatePoint(piWidth:Number, piDistance:Number, piArc:Number, firingPointX:Number, firingPointY:Number):MapPoint
{
var direction:Number;
var targetBearing:Number;
var distance:Number;
var xValue:Number;
var yValue:Number;
var spatRef:SpatialReference = new SpatialReference(27700);
try
{
//Flex uses radians to calculate angles, user entered details in mils.
direction = milsToRads(piArc);
//make adjustments for targetBearing in different quadrants of an x/y grid.
targetBearing = adjustAngleForQuadrant(piWidth, piDistance) + direction;
//basic trig: the hypotonuse length = sqrt of the sum of the squares of the other 2 sides
distance = Math.sqrt((piWidth * piWidth) + (piDistance * piDistance))
//create the co-ordinates for the newly calculated point
xValue = Math.sin(targetBearing) * distance + firingPointX;
yValue = Math.cos(targetBearing) * distance + firingPointY;
//nb some extra code may need to be added later if we start to deal with non Uk maps to determine which
//spatial reference to use
myPoint = new MapPoint(xValue,yValue, spatRef);
[etc]
return myPoint;
var spatRef:SpatialReference = new SpatialReference(27700); var newTrace:Polygon = new Polygon(); newTrace = FPClass.PlotTrace() newTrace.spatialReference = spatRef; graphic = new Graphic(newTrace, s_lineSymbol); gfxTemplates.add(graphic);
<esri:SimpleLineSymbol id="s_lineSymbol" color="0xFF000" width="3" alpha="0.5"/>