public void SetPoint(WalkPoint point)
        {
            CurrentPoint = point;

            _setting = true;

            if (TtUtils.PointHasValue(CurrentPoint))
            {
                txtAcc.Text = CurrentPoint.ManualAccuracy.ToString();

                lblWalkName.Text = CurrentPoint.GroupName;
            }
            else
            {
                txtAcc.Text = "";
                lblWalkName.Text = "";
            }

            _setting = false;
        }
        public void Init(TtPolygon poly, DataAccessLayer dal, TtMetaData meta, int currIndex)
        {
            this.Icon = Properties.Resources.Map;
            TtUtils.ShowWaitCursor();
            Values.GPSA.BurstReceived += GPSA_BurstReceived;
            Values.GPSA.InvalidStringFound += GPSA_InvalidStringFound;
            Values.GPSA.ComTimeout += GPSA_ComTimeout;
            Values.GPSA.GpsStarted += GPSA_GpsStarted;
            Values.GPSA.GpsEnded += GPSA_GpsEnded;
            Values.GPSA.GpsError += GPSA_GpsError;

            Polygon = poly;
            DAL = dal;
            _currmeta = meta;

            logging = false;
            this.DialogResult = DialogResult.Cancel;
            OnBound = true;

            lblPoly.Text = "Poly: " + Polygon.Name;

            logged = 0;
            _locked = true;

            _sound = true;
            #if (PocketPC || WindowsCE || Mobile)
            player = new SoundPlayer(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ring.wav"));
            #else
            player = new SoundPlayer(Properties.Resources.Ring);
            #endif

            #if !(PocketPC || WindowsCE || Mobile)
            picBox.SizeMode = PictureBoxSizeMode.StretchImage;
            picBox.Image = Properties.Resources.Walking_Transparent;
            #else
            animation = new AnimationCtrl();
            animation.Location = new Point((this.Width - Properties.Resources.walking1.Width / 5) - 10, 0);
            this.Controls.Add(animation);
            animation.BringToFront();
            animation.LoadImage(new List<Bitmap>() { Properties.Resources.walking1, Properties.Resources.walking2,
            Properties.Resources.walking3 ,Properties.Resources.walking4, Properties.Resources.walking5,
            Properties.Resources.walking6, Properties.Resources.walking7,},
            Properties.Resources.walking1.Width / 5, Properties.Resources.walking1.Height / 5, 75, -1);
            #endif
            CurrentPoint = null;

            List<TtPoint> points = DAL.GetPointsInPolygon(Polygon);
            _index = currIndex;

            if (_index > 0)
            {
                TtPoint lPoint = (points[_index - 1]);
                LastPoint = new WalkPoint();
                LastPoint.PID = lPoint.PID;
                LastPoint.Index = lPoint.Index;
            }

            cboDOP.SelectedIndex = Values.Settings.DeviceOptions.Filter_WALK_DOP_TYPE;
            cboFixType.SelectedIndex = Values.Settings.DeviceOptions.Filter_WALK_FixType;

            #if (PocketPC || WindowsCE || Mobile)
            btnDOP.Text = cboDOP.Text;
            btnFixType.Text = cboFixType.Text;
            #endif

            txtDOP.Text = Values.Settings.DeviceOptions.Filter_WALK_DOP_VALUE.ToString();

            txtAcc.Text = Values.Settings.DeviceOptions.Filter_Accuracy.ToString();

            txtFreq.Text = Values.Settings.DeviceOptions.Filter_Frequency.ToString();

            txtIncrement.Text = Values.Settings.DeviceOptions.WalkIncrement.ToString();
            _increment = Values.Settings.DeviceOptions.WalkIncrement;

            gpsInfoAdvCtrl.SetZone(_currmeta.Zone);
            gpsInfoAdvCtrl.StartControl();

            TtUtils.HideWaitCursor();
        }
        private bool SetupPoint()
        {
            CurrentPoint = new WalkPoint();

            try
            {
                if (LastPoint == null)
                    CurrentPoint.PID = PointNaming.NameFirstPoint(Polygon);
                else
                    CurrentPoint.PID = PointNaming.NamePoint(LastPoint, Values.Settings.DeviceOptions.WalkIncrement);

                _index++;
                CurrentPoint.PolyCN = Polygon.CN;
                CurrentPoint.PolyName = Polygon.Name;
                CurrentPoint.OnBnd = OnBound;
                CurrentPoint.Index = _index;
                CurrentPoint.GroupCN = WalkGroup.CN;
                CurrentPoint.GroupName = WalkGroup.Name;
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "WalkFormLogic:SetupPoint", ex.StackTrace);
                return false;
            }

            this.GuiInvoke(() =>
                {
                    txtPID.Text = CurrentPoint.PID.ToString();
                });

            return true;
        }
        private void CreateWalkPoint(NmeaBurst b)
        {
            try
            {
                if (WalkGroup == null)
                {
                    WalkGroup = new TtGroup();
                    WalkGroup.SetGroupName(String.Format("Walk_{0}", WalkGroup.CN.Truncate(8)), null);

                    DAL.InsertGroup(WalkGroup);
                }

                if (CurrentPoint != null)
                {
                    DAL.InsertPoint(CurrentPoint);
                    DAL.SaveNmeaBurst(CurrentNmea, CurrentPoint.CN);

                    LastPoint = CurrentPoint;

                    btnOk.GuiInvoke(() => { btnOk.Enabled = true; });
                }
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "WalkFormLogic:CreateWalkPoint-Save Current Point", ex.StackTrace);
            }

            LastNmea = CurrentNmea;
            CurrentNmea = b;

            if (SetupPoint())
            {
                try
                {
                    CurrentPoint.UnAdjX = b._X;
                    CurrentPoint.UnAdjY = b._Y;
                    CurrentPoint.UnAdjZ = b._Z;
                    //CurrentPoint.X = b._X;
                    //CurrentPoint.Y = b._Y;
                    //CurrentPoint.Z = b._Z;
                    CurrentPoint.Time = DateTime.Now;
                    CurrentPoint.MetaDefCN = _currmeta.CN;
                    CurrentPoint.RMSEr = Values.Settings.DeviceOptions.MIN_POINT_ACCURACY;

                    b._Used = true;

                    if (_sound)
                    {
                        try
                        {
                            player.Play();
                        }
                        catch
                        {

                        }
                    }

                    new Thread(()=>
                        {
                            if(TtUtils.PointHasValue(CurrentPoint) || !Values.Settings.ProjectOptions.DropZero)
                                DrawSavePointIcon();
                            else
                                CurrentPoint = LastPoint;
                        }).Start();
                }
                catch (Exception ex)
                {
                    TtUtils.WriteError(ex.Message, "WalkFormLogic:CreateWalkPoint", ex.StackTrace);
                }
            }
        }
