Exemplo n.º 1
0
        /// <summary>
        /// KmlDocument 의 Visibility 변경
        /// </summary>
        /// <param name="document"></param>
        /// <param name="isVisible"></param>
        public void SetKmlDocumentVisible(IKmlDocument document, bool isVisible)
        {
            if (document == null)
            {
                System.Console.WriteLine("SetKmlDocumentVisible - KmlDocument is null");
                FileLogManager.GetInstance().WriteLog("[GEController] SetKmlDocumentVisible( KmlDocument is null )");

                return;
            }

            try
            {
                document.setVisibility(Convert.ToInt32(isVisible));

                KmlObjectListCoClass kmlObjectListCoClass = document.getFeatures().getChildNodes();
                for (int i = 0; i < kmlObjectListCoClass.getLength(); i++)
                {
                    IKmlObject kmlObject = kmlObjectListCoClass.item(i);
                    string     strType   = kmlObject.getType();
                    if (strType == "KmlPlacemark")
                    {
                        IKmlPlacemark placemark = kmlObject as IKmlPlacemark;
                        placemark.setVisibility(Convert.ToInt32(isVisible));
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("SetKmlDocumentVisible Exception : " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[GEController] SetKmlDocumentVisible( " + ex.ToString() + " )");
            }
        }
Exemplo n.º 2
0
        /*
         * get the trip distance from kml
         */
        public static double getDistance(IKmlPlacemark point)
        {
            String xml  = point.getDescription();
            String temp = System.Text.RegularExpressions.Regex.Split(xml, "Distance</td><td>")[1];

            return(double.Parse((String)temp.Split('<')[0]));
        }
Exemplo n.º 3
0
        public Boolean make_start_test(String name)
        {
            IKmlFolder     t_name      = t_pool.getByName(name);
            IKmlPlacemark  init_start  = t_pool.getStart(t_name);
            IKmlObjectList init_points = t_name.getFeatures().getChildNodes();

            // int init_size = init_points.getLength() - 1;
            String[] att1 = t_pool.getAttByName(name);

            //  core.makeStart(name, t_name);
            //IKmlObjectList final_points = t_name.getFeatures().getChildNodes();

            // Hashtable cord1 = getCoordinates(final_start);

            Boolean gflag = true;

            try
            {
                IKmlPlacemark final_start = t_pool.getStart(t_name);
                String        final_name  = final_start.getName();
                //Case 1: compare initial name and final name of start point
                Assert.AreEqual(name, final_name);



                Console.WriteLine("     >>>>>>>>>> Passed the test for make start at GUI level <<<<<<");
            }
            catch
            {
                Console.WriteLine("    ----------> Failed the test for make start at GUI level <------");
                gflag = false;
            }
            return(gflag);
        }
Exemplo n.º 4
0
        /*
         * add a new trip to the end of trippool
         */
        public void add(IKmlFolder trip)
        {
            IKmlFolder     addTrip     = trip;
            IKmlObjectList points      = trip.getFeatures().getChildNodes();
            IKmlPlacemark  startPoint  = (IKmlPlacemark)points.item(0);
            IKmlPlacemark  finishPoint = (IKmlPlacemark)points.item(points.getLength() - 1);
            String         startTime   = startPoint.getName();
            String         finishTime  = finishPoint.getName();
            String         startLong   = Module.getCoordinates(startPoint)["lon"].ToString();
            String         startLat    = Module.getCoordinates(startPoint)["lat"].ToString();
            String         time        = (DateTime.Parse(finishTime) - DateTime.Parse(startTime)).ToString();
            String         distance    = Module.calDistance(trip).ToString();
            String         finishLong  = Module.getCoordinates(finishPoint)["lon"].ToString();
            String         finishLat   = Module.getCoordinates(finishPoint)["lat"].ToString();

            String[] timeSplit = new String[3];
            timeSplit = time.ToString().Split(':');
            double coEff = (3600 / (double)((Convert.ToInt32(timeSplit[0]) * 3600) + (Convert.ToInt32(timeSplit[1]) * 60) + (Convert.ToInt32(timeSplit[2]))));
            String speed = Math.Round((double.Parse(distance) * coEff), 3).ToString();

            _core.Add(addTrip);
            //_attr.Add(addAtt);
            TripDetails.Rows.Add(tripCount, Day, "-", HouseHoldID, "-", Date, WeekDay, startTime, finishTime, time, distance, speed, startLong, startLat, finishLong, finishLat, "-");
            ++tripCount;
        }
Exemplo n.º 5
0
        public void insertTrip(IKmlFolder trip, String tripNumber, TripPool t_pool)
        {
            //This will add a trip to the dataTable
            addToUndoTypeTable("Insert");
            undoTable.Rows.Add(tripNumber, "");
            DataRow row = NewRowDataTableCustom();

            row[0] = tripNumber;
            row[1] = databaseViewer.Rows[0][1];
            //The trip count will be set with the resetTripCount
            row[3] = databaseViewer.Rows[0][3];
            row[4] = databaseViewer.Rows[0][4];
            row[5] = databaseViewer.Rows[0][5];
            row[6] = databaseViewer.Rows[0][6];
            IKmlObjectList points      = trip.getFeatures().getChildNodes();
            IKmlPlacemark  startPoint  = (IKmlPlacemark)points.item(0);
            IKmlPlacemark  finishPoint = (IKmlPlacemark)points.item(points.getLength() - 1);

            row[12] = Module.getCoordinates(startPoint)["lon"].ToString();
            row[13] = Module.getCoordinates(startPoint)["lat"].ToString();
            row[14] = Module.getCoordinates(finishPoint)["lon"].ToString();
            row[15] = Module.getCoordinates(finishPoint)["lat"].ToString();
            databaseViewer.Rows.InsertAt(row, Convert.ToInt32(tripNumber) - 1);
            DataRow newRowKML = t_pool.NewRowDataTableCustom();

            newRowKML = copyDataRowContents(row, newRowKML);
            t_pool.getTripDetails().Rows.InsertAt(newRowKML, Convert.ToInt32(tripNumber) - 1);
            completeMissingData(t_pool);
            t_pool.resetTripCount();
            resetTripCountForDay();
        }
Exemplo n.º 6
0
 public void crt_point(IKmlPlacemark data)
 {
     Hashtable mem = new Hashtable();
     mem["opt"] = "crt";
     mem["data"] = data;
     timeline.Insert(0, mem);
 }
Exemplo n.º 7
0
        public void highlight(String name)
        {
            if (p_highlight != "")
            {
                de_highlight();
            }
            IKmlFolder    trip    = getByName(name);
            IKmlPlacemark s_point = getStart(trip);
            IKmlPlacemark f_point = getFinish(trip);

            if (s_point == f_point)
            {
                return;
            }

            String col = ((IKmlPlacemark)trip.getFeatures().getChildNodes().item(0)).getComputedStyle().getIconStyle().getColor().get();

            IKmlIcon icon = ge.createIcon("");

            icon.setHref(@"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png");
            IKmlStyle ssty = ge.createStyle("");

            ssty.getIconStyle().setIcon(icon);
            ssty.getIconStyle().setScale((float)0.9);
            ssty.getIconStyle().getColor().set(col);

            s_point.setStyleSelector(ssty);
            f_point.setStyleSelector(ssty);
            p_highlight = name;
        }
Exemplo n.º 8
0
 public void add(String name, IKmlPlacemark point)
 {
     if (!core.ContainsKey(name))
     {
         core[name] = new ArrayList();
     }
     core[name] = point;
 }
Exemplo n.º 9
0
 public void add(String name, IKmlPlacemark point)
 {
     if (!core.ContainsKey(name))
     {
         core[name] = new ArrayList();
     }
     core[name] = point;
 }
Exemplo n.º 10
0
 public void dehighlight()
 {
     if (p_highlight != "")
     {
         IKmlPlacemark point = getByName(p_highlight);
         point.getComputedStyle().getIconStyle().setScale((float)0.3);
     }
 }
Exemplo n.º 11
0
        public void crt_point(IKmlPlacemark data)
        {
            Hashtable mem = new Hashtable();

            mem["opt"]  = "crt";
            mem["data"] = data;
            timeline.Insert(0, mem);
        }
Exemplo n.º 12
0
        public void highlight(String name)
        {
            if (p_highlight != "")
            {
                dehighlight();
            }
            IKmlPlacemark point = getByName(name);

            point.getComputedStyle().getIconStyle().setScale((float)0.5);
            p_highlight = name;
        }
Exemplo n.º 13
0
 /*
  * get the GPS coordinate of a point
  */
 public static Hashtable getCoordinates(IKmlPlacemark point)
 {
     Hashtable cods = new Hashtable();
     String xml = point.getKml();
     String temp = System.Text.RegularExpressions.Regex.Split(xml, "<coordinates>")[1];
     String coords = System.Text.RegularExpressions.Regex.Split(temp, "</coordinates>")[0];
     Array value = System.Text.RegularExpressions.Regex.Split(coords, ",");
     cods["lon"] = double.Parse((String)value.GetValue(0));
     cods["lat"] = double.Parse((String)value.GetValue(1));
     return cods;
 }
Exemplo n.º 14
0
 public void de_highlight()
 {
     if (p_highlight != "")
     {
         IKmlPlacemark p_s_point = getStart(getByName(p_highlight));
         IKmlPlacemark p_f_point = getFinish(getByName(p_highlight));
         p_s_point.setStyleUrl(_style);
         p_f_point.setStyleUrl(_style);
         p_highlight = "";
     }
 }
Exemplo n.º 15
0
        private Hashtable getCoordinates(IKmlPlacemark point)
        {
            Hashtable cods   = new Hashtable();
            String    xml    = point.getKml();
            String    temp   = System.Text.RegularExpressions.Regex.Split(xml, "<coordinates>")[1];
            String    coords = System.Text.RegularExpressions.Regex.Split(temp, "</coordinates>")[0];
            Array     value  = System.Text.RegularExpressions.Regex.Split(coords, ",");

            cods["lon"] = value.GetValue(1);
            cods["lat"] = value.GetValue(0);
            return(cods);
        }
Exemplo n.º 16
0
        public Hashtable getCoordinates(String name)
        {
            Hashtable     cods   = new Hashtable();
            IKmlPlacemark point  = getByName(name);
            String        xml    = point.getKml();
            String        temp   = System.Text.RegularExpressions.Regex.Split(xml, "<coordinates>")[1];
            String        coords = System.Text.RegularExpressions.Regex.Split(temp, "</coordinates>")[0];
            Array         value  = System.Text.RegularExpressions.Regex.Split(coords, ",");

            cods["lat"] = float.Parse((String)value.GetValue(1));
            cods["lon"] = float.Parse((String)value.GetValue(0));
            return(cods);
        }
Exemplo n.º 17
0
        public PointPool(IKmlFolder trip)
        {
            core  = new Hashtable();
            names = new ArrayList();
            IKmlObjectList points = trip.getFeatures().getChildNodes();

            for (int i = 0; i < points.getLength(); i++)
            {
                IKmlPlacemark pt = (IKmlPlacemark)points.item(i);
                core[pt.getName()] = pt;
                names.Add(pt.getName());
            }
            p_highlight = "";
            _style      = "";
        }
Exemplo n.º 18
0
        public void highlight(String name)
        {
            if (p_highlight != "")
            {
                de_highlight();
            }
            IKmlFolder    trip    = getByName(name);
            IKmlPlacemark s_point = getStart(trip);
            IKmlPlacemark f_point = getFinish(trip);

            _style = s_point.getStyleUrl();
            s_point.setStyleUrl("");
            f_point.setStyleUrl("");
            p_highlight = name;
        }
Exemplo n.º 19
0
        public Hashtable getFocus(String name)
        {
            Hashtable     output  = new Hashtable();
            IKmlFolder    trip    = getByName(name);
            IKmlPlacemark s_point = getStart(trip);
            IKmlPlacemark f_point = getFinish(trip);
            Hashtable     s_cords = getCoordinates(s_point);
            Hashtable     f_cords = getCoordinates(f_point);
            float         m_lon   = (float.Parse((String)s_cords["lon"]) + float.Parse((String)f_cords["lon"])) / 2;
            float         m_lat   = (float.Parse((String)s_cords["lat"]) + float.Parse((String)f_cords["lat"])) / 2;

            output["lon"] = m_lon;
            output["lat"] = m_lat;
            return(output);
        }
Exemplo n.º 20
0
        public void highlight(IKmlPlacemark point)
        {
            de_highlight();

            IKmlIcon icon = ge.createIcon("");

            icon.setHref(@"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png");
            IKmlStyle ssty = ge.createStyle("");

            ssty.getIconStyle().setIcon(icon);
            ssty.getIconStyle().setScale((float)0.9);
            ssty.getIconStyle().getColor().set(point.getComputedStyle().getIconStyle().getColor().get());

            point.setStyleSelector(ssty);
            sel_point = point;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Icon을 생성하여 GEPlugin 에 Append
        /// </summary>
        /// <param name="placemarkID"></param>
        /// <param name="iconName"></param>
        /// <param name="iconURL"></param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        public void CreateSystemIcon(string placemarkID, string iconName, string iconUrl, double latitude, double longitude)
        {
            try
            {
                if (this.ge == null)
                {
                    FileLogManager.GetInstance().WriteLog("[GEController] CreateSystemIcon( GEPlugin is null. )");

                    throw new Exception("External Exception : GEPlugin is null.");
                }

                //아이콘 생성---------------------------------------시작
                IKmlPlacemark placemark = ge.createPlacemark("icon" + placemarkID);
                placemark.setDescription(iconName);
                if (!string.IsNullOrEmpty(iconUrl))
                {
                    //아이콘 스타일 변경----------------------------시작
                    IKmlIcon icon = ge.createIcon("");
                    icon.setHref(iconUrl);
                    IKmlStyle style = ge.createStyle("");
                    style.getIconStyle().setIcon(icon);
                    placemark.setStyleSelector(style);
                    //아이콘 스타일 변경------------------------------끝
                }
                else
                {
                    //아이콘 스타일 변경----------------------------시작
                    IKmlIcon icon = ge.createIcon("");
                    icon.setHref("http://maps.google.com/mapfiles/kml/paddle/red-circle.png");
                    IKmlStyle style = ge.createStyle("");
                    style.getIconStyle().setIcon(icon);
                    placemark.setStyleSelector(style);
                    //아이콘 스타일 변경------------------------------끝
                }
                IKmlPoint point = ge.createPoint("");
                point.setLatitude(latitude);
                point.setLongitude(longitude);
                placemark.setGeometry(point);
                ge.getFeatures().appendChild(placemark);
                //아이콘 생성-----------------------------------------끝
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("CreateSystemIcon Exception : " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[GEController] CreateSystemIcon( " + ex.ToString() + " )");
            }
        }
Exemplo n.º 22
0
        public void addToEnd(string name, IKmlPlacemark point)
        {
            IKmlFolder     trip   = getByName(name);
            IKmlObjectList points = trip.getFeatures().getChildNodes();

            String col = ((IKmlPlacemark)trip.getFeatures().getChildNodes().item(2)).getComputedStyle().getIconStyle().getColor().get();

            IKmlStyleMap sm        = ge.createStyleMap("");
            IKmlStyle    normal    = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3);
            IKmlStyle    highlight = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4);

            sm.setNormalStyle(normal);
            sm.setHighlightStyle(highlight);
            point.setStyleSelector(sm);

            trip.getFeatures().appendChild(point);
        }
Exemplo n.º 23
0
        public Boolean join(String t_name1, String t_name2)
        {
            try
            {
                IKmlFolder temp  = ge.createFolder("");
                String[]   trip1 = t_pool.getTripDetailsForTrip(Module.getIndex(t_name1).ToString());
                String[]   trip2 = t_pool.getTripDetailsForTrip(Module.getIndex(t_name2).ToString());

                IKmlPlacemark point = t_pool.getStart(t_pool.getByName(t_name2));

                String[] trip = (String[])trip1.Clone();

                /*               trip[5] = trip2[5];
                 *             trip[6] = Module.duration(trip[4], trip[5]);
                 *             trip[11] = trip2[11];
                 *             trip[12] = trip2[12];
                 */
                Hashtable cord1 = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(t_name1)));
                Hashtable cord2 = Module.getCoordinates(t_pool.getStart(t_pool.getByName(t_name2)));

/*
 *              trip[7] = (double.Parse(trip1[7]) + double.Parse(trip2[7]) + DistanceAlgorithm.DistanceBetweenPlaces((double)cord1["lat"], (double)cord1["lon"]
 *                          , (double)cord2["lat"], (double)cord2["lon"])).ToString();
 *
 *              trip[8] = Math.Round((double.Parse(trip[7]) / Module.durationConverter(trip[6])), 3).ToString();
 */
                String         style = t_pool.insert(t_name1, temp, trip, ge.createStyle(""));
                IKmlObjectList days  = ge.getFeatures().getChildNodes();
                IKmlDocument   day   = (IKmlDocument)days.item(0);
                day.getFeatures().appendChild(temp);

                ArrayList data = new ArrayList();
                data.Add(t_name1);
                data.Add(point);
                data.Add(trip1);
                data.Add(trip2);
                data.Add(style);
                record.joi_trip(data);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 24
0
        public String insert(String name, IKmlFolder trip, String[] att)
        {
            de_highlight();
            int    index  = int.Parse(name.Split('_')[1]);
            String style  = "";
            String _style = "";

            IKmlFolder temp1 = getByName("Trip_" + index);
            IKmlFolder temp2 = getByName("Trip_" + (index + 1));

            IKmlObjectList points = temp1.getFeatures().getChildNodes();

            for (int ii = 0; ii != points.getLength(); ii++)
            {
                IKmlPlacemark point = (IKmlPlacemark)points.item(ii);
                trip.getFeatures().appendChild(point);
                if (ii == 1)
                {
                    style = point.getStyleUrl();
                }
            }

            points = temp2.getFeatures().getChildNodes();
            for (int ii = 0; ii != points.getLength(); ii++)
            {
                IKmlPlacemark point = (IKmlPlacemark)points.item(ii);
                if (ii == 1)
                {
                    _style = point.getStyleUrl();
                }
                point.setStyleUrl(style);
                trip.getFeatures().appendChild(point);
            }

            _core.RemoveAt(index - 1);
            _attr.RemoveAt(index - 1);

            _core.RemoveAt(index - 1);
            _attr.RemoveAt(index - 1);

            _core.Insert(index - 1, trip);
            _attr.Insert(index - 1, att);

            return(_style);
        }
Exemplo n.º 25
0
        public String ch_col(String name, String col)
        {
            IKmlStyleMap sm        = ge.createStyleMap("");
            IKmlStyle    normal    = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3);
            IKmlStyle    highlight = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4);

            sm.setNormalStyle(normal);
            sm.setHighlightStyle(highlight);
            IKmlFolder     trip   = getByName(name);
            IKmlObjectList points = trip.getFeatures().getChildNodes();
            String         temp   = ((IKmlPlacemark)points.item(0)).getComputedStyle().getIconStyle().getColor().get();

            for (int i = 0; i < points.getLength(); i++)
            {
                IKmlPlacemark pt = (IKmlPlacemark)points.item(i);
                pt.setStyleSelector(sm);
            }
            return(temp);
        }
Exemplo n.º 26
0
        public void addAtPosition(IKmlFolder trip, int tripNumber)
        {
            IKmlFolder     addTrip     = trip;
            IKmlObjectList points      = trip.getFeatures().getChildNodes();
            IKmlPlacemark  startPoint  = (IKmlPlacemark)points.item(0);
            IKmlPlacemark  finishPoint = (IKmlPlacemark)points.item(points.getLength() - 1);
            String         startTime   = startPoint.getName();
            String         finishTime  = finishPoint.getName();
            String         startLong   = Module.getCoordinates(startPoint)["lon"].ToString();
            String         startLat    = Module.getCoordinates(startPoint)["lat"].ToString();
            String         time        = (DateTime.Parse(finishTime) - DateTime.Parse(startTime)).ToString();
            String         distance    = Module.calDistance(trip).ToString();
            String         finishLong  = Module.getCoordinates(finishPoint)["lon"].ToString();
            String         finishLat   = Module.getCoordinates(finishPoint)["lat"].ToString();

            String[] timeSplit = new String[3];
            timeSplit = time.ToString().Split(':');
            double coEff = (3600 / (double)((Convert.ToInt32(timeSplit[0]) * 3600) + (Convert.ToInt32(timeSplit[1]) * 60) + (Convert.ToInt32(timeSplit[2]))));
            String speed = Math.Round((double.Parse(distance) * coEff), 3).ToString();
            //          _core.Add(addTrip);
            //_attr.Add(addAtt);
            DataRow newRow = NewRowDataTableCustom();

            newRow["KMLTrip"]     = tripCount;
            newRow["HouseHoldID"] = HouseHoldID;
            newRow["Trip"]        = "-";
            newRow["Person"]      = "-";
            newRow["Day"]         = Day;
            newRow["Date"]        = Date;
            newRow["WeekDay"]     = WeekDay;
            newRow["Start Time"]  = startTime;
            newRow["Finish Time"] = finishTime;
            newRow["Time"]        = time;
            newRow["Distance"]    = distance;
            newRow["Speed"]       = speed;
            newRow["StartLong"]   = startLong;
            newRow["StartLat"]    = startLat;
            newRow["Finishlong"]  = finishLong;
            newRow["FinishLat"]   = finishLat;
            newRow["Remain"]      = "-";
            TripDetails.Rows.InsertAt(newRow, tripNumber);
            resetTripCount();
        }
Exemplo n.º 27
0
        /*
         * distance calculation using big-circle formula
         */
        public static double calDistance(IKmlFolder trip)
        {
            double         distance = 0;
            IKmlObjectList points   = trip.getFeatures().getChildNodes();
            IKmlPlacemark  prev     = null;

            for (int i = 0; i != (points.getLength()); i++)
            {
                IKmlPlacemark curr = (IKmlPlacemark)points.item(i);
                if (prev != null)
                {
                    double d = DistanceAlgorithm.DistanceBetweenPlaces((double)getCoordinates(curr)["lat"], (double)getCoordinates(curr)["lon"]
                                                                       , (double)getCoordinates(prev)["lat"], (double)getCoordinates(prev)["lon"]);
                    distance += d;
                }
                prev = curr;
            }
            return(Math.Round(distance, 3));
        }
Exemplo n.º 28
0
        public IKmlPlacemark getNextPoint(IKmlFolder trip, IKmlPlacemark point)
        {
            bool           flag   = false;
            IKmlObjectList points = trip.getFeatures().getChildNodes();

            for (int i = 0; i != points.getLength(); ++i)
            {
                IKmlPlacemark pt = (IKmlPlacemark)points.item(i);
                if (flag == true)
                {
                    return(pt);
                }
                if (pt.getName() == point.getName())
                {
                    flag = true;
                }
            }
            return(null);
        }
Exemplo n.º 29
0
        public void de_highlight()
        {
            if (p_highlight != "")
            {
                IKmlPlacemark p_s_point = getStart(getByName(p_highlight));
                IKmlPlacemark p_f_point = getFinish(getByName(p_highlight));

                String col = ((IKmlPlacemark)getByName(p_highlight).getFeatures().getChildNodes().item(0)).getComputedStyle().getIconStyle().getColor().get();

                IKmlStyleMap sm        = ge.createStyleMap("");
                IKmlStyle    normal    = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3);
                IKmlStyle    highlight = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4);
                sm.setNormalStyle(normal);
                sm.setHighlightStyle(highlight);
                p_s_point.setStyleSelector(sm);
                p_f_point.setStyleSelector(sm);

                p_highlight = "";
            }
        }
