コード例 #1
0
        public static int NamePoint(TtPoint previousPoint, TtPolygon parentPolygon)
        {
            if (previousPoint == null)
                return NameFirstPoint(parentPolygon);

            return NamePoint(previousPoint, parentPolygon.IncrementBy);
        }
コード例 #2
0
        public MassEditNewPoly(string name, int startIndex)
        {
            InitializeComponent();

            Poly = new TtPolygon();
            Poly.Name = name;
            Poly.PointStartIndex = startIndex;
        }
コード例 #3
0
        public Take5Form(TtPolygon poly, DataAccessLayer dal, TtMetaData meta, TtPoint currentPoint, int currIndex)
        {
            if (Engine.Values.WideScreen)
                InitializeComponentWide();
            else
                InitializeComponent();

            Init(poly, dal, meta, currentPoint, currIndex);
        }
コード例 #4
0
 public TtPolygon(TtPolygon p)
 {
     _CN = p.CN;
     Name = p.Name;
     Description = p.Description;
     //#Comment = p.Comment;
     IsLocked = p.IsLocked;
     PolyAccu = p.PolyAccu;
     Area = p.Area;
     Perimeter = p.Perimeter;
     _incrementBy = p.IncrementBy;
     _PointStartIndex = p._PointStartIndex;
 }
コード例 #5
0
        public static void RenamePoints(ref List<TtPoint> points, TtPolygon parentPoly)
        {
            RenamePoints(ref points, parentPoly.PointStartIndex, parentPoly.IncrementBy);

            /*
            if (points != null && points.Count > 0)
            {
                int pid = parentPoly.PointStartIndex;

                for (int i = 0; i < points.Count; i++)
                {
                    points[i].PID = pid;
                    pid += parentPoly.IncrementBy;
                }
            }
            */
        }
コード例 #6
0
        private QuondamPoint CreateQuondam(TtPoint parentpoint, TtPolygon poly, TtMetaData meta)
        {
            QuondamPoint tmpPoint = new QuondamPoint();
            tmpPoint.PolyCN = poly.CN;
            tmpPoint.PolyName = poly.Name;
            tmpPoint.MetaDefCN = meta.CN;
            tmpPoint.GroupCN = Values.MainGroup.CN;
            tmpPoint.GroupName = Values.MainGroup.Name;

            if (parentpoint.op == OpType.Quondam)
            {
                tmpPoint.ParentPoint = ((QuondamPoint)parentpoint).ParentPoint;
            }
            else
                tmpPoint.ParentPoint = parentpoint;

            tmpPoint.OnBnd = parentpoint.OnBnd;

            return tmpPoint;
        }
コード例 #7
0
        private void LoadListboxes(TtPolygon poly)
        {
            if (poly == null)
            {
                listBoxPID.Items.Clear();
            }
            else
            {
                if (DAL != null)
                {
                    try
                    {
                        _points = DAL.GetPointsInPolygon(poly.CN).Where(p => p.op != OpType.WayPoint && p.op != OpType.Quondam).ToList();

                        #region Trigger Event
                        if (Polygon_OnIndexChanged != null)
                        {
                            Polygon_OnIndexChanged();
                        }
                        #endregion

                        if (_current != null)
                        {
                            TtPointBindingSource.DataSource = _points;

                            if (_current.ParentPoint == null)
                            {
            #if !(PocketPC || WindowsCE || Mobile)
                                listBoxPID.ClearSelected();
            #else
                                listBoxPID.SelectedItem = null;
            #endif
                            }
                            else
                            {
                                listBoxPID.SelectedItem = _current;
                            }
                        }
                        else
                        {
                            listBoxPID.Items.Clear();
                        }
                    }
                    catch
                    {

                    }
                }
            }
        }
コード例 #8
0
        private void cboPoly1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (init)
            {
                if (cboPoly1.SelectedIndex == cboPoly2.SelectedIndex)
                {
                    MessageBox.Show("You cannot merge to the same polygon.");
                    ignorePolyChange = true;
                    cboPoly1.SelectedIndex = lastPolyIndex1;
                }
                else
                {
                    lastPolyIndex1 = cboPoly1.SelectedIndex;

                    if (ignorePolyChange)
                    {
                        _Poly1 = _Polys[lastPolyIndex1];
                        point1StartList = new BindingList<TtPoint>(dal.GetPointsInPolygon(_Poly1.CN));
                        point1EndList = new BindingList<TtPoint>(dal.GetPointsInPolygon(_Poly1.CN));
                        cboStartPointPoly1.DataSource = point1StartList;
                        cboEndPointPoly1.DataSource = point1EndList;
                        cboEndPointPoly1.SelectedIndex = point1EndList.Count - 1;
                        ignorePolyChange = false;
                    }
                }
            }
        }
コード例 #9
0
        private void ChangePolygon(string cn)
        {
            CurrPoly = Polygons[cn];

            cboPoly.SelectedItem = CurrPoly.Name;
            btnPolygon.Text = CurrPoly.Name;

            LoadPolygon(CurrPoly.CN);
        }
コード例 #10
0
        private void pointNavigationCtrl1_IndexChanged2(object sender, TwoTrails.Controls.PointNavigationCtrl.PointNavEventArgs e)
        {
            SaveCurrentPolygon();

            _ignoreMakeDirty = true;

            int index = CNs.IndexOf(e.NextPointCN);

            if (index > -1 && index < Polygons.Count)
            {
                CurrentPolygon = Polygons[index];
                UpdatedPolygon = CurrentPolygon;
                AdjustNavControls(index);
                actionsControlPolygons.MiscButtonEnabled = true;
            }
            else
            {
                actionsControlPolygons.MiscButtonEnabled = false;
            }

            Lock(true);

            Kb.Hide(this);

            _ignoreMakeDirty = false;
        }
コード例 #11
0
        private void actionsControlPolygons_NewClicked_OnClick2(object sender, EventArgs e)
        {
            SaveCurrentPolygon();

            TtPolygon p = new TtPolygon();
            CurrentPolygon = null;

            int num = 0;
            if (Polygons.Count > 0)
            {
                //try
                //{
                //    num = (int)TtUtils.GetEndingNumber(Polygons.Last().Name);
                //}
                //catch
                //{
                //    num = Polygons.Count;
                //}

                //num++;
                num = Polygons.Count + 1;

                p.Name = string.Format("Poly {0}", num);

                TtPolygon lastPoly = Polygons[Polygons.Count - 1];

                int numInLastPoly = DAL.GetNumberOfPointsinPolygon(lastPoly.CN);

                p.PointStartIndex = (((numInLastPoly * lastPoly.IncrementBy) / 1000) * 1000) + num * 1000 + 10;
            }
            else
            {
                p.Name = "Poly 1";
                p.PointStartIndex = 1010;
            }

            p.PolyAccu = Values.Settings.DeviceOptions.DEFAULT_POINT_ACCURACY;

            UpdatedPolygon = p;

            CNs.Add(p.CN);
            Polygons.Add(p);

            pointNavigationCtrl1.UpdatePointList(CNs, CNs.Count - 1);
            AdjustNavControls(CNs.Count - 1);
            Lock(false);
            _recalc = true;
        }