Exemplo n.º 5
0
        public bool ImportTt(List<string> polys, bool useNmea)
        {
            if (!_MetaOpen)
                return false;

            _Points = new List<TtPoint>();
            _Polygons = new Dictionary<string, TtPolygon>();
            _IdToCN = new Dictionary<string, string>();
            pidToCN = new Dictionary<int, string>();
            _PolyIndexes = new Dictionary<string, int>();

            Dictionary<string, TtMetaData> metaData = new Dictionary<string, TtMetaData>();
            Dictionary<string, string> metaLinkToId = new Dictionary<string, string>();
            Dictionary<string, int> qndLinks = new Dictionary<string, int>();
            List<int> pointWNMEA = new List<int>();

            Dictionary<int, List<TwoTrails.GpsAccess.NmeaBurst>> nmeas = new Dictionary<int, List<TwoTrails.GpsAccess.NmeaBurst>>();

            int viewId = metaKitViews[polydata];
            int rowCount;
            int polyCount = (int)dal.GetPolyCount();
            polyCount++;

            string tmpStr, tmpStr2;
            int tmpInt;
            double tmpDouble;

            try
            {
                #region Polygons
                rowCount = metaKit.GetRowCount(viewId);
                for (int i = 0; i < rowCount; i++)
                {
                    _Poly = new TtPolygon();

                    tmpStr = metaKit.GetString(viewId, i, 0);

                    if (!tmpStr.IsEmpty())
                    {
                        tmpStr2 = null;
                        _Poly.Name = tmpStr;
                    }
                    else
                    {
                        tmpStr2 = tmpStr;
                        _Poly.Name = String.Format("Poly {0}", polyCount);
                    }

                    _Poly.PointStartIndex = 1000 * polyCount + 10;

                    if (!polys.Contains(tmpStr))
                        continue;
                    polyCount++;

                    tmpStr = metaKit.GetString(viewId, i, 1);
                    if (!tmpStr.IsEmpty())
                        _Poly.Description = tmpStr;

                    tmpStr = metaKit.GetString(viewId, i, 10);
                    if (!tmpStr.IsEmpty())
                    {
                        if(_Poly.Description.IsEmpty())
                            _Poly.Description = tmpStr;
                        else
                            String.Format("{0}, Comment: {1}", _Poly.Description, tmpStr);
                    }

                    tmpDouble = metaKit.GetDouble(viewId, i, 11);
                    if(tmpDouble > 0)
                        _Poly.PolyAccu = tmpDouble;

                    _Polygons.Add(_Poly.CN, _Poly);
                    _IdToCN.Add(_Poly.Name, _Poly.CN);
                    _PolyIndexes.Add(_Poly.CN, 0);

                    if (tmpStr2 != null)
                    {
                        _IdToCN.Add(tmpStr2, _Poly.CN);
                    }
                }
                #endregion

                #region Metadata
                viewId = metaKitViews[metadata];

                TtMetaData newMeta;

                for (int i = 0; i < metaKit.GetRowCount(viewId); i++)
                {
                    newMeta = new TtMetaData();
                    newMeta.CN = Guid.NewGuid().ToString();

                    tmpInt = metaKit.GetInt(viewId, i, 2);
                    if (tmpInt > -1)
                        newMeta.Zone = tmpInt;

                    newMeta.Receiver = metaKit.GetString(viewId, i, 3);
                    newMeta.Laser = metaKit.GetString(viewId, i, 4);
                    newMeta.Compass = metaKit.GetString(viewId, i, 5);
                    newMeta.Crew = metaKit.GetString(viewId, i, 9);
                    newMeta.Comment = metaKit.GetString(viewId, i, 17);

                    tmpStr = metaKit.GetString(viewId, i, 10);
                    if(tmpStr.IsEmpty())
                    {
                        newMeta.Name = String.Format("Metadata {0}", metaData.Count + 1);
                        metaLinkToId.Add(newMeta.Name, newMeta.CN);
                        if (!metaLinkToId.ContainsKey(tmpStr))
                            metaLinkToId.Add(tmpStr, newMeta.CN);
                    }
                    else
                    {
                        newMeta.Name = tmpStr;
                        metaLinkToId.Add(tmpStr, newMeta.CN);
                    }

                    tmpStr = metaKit.GetString(viewId, i, 11);
                    tmpStr = tmpStr.ToLower();
                    if (tmpStr.Contains("meter"))
                        newMeta.uomDistance = UomDistance.Meters;
                    else if (tmpStr.Contains("chain"))
                        newMeta.uomDistance = UomDistance.Chains;
                    else if (tmpStr.Contains("tenth"))
                        newMeta.uomDistance = UomDistance.FeetTenths;
                    else if (tmpStr.Contains("inch"))
                        newMeta.uomDistance = UomDistance.FeetInches;
                    else if (tmpStr.Contains("yard"))
                        newMeta.uomDistance = UomDistance.Yards;

                    tmpStr = metaKit.GetString(viewId, i, 15);
                    tmpStr = tmpStr.ToLower();
                    if (tmpStr.Contains("feet"))
                        newMeta.uomElevation = UomElevation.Feet;
                    else if (tmpStr.Contains("meter"))
                        newMeta.uomElevation = UomElevation.Meters;

                    tmpStr = metaKit.GetString(viewId, i, 16);
                    tmpStr = tmpStr.ToLower();
                    if (tmpStr.Contains("deg"))
                        newMeta.uomSlope = UomSlope.Degrees;
                    else if (tmpStr.Contains("per"))
                        newMeta.uomSlope = UomSlope.Percent;

                    metaData.Add(newMeta.CN, newMeta);
                }
                #endregion

                #region Points
                TtPoint point;

                GpsPoint gps;
                SideShotPoint ssp;

                viewId = metaKitViews[ptdata];
                rowCount = metaKit.GetRowCount(viewId);
                for (int i = 0; i < rowCount; i++)
                {
                    tmpStr = metaKit.GetString(viewId, i, 0);

                    if (tmpStr.IsEmpty() || !polys.Contains(tmpStr))
                        continue;

                    point = new TtPoint();

                    _Poly = _Polygons[_IdToCN[tmpStr]];
                    point.PolyCN = _Poly.CN;
                    point.PolyName = _Poly.Name;

                    point.GroupCN = Values.MainGroup.CN;
                    point.GroupName = Values.MainGroup.Name;

                    tmpInt = metaKit.GetInt(viewId, i, 1);
                    if (tmpInt > 0)
                        point.PID = tmpInt;
                    else
                    {
                        if (_Points.Count > 1)
                            PointNaming.NamePoint(_Points[_Points.Count - 1], _Poly);
                        else
                            PointNaming.NameFirstPoint(_Poly);
                    }

                    pidToCN.Add(point.PID, point.CN);

                    tmpStr = metaKit.GetString(viewId, i, 2);
                    if (tmpStr.IsEmpty() || !tmpStr.IsBool())
                        point.OnBnd = false;
                    else
                        point.OnBnd = tmpStr.ToBool();

                    OpType op;

                    tmpStr = metaKit.GetString(viewId, i, 3);
                    if (tmpStr.IsEmpty())
                        continue;
                    else
                    {
                        try
                        {
                            op = (OpType)Enum.Parse(typeof(OpType), tmpStr, true);
                        }
                        catch
                        {
                            continue;
                        }
                    }

                    switch (op)
                    {
                        case OpType.GPS:
                        case OpType.Walk:
                        case OpType.WayPoint:
                            {
                                gps = new GpsPoint(point);

                                gps.UnAdjX = metaKit.GetDouble(viewId, i, 4);
                                gps.UnAdjY = metaKit.GetDouble(viewId, i, 5);
                                gps.UnAdjZ = metaKit.GetDouble(viewId, i, 6);
                                //gps.UnAdjX = gps.X;
                                //gps.UnAdjY = gps.Y;
                                //gps.UnAdjZ = gps.Z;

                                tmpDouble = metaKit.GetDouble(viewId, i, 32);
                                if (tmpDouble != 0)
                                    gps.ManualAccuracy = tmpDouble;

                                tmpDouble = metaKit.GetDouble(viewId, i, 33);
                                if (tmpDouble != 0)
                                    gps.RMSEr = tmpDouble;

                                if(metaKit.GetInt(viewId, i, 55) > 0)
                                    pointWNMEA.Add(point.PID);

                                if (op == OpType.Walk)
                                    point = new WalkPoint(gps);
                                else if (op == OpType.WayPoint)
                                    point = new WayPoint(gps);
                                else
                                    point = gps;
                            }
                            break;
                        case OpType.SideShot:
                        case OpType.Traverse:
                            {
                                ssp = new SideShotPoint(point);

                                tmpDouble = metaKit.GetDouble(viewId, i, 22);
                                if (tmpDouble != -1)
                                    ssp.ForwardAz = tmpDouble;

                                tmpDouble = metaKit.GetDouble(viewId, i, 23);
                                if (tmpDouble != -1)
                                    ssp.BackwardAz = tmpDouble;

                                ssp.SlopeDistance = metaKit.GetDouble(viewId, i, 24);
                                ssp.SlopeAngle = metaKit.GetDouble(viewId, i, 25);

                                if (op == OpType.Traverse)
                                    point = new TravPoint(ssp);
                                else
                                    point = ssp;
                            }
                            break;
                        case OpType.Quondam:
                            {
                                point = new QuondamPoint(point);

                                tmpStr = metaKit.GetString(viewId, i, 29);
                                try
                                {
                                    if (!tmpStr.IsEmpty())
                                    {
                                        tmpStr2 = tmpStr.Split(',')[1].Trim();
                                        qndLinks.Add(point.CN, tmpStr2.ToInteger());
                                    }
                                }
                                catch
                                {
                                    //bad quondam
                                }
                            }
                            break;
                        default:
                            continue;
                    }

                    tmpStr = metaKit.GetString(viewId, i, 56);
                    if (tmpStr.IsEmpty() || !metadata.Contains(tmpStr))
                        point.MetaDefCN = _Meta.CN;
                    else
                    {
                        point.MetaDefCN = metaData[tmpStr].CN;
                    }

                    tmpStr = metaKit.GetString(viewId, i, 38);
                    if (!tmpStr.IsEmpty())
                        point.Comment = tmpStr;

                    point.Index = _PolyIndexes[point.PolyCN];
                    _PolyIndexes[point.PolyCN]++;

                    point.Time = DateTime.Now;

                    _Points.Add(point);
                }

                for (int i = 0; i < _Points.Count; i++)
                {
                    if (_Points[i].op == OpType.Quondam)
                    {
                        if(qndLinks.ContainsKey(_Points[i].CN))
                        {
                            QuondamPoint qp = ((QuondamPoint)_Points[i]);
                            qp.ParentPoint = _Points.Where(p => p.PID == qndLinks[qp.CN]).First();
                            _Points[i] = qp;
                        }
                    }
                }

                #endregion

                #region NMEA
                if (useNmea)
                {
                    TwoTrails.GpsAccess.NmeaBurst burst;

                    viewId = metaKitViews[nmeadata];
                    tmpInt = metaKit.GetRowCount(viewId);
                    for (int i = 0; i < tmpInt; i++)
                    {
                        tmpStr = metaKit.GetString(viewId, i, 1);
                        if (tmpStr.IsInteger())
                        {
                            int pid = tmpStr.ToInteger();
                            if (pointWNMEA.Contains(pid))
                            {
                                if (!nmeas.ContainsKey(pid))
                                    nmeas.Add(pid, new List<TwoTrails.GpsAccess.NmeaBurst>());

                                burst = new TwoTrails.GpsAccess.NmeaBurst();
                                burst._CN = Guid.NewGuid().ToString();

                                burst._Used = metaKit.GetInt(viewId, i, 2) > 0;

                                tmpStr = metaKit.GetString(viewId, i, 3);
                                if (!tmpStr.IsEmpty())
                                    burst._date = DateTime.ParseExact(tmpStr, "MMddyy", null);

                                tmpStr2 = metaKit.GetString(viewId, i, 4);
                                if (!tmpStr2.IsEmpty())
                                    burst._date = DateTime.ParseExact(tmpStr + tmpStr2, "MMddyyHHmmss", null);

                                burst._GGA_longitude = metaKit.GetDouble(viewId, i, 5);
                                burst._RMC_longitude = burst._GGA_longitude;

                                burst._GGA_latitude = metaKit.GetDouble(viewId, i, 6);
                                burst._RMC_latitude = burst._GGA_latitude;

                                burst._alt_unit = Unit.METERS;
                                burst._altitude = metaKit.GetFloat(viewId, i, 11);

                                burst._horiz_dilution_position = metaKit.GetDouble(viewId, i, 12);
                                burst._fix_quality = metaKit.GetInt(viewId, i, 13);

                                burst._fix = metaKit.GetInt(viewId, i, 15);

                                burst._PDOP = metaKit.GetFloat(viewId, i, 16);
                                burst._HDOP = metaKit.GetFloat(viewId, i, 17);
                                burst._VDOP = metaKit.GetFloat(viewId, i, 18);

                                burst._magVar = metaKit.GetFloat(viewId, i, 19);
                                burst._num_of_sat = metaKit.GetInt(viewId, i, 20);
                                burst._fixed_PRNs = metaKit.GetString(viewId, i, 21);

                                burst._GGA_latDir = TwoTrails.GpsAccess.NorthSouth.North;
                                burst._GGA_longDir = TwoTrails.GpsAccess.EastWest.West;
                                burst._magVarDir = TwoTrails.GpsAccess.EastWest.East;
                                burst._RMC_latDir = TwoTrails.GpsAccess.NorthSouth.North;
                                burst._RMC_longDir = TwoTrails.GpsAccess.EastWest.West;

                                for (int j = 22; j < 70; j += 4)
                                {
                                    GpsAccess.Satellite s = new TwoTrails.GpsAccess.Satellite();

                                    s.ID = metaKit.GetString(viewId, i, j);
                                    s.Elevation = metaKit.GetInt(viewId, i, j + 1);
                                    s.Azimuth = metaKit.GetInt(viewId, i, j + 2);
                                    s.SNR = metaKit.GetInt(viewId, i, j + 3);

                                    burst.AddSatalite(s);
                                }

                                burst.Complete();

                                nmeas[pid].Add(burst);
                            }
                        }
                    }
                }

                #endregion

                dal.InsertPoints(_Points);

                foreach (TtMetaData m in metaData.Values)
                    dal.InsertMetaData(m);
                foreach (TtPolygon poly in _Polygons.Values)
                    dal.InsertPolygon(poly);

                foreach (KeyValuePair<int, List<GpsAccess.NmeaBurst>> bl in nmeas)
                    dal.SaveNmeaBursts(bl.Value, pidToCN[bl.Key]);
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataImport:ImportTt", ex.StackTrace);
                return false;
            }

            return true;
        }
Exemplo n.º 6
0
 public WalkPoint(WalkPoint p)
     : base(p)
 {
     _op = TwoTrails.Engine.OpType.Walk;
 }
 private void DisplayWalk(WalkPoint point)
 {
     walkInfoCtrl1.SetPoint(point);
     walkInfoCtrl1.Visible = false;
     take5InfoCtrl1.Visible = false;
     gpsInfoControl1.Visible = true;
     gpsInfoControl1.MiscButtonText = "Edit Walk";
     gpsInfoControl1.ShowMiscButton = false;
     gpsInfoControl1.CurrentPoint = point;
     gpsInfoControl1.Meta = CurrMeta;
     travInfoControl1.Visible = false;
     quondamInfoControl1.Visible = false;
     actionsControl.MiscButtonText = "Walk";
     actionsControl.MiscButtonEnabled = true;
 }