Exemplo n.º 30
0
 public void makeFinish(String trip, IKmlPlacemark newFinishPoint, TripPool t_pool)
 {
     //This function will change the starting time of a trip
     //First we'll find the row to edit. The trip should match
     for (int i = 0; i < databaseViewer.Rows.Count; ++i)
     {
         if (databaseViewer.Rows[i]["KMLTrip"].ToString().Equals(trip))
         {
             addToUndotable(databaseViewer.Rows[i]);
             addToUndoTypeTable("Make Finish");
             databaseViewer.Rows[i]["Finish"]     = newFinishPoint.getName();
             databaseViewer.Rows[i]["fLongitude"] = Module.getCoordinates(newFinishPoint)["lon"];
             databaseViewer.Rows[i]["fLatitude"]  = Module.getCoordinates(newFinishPoint)["lat"];
             t_pool.getTripDetails().Rows[i]["FinishLong"]  = Module.getCoordinates(newFinishPoint)["lon"];
             t_pool.getTripDetails().Rows[i]["FinishLat"]   = Module.getCoordinates(newFinishPoint)["lat"];
             t_pool.getTripDetails().Rows[i]["Finish Time"] = newFinishPoint.getName();
             t_pool.resetTripData("Trip_" + trip);
             completeMissingData(t_pool, trip);
         }
     }
 }