コード例 #12
0
        public bool ImportShapes(List<string> files, bool latlon, bool useShapeProps, bool useElev, bool elevFeet)
        {
            GeometryFactory factory;
            ShapefileDataReader shapeFileDataReader;
            ArrayList features;
            Feature feature;
            AttributesTable attributesTable;
            string[] keys;
            Geometry geometry;
            DbaseFieldDescriptor fldDescriptor;
            int polyCount = (int)dal.GetPolyCount();

            GpsPoint gps;
            int index = 0;

            _Polygons = new Dictionary<string, TtPolygon>();
            _Points = new List<TtPoint>();

            List<TtPoint> tmpPoints = new List<TtPoint>();

            try
            {
                foreach (string file in files)
                {
                    //polyCount = 1;

                    factory = new GeometryFactory();
                    shapeFileDataReader = new ShapefileDataReader(file, factory);
                    DbaseFileHeader header = shapeFileDataReader.DbaseHeader;

                    features = new ArrayList();
                    while (shapeFileDataReader.Read())
                    {
                        feature = new Feature();
                        attributesTable = new AttributesTable();
                        keys = new string[header.NumFields];
                        geometry = (Geometry)shapeFileDataReader.Geometry;

                        for (int i = 0; i < header.NumFields; i++)
                        {
                            fldDescriptor = header.Fields[i];
                            keys[i] = fldDescriptor.Name;
                            attributesTable.AddAttribute(fldDescriptor.Name, shapeFileDataReader.GetValue(i));
                        }

                        feature.Geometry = geometry;
                        feature.Attributes = attributesTable;
                        features.Add(feature);
                    }

                    bool areAllPoints = true;
                    foreach (Feature feat in features)
                    {
                        if (feat.Geometry.GeometryType.ToLower() != "point")
                        {
                            areAllPoints = false;
                            break;
                        }
                    }

                    //if all features are points
                    if (areAllPoints)
                    {
                        tmpPoints.Clear();

                        _Poly = new TtPolygon(1000 * polyCount + 10);

                        _Poly.Name = Path.GetFileNameWithoutExtension(file);

                        index = 0;

                        foreach (Feature feat in features)
                        {
                            //if features is only a point there should only be 1 coord
                            foreach (Coordinate coord in feat.Geometry.Coordinates)
                            {
                                gps = new GpsPoint();
                                gps.OnBnd = true;

                                gps.Index = index;
                                index++;

                                gps.MetaDefCN = _Meta.CN;

                                if (tmpPoints.Count > 0)
                                    gps.PID = PointNaming.NamePoint(tmpPoints.Last(), _Poly);
                                else
                                    gps.PID = PointNaming.NameFirstPoint(_Poly);

                                if (latlon)
                                {
                                    double x,y;

                                    TtUtils.LatLontoUTM(coord.Y, coord.X, _Meta.Zone, out y, out x);

                                    gps.UnAdjX = x;
                                    gps.UnAdjY = y;
                                }
                                else
                                {
                                    gps.UnAdjX = coord.X;
                                    gps.UnAdjY = coord.Y;
                                }

                                if (useElev)
                                {
                                    if (coord.Z != double.NaN)
                                    {
                                        if (elevFeet)
                                            gps.UnAdjZ = TtUtils.ConvertToMeters(coord.Z, Unit.FEET_TENTH);
                                        else
                                            gps.UnAdjZ = coord.Z;
                                    }
                                    else
                                        gps.UnAdjZ = 0;
                                }
                                else
                                    gps.UnAdjZ = 0;

                                gps.PolyCN = _Poly.CN;
                                gps.PolyName = _Poly.Name;

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

                                tmpPoints.Add(gps);
                            }

                            _Points.AddRange(tmpPoints);
                        }

                        _Polygons.Add(_Poly.CN, _Poly);
                        polyCount++;
                    }
                    else //else get points out of each features
                    {
                        int fidInc = 0;

                        foreach (Feature feat in features)
                        {
                            tmpPoints.Clear();

                            _Poly = new TtPolygon(1000 * polyCount + 10);

                            if (features.Count < 2)
                                _Poly.Name = Path.GetFileNameWithoutExtension(file);
                            else
                                _Poly.Name = String.Format("{0}-{1}", fidInc++, Path.GetFileNameWithoutExtension(file));

                            #region Shape Desc Properties
                            if (useShapeProps)
                            {
                                object[] objs = feat.Attributes.GetValues();
                                string[] names = feat.Attributes.GetNames();
                                string objv;

                                for (int i = 0; i < feat.Attributes.Count; i++)
                                {
                                    if (objs[i] is string)
                                    {
                                        objv = (string)objs[i];

                                        if (objv.IsEmpty())
                                            continue;

                                        switch (names[i].ToLower())
                                        {
                                            case "description":
                                            case "comment":
                                            case "poly":
                                                if (_Poly.Description.IsEmpty())
                                                    _Poly.Description = objv;
                                                else
                                                    _Poly.Description = String.Format("{0} | {1}", _Poly.Description, objv);
                                                break;
                                            case "name":
                                            case "unit":
                                                _Poly.Name = objv;
                                                break;
                                        }
                                    }
                                }
                            }
                            #endregion

                            index = 0;

                            foreach (Coordinate coord in feat.Geometry.Coordinates)
                            {
                                gps = new GpsPoint();
                                gps.OnBnd = true;

                                gps.Index = index;
                                index++;

                                gps.MetaDefCN = _Meta.CN;

                                if (tmpPoints.Count > 0)
                                    gps.PID = PointNaming.NamePoint(tmpPoints.Last(), _Poly);
                                else
                                    gps.PID = PointNaming.NameFirstPoint(_Poly);

                                if (latlon)
                                {
                                    double x, y;

                                    TtUtils.LatLontoUTM(coord.Y, coord.X, _Meta.Zone, out y, out x);

                                    gps.UnAdjX = x;
                                    gps.UnAdjY = y;
                                }
                                else
                                {
                                    gps.UnAdjX = coord.X;
                                    gps.UnAdjY = coord.Y;
                                }

                                if (useElev)
                                {
                                    if (coord.Z == double.NaN)
                                    {
                                        if (elevFeet)
                                            gps.UnAdjZ = TtUtils.ConvertToMeters(coord.Z, Unit.FEET_TENTH);
                                        else
                                            gps.UnAdjZ = coord.Z;
                                    }
                                    else
                                        gps.UnAdjZ = 0;
                                }
                                else
                                    gps.UnAdjZ = 0;

                                gps.PolyCN = _Poly.CN;
                                gps.PolyName = _Poly.Name;

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

                                tmpPoints.Add(gps);
                            }

                            _Points.AddRange(tmpPoints);
                            _Polygons.Add(_Poly.CN, _Poly);
                            polyCount++;
                        }
                    }

                    //Close and free up any resources
                    shapeFileDataReader.Close();
                    shapeFileDataReader.Dispose();
                }

                foreach (TtPolygon poly in _Polygons.Values)
                    dal.InsertPolygon(poly);

                dal.InsertPoints(_Points);

                PolygonAdjuster.Adjust(dal);
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataImport:ImportShapes", ex.StackTrace);

                return false;
            }

            return true;
        }
