Esempio n. 1
0
        public bool sameAs(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            GeoCoord other = (GeoCoord)obj;

            other.Normalize();
            Normalize();
            return(other.Lat == m_Y && other.Lng == m_X);            // && other.Elev == m_H;
        }
Esempio n. 2
0
        // tolerance 0.0001 degree = 10 meters
        public bool almostAs(object obj, double tolerance)
        {
            if (obj == null)
            {
                return(false);
            }
            GeoCoord other = (GeoCoord)obj;

            other.Normalize();
            Normalize();
            return(Math.Abs(other.Lat - m_Y) <= tolerance && Math.Abs(other.Lng - m_X) <= tolerance);            // && other.Elev == m_H;
        }
Esempio n. 3
0
        private void act()
        {
            double lng = 0.0d;
            double lat = 0.0d;
            double elev = 0.0d;

            bool allcool = true;

            if(Project.coordStyle == 3)		// UTM?
            {
                // something like "11S 0432345E 3712345N" in the latitudeTextBox
                allcool = Project.mainCommand.fromUtmString(latitudeTextBox.Text, out lng, out lat);
                if(allcool)
                {
                    latLabel.ForeColor = Color.Black;
                }
                else
                {
                    latLabel.ForeColor = Color.Red;
                }
            }
            else
            {
                try
                {
                    lng = GeoCoord.stringLngToDouble(longitudeTextBox.Text);
                    lngLabel.ForeColor = Color.Black;
                }
                catch
                {
                    lngLabel.ForeColor = Color.Red;
                    allcool = false;
                }

                try
                {
                    lat = GeoCoord.stringLatToDouble(latitudeTextBox.Text);
                    latLabel.ForeColor = Color.Black;
                }
                catch
                {
                    latLabel.ForeColor = Color.Red;
                    allcool = false;
                }
            }

            try
            {
                Distance elevDist = new Distance(0.0d);
                int unitsCompl = elevDist.UnitsCompl;

                double nuElev = Convert.ToDouble(elevationTextBox.Text.Replace(",",""));
                elevDist.byUnits(nuElev, unitsCompl);

                elev = elevDist.Meters;

                if(elev < Project.cameraHeightMin*1000.0d)
                {
                    elevDist.byUnits(Project.cameraHeightMin*1000.0d, Distance.UNITS_DISTANCE_M);
                    elev = elevDist.Meters;
                }
                else if(elev > Project.CAMERA_HEIGHT_MAX*1000.0d)
                {
                    elevDist.byUnits(Project.CAMERA_HEIGHT_MAX*1000.0d, Distance.UNITS_DISTANCE_M);
                    elev = elevDist.Meters;
                }

                elevationUnitsLabel.Text = elevDist.toStringU(unitsCompl);

                elevLabel.ForeColor = Color.Black;
            }
            catch
            {
                elevLabel.ForeColor = Color.Red;
                allcool = false;
            }

            if(makeWaypointCheckBox.Checked && waypointNameTextBox.Text.Length == 0)
            {
                waypointNameLabel.ForeColor = Color.Red;
                allcool = false;
            }
            else
            {
                waypointNameLabel.ForeColor = Color.Black;
            }

            if(allcool)
            {
                try
                {
                    GeoCoord location = new GeoCoord(lng, lat, elev);
                    location.Normalize();
                    m_cameraManager.MarkLocation(location, 0);
                    if(makeWaypointCheckBox.Checked)
                    {
                        LiveObjectTypes type = LiveObjectTypes.LiveObjectTypeWaypoint;
                        bool isFound = false;
                        switch(waypointTypeComboBox.SelectedIndex)
                        {
                            case 0:
                                type = LiveObjectTypes.LiveObjectTypeWaypoint;
                                break;
                            case 1:
                                type = LiveObjectTypes.LiveObjectTypeGeocache;
                                break;
                            case 2:
                                type = LiveObjectTypes.LiveObjectTypeGeocache;
                                isFound = true;
                                break;
                        }
                        string stype = "" + waypointTypeComboBox.SelectedItem;
                        string comment = waypointNameTextBox.Text;
                        Waypoint wpt = new Waypoint(location, Project.localToZulu(DateTime.Now), type, -1L, comment, "", "");
                        wpt.Found = isFound;
                        WaypointsCache.WaypointsAll.Add(wpt);
                        WaypointsCache.WaypointsDisplayed.Add(wpt);
                        WaypointsCache.isDirty = true;
                        Project.drawWaypoints = true;
                        m_cameraManager.PictureManager.LayersManager.ShowWaypoints = true;
                        if(!moveCameraCheckBox.Checked)
                        {
                            Cursor.Current = Cursors.WaitCursor;
                        }
                        m_cameraManager.PictureManager.Refresh();
                    }
                    if(moveCameraCheckBox.Checked)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        m_cameraManager.SpoilPicture();
                        m_cameraManager.Location = new GeoCoord(location);		// must be a new instance of GeoCoord
                        setCoordTextBoxes();
                        Cursor.Current = Cursors.Default;
                    }
                }
                catch
                {
                    elevLabel.ForeColor = Color.Red;
                    allcool = false;
                }
            }
        }