Exemplo n.º 31
0
        public void SetIconUrl(IKmlPlacemark placemark, string iconUrl, bool isSelect)
        {
            try
            {
                if (this.ge == null)
                {
                    FileLogManager.GetInstance().WriteLog("[GEController] SetIconUrl( GEPlugin is null. )");

                    throw new Exception("External Exception : GEPlugin is null.");
                }

                string url = iconUrl;
                //아이콘 스타일 변경----------------------------시작
                IKmlIcon icon = ge.createIcon("");
                if (isSelect)
                {
                    if (!url.Contains("_preferences"))
                    {
                        url = url.Split('.')[0] + "_preferences." + url.Split('.')[1];
                    }
                }
                else
                {
                    if (url.Contains("_preferences"))
                    {
                        url = url.Replace("_preferences", "");
                    }
                }
                icon.setHref(url);
                IKmlStyle style = ge.createStyle("");
                style.getIconStyle().setIcon(icon);
                placemark.setStyleSelector(style);
                //아이콘 스타일 변경------------------------------끝
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("SetIconUrl Exception : " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[GEController] SetIconUrl( " + ex.ToString() + " )");
            }
        }
Exemplo n.º 32
0
        public void resetTripData(String trip)
        {
            IKmlFolder tripData = getByName(trip);

            for (int i = 0; i != TripDetails.Rows.Count; ++i)
            {
                if (TripDetails.Rows[i]["KMLTrip"].ToString().Trim().Equals(Module.getIndex(trip).ToString()))
                {
                    //                   MessageBox.Show("FCKING "+trip);
                    IKmlFolder     addTrip     = tripData;
                    IKmlObjectList points      = tripData.getFeatures().getChildNodes();
                    IKmlPlacemark  startPoint  = (IKmlPlacemark)points.item(0);
                    IKmlPlacemark  finishPoint = (IKmlPlacemark)points.item(points.getLength() - 1);
                    String         startTime   = startPoint.getName();
                    String         finishTime  = finishPoint.getName();
                    String         startLong   = Module.getCoordinates(startPoint)["lon"].ToString();
                    String         startLat    = Module.getCoordinates(startPoint)["lat"].ToString();
                    String         time        = (Convert.ToDateTime(finishTime) - Convert.ToDateTime(startTime)).ToString();
                    String         distance    = Module.calDistance(tripData).ToString();
                    String         finishLong  = Module.getCoordinates(finishPoint)["lon"].ToString();
                    String         finishLat   = Module.getCoordinates(finishPoint)["lat"].ToString();
                    String[]       timeSplit   = new String[3];
                    timeSplit = time.ToString().Split(':');
                    double coEff = (3600 / (double)((Convert.ToInt32(timeSplit[0]) * 3600) + (Convert.ToInt32(timeSplit[1]) * 60) + (Convert.ToInt32(timeSplit[2]))));
                    String speed = Math.Round((double.Parse(distance) * coEff), 3).ToString();
                    TripDetails.Rows[i]["Start Time"]  = startTime;
                    TripDetails.Rows[i]["Finish Time"] = finishTime;
                    TripDetails.Rows[i]["Time"]        = time;
                    TripDetails.Rows[i]["Distance"]    = distance;
                    TripDetails.Rows[i]["Speed"]       = speed;
                    TripDetails.Rows[i]["StartLong"]   = startLong;
                    TripDetails.Rows[i]["StartLat"]    = startLat;
                    TripDetails.Rows[i]["Finishlong"]  = finishLong;
                    TripDetails.Rows[i]["FinishLat"]   = finishLat;
                    TripDetails.Rows[i]["Remain"]      = "-";
                }
            }
        }
Exemplo n.º 33
0
        public IKmlCamera allocate()
        {
            double         lat = 0, lon = 0;
            IKmlObjectList days  = ge.getFeatures().getChildNodes();
            IKmlDocument   day   = (IKmlDocument)days.item(0);
            IKmlObjectList trips = day.getFeatures().getChildNodes();

            for (int i = 0; i != (t_pool.getSize() / 2); i++)
            {
                IKmlFolder     trip   = t_pool.getByName("Trip_" + (i + 1));
                IKmlObjectList points = trip.getFeatures().getChildNodes();
                IKmlPlacemark  point  = (IKmlPlacemark)points.item(1);

                lon = (double)Module.getCoordinates(point)["lon"];
                lat = (double)Module.getCoordinates(point)["lat"];
            }
            //lon = lon / t_pool.getSize();
            // lat = lat / t_pool.getSize();
            IKmlCamera vw = ge.createCamera("");

            vw.set(lat, lon, 25000.0, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 0);
            return(vw);
        }
Exemplo n.º 34
0
 /*
  * This function is called by the placemark double clicking event handler, the argument is the particular point
  */
 public void JScallName(IKmlPlacemark point)
 {
     core.highlight(point);
 }
Exemplo n.º 35
0
        public void JSInitSuccessCallback_(object pluginInstance)
        {
            ge = (IGEPlugin)pluginInstance;
            ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
            btResetTilt.Visible = true;
            ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, 1);
            panel1.Enabled = true;
            Console.WriteLine("Google Earth GUI established");
            start = ge.createPlacemark("");
            finish = ge.createPlacemark("");
            t_pool = new TripPool(ge);

            loadSession();
        }
