Beispiel #1
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      = "";
        }
Beispiel #2
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);
        }
Beispiel #3
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;
        }
Beispiel #4
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);
         }
     }
 }
Beispiel #5
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);
        }
Beispiel #6
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();
        }
Beispiel #7
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"]      = "-";
                }
            }
        }
Beispiel #8
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);
                }
            }
        }
Beispiel #9
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);
                    }

            }
        }
Beispiel #10
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);
         }
     }
 }
Beispiel #11
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);
        }
Beispiel #12
0
        public Boolean insert(String tp1, String tp2)
        {
            try
            {
                // Get the end placemark of the 1st trip  and the start placemark of the second trip
                IKmlPlacemark tp1fn = t_pool.getFinish(t_pool.getByName(tp1));
                IKmlPlacemark tp2st = t_pool.getStart(t_pool.getByName(tp2));

                //create a place mark to store the new place mark

                IKmlPlacemark start  = ge.createPlacemark("");
                IKmlPlacemark finish = ge.createPlacemark("");

                start.setName(tp1fn.getName());
                finish.setName(tp2st.getName());

                IKmlPoint sp = ge.createPoint("");
                IKmlPoint fp = ge.createPoint("");

                IKmlPlacemark _temp = ge.createPlacemark("");

                IKmlLineString temp = ge.createLineString("");

                // Retrieve the coordinates of the two trips
                Hashtable cds1 = Module.getCoordinates(tp1fn);
                Hashtable cds2 = Module.getCoordinates(tp2st);

                sp.setLatLng((double)cds1["lat"], (double)cds1["lon"]);
                start.setGeometry(sp);
                fp.setLatLng((double)cds2["lat"], (double)cds2["lon"]);
                finish.setGeometry(fp);

                String color = randomCol();

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

                temp.getCoordinates().pushLatLngAlt((double)cds1["lat"], (double)cds1["lon"], 0);
                temp.getCoordinates().pushLatLngAlt((double)cds2["lat"], (double)cds2["lon"], 0);
                _temp.setGeometry(temp);

                IKmlStyle sty = ge.createStyle("");
                sty.getLineStyle().setWidth((float)4);
                sty.getLineStyle().getColor().set(color);

                _temp.setStyleSelector(sty);

                //create a new KML folder for the new trip  and append the tmp features of the previous trip
                IKmlFolder temp1 = ge.createFolder("");

                temp1.getFeatures().appendChild(start);
                temp1.getFeatures().appendChild(_temp);
                temp1.getFeatures().appendChild(finish);

                String[] attributes = new String[14];

                //Add the new trip to the trip pools
                t_pool.add(tp2, temp1, attributes);
                ge.getFeatures().appendChild(temp1);

                // record the insert action for undo action
                record.ins_trip(tp2);


                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #13
0
        public Boolean split(IKmlPlacemark sp_point)
        {
            try
            {
                Hashtable cords = Module.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.getTripDetailsForTrip(Module.getIndex(t_name).ToString());
                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, null);

                IKmlPlacemark fn     = t_pool.getFinish(sub[0]);
                Hashtable     _cords = Module.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] = Module.duration(att_temp1[4], att_temp1[5]);
 *              att_temp2[6] = Module.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 = Module.calDistance(sub[0]);
 *                  att_temp1[7] = distance.ToString();
 *                  att_temp2[7] = (double.Parse(t_att[7]) - distance).ToString();
 *              }
 *              else
 *              {
 *                  double distance = Module.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]) / Module.durationConverter(att_temp1[6])), 3).ToString();
                 *                 att_temp2[8] = Math.Round((double.Parse(att_temp2[7]) / Module.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);
            }
        }
Beispiel #14
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;
            }
        }
Beispiel #15
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;
 }
Beispiel #16
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;
        }
Beispiel #17
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;
        }