Esempio n. 4
0
        protected override void act()
        {
            double lng;
            double lat;
            double elev;

            bool allcool = validateCoord(out lng, out lat, out elev);

            if(m_wpt.TrackId == -1)
            {
                if(waypointNameTextBox.Text.Length == 0)
                {
                    waypointNameLabel.ForeColor = Color.Red;
                    allcool = false;
                }
                else
                {
                    waypointNameLabel.ForeColor = Color.Black;
                }
            }

            if(allcool)
            {
                try
                {
                    GeoCoord location = new GeoCoord(lng, lat, elev);
                    location.Normalize();
                    if(m_wpt.TrackId == -1)
                    {
                        switch(waypointTypeComboBox.SelectedIndex)
                        {
                            case 0:
                                m_wpt.LiveObjectType = LiveObjectTypes.LiveObjectTypeWaypoint;
                                m_wpt.Found = false;
                                break;
                            case 1:
                                m_wpt.LiveObjectType = LiveObjectTypes.LiveObjectTypeGeocache;
                                m_wpt.Found = false;
                                break;
                            case 2:
                                m_wpt.LiveObjectType = LiveObjectTypes.LiveObjectTypeGeocache;
                                m_wpt.Found = true;
                                break;
                        }
                        m_wpt.WptName = waypointNameTextBox.Text.Trim();
                    }
                    m_wpt.Location = location;
                    if(timePicker.isActive)
                    {
                        m_wpt.DateTime = Project.localToZulu(timePicker.dateTime);
                    }
                    else
                    {
                        m_wpt.DateTime = DateTime.MinValue;
                    }
                    m_wpt.UrlName = urlNameTextBox.Text.Trim();
                    string url = urlTextBox.Text.Trim();
                    if(url.Equals("http://"))		// if something meaningful has been entered
                    {
                        url = "";
                    }
                    m_wpt.Url = url;
                    m_wpt.Comment = commentTextBox.Text.Trim();
                    m_wpt.Sym = symbolTextBox.Text.Trim();
                    m_wpt.Desc = detailTextBox.Text.Trim();
                    WaypointsCache.isDirty = true;
                    Project.drawWaypoints = true;
                    //this.Hide();
                    this.ClientSize = new Size(1,1);
                    Cursor.Current = Cursors.WaitCursor;
                    m_cameraManager.PictureManager.LayersManager.ShowWaypoints = true;
                    m_cameraManager.ProcessCameraMove();	// need to put on map
                    this.Close();
                }
                catch
                {
                    elevLabel.ForeColor = Color.Red;
                    allcool = false;
                }
            }
        }