Exemplo n.º 36
0
        public void loadSession()
        {
            //If file doesnt exist, we must create it
            if (!File.Exists("data.txt"))
            {
                File.Create("data.txt").Dispose();
            }
            // Check if file contains data and correct data before attempting reload the session
            if (new FileInfo("data.txt").Length > 0)
            {
                using (StreamReader reader = new StreamReader("data.txt"))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        list.Add(line); // Add to list.
                        Console.WriteLine(line); // Write to console.
                    }
                    // close the stream
                    reader.Close();
                }

                if (list.Count == 6)
                {
                    kmlfpath = list[0].ToString();
                    kmlex = list[1].ToString();
                    kmln = list[2].ToString();

                    txtfpath = list[3].ToString();
                    txtex = list[4].ToString();
                    txtn = list[5].ToString();

                    btLoad.PerformClick();
                }
                else
                {
                    MessageBox.Show("Cannot peform Restart due to error inside data.txt. Data.txt is cleared.");
                }
                // Must clear the textfile after it has been reload a session /
                File.Create("data.txt").Dispose();

            }
        }
Exemplo n.º 37
0
 public void highlight(IKmlPlacemark point)
 {
     de_highlight();
     sel_style = point.getStyleUrl();
     point.setStyleUrl("");
     sel_point = point;
 }
