예제 #1
0
 /// <summary>
 /// Clone constructor is needed for Magellan GetRoutes, when CreateInfo instances are buffered
 /// </summary>
 /// <param name="ci"></param>
 public CreateInfo(CreateInfo ci)
 {
     id = ci.id;
     type = ci.type;
     typeExtra = ci.typeExtra;
     lat = ci.lat;
     lng = ci.lng;
     elev = ci.elev;
     magn = ci.magn;
     dateTime = ci.dateTime;
     name = ci.name;
     urlName = ci.urlName;
     url = ci.url;
     desc = ci.desc;
     comment = ci.comment;
     sym = ci.sym;
     source = ci.source;
     par1 = ci.par1;
     node1 = ci.node1;	// ref
     node2 = ci.node2;	// ref
 }
예제 #2
0
        public void createWaypoint(CreateInfo ci, bool keepInView)
        {
            string cmd = "api|newwpt";

            cmd += "|" + ci.lat;
            cmd += "|" + ci.lng;
            cmd += "|" + ci.elev;
            cmd += "|" + ci.dateTime;
            cmd += "|" + ci.name;
            cmd += "|" + ci.urlName;
            cmd += "|" + ci.type;
            cmd += "|" + ci.typeExtra;
            cmd += "|" + ci.sym;
            cmd += "|" + ci.id;
            cmd += "|" + ci.url;
            cmd += "|" + ci.desc;
            cmd += "|" + ci.source;
            cmd += "|" + keepInView;

            CommandMappingEngine(cmd);
        }
예제 #3
0
        /// <summary>
        /// delete waypoint by one of: name, urlName, source
        /// </summary>
        /// <param name="ci"></param>
        /// <returns></returns>
        public void deleteWaypoint(CreateInfo ci)
        {
            string cmd = "api|delwpt";

            cmd += "|" + ci.name;
            cmd += "|" + ci.urlName;
            cmd += "|" + ci.source;

            CommandMappingEngine(cmd);
        }
예제 #4
0
        private void doWork()
        {
            try
            {
                // first make sure we are at a good altitude:
                string strCmd = "/map=aerial";
                qmApiLib.CommandMappingEngine(strCmd);

                qmApiLib.resetZoom();		// prepare for a zoom into whole set of waypoints created below

                DataRowCollection dra = m_dataSet.Tables["events"].Rows;

                int count = 0;
                foreach(DataRow row in dra)
                {
                    string sLat = "" + row["latitude"];
                    double lat = toDegree(sLat);
                    string sLon = "" + row["longitude"];
                    double lon = toDegree(sLon);

                    if(lon < lngMin || lon > lngMax)
                    {
                        continue;
                    }

                    string eventId = "" + row["ev_id"];
                    DateTime date = DateTime.MinValue;
                    string sDT0 = "";
                    try
                    {
                        DateTime dateLoc = (DateTime)row["ev_date"];
                        string sTimeLoc = "" + row["ev_time"];
                        if(sTimeLoc.Length < 4)
                        {
                            sTimeLoc = "0" + sTimeLoc;
                        }
                        sTimeLoc = sTimeLoc.Substring(0,2) + ":" + sTimeLoc.Substring(2,2) + ":00";
                        string timeZone = "" + row["ev_tmzn"];

                        sDT0 = dateLoc.ToShortDateString() + " " + sTimeLoc + " " + timeZone;

                        string timeShift = "+0";
                        switch (timeZone)
                        {
                            case "GMT":
                            case "UTC":
                                break;

                            case "ADT":
                                timeShift = "-9";
                                break;
                            case "AST":
                                timeShift = "-10";
                                break;
                            case "BDT":				// British
                                timeShift = "+0";
                                break;
                            case "BST":
                                timeShift = "+1";
                                break;
                            case "CDT":
                                timeShift = "-5";
                                break;
                            case "CST":
                                timeShift = "-6";
                                break;
                            case "EDT":
                                timeShift = "-4";
                                break;
                            case "EST":
                                timeShift = "-5";
                                break;
                            case "HDT":
                                timeShift = "-10";
                                break;
                            case "HST":
                                timeShift = "-11";
                                break;
                            case "MDT":
                                timeShift = "-6";
                                break;
                            case "MST":
                                timeShift = "-7";
                                break;
                            case "PDT":
                                timeShift = "-7";
                                break;
                            case "PST":
                                timeShift = "-8";
                                break;
                            case "YDT":					// Yukon
                                timeShift = "-9";
                                break;
                            case "YST":
                                timeShift = "-10";
                                break;
                        }
                        string sDT = dateLoc.ToShortDateString() + " " + sTimeLoc + timeShift;

                        string format = "M/d/yyyy H:mm:ssz";

                        CultureInfo en = new CultureInfo("en-US");
                        Thread.CurrentThread.CurrentCulture = en;

                        DateTime timeLoc = DateTime.ParseExact(sDT, format, en.DateTimeFormat);

                        TimeZone tz = TimeZone.CurrentTimeZone;

                        date = tz.ToUniversalTime(timeLoc);
                    }
                    catch {}
                    string type = "" + row["ev_type"];
                    string injLevel = "" + row["ev_highest_injury"];
                    int fatalities = 0;
                    string desc = "" + injLevel;

                    try
                    {
                        fatalities = Convert.ToInt32("" + row["inj_tot_f"]);
                    }
                    catch {}

                    if(fatalities > 0)
                    {
                        type += "-" + injLevel + "-" + fatalities;
                        desc += " - " + fatalities + " fatalities";
                    }

                    desc += " " + sDT0;

                    this.Invoke(new UpdateTextHandler(UpdateMessageText), new object[1] { eventId + " " + sLat + "=" + lat + " " + sLon + "=" + lon });

                    string url = "http://www.ntsb.gov/ntsb/brief.asp?ev_id=" + eventId;

                    CreateInfo ci = new CreateInfo();

                    ci.lng = lon;
                    ci.lat = lat;
                    ci.name = eventId;
                    ci.urlName = type + (date.Equals(DateTime.MinValue) ? "" : "-" + date.ToShortDateString());
                    ci.type = "waypoint";
                    ci.typeExtra = "NTSB Crash";
                    ci.url = url;
                    ci.dateTime = date;
                    ci.desc = desc;
                    ci.source = "NTSB Database - " + m_source;

                    bool keepInView = false;

                    this.Invoke(new UpdateTextHandler(UpdateMessageText), new object[1] { "Creating Waypoint" + eventId });

                    qmApiLib.createWaypoint(ci, keepInView);

                    count++;

                    Thread.Sleep(10);
                }
                this.Invoke(new UpdateTextHandler(UpdateMessageText), new object[1] { "Created " + count + " waypoints" });

                // perform zoom into the whole set of points:
                qmApiLib.doZoom();
            }
            catch (Exception exc)
            {
                this.Invoke(new UpdateTextHandler(UpdateMessageText), new object[1] { exc.Message });
            }
        }