コード例 #13
0
        public bool ImportGpx(bool useElev, bool elevFeet)
        {
            _Points = new List<TtPoint>();
            List<TtPolygon> polys = new List<TtPolygon>();

            using(XmlTextReader r = new XmlTextReader(new StreamReader(_FileName)))
            {
                bool inObject, inPoly, inPoint, inElev, fpoint;
                inObject = inPoly = inPoint = inElev = fpoint = false;

                double lat, lon, elev, utmX, utmY;
                lat = lon = elev = utmX = utmY = 0;

                GpsPoint point = new GpsPoint();
                TtPolygon poly = new TtPolygon();

                int polyCount = (int)dal.GetPolyCount() + 1, index = 0;

                string tmp;

                try
                {
                    try
                    {
                        r.Namespaces = false;

                        while (r.Read())
                        {
                            switch (r.NodeType)
                            {
                                case XmlNodeType.Element:
                                    {
                                        if (r.Name == "rte" || r.Name == "trk")
                                            inObject = true;
                                        else if (!inPoly && (r.Name == "rtept" || r.Name == "trkseg"))
                                        {
                                            inPoly = true;
                                            poly = new TtPolygon();
                                            poly.Name = String.Format("Poly {0}", polyCount);
                                            poly.PointStartIndex = polyCount * 1000 + 10;
                                            polyCount++;
                                            poly.IncrementBy = 10;
                                            fpoint = true;
                                            index = 0;
                                        }
                                        else if (inPoly && (r.Name == "rtept" || r.Name == "trkpt"))
                                        {
                                            inPoint = true;
                                            point = new GpsPoint();

                                            tmp = r.GetAttribute("lat");
                                            if (tmp.IsDouble())
                                                lat = tmp.ToDouble();

                                            tmp = r.GetAttribute("lon");
                                            if (tmp.IsDouble())
                                                lon = tmp.ToDouble();
                                        }
                                        else if (r.Name == "ele")
                                            inElev = true;
                                    }
                                    break;
                                case XmlNodeType.EndElement:
                                    {
                                        if (r.Name == "rte" || r.Name == "trk")
                                            inObject = false;
                                        else if (!inPoint && (r.Name == "rtept" || r.Name == "trkseg"))
                                        {
                                            inPoly = false;
                                            polys.Add(poly);
                                        }
                                        else if (inPoint && (r.Name == "rtept" && inPoint || r.Name == "trkpt"))
                                        {
                                            inPoint = false;

                                            if (lat != 0 && lon != 0)
                                            {
                                                if (fpoint)
                                                    point.PID = PointNaming.NameFirstPoint(poly);
                                                else
                                                    point.PID = PointNaming.NamePoint(_Points[_Points.Count - 1], poly);

                                                point.PolyCN = poly.CN;
                                                point.PolyName = poly.Name;

                                                point.MetaDefCN = _Meta.CN;

                                                point.Index = index;
                                                index++;

                                                point.OnBnd = true;

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

                                                TtUtils.LatLontoUTM(lat, lon, _Meta.Zone, out utmY, out utmX);

                                                point.UnAdjX = utmX;
                                                point.UnAdjY = utmY;

                                                if (useElev)
                                                {
                                                    if (elevFeet)
                                                        point.UnAdjZ = TtUtils.ConvertToMeters(elev, Unit.FEET_TENTH);
                                                    else
                                                        point.UnAdjZ = elev;
                                                }

                                                _Points.Add(point);

                                                fpoint = false;
                                            }
                                        }
                                        else if (r.Name == "ele")
                                            inElev = false;
                                    }
                                    break;
                                case XmlNodeType.Text:
                                    {
                                        if (inElev)
                                        {
                                            if (r.Value.IsDouble())
                                                elev = r.Value.ToDouble();
                                        }
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                    catch (XmlException ex)
                    {
                        if (!ex.Message.ToLower().Contains("undeclared"))
                        {
                            return false;
                        }
                    }

                    foreach (TtPolygon p in polys)
                        dal.InsertPolygon(p);
                    dal.InsertPoints(_Points);
                }
                catch (Exception ex)
                {
                    TtUtils.WriteError(ex.Message, "DataImport:ImportGpx", ex.StackTrace);
                    return false;
                }
            }

            return true;
        }
コード例 #14
0
        private void ChangeFromPoly(int index)
        {
            if(index < 0 || index > _Polygons.Count -1)
                return;

            if (_FromPolygon != _Polygons[index])
            {
                _FromPolygon = _Polygons[index];
            #if (PocketPC || WindowsCE || Mobile)
                btnFromPoly.Text = _FromPolygon.Name;
            #endif

                cboFromPoint.Items.Clear();
                _FromPointNames.Clear();

                _FromPoints = DAL.GetPointsInPolygon(_FromPolygon.CN);

                if (_FromPoints.Count == 0)
                {
                    _FromPoint = new GpsPoint(0, 0, 0);
                    txtFromX.Text = String.Empty;
                    txtFromY.Text = String.Empty;
                    cboFromPoint.Text = String.Empty;
                }
                else
                {
                    foreach (TtPoint p in _FromPoints)
                    {
                        cboFromPoint.Items.Add(p.PID);
                        _FromPointNames.Add(p.PID.ToString());
                    }

                    cboFromPoint.SelectedIndex = 0;
                }
            }
        }
コード例 #15
0
        public void Init()
        {
            this.Icon = Properties.Resources.Map;
            _init = false;

            _Polygons = new List<TtPolygon>();
            _FromPoints = new List<TtPoint>();
            _ToPoints = new List<TtPoint>();
            _PolyNames = new List<string>();
            _FromPointNames = new List<string>();
            _ToPointNames = new List<string>();
            _Meta = new List<TtMetaData>();

            pointsAvail = false;

            _FromPoint = null;
            _ToPoint = null;
            _FromPolygon = null;
            _ToPolygon = null;
            _CurrMeta = null;

            _navigating = false;

            if (DAL != null)
            {
                _Polygons = DAL.GetPolygons();

                _Meta = DAL.GetMetaData();

                if (_Meta.Count > 0)
                {
                    foreach (TtMetaData m in _Meta)
                    {
                        cboMeta.Items.Add(m.Name);
                    }

                    _CurrMeta = _Meta[0];
            #if (PocketPC || WindowsCE || Mobile)
                    btnMeta.Text = _CurrMeta.Name;
            #endif
                    cboMeta.SelectedIndex = 0;
                }

                if (_Polygons.Count > 0)
                {
                    foreach (TtPolygon poly in _Polygons)
                    {
                        if (DAL.GetPointCount(poly.CN) > 0)
                            pointsAvail = true;
                    }
                }
            }
            else
            {
            #if (PocketPC || WindowsCE || Mobile)
                btnMeta.Enabled = false;
            #endif
                cboMeta.Enabled = false;
                _CurrMeta = Values.Settings.ReadMetaSettings();

                if (_CurrMeta == null)
                {
                    _CurrMeta = new TtMetaData()
                    {
                        CN = Guid.Empty.ToString(),
                        Name = "DefaultMeta",
                        magDec = 0,
                        decType = DeclinationType.MagDec,
                        Zone = 13,
                        uomSlope = UomSlope.Percent,
                        uomElevation = UomElevation.Feet,
                        uomDistance = UomDistance.FeetTenths,
                        datum = Datum.NAD83
                    };
                }
            }

            UseMyPos = false;

            #region Setup Controls
            if (Values.Settings.DeviceOptions.UseSelection)
            {
                cboFromPoint.Visible = false;
                cboFromPoly.Visible = false;
                cboToPoint.Visible = false;
                cboToPoly.Visible = false;
                cboMeta.Visible = false;

            #if (PocketPC || WindowsCE || Mobile)
                btnToPoint.Visible = true;
                btnToPoly.Visible = true;
                btnFromPoint.Visible = true;
                btnFromPoly.Visible = true;
                btnMeta.Visible = true;

                btnToPoint.Enabled = true;
                btnToPoly.Enabled = true;
                btnFromPoint.Enabled = true;
                btnFromPoly.Enabled = true;
            #endif
                cboFromPoint.Enabled = false;
                cboFromPoly.Enabled = false;
                cboToPoint.Enabled = false;
                cboToPoly.Enabled = false;
            }
            else
            {
                cboFromPoint.Visible = true;
                cboFromPoly.Visible = true;
                cboToPoint.Visible = true;
                cboToPoly.Visible = true;
                cboMeta.Visible = true;

            #if (PocketPC || WindowsCE || Mobile)
                btnToPoint.Visible = false;
                btnToPoly.Visible = false;
                btnFromPoint.Visible = false;
                btnFromPoly.Visible = false;
                btnMeta.Visible = false;

                btnToPoint.Enabled = false;
                btnToPoly.Enabled = false;
                btnFromPoint.Enabled = false;
                btnFromPoly.Enabled = false;
            #endif
                cboFromPoint.Enabled = true;
                cboFromPoly.Enabled = true;
                cboToPoint.Enabled = true;
                cboToPoly.Enabled = true;
            }

            txtFromX.Enabled = false;
            txtFromY.Enabled = false;
            txtToX.Enabled = false;
            txtToY.Enabled = false;

            if (pointsAvail == true)
            {
                foreach (TtPolygon poly in _Polygons)
                {
                    cboFromPoly.Items.Add(poly.Name);
                    cboToPoly.Items.Add(poly.Name);
                    _PolyNames.Add(poly.Name);
                }

                cboFromPoly.SelectedIndex = 0;
                cboToPoly.SelectedIndex = 0;
                //ChangeFromPoly(0);
                //ChangeToPoly(0);
            }
            else
            {
                radToPoint.Enabled = false;
                radFromPoint.Enabled = false;

                txtFromX.Enabled = true;
                txtFromY.Enabled = true;
                txtToX.Enabled = true;
                txtToY.Enabled = true;

                radFromUTM.Checked = true;
                radToUTM.Checked = true;
            }
            #endregion
        }
コード例 #16
0
        public void Init(TtPolygon poly, DataAccessLayer dal, TtMetaData meta, TtPoint currentPoint, int currIndex)
        {
            this.Icon = Properties.Resources.Map;
            TtUtils.ShowWaitCursor();
            #if (PocketPC || WindowsCE || Mobile)
            lblLabel.Text = "Take " + Values.Settings.DeviceOptions.Take5NmeaAmount.ToString();
            #endif
            btnCapture.Text = "Take " + Values.Settings.DeviceOptions.Take5NmeaAmount.ToString();
            this.Text = "Take " + Values.Settings.DeviceOptions.Take5NmeaAmount.ToString() + " Point Capture";

            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;

            travInfoControl1.UseLaser = false;

            Polygon = poly;
            DAL = dal;
            CurrMeta = meta;

            logging = false;
            this.DialogResult = DialogResult.Cancel;
            OnBound = true;
            _index = 0;
            ignore = 0;

            progCapture.Value = 0;
            progCapture.Minimum = 0;
            progCapture.Maximum = Values.Settings.DeviceOptions.Take5NmeaAmount;

            logged = 0;
            _locked = true;

            CurrentNmea = new List<NmeaBurst>();
            LastNmea = new List<NmeaBurst>();
            CurrentPoint = null;

            _index = currIndex;
            LastPoint = currentPoint;

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

            if (Values.GPSA.UsesFile && Values.Settings.DeviceOptions.GetGpsOnStart)
            {
                using (DeviceSetupForm dsf = new DeviceSetupForm())
                {
                    dsf.ShowDialog();
                }
            }

            T5Group = new TtGroup();
            T5Group.Name = String.Format("Take5_{0}", T5Group.CN.Truncate(8));
            T5Group.GroupType = GroupType.Take5;

            if(!Values.GPSA.IsBusy)
                Values.GPSA.OpenGps(Values.Settings.DeviceOptions.GpsComPort, Values.Settings.DeviceOptions.GpsBaud);
            TtUtils.HideWaitCursor();

            if (dal.GetPointCount(poly.CN) < 1)
            {
                checkMeta = true;
            }
        }
コード例 #17
0
        private List<TtPolygon> GetUpgradePolygons()
        {
            //#query.AppendFormat("SELECT {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10} from {11} ",
            StringBuilder query = new StringBuilder();
            query.AppendFormat("SELECT {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} from {8} ",
                TwoTrailsSchema.SharedSchema.CN,
                TwoTrailsSchema.PolygonSchema.PolyID,
                //#TwoTrailsSchema.PolygonSchema.Comment,
                TwoTrailsSchema.PolygonSchema.Description,
                //#TwoTrailsSchema.PolygonSchema.Locked,
                TwoTrailsSchema.PolygonSchema.Accuracy,
                TwoTrailsSchema.PolygonSchema.Area,
                TwoTrailsSchema.PolygonSchema.Perimeter,
                //#TwoTrailsSchema.PolygonSchema.NumOfLinks,
                TwoTrailsSchema.PolygonSchema.IncrementBy,
                TwoTrailsSchema.PolygonSchema.PointStartIndex,
                TwoTrailsSchema.PolygonSchema.TableName);

            SQLiteCommand cmd = _dbConnection.CreateCommand();
            List<TtPolygon> polys = new List<TtPolygon>();

            try
            {
                cmd.CommandText = query.ToString();
                TtPolygon poly = new TtPolygon();
                SQLiteDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    poly.CN = reader.GetString(0);
                    poly.Name = reader.GetString(1);
                    //#if (!reader.IsDBNull(2))
                    //#    poly.Comment = reader.GetString(2);
                    if (!reader.IsDBNull(2))
                        poly.Description = reader.GetString(2);
                    //#poly.IsLocked = Boolean.Parse(reader.GetString(4));
                    if (!reader.IsDBNull(3))
                        poly.PolyAccu = reader.GetDouble(3);
                    if (!reader.IsDBNull(4))
                        poly.Area = reader.GetDouble(4);
                    if (!reader.IsDBNull(5))
                        poly.Perimeter = reader.GetDouble(5);
                    //#if (!reader.IsDBNull(8))
                    //#    poly.LinkedQuondams = reader.GetInt32(8);
                    if (!reader.IsDBNull(6))
                        poly.IncrementBy = reader.GetInt32(6);
                    if (!reader.IsDBNull(7))
                        poly.PointStartIndex = reader.GetInt32(7);

                    polys.Add(poly);
                    poly = new TtPolygon();
                }
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataAccessUpgrader:GetQuondamPointData", ex.StackTrace);
            }
            finally
            {
                cmd.Dispose();
            }

            return polys;
        }
コード例 #18
0
        public Take5Form(TtPolygon poly, DataAccessLayer dal, TtMetaData meta, TtPoint lastPoint, int cIndex)
        {
            InitializeComponent();

            Init(poly, dal, meta, lastPoint, cIndex);
        }
コード例 #19
0
        private void actionsControlPolygons_MiscClicked_OnClick2(object sender, EventArgs e)
        {
            if (CurrentPolygon != null &&
                MessageBox.Show("Would you like to duplicate this Polygon?", "Duplicate Polygon",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                SaveCurrentPolygon();

                TtPolygon p = new TtPolygon();

                int num = 0;
                if (Polygons.Count > 0)
                {
                    try
                    {
                        num = (int)TtUtils.GetEndingNumber(Polygons.Last().Name);
                    }
                    catch
                    {
                        num = Polygons.Count;
                    }

                    num++;
                    p.Name = string.Format("{0} Copy", CurrentPolygon.Name);

                    TtPolygon lastPoly = Polygons[Polygons.Count - 1];

                    int numInLastPoly = DAL.GetNumberOfPointsinPolygon(lastPoly.CN);

                    p.PointStartIndex = (((numInLastPoly * lastPoly.IncrementBy) / 1000) * 1000) + num * 1000 + 10;
                }

                p.PolyAccu = CurrentPolygon.PolyAccu;

                CNs.Add(p.CN);
                Polygons.Add(p);

                TtPolygon oldPoly = CurrentPolygon;
                DAL.InsertPolygon(p);
                UpdatedPolygon = null;
                CurrentPolygon = p;

                List<TtPoint> points = new List<TtPoint>();
                TtPoint newPoint, oldPoint = null;
                foreach (TtPoint point in DAL.GetPointsInPolygon(oldPoly))
                {
                    newPoint = TtUtils.ClonePoint(point);
                    newPoint.PID = PointNaming.NamePoint(oldPoint, CurrentPolygon);
                    newPoint.PolyCN = CurrentPolygon.CN;
                    newPoint.PolyName = CurrentPolygon.Name;
                    points.Add(newPoint);
                    oldPoint = newPoint;
                }

                DAL.InsertPoints(points);

                LoadPolys();
                Lock(false);
                _recalc = true;
            }
        }
コード例 #20
0
        public bool ImportText(bool latLng, bool multiPoly, bool usePID,
            bool useIndex, bool useElev, bool elevFeet, bool useComment, bool useBound)
        {
            try
            {
                string line, tmp;

                int pidIndex = -1, xIndex = -1, yIndex = -1, zIndex = -1,
                    cmtIndex = -1, polyIndex = -1, bndIndex = -1, iIndex = -1;

                int mX = 0, mY = 0, mZ = 0;

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

                int requiredFields = 2 + (multiPoly ? 1 : 0) + (usePID ? 1 : 0) +
                    (useIndex ? 1 : 0) + (useElev ? 1 : 0);

                if (!multiPoly)
                {
                    int polyCount = (int)dal.GetPolyCount();
                    polyCount++;
                    _Poly = new TtPolygon(1000 * polyCount + 10);
                    _Poly.Name = String.Format("Poly {0}", polyCount);
                    _Polygons.Add(_Poly.CN, _Poly);
                }

                using (StreamReader sr = new StreamReader(_FileName))
                {
                    if (sr.EndOfStream)
                    {
                        MessageBox.Show("Empty File");
                        return false;
                    }

                    line = sr.ReadLine();

                    #region Get Fields

                    List<string> strOrder = line.Split(',').ToList();

                    if (strOrder.Count < 2)
                    {
                        MessageBox.Show("Invalid File Info");
                        return false;
                    }
                    else
                    {

                        for (int i = 0; i < strOrder.Count; i++)
                        {
                            #region Parse Fields
                            switch (strOrder[i].ToLower())
                            {
            #if !(PocketPC || WindowsCE || Mobile)
                                    //pc only
                                case "x":
                                case "adjx":
                                case "xadj":
                                    if (!latLng)
                                    {
                                        xIndex = i;
                                        mX++;
                                    }
                                    break;
                                case "lon":
                                case "lng":
                                case "long":
                                case "longitude":
                                    if (latLng)
                                    {
                                        xIndex = i;
                                        mX++;
                                    }
                                    break;
                                case "y":
                                case "adjy":
                                case "yadj":
                                    if (!latLng)
                                    {
                                        yIndex = i;
                                        mY++;
                                    }
                                    break;
                                case "lat":
                                case "latitude":
                                    if (latLng)
                                    {
                                        yIndex = i;
                                        mY++;
                                    }
                                    break;
                                case "z":
                                case "adjz":
                                case "zadj":
                                case "elev":
                                case "elevation":
                                case "altitide":
                                    zIndex = i;
                                    mZ++;
                                    break;
                                    //pc only
            #endif
                                case "pid":
                                case "id":
                                case "point id":
                                    pidIndex = i;
                                    break;
                                case "cmt":
                                case "comment":
                                case "note":
                                case "notes":
                                    cmtIndex = i;
                                    break;
                                case "poly":
                                case "polygon":
                                case "poly name":
                                case "polygon name":
                                case "poly index":
                                case "polygon index":
                                    polyIndex = i;
                                    break;
                                case "bnd":
                                case "bound":
                                case "onbnd":
                                case "onbound":
                                case "boundary":
                                case "onboundary":
                                    bndIndex = i;
                                    break;
                                case "idx":
                                case "indx":
                                case "index":
                                    iIndex = i;
                                    break;
                                default:
                                    //unknown field
                                    break;
                            }
                            #endregion
                        }
            #if !(PocketPC || WindowsCE || Mobile)

                        using (TextImportFieldSelectionForm form =
                            new TextImportFieldSelectionForm(
                        pidIndex, xIndex, yIndex, zIndex, cmtIndex, polyIndex,
                        bndIndex, iIndex, strOrder.ToArray()))
                        {
                            if (form.ShowDialog() == DialogResult.OK)
                            {

                                pidIndex = form.iPID;
                                xIndex = form.iX;
                                yIndex = form.iY;
                                zIndex = form.iZ;
                                cmtIndex = form.iComment;
                                polyIndex = form.iPoly;
                                bndIndex = form.iBound;
                                iIndex = form.iIndex;
                                elevFeet = form.bFeet;
                                latLng = form.bLatLon;
                            }
                            else
                            {
                                return false;
                            }
                        }

            #else
                        #region Unknown / Dup Fields
                        if (xIndex < 0 || mX > 1)
                        {
                            using (Selection form = new Selection("Select X value field", strOrder, 0))
                            {
                                if (form.ShowDialog() == DialogResult.OK)
                                {
                                    form.Width = form.Width + 100;
                                    if (form.selection > -1)
                                        xIndex = form.selection;
                                }
                                else
                                    return false;
                            }
                        }

                        if (yIndex < 0 || mY > 1)
                        {
                            using (Selection form = new Selection("Select Y value field", strOrder, 0))
                            {
                                if (form.ShowDialog() == DialogResult.OK)
                                {
                                    if (form.selection > -1)
                                        yIndex = form.selection;
                                }
                                else
                                    return false;
                            }
                        }

                        if (useElev && (zIndex < 0 || mZ > 1))
                        {
                            using (Selection form = new Selection("Select Elevation field", strOrder, 0))
                            {
                                if (form.ShowDialog() == DialogResult.OK)
                                {
                                    if (form.selection > -1)
                                        zIndex = form.selection;
                                }
                                else
                                    return false;
                            }
                        }

                        if (usePID && pidIndex < 0)
                        {
                            using (Selection form = new Selection("Select Point ID field", strOrder, 0))
                            {
                                if (form.ShowDialog() == DialogResult.OK)
                                {
                                    if (form.selection > -1)
                                        pidIndex = form.selection;
                                }
                                else
                                    return false;
                            }
                        }

                        if (multiPoly && polyIndex < 0)
                        {
                            using (Selection form = new Selection("Select Poly ID field", strOrder, 0))
                            {
                                if (form.ShowDialog() == DialogResult.OK)
                                {
                                    if (form.selection > -1)
                                        polyIndex = form.selection;
                                }
                                else
                                    return false;
                            }
                        }

                        if (useIndex && iIndex < 0)
                        {
                            using (Selection form = new Selection("Select Point Index field", strOrder, 0))
                            {
                                if (form.ShowDialog() == DialogResult.OK)
                                {
                                    if (form.selection > -1)
                                        iIndex = form.selection;
                                }
                                else
                                    return false;
                            }
                        }
                        #endregion
            #endif
                    }

                    #endregion

                    int index = 0;

                    #region Parse Data
                    while (!sr.EndOfStream)
                    {
                        line = sr.ReadLine();

                        List<string> details = line.Split(',').ToList();

                        if (details.Count < requiredFields)
                            continue;

                        GpsPoint p = new GpsPoint();

                        if (multiPoly || polyIndex > -1)
                        {
                            tmp = details[polyIndex];

                            if (tmp.Length > 0)
                            {
                                if(_IdToCN.ContainsKey(tmp))
                                {
                                    _Poly = _Polygons[_IdToCN[tmp]];
                                }
                                else
                                {
                                    _Poly = new TtPolygon(1000 * (_Polygons.Count + 1) + 10);
                                    _Poly.Name = details[polyIndex];

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

                        p.PolyCN = _Poly.CN;
                        p.PolyName = _Poly.Name;
                        p.MetaDefCN = _Meta.CN;

                        if (!usePID || polyIndex < 0)
                        {
                            if (_Points.Count > 0)
                            {
                                p.PID = PointNaming.NamePoint(_Points.Last(), _Poly);
                            }
                            else
                            {
                                p.PID = PointNaming.NameFirstPoint(_Poly);
                            }
                        }
                        else
                        {
                            tmp = details[pidIndex];
                            if (tmp.Length > 0 && tmp.IsInteger())
                            {
                                p.PID = Convert.ToInt32(tmp);
                            }
                            else
                            {
                                PointNaming.NamePoint(_Points.Last(), _Poly);
                            }
                        }

                        try
                        {
                            tmp = details[xIndex];
                            if (tmp.Length > 0 && tmp.IsDouble())
                            {
                                p.UnAdjX = Convert.ToDouble(tmp);
                            }
                            else
                                p.UnAdjX = 0;

                            tmp = details[yIndex];
                            if (tmp.Length > 0)
                                p.UnAdjY = Convert.ToDouble(tmp);
                            else
                                p.UnAdjY = 0;

                            if (useElev)
                            {
                                tmp = details[zIndex];
                                if (tmp.Length > 0 && tmp.IsDouble())
                                {
                                    if (elevFeet)
                                        p.UnAdjZ = TtUtils.ConvertToMeters(tmp.ToDouble(), Unit.FEET_TENTH);
                                    else
                                        p.UnAdjZ = tmp.ToDouble();
                                }
                                else
                                {
                                    p.UnAdjZ = 0;
                                }
                            }

                            if (latLng)
                            {
                                double x, y;

                                TtUtils.LatLontoUTM(p.UnAdjY, p.UnAdjX, _Meta.Zone, out y, out x);

                                p.UnAdjX = x;
                                p.UnAdjY = y;
                            }

                        }
                        catch
                        {
                            continue;
                        }

                        if (cmtIndex > -1)
                        {
                            p.Comment = details[cmtIndex];
                        }

                        if (useIndex && iIndex > -1)
                        {
                            tmp = details[iIndex];
                            if (tmp.IsInteger())
                            {
                                p.Index = tmp.ToInteger();
                                index = (int)(p.Index + 1);
                            }
                            else continue;
                        }
                        else
                        {
                            if (multiPoly || polyIndex > -1)
                            {
                                p.Index = _PolyIndexes[p.PolyCN];
                                _PolyIndexes[p.PolyCN]++;
                            }
                            else
                            {
                                p.Index = index;
                                index++;
                            }
                        }

                        if (bndIndex > -1)
                        {
                            tmp = details[bndIndex];
                            if (tmp.IsBool())
                            {
                                p.OnBnd = tmp.ToBool();
                            }
                        }
                        else
                        {
                            p.OnBnd = true;
                        }

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

                        _Points.Add(p);
                    }
                    #endregion

                    foreach (TtPolygon p in _Polygons.Values)
                    {
                        dal.InsertPolygon(p);
                    }

                    dal.InsertPoints(_Points);

                    PolygonAdjuster.Adjust(dal);

                    return true;
                }
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "ImportFormnLogic:ParseTxt", ex.StackTrace);
                MessageBox.Show(@"An Error has occured while importing data.
            Make sure other applications are not using the file which is being imported.
            Check the error log for complete details.", "Import Error");
            }

            return false;
        }
コード例 #21
0
        private void LoadPolys()
        {
            Polygons = DAL.GetPolygons();
            CNs = new List<string>();
            int index = Polygons.Count - 1;

            if (Polygons != null && Polygons.Count > 0)
            {
                CurrentPolygon = Polygons[index];
                UpdatedPolygon = new TtPolygon(CurrentPolygon);
                _dirty = false;

                for (int i = 0; i < Polygons.Count; i++)
                {
                    CNs.Add(Polygons[i].CN);
                }

                actionsControlPolygons.MiscButtonEnabled = true;
            }
            else
            {
                CurrentPolygon = null;
                UpdatedPolygon = null;
                _dirty = false;
                Lock(true);
            }

            pointNavigationCtrl1.UpdatePointList(CNs, index);
            AdjustNavControls(index);

            Lock(true);
        }
コード例 #22
0
        public bool ImportTt2(List<string> cns, bool useGroups, bool useNmea)
        {
            try
            {
                Dictionary<string, TtMetaData> metas = new Dictionary<string, TtMetaData>();
                List<TtMetaData> tmpMeta = importDal.GetMetaData();

                foreach (TtMetaData meta in tmpMeta)
                {
                    meta.Name = String.Format("{0} {1}", meta.Name, "(Imported)");
                }

                Dictionary<string, TtMetaData> importedMetas = tmpMeta.ToDictionary(m => m.CN, m => m);
                tmpMeta.Clear();

                List<string> currPolyCNs = dal.GetPolygons().Select(p => p.CN).ToList();
                _Polygons = new Dictionary<string, TtPolygon>();
                _Points = new List<TtPoint>();
                Dictionary<string, TtPoint> tmpPoints = new Dictionary<string, TtPoint>();
                Dictionary<string, TtGroup> groups = dal.GetGroups().ToDictionary(g => g.CN, g => g);

                List<TwoTrails.GpsAccess.NmeaBurst> nmea = new List<TwoTrails.GpsAccess.NmeaBurst>();

                Action<TtPoint> parsePoint = null;
                parsePoint = (TtPoint ip) =>
                {
                    if(tmpPoints.ContainsKey(ip.CN))
                        return;

                    if (useGroups)
                    {
                        try
                        {
                            if (groups.ContainsKey(ip.GroupCN))
                            {
                                ip.GroupCN = ip.GroupCN;
                                ip.GroupName = groups[ip.GroupCN].Name;
                            }
                            else
                            {
                                dal.InsertGroup(importDal.GetGroupByCN(ip.GroupCN));
                                ip.GroupCN = ip.GroupCN;
                                ip.GroupName = groups[ip.GroupCN].Name;
                            }
                        }
                        catch
                        {
                            ip.GroupCN = Values.MainGroup.CN;
                            ip.GroupName = Values.MainGroup.Name;
                        }
                    }
                    else
                    {
                        ip.GroupCN = Values.MainGroup.CN;
                        ip.GroupName = Values.MainGroup.Name;
                    }

                    if (!metas.ContainsKey(ip.MetaDefCN))
                    {
                        metas.Add(ip.MetaDefCN, importedMetas[ip.MetaDefCN]);
                        dal.InsertMetaData(importedMetas[ip.MetaDefCN]);
                    }

                    if (useNmea && ip.IsGpsType())
                    {
                        nmea.AddRange(importDal.GetNmeaBurstsByPointCN(ip.CN));
                    }
                    else if (ip.op == OpType.Quondam)
                    {
                        parsePoint(importDal.GetPoint(((QuondamPoint)ip).ParentCN));
                    }

                    tmpPoints.Add(ip.CN, ip);
                };

                foreach (string icn in cns)
                {
                    if (currPolyCNs.Contains(icn))
                        continue;

                    _Poly = importDal.GetPolygonByCn(icn);

                    foreach (TtPoint ip in importDal.GetPointsInPolygon(_Poly.CN))
                    {
                        parsePoint(ip);
                    }

                    _Polygons.Add(_Poly.CN, _Poly);
                }

                foreach (TtPolygon poly in _Polygons.Values)
                    dal.InsertPolygon(poly);

                dal.InsertPoints(tmpPoints.Values.ToList());
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataImport:ImportTt2", ex.StackTrace);
                return false;
            }

            return true;
        }
コード例 #23
0
        public void Init(DataAccessLayer dal)
        {
            this.DialogResult = DialogResult.Abort;

            DAL = dal;
            _recalc = false;

            List<TtPolygon> polys = DAL.GetPolygons();

            if (polys.Count < 1)
            {
                MessageBox.Show("There are no Polygons to edit from.");
                return;
            }

            Polygons = new Dictionary<string, TtPolygon>();
            PolyNames = new Dictionary<string, string>();
            Points = new Dictionary<string, Dictionary<string, TtPoint>>();
            OldPoints = new Dictionary<string, Dictionary<string, TtPoint>>();

            _DeleteNmea = new List<string>();

            try
            {
                foreach (TtPolygon poly in polys)
                {
                    Polygons.Add(poly.CN, poly);
                    PolyNames.Add(poly.Name, poly.CN);
                    Points.Add(poly.CN, new Dictionary<string, TtPoint>());
                    OldPoints.Add(poly.CN, new Dictionary<string, TtPoint>());
                    foreach (TtPoint point in DAL.GetPointsInPolygon(poly.CN))
                    {
                        Points[poly.CN].Add(point.CN, point);
                        OldPoints[poly.CN].Add(point.CN, point);
                    }

                    cboPoly.Items.Add(poly.Name);
                }
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "MassEditFormLogic:Init");
                return;
            }

            if (Values.Settings.DeviceOptions.UseSelection)
            {
                cboPoly.Visible = false;

                btnPolygon.Visible = true;
            }
            else
            {
                cboPoly.Visible = true;

                btnPolygon.Visible = false;
            }

            CurrPoly = Polygons.First().Value;
            btnPolygon.Text = CurrPoly.Name;

            lstPoints.Columns.Add("Point", 70, HorizontalAlignment.Left);
            lstPoints.Columns.Add("Polygon", 70, HorizontalAlignment.Left);
            lstPoints.Columns.Add("Type", 70, HorizontalAlignment.Left);
            lstPoints.Columns.Add("OnBound", 50, HorizontalAlignment.Left);
            lstPoints.Columns.Add("CN", 180, HorizontalAlignment.Left);

            LoadPolygon();

            btnBnd.Text = "On";
            onBnd = true;

            this.DialogResult = DialogResult.Cancel;
        }
コード例 #24
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;
        }
コード例 #25
0
            public PolyWPoints(TtPolygon poly, DataAccessLayer DAL)
            {
                this.polygon = poly;
                this.points = DAL.GetPointsInPolygon(poly.CN);

                for (int i = 0; i < points.Count; i++)
                {
                    //points[i].AdjX *= -1;
                    points[i].AdjY *= -1;
                    //points[i].AdjZ *= -1;

                    //points[i].UnAdjX *= -1;
                    points[i].UnAdjY *= -1;
                    //points[i].UnAdjZ *= -1;
                }
            }
コード例 #26
0
        private void Merge(bool link)
        {
            int index = 0;
            newPoints = new List<TtPoint>();
            _NewPoly = new TtPolygon();

            _NewPoly.Name = txtNewPolyName.Text;

            if (radPoly1CW.Checked)
            {
                for (int i = cboStartPointPoly1.SelectedIndex; i <= cboEndPointPoly1.SelectedIndex; i++)
                {
                    newPoints.Add(MakePoint(point1StartList[i], _NewPoly, link, index));
                    index++;
                }
            }
            else
            {
                for (int i = cboEndPointPoly1.SelectedIndex; i >= cboStartPointPoly1.SelectedIndex; i--)
                {
                    newPoints.Add(MakePoint(point1StartList[i], _NewPoly, link, index));
                    index++;
                }
            }

            if (radPoly2CW.Checked)
            {
                for (int i = cboStartPointPoly2.SelectedIndex; i <= cboEndPointPoly2.SelectedIndex; i++)
                {
                    newPoints.Add(MakePoint(point2StartList[i], _NewPoly, link, index));
                    index++;
                }
            }
            else
            {
                for (int i = cboEndPointPoly2.SelectedIndex; i <= cboStartPointPoly2.SelectedIndex; i--)
                {
                    newPoints.Add(MakePoint(point2StartList[i], _NewPoly, link, index));
                    index++;
                }
            }

            foreach (TtPoint p in newPoints)
            {
                p.GroupName = Values.MainGroup.Name;
                p.GroupCN = Values.MainGroup.CN;
            }

            dal.InsertPolygon(_NewPoly);
            dal.InsertPoints(newPoints);

            _AllPolys.Add(_NewPoly);
            _Polys.Add(_NewPoly);
            polys1.Add(_NewPoly);
            polys2.Add(_NewPoly);
        }
コード例 #27
0
        private TtPoint MakePoint(TtPoint point, TtPolygon poly, bool link, int index)
        {
            if (link)
                point = new QuondamPoint() { ParentPoint = point };
            else
                point = TtUtils.ClonePoint(point);

            if (index == 0)
                point.PID = PointNaming.NameFirstPoint( _NewPoly);
            else
                point.PID = PointNaming.NamePoint(newPoints[ newPoints.Count - 1], _NewPoly);

            point.Index = index;
            point.MetaDefCN = _Meta.CN;

            return point;
        }
コード例 #28
0
        public WalkForm(TtPolygon poly, DataAccessLayer dal, TtMetaData meta, int cIndex)
        {
            InitializeComponent();

            Init(poly, dal, meta, cIndex);
        }
コード例 #29
0
        private void MergePolygonForm_Load(object sender, EventArgs e)
        {
            this.Icon = Properties.Resources.Map;

            polys1 = new BindingList<TtPolygon>(_Polys);
            cboPoly1.DataSource = polys1;
            cboPoly1.SelectedIndex = 0;
            _Poly1 = _Polys[0];
            lastPolyIndex1 = 0;

            polys2 = new BindingList<TtPolygon>(_Polys);
            cboPoly2.DataSource = polys2;
            cboPoly2.SelectedIndex = 1;
            _Poly2 = _Polys[1];
            lastPolyIndex1 = 1;

            point1StartList = new BindingList<TtPoint>(dal.GetPointsInPolygon(_Poly1.CN));
            point1EndList = new BindingList<TtPoint>(dal.GetPointsInPolygon(_Poly1.CN));
            point2StartList = new BindingList<TtPoint>(dal.GetPointsInPolygon(_Poly2.CN));
            point2EndList = new BindingList<TtPoint>(dal.GetPointsInPolygon(_Poly2.CN));

            cboStartPointPoly1.DataSource = point1StartList;
            cboStartPointPoly1.SelectedIndex = 0;
            cboStartPointPoly1.DisplayMember = "PID";

            cboEndPointPoly1.DataSource = point1EndList;
            cboEndPointPoly1.SelectedIndex = point1EndList.Count - 1;
            cboEndPointPoly1.DisplayMember = "PID";

            cboStartPointPoly2.DataSource = point2StartList;
            cboStartPointPoly2.SelectedIndex = 0;
            cboStartPointPoly2.DisplayMember = "PID";

            cboEndPointPoly2.DataSource = point2EndList;
            cboEndPointPoly2.SelectedIndex = point2EndList.Count - 1;
            cboEndPointPoly2.DisplayMember = "PID";

            txtNewPolyName.Text = String.Format("Poly {0}", _AllPolys.Count + 1);

            init = true;
        }
コード例 #30
0
        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();
        }