Exemplo n.º 38
0
        private void selectTextDataRow(object sender, DataGridViewCellMouseEventArgs e)
        {
            if ( textPointSet == true )
            {
                ge.getFeatures().removeChild(start);
                ge.getFeatures().removeChild(finish);
            }
            float scale = 2;
            textPointSet = true;
            //When you select a row in the DataTable it populates it's information in the Panel
            DataGridViewRow row = textDataGrid.SelectedRows[0];
            startTimeText.Text = row.Cells[7].Value.ToString();
            finishTimeText.Text = row.Cells[8].Value.ToString();
            startCoordinatesText.Text = row.Cells[12].Value.ToString() + ", " + row.Cells[13].Value.ToString();
            finishCoordinatesText.Text = row.Cells[14].Value.ToString() + ". " + row.Cells[15].Value.ToString();
            distanceText.Text = row.Cells[10].Value.ToString() + " km";
            timeText.Text = row.Cells[9].Value.ToString() + " hrs";
            speedText.Text = Math.Round(Convert.ToDecimal(row.Cells[11].Value), 2).ToString() + " kmph";
            panel6.Visible = true;

            IKmlIcon startIcon = ge.createIcon("");
            startIcon.setHref("http://maps.google.com/mapfiles/kml/paddle/S.png");
            IKmlStyle startPointStyle = ge.createStyle("");
            startPointStyle.getIconStyle().setIcon(startIcon);
            startPointStyle.getIconStyle().setScale(scale);

            IKmlIcon finishIcon = ge.createIcon("");
            finishIcon.setHref("http://maps.google.com/mapfiles/kml/paddle/F.png");
            IKmlStyle finishPointStyle = ge.createStyle("");
            finishPointStyle.getIconStyle().setIcon(finishIcon);
            finishPointStyle.getIconStyle().setScale(scale);

            IKmlPlacemark textTripStartPlaceMark = ge.createPlacemark("start" + temp);
            IKmlPlacemark textTripFinishPlaceMark = ge.createPlacemark("finish" + temp);
            ++temp;

            textTripStartPlaceMark.setStyleSelector(startPointStyle);
            textTripFinishPlaceMark.setStyleSelector(finishPointStyle);

            IKmlPoint textTripStartPoint = ge.createPoint("");
            IKmlPoint textTripFinishPoint = ge.createPoint("");

            textTripStartPoint.setLatitude(Convert.ToDouble(row.Cells[13].Value));
            textTripStartPoint.setLongitude(Convert.ToDouble(row.Cells[12].Value));

            textTripFinishPoint.setLatitude(Convert.ToDouble(row.Cells[15].Value));
            textTripFinishPoint.setLongitude(Convert.ToDouble(row.Cells[14].Value));

            textTripStartPlaceMark.setGeometry(textTripStartPoint);
            textTripFinishPlaceMark.setGeometry(textTripFinishPoint);

            ge.getFeatures().appendChild(textTripStartPlaceMark);
            ge.getFeatures().appendChild(textTripFinishPlaceMark);

            start = textTripStartPlaceMark;
            finish = textTripFinishPlaceMark;

            if (textPointHide)
            {
                start.setVisibility(0);
                finish.setVisibility(0);
            }
        }
Exemplo n.º 39
0
        private void btRuler_Click(object sender, EventArgs e)
        {
            if (!rulerMode)  //If the program isn't in ruler mode
            {
                //Okay so this function will allow the user to create points on the map that will be used to calculate distance
                //between a path.
                //So the first we'll have to do is call the JsCrt function which readies the double click event handler.
                webBrowser1.Document.InvokeScript("JSrulerPoint", new object[] { });
                //So now the map will be ready for a double click
                rulerMode = true;
                this.btRuler.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.hover));  // This will leave the colour on, giving the user an indication that rulerMode is still on.
                IKmlPlacemark newLine = ge.createPlacemark("line"+lineNumber);
                IKmlLineString newLinePoints = ge.createLineString("linePoints" + lineNumber);
                IKmlFolder rulerConstruct = ge.createFolder("construct"+lineNumber);
                ++lineNumber;
                line = newLine;
                linePoints = newLinePoints;
                ruler = rulerConstruct;
                ruler.getFeatures().appendChild(line);
                ge.getFeatures().appendChild(ruler);
                rulerPanel.Visible = true;

            }
            else
            {
                //Now the user has completed measuring the path, so now we should delete the points that were created and call of the double click event handler
                webBrowser1.Document.InvokeScript("JSrmCT", new object[] {} );
                this.btRuler.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.normal)); //This will put the colour back to normal, giving the user an indication that rulerMode is off.
                rulerMode = false;
                ge.getFeatures().removeChild(ruler);
                rulerDistance = 0;
                rulerDistanceText.Text = "";
                pointsMeasured = 0;
                rulerPanel.Visible = false;
            }
        }
Exemplo n.º 40
0
 public double getDistance(IKmlPlacemark point)
 {
     String xml = point.getDescription();
     String temp =System.Text.RegularExpressions.Regex.Split(xml, "Distance</td><td>")[1];
     return double.Parse((String) temp.Split('<')[0]);
 }
Exemplo n.º 41
0
        public void D_parser()
        {
            IKmlObjectList days = ge.getFeatures().getChildNodes();
            IKmlDocument day = (IKmlDocument)days.item(0);
            d_pool[day.getName()] = day;

            d_name = day.getName().Split('_')[4];
            String[] line = new String[14];
            objReader = new System.IO.StreamReader(txtfpath);

            do
            {
                String buff = objReader.ReadLine();
                List<String> input = buff.Split('\t').ToList();
                if (input[0] == d_name)
                {
                    input.RemoveAt(0);
                    input.RemoveAt(0);
                    line = input.ToArray();
                    break;
                }
                else
                {
                    header += buff+"\n";
                }
            }
            while (objReader.Peek() != -1);
            objReader.Dispose();

            String temp= "";
            //Get Total Points in the KML File for estimated time
            IKmlObjectList trips = day.getFeatures().getChildNodes();
            int tripCount = trips.getLength();
            int currentTrip = 1;
            for (int i = 0; i != trips.getLength(); ++i)
            {
                IKmlFolder trip = (IKmlFolder)trips.item(i);
                IKmlObjectList points = trip.getFeatures().getChildNodes();
                totalPoints = totalPoints + points.getLength();
            }
            for (int i = 0; i != trips.getLength(); i++)
            {
                Module.writeToTestingFile("Parsing KML Data for Trip"+(i+1)+" Time:"+DateTime.Now.ToString());
                String[] att = new String[4];
                IKmlFolder trip = (IKmlFolder)trips.item(i);
                att[0] = line[2];
                att[1] = line[0];
                att[2] = line[4];
                att[3] = line[5];
                T_parser(trip, tripCount, currentTrip);
                ++currentTrip;
               // att[8] = Math.Round((double.Parse(att[7]) / Module.durationConverter(att[6])), 3).ToString();

                t_pool.addGlobalVariables(att);

                t_pool.add(trip);

                /*if (i + 1 <trips.getLength())
                {
                    temp = objReader.ReadLine();
                    List<String> input = temp.Split('\t').ToList();
                    input.RemoveAt(0);
                    input.RemoveAt(0);
                    line = input.ToArray();
                } */
            }
            Module.averagePointsPerSecond(pointsPerSeconds);
            footer += temp+'\n';
        }
Exemplo n.º 42
0
        public void highlight(IKmlPlacemark point)
        {
            de_highlight();

            IKmlIcon icon = ge.createIcon("");
            icon.setHref(@"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png");
            IKmlStyle ssty = ge.createStyle("");
            ssty.getIconStyle().setIcon(icon);
            ssty.getIconStyle().setScale((float)0.9);
            ssty.getIconStyle().getColor().set(point.getComputedStyle().getIconStyle().getColor().get());

            point.setStyleSelector(ssty);
            sel_point = point;
        }
Exemplo n.º 43
0
        public void splitTrip(String day, String trip, IKmlPlacemark s_point, IKmlPlacemark f_point, TripPool t_pool)
        {
            //           MessageBox.Show(tripData.getFeatures().getChildNodes().getLength().ToString() + " " + point.getName() +"    "+point.getId());

            Module testModule = new Module();
            //This function will split a trip in the text file
            //First we'll need to find the day we're talking about
            for (int i = 0; i < databaseViewer.Rows.Count; ++i)
            {
                    //once we have found the right day we'll go and find the right trip
                    if (databaseViewer.Rows[i]["KMLTrip"].ToString() == trip)
                    {
                        //Once we have found the trip we'll first have to add it to the Undo Table
                        //First we'll add the entry of what type of action was performed.
                        addToUndoTypeTable("Split");
                        addToUndotable(databaseViewer.Rows[i]);  // So we've added the whole row back into place.
                        //once we have found our trip record we'll make the further modifications
                        //Now the split point of the trip will become the finishing point of the original trip. Before we insert the new values, we should store the other values first
                        String oldFinishTime = databaseViewer.Rows[i]["Finish"].ToString();
                        String oldFinishLat = databaseViewer.Rows[i]["fLatitude"].ToString();
                        String oldFinishLong = databaseViewer.Rows[i]["fLongitude"].ToString();
                        //Now that we've stored these values, we can safely replace these fields with the new data.
                        databaseViewer.Rows[i]["Finish"] = f_point.getName();
                        t_pool.getTripDetails().Rows[i]["Finish Time"] = f_point.getName();
                        Hashtable coords = Module.getCoordinates(f_point);
                        databaseViewer.Rows[i]["fLatitude"] = coords["lat"];
                        databaseViewer.Rows[i]["fLongitude"] = coords["lon"];
                        t_pool.getTripDetails().Rows[i]["FinishLat"] = coords["lat"];
                        t_pool.getTripDetails().Rows[i]["FinishLong"] = coords["long"];
                        t_pool.resetTripData("Trip_"+ trip);
                        //By this time the original trip would have been modified correctly. Now we need to create a new trip and set it's fields correctly
                        //Now we need to get the details of the next point
             //                       point = getNextPoint(tripData, point); //This should give us the next point after the split point.
                        coords = Module.getCoordinates(s_point);
                        //Now once we have all the information we'll create a new record in the table
                        DataRow newRow = NewRowDataTableCustom();
                        DataRow newRowKML = t_pool.NewRowDataTableCustom();
                        //Most of the information will be the same as the current record
                        newRow["Day"] = databaseViewer.Rows[i]["Day"];
                        newRow["Household"] = databaseViewer.Rows[i]["HouseHold"];
                        newRow["Person"] = databaseViewer.Rows[i]["Person"];
                        newRow["Date"] = databaseViewer.Rows[i]["Date"];
                        newRow["Weekday"] = databaseViewer.Rows[i]["Weekday"];
                        newRow["Remain"] = databaseViewer.Rows[i]["Remain"];
                        //Now we'll add the new data
                        newRow["KMLTrip"] = (Convert.ToInt32(databaseViewer.Rows[i]["KMLTrip"])+1).ToString();
                        newRow["Start"] = s_point.getName();
                        newRow["Finish"] = oldFinishTime;
                        newRow["sLongitude"] = coords["lon"];
                        newRow["sLatitude"] = coords["lat"];
                        newRow["fLongitude"] = oldFinishLong;
                        newRow["fLatitude"] = oldFinishLat;
                        //Now we'll add this row in the dataTable
                        databaseViewer.Rows.InsertAt(newRow, i+1);
                        newRowKML = copyDataRowContents(newRow, newRowKML);
                        t_pool.getTripDetails().Rows.InsertAt(newRowKML, i + 1);
                        //Now once everything is done, we'll reset the tripCount for that day
                        resetTripCountForDay();
                        t_pool.resetTripCount();
                        t_pool.resetTripData("Trip_" + (Convert.ToInt32(trip)+1).ToString());
                        completeMissingData(t_pool);
                    }

            }
        }
Exemplo n.º 44
0
        private void selectKMLDataRow(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (KMLPointSet == true)
            {
                ge.getFeatures().removeChild(KMLStart);
                ge.getFeatures().removeChild(KMLFinish);
            }
            float scale = 2;
            KMLPointSet = true;
            //When you select a row in the DataTable it populates it's information in the Panel
            DataGridViewRow row = KMLTripView.SelectedRows[0];
            startTimeText.Text = row.Cells[7].Value.ToString();
            finishTimeText.Text = row.Cells[8].Value.ToString();
            startCoordinatesText.Text = row.Cells[12].Value.ToString() + ", " + row.Cells[13].Value.ToString();
            finishCoordinatesText.Text = row.Cells[14].Value.ToString() + ". " + row.Cells[15].Value.ToString();
            distanceText.Text = row.Cells[10].Value.ToString() + " km";
            timeText.Text = row.Cells[9].Value.ToString() + " hrs";
            speedText.Text = Math.Round(Convert.ToDecimal(row.Cells[11].Value), 2).ToString() + " kmph";
            panel6.Visible = true;

            IKmlIcon KMLstartIcon = ge.createIcon("");
            KMLstartIcon.setHref("http://www.vishwaas.org.au/icons/KMLStart.png");
            IKmlStyle KMLstartPointStyle = ge.createStyle("");
            KMLstartPointStyle.getIconStyle().setIcon(KMLstartIcon);
            KMLstartPointStyle.getIconStyle().setScale(scale);

            IKmlIcon KMLfinishIcon = ge.createIcon("");
            KMLfinishIcon.setHref("http://www.vishwaas.org.au/icons/KMLFinish.png");
            IKmlStyle KMLfinishPointStyle = ge.createStyle("");
            KMLfinishPointStyle.getIconStyle().setIcon(KMLfinishIcon);
            KMLfinishPointStyle.getIconStyle().setScale(scale);

            IKmlPlacemark KMLTripStartPlaceMark = ge.createPlacemark("KMLstart" + temp);
            IKmlPlacemark KMLTripFinishPlaceMark = ge.createPlacemark("KMLfinish" + temp);
            ++temp;

            KMLTripStartPlaceMark.setStyleSelector(KMLstartPointStyle);
            KMLTripFinishPlaceMark.setStyleSelector(KMLfinishPointStyle);

            IKmlPoint KMLTripStartPoint = ge.createPoint("");
            IKmlPoint KMLTripFinishPoint = ge.createPoint("");

            KMLTripStartPoint.setLatitude(Convert.ToDouble(row.Cells[13].Value));
            KMLTripStartPoint.setLongitude(Convert.ToDouble(row.Cells[12].Value));

            KMLTripFinishPoint.setLatitude(Convert.ToDouble(row.Cells[15].Value));
            KMLTripFinishPoint.setLongitude(Convert.ToDouble(row.Cells[14].Value));

            KMLTripStartPlaceMark.setGeometry(KMLTripStartPoint);
            KMLTripFinishPlaceMark.setGeometry(KMLTripFinishPoint);

            ge.getFeatures().appendChild(KMLTripStartPlaceMark);
            ge.getFeatures().appendChild(KMLTripFinishPlaceMark);

            KMLStart = KMLTripStartPlaceMark;
            KMLFinish = KMLTripFinishPlaceMark;

            if (KMLPointhide)
            {
                KMLStart.setVisibility(0);
                KMLFinish.setVisibility(0);
            }
        }
Exemplo n.º 45
0
        public IKmlFolder[] split(int index, IKmlFolder raw, IKmlPlacemark _point, String style)
        {
            IKmlFolder[] output = new IKmlFolder[2];

            String col = randomCol();
            IKmlFolder temp1 = ge.createFolder("");
            IKmlFolder temp2 = ge.createFolder("");
            temp1.setName("Trip_" + (index).ToString());
            temp2.setName("Trip_" + (index + 1).ToString());

            int sw = 0;
            IKmlObjectList points = raw.getFeatures().getChildNodes();
            for (int i = 0; i != points.getLength(); i++)
            {
                IKmlPlacemark point = (IKmlPlacemark)points.item(i);
                if (point.getName() == _point.getName())
                {
                    sw = 1;
                }
                if (sw == 0)
                {
                    temp1.getFeatures().appendChild(point);

                }
                else
                {
                    IKmlStyleMap sm = ge.createStyleMap("");
                    if (style != null)
                    {
                        if (point.getGeometry().getType() != "KmlPoint")
                        {
                            IKmlStyle sty = ge.createStyle("");
                            sty.getLineStyle().setWidth((float)4);
                            sty.getLineStyle().getColor().set(style);
                            point.setStyleSelector(sty);

                        }
                        else
                        {
                            IKmlStyle normal = mkStyle(style, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3);
                            IKmlStyle highlight = mkStyle(style, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4);
                            sm.setNormalStyle(normal);
                            sm.setHighlightStyle(highlight);
                            point.setStyleSelector(sm);
                        }
                    }
                    else
                    {
                        if (point.getGeometry().getType() != "KmlPoint")
                        {
                            IKmlStyle sty = ge.createStyle("");
                            sty.getLineStyle().setWidth((float)4);
                            sty.getLineStyle().getColor().set(col);
                            point.setStyleSelector(sty);
                        }
                        else
                        {

                            IKmlStyle normal = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3);
                            IKmlStyle highlight = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4);
                            sm.setNormalStyle(normal);
                            sm.setHighlightStyle(highlight);
                            point.setStyleSelector(sm);
                        }
                    }
                    temp2.getFeatures().appendChild(point);
                }
            }
            output[0] = temp1;
            output[1] = temp2;
            return output;
        }
Exemplo n.º 46
0
 private void button3_Click(object sender, EventArgs e)
 {
     foreach (int trip in checkedListBox1.CheckedIndices)
     {
         checkedListBox1.SetItemCheckState(trip, 0);
     }
     if (sel_point != null)
     {
         de_highlight();
         sel_point = null;
     }
 }
Exemplo n.º 47
0
 public void rm_sel_pt()
 {
     sel_point = null;
 }
Exemplo n.º 48
0
        public void addToStart(String name, IKmlPlacemark point)
        {
            IKmlFolder trip = getByName(name);
            IKmlObjectList points = trip.getFeatures().getChildNodes();

            String col = ((IKmlPlacemark)trip.getFeatures().getChildNodes().item(2)).getComputedStyle().getIconStyle().getColor().get();

             	    IKmlStyleMap sm = ge.createStyleMap("");
             	    IKmlStyle normal = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3);
             	    IKmlStyle highlight = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4);
             	    sm.setNormalStyle(normal);
             	    sm.setHighlightStyle(highlight);

             	    point.setStyleSelector(sm);

            trip.getFeatures().insertBefore(point,points.item(0));
        }
Exemplo n.º 49
0
        private Boolean split(IKmlPlacemark sp_point)
        {
            try{
                Hashtable cords = getCoordinates(sp_point);

                IKmlFolder _trip = (IKmlFolder)sp_point.getParentNode();
                _trip.setVisibility(0);

                String t_name = t_pool.getParent(sp_point.getName());
                String[] t_att = t_pool.getAttByName(t_name);
                ArrayList trip = new ArrayList();
                trip.Add(t_name);
                trip.Add(_trip);
                trip.Add(t_att);
                record.spl_trip(trip);

                int index = int.Parse((t_name.Split('_')[1]));
                IKmlFolder[] sub = split(index, _trip, sp_point, sp_point.getStyleUrl());

                IKmlPlacemark fn = t_pool.getFinish(sub[0]);
                Hashtable _cords = getCoordinates(fn);

                String[] att_temp1 = (String[])t_att.Clone();
                String[] att_temp2 = (String[])t_att.Clone();

                att_temp1[5] = fn.getName();
                att_temp2[4] = sp_point.getName();

                att_temp1[6] = duration(att_temp1[4], att_temp1[5]);
                att_temp2[6] = duration(att_temp2[4], att_temp2[5]);

                att_temp1[11] = _cords["lon"].ToString();
                att_temp1[12] = _cords["lat"].ToString();

                att_temp2[9] = cords["lon"].ToString();
                att_temp2[10] = cords["lat"].ToString();

                IKmlObjectList days = ge.getFeatures().getChildNodes();
                IKmlDocument day = (IKmlDocument)days.item(0);

                day.getFeatures().appendChild(sub[0]);
                day.getFeatures().appendChild(sub[1]);

                if (sub[0].getFeatures().getChildNodes().getLength() <= sub[1].getFeatures().getChildNodes().getLength())
                {
                    double distance = calDistance(sub[0]);
                    att_temp1[7] = distance.ToString();
                    att_temp2[7] = (double.Parse(t_att[7]) - distance).ToString();
                }
                else
                {
                    double distance = calDistance(sub[1]);
                    att_temp2[7] = distance.ToString();
                    att_temp1[7] = (double.Parse(t_att[7]) - distance).ToString();
                }

                /*
                 * The duration of a trip from might be less than 0 when the program interpreter inconsistent kml and txt file
                 *
                 * chen
                 */
                try
                {
                    att_temp1[8] = Math.Round((double.Parse(att_temp1[7]) / durationConverter(att_temp1[6])), 3).ToString();
                    att_temp2[8] = Math.Round((double.Parse(att_temp2[7]) / durationConverter(att_temp2[6])), 3).ToString();
                }
                catch
                {
                    MessageBox.Show("kml and txt file doesn't match");
                    att_temp2[8] = "-0";
                    att_temp1[8] = "-0";
                }
                t_pool.insert(index, sub[0], att_temp1, sub[1], att_temp2);

                return true;
                }
            catch
            {
                return false;
            }
        }
Exemplo n.º 50
0
        /*
         * Function used to create a random point on the map
         * */
        /*
         * This function is called by the globe double clicking event handler, the argument is the newly created point
         */
        public void CreatePoint(IKmlPlacemark point)
        {
            IKmlFolder trip = t_pool.getByName((String)cblTrips.CheckedItems[0]); //gets the selected trip object

            String col = ((IKmlPlacemark)trip.getFeatures().getChildNodes().item(1)).getComputedStyle().getIconStyle().getColor().get();

            IKmlStyleMap sm = ge.createStyleMap("");
            IKmlStyle normal = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3);
            IKmlStyle highlight = mkStyle(col, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4);
            sm.setNormalStyle(normal);
            sm.setHighlightStyle(highlight);

            point.setStyleSelector(sm); //getting the style of the trip

            Hashtable _temp = Module.getCoordinates(point); //getting the coordinates of a point
            GEHtmlStringBalloonCoClass temp = ge.createHtmlStringBalloon(""); // creates a balloon with the new point
            temp.setFeature(point);
            btCrt.Enabled = true;

            webBrowser1.Document.InvokeScript("JSmk", new object[] { point });

            record.crt_point(point);

            ge.getFeatures().appendChild(point);
        }
Exemplo n.º 51
0
        private IKmlFolder[] split(int index, IKmlFolder raw, IKmlPlacemark _point, String style)
        {
            IKmlFolder[] output = new IKmlFolder[2];

            IKmlFolder temp1 = ge.createFolder("");
            IKmlFolder temp2 = ge.createFolder("");
            temp1.setName("Trip_" + (index).ToString());
            temp2.setName("Trip_" + (index + 1).ToString());

            int sw = 0;
            IKmlObjectList points = raw.getFeatures().getChildNodes();

            for (int i = 0; i != points.getLength(); i++)
            {
                IKmlPlacemark point = (IKmlPlacemark)points.item(i);
                if (point.getName() == _point.getName())
                {
                    sw = 1;
                }
                if (sw == 0)
                {
                    temp1.getFeatures().appendChild(point);

                }
                else
                {
                    point.setStyleUrl(style);
                    temp2.getFeatures().appendChild(point);
                }
            }
            output[0] = temp1;
            output[1] = temp2;
            return output;
        }
Exemplo n.º 52
0
 /*This is called by the Javascript function that will show the ruler point on the map and will do the calculation of distance */
 public void createRulerPoint(IKmlPlacemark rulerPoint, IKmlPoint point)
 {
     IKmlIcon rulerPointIcon = ge.createIcon("");
     rulerPointIcon.setHref("http://maps.google.com/mapfiles/kml/shapes/placemark_square.png");
     IKmlStyle rulerPointStyle = ge.createStyle("");
     rulerPointStyle.getIconStyle().setIcon(rulerPointIcon);
     rulerPoint.setStyleSelector(rulerPointStyle);
     ruler.getFeatures().appendChild(rulerPoint);  // Add the point to the map.
     /*We will then implement the feature that will calculate the distance between the points*/
     linePoints.getCoordinates().pushLatLngAlt(point.getLatitude(), point.getLongitude(), 0);
     line.setGeometry(linePoints);
     if (pointsMeasured != 0)
     {
         //This means this is not the first point we're measuring. Hence we should find out the distance
         //The distance will be the distance measured so far, plus the distance between the last point and the current point
         rulerDistance += Math.Round(DistanceAlgorithm.DistanceBetweenPlaces(lastPoint.getLatitude(), lastPoint.getLongitude(), point.getLatitude(), point.getLongitude()), 2);
         rulerDistanceText.Text = rulerDistance.ToString() + " km";
         ++pointsMeasured;
     }
     else
     {
         ++pointsMeasured;
     }
     lastPoint = point;
 }
Exemplo n.º 53
0
 public void JScallName(IKmlPlacemark point)
 {
     //           MessageBox.Show("You are clicking on " +point.getName(), "Caution");
     highlight(point);
 }
Exemplo n.º 54
0
 public IKmlPlacemark getNextPoint(IKmlFolder trip, IKmlPlacemark point)
 {
     bool flag = false;
     IKmlObjectList points = trip.getFeatures().getChildNodes();
     for (int i = 0; i != points.getLength(); ++i)
     {
         IKmlPlacemark pt = (IKmlPlacemark) points.item(i);
         if (flag == true)
         {
             return pt;
         }
         if (pt.getName() == point.getName())
         {
             flag = true;
         }
     }
     return null;
 }
Exemplo n.º 55
0
        /*
         * Split function
         */
        private void button5_Click(object sender, EventArgs e)
        {
            if (sel_point == null) { MessageBox.Show("Select a split point first.", "Caution"); return; }

            t_pool.de_highlight();
            de_highlight();

            if (split(sel_point))
            {
                sel_point = null;
                checkedListBox1.Items.Clear();
                checkedListBox1.Items.AddRange(t_pool.getNames().ToArray());
            }
            else
            {
                MessageBox.Show("Failed to split a trip a point.","Error");
            }
        }
Exemplo n.º 56
0
 public void makeStart(String trip, IKmlPlacemark newStartPoint, TripPool t_pool)
 {
     //This function will change the starting time of a trip
     //First we'll find the row to edit. The trip should match
     for (int i = 0; i < databaseViewer.Rows.Count; ++i)
     {
         if (databaseViewer.Rows[i]["KMLTrip"].ToString().Equals(trip))
         {
             addToUndotable(databaseViewer.Rows[i]);
             addToUndoTypeTable("Make Start");
             databaseViewer.Rows[i]["Start"] = newStartPoint.getName();
             databaseViewer.Rows[i]["sLongitude"] = Module.getCoordinates(newStartPoint)["lon"];
             databaseViewer.Rows[i]["sLatitude"] = Module.getCoordinates(newStartPoint)["lat"];
             t_pool.getTripDetails().Rows[i]["StartLong"] = Module.getCoordinates(newStartPoint)["lon"];
             t_pool.getTripDetails().Rows[i]["StartLat"] = Module.getCoordinates(newStartPoint)["lat"];
             t_pool.getTripDetails().Rows[i]["Start Time"] = newStartPoint.getName();
             t_pool.resetTripData("Trip_" + trip);
             completeMissingData(t_pool, trip);
         }
     }
 }