/* * 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; }
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(); }
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); }
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; }
public IKmlPlacemark getStart(IKmlFolder trip) { IKmlObjectList points = trip.getFeatures().getChildNodes(); // MessageBox.Show(points.getLength().ToString()); return((IKmlPlacemark)points.item(0)); }
public void add(String name, IKmlFolder trip, String[] att) { de_highlight(); int index = getIndex(name); _core.Insert(index - 1, trip); _attr.Insert(index - 1, att); }
public void removeFirstPoint(String trip) { //This will remove the first point of the trip IKmlFolder tripDetails = getByName(trip); //Once we've found the trip, we'll remove the first child tripDetails.getFeatures().removeChild(tripDetails.getFeatures().getFirstChild()); }
public void add(IKmlFolder trip, String[] att) { if (!_core.Contains(trip)) { _core.Add(trip); _attr.Add(att); } }
public String getParent(String name) { for (int i = 0; i != _core.Count; i++) { IKmlFolder trip = (IKmlFolder)_core[i]; if (include(trip, name)) { return("Trip_" + (i + 1).ToString()); } } return(null); }
public void insert(int index, IKmlFolder trip1, String[] att1, IKmlFolder trip2, String[] att2) { int t = getIndex(trip1.getName()); _core.RemoveAt(t - 1); _attr.RemoveAt(t - 1); _core.Insert(t - 1, trip1); _attr.Insert(t - 1, att1); _core.Insert(t, trip2); _attr.Insert(t, att2); }
public bool include(IKmlFolder trip, String point) { DateTime s_point = Convert.ToDateTime(getStart(trip).getName()); DateTime _point = Convert.ToDateTime(point); if (Convert.ToDateTime(getFinish(trip).getName()).CompareTo(_point) == 1 && _point.CompareTo(Convert.ToDateTime(getStart(trip).getName())) == 1) { return(true); } else { return(false); } }
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 = ""; }
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 = ""; }
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); }
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; }
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); }
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); } }
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); }
/* * 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); }
/* * 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)); }
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(); }
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); }
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); }
public Boolean delete(String name) { try { ArrayList trip = new ArrayList(); IKmlFolder _trip = t_pool.getByName(name); String[] att = t_pool.getTripDetailsForTrip(Module.getIndex(name).ToString()); _trip.setVisibility(0); trip.Add(name); trip.Add(_trip); trip.Add(att); t_pool.remove(name); record.del_trip(trip); return(true); } catch { return(false); } }
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"] = "-"; } } }
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); }
public ArrayList trimToEnd(String name, String time) { IKmlFolder trip = getByName(name); IKmlObjectList points = trip.getFeatures().getChildNodes(); ArrayList buffer = new ArrayList(); for (int i = points.getLength() - 1; i >= 0; i--) { if (Convert.ToDateTime(((IKmlPlacemark)points.item(i)).getName()) > Convert.ToDateTime(time)) { buffer.Add(points.item(i)); } else { break; } } for (int i = 0; i < buffer.Count; i++) { trip.getFeatures().removeChild(buffer[i]); } return(buffer); }
/* * 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; }
/* * get the coordinates of a point */ public IKmlPlacemark getStart(IKmlFolder trip) { IKmlObjectList points = trip.getFeatures().getChildNodes(); return((IKmlPlacemark)points.item(0)); }
public void T_parser(IKmlFolder trip, int tripCount, int currentTrip) { IKmlObjectList points = trip.getFeatures().getChildNodes(); int lastRecordedTime = DateTime.Now.Second; int pointsInSecond = 0; for (int ii = 0; ii != points.getLength(); ++ii) { Console.Clear(); Console.WriteLine(statusText + "\n" + "Trip " + currentTrip + " out of " + tripCount + "\n" + "Point " + (ii+1) + " out of " + points.getLength() + "\n" + (Math.Round(Convert.ToDouble(ii) / points.getLength() * 100, 0).ToString() + "%") + "\nTime Remaining: " + estimatedTimeOfCompletion + "\nAverage points per second: " + (int)average); if (lastRecordedTime == DateTime.Now.Second) { ++pointsInSecond; } else { totalPoints = totalPoints - pointsInSecond; pointsPerSeconds.Add(pointsInSecond); average = Module.averagePointsPerSecond(pointsPerSeconds); double secondsLeft = totalPoints / average; estimatedTimeOfCompletion = Module.getNewTime("00:00:00", secondsLeft.ToString(), 2); Module.writeToTestingFile("Points this second: " + pointsInSecond); pointsInSecond = 0; lastRecordedTime = DateTime.Now.Second; } IKmlPlacemark point = (IKmlPlacemark)points.item(ii); String temp = point.getComputedStyle().getIconStyle().getColor().get(); IKmlStyleMap sm = ge.createStyleMap(""); IKmlStyle normal = mkStyle(temp, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.3); IKmlStyle highlight = mkStyle(temp, @"http://maps.google.com/mapfiles/kml/paddle/wht-blank.png", (float)0.4); sm.setNormalStyle(normal); sm.setHighlightStyle(highlight); point.setStyleSelector(sm); System.Diagnostics.Process hello; System.Diagnostics.ProcessPriorityClass prioritySet; prioritySet //webBrowser1.Document.InvokeScript("JSmk", new object[] { point }); } }
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; } }
public IKmlPlacemark getFinish(IKmlFolder trip) { IKmlObjectList points = trip.getFeatures().getChildNodes(); return((IKmlPlacemark)points.item(points.getLength() - 1)); }
public Boolean split_test(String name, int index) { //create a kml folder by tripname IKmlFolder temp = t_pool.getByName(name); // get the current placemark and the pre placemark at a given index IKmlPlacemark sst = (IKmlPlacemark)temp.getFeatures().getChildNodes().item(index - 1); IKmlPlacemark st = (IKmlPlacemark)temp.getFeatures().getChildNodes().item(index); // get trip size, number of trips and number of columns(lat,long ,elapse time etc) int pt_size = temp.getFeatures().getChildNodes().getLength(); int init_size_t = t_pool.getSize(); core.split(st); //get index + 1 of the current trip String _name = "Trip_" + (Module.getIndex(name) + 1); Boolean gflag = true; Boolean fflag = true; try { int final_size_t = t_pool.getSize(); //compare the initial size of the t pool against the final t pool. Assert.AreEqual(init_size_t, final_size_t - 1); //compare the split index with the size of the first half of the splitted trip Assert.AreEqual(index, t_pool.getByName(name).getFeatures().getChildNodes().getLength()); // compare the split index with the size of the second half of the splitted trip Assert.AreEqual(pt_size - index, t_pool.getByName(_name).getFeatures().getChildNodes().getLength()); Console.WriteLine(" >>>>>>>>>>>> Passed the test for split the trip on GUI level <<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed the test for split the trip on GUI level <-----------"); gflag = false; } try { IKmlObjectList days = ge.getFeatures().getChildNodes(); IKmlDocument day = (IKmlDocument)days.item(0); String r_start = txtedit.getViewer().Rows[0]["Start"].ToString(); String r_finsih = txtedit.getViewer().Rows[0]["Finish"].ToString(); String r_duration = txtedit.getViewer().Rows[0]["Time"].ToString(); String r_slon = txtedit.getViewer().Rows[0]["sLongitude"].ToString(); String r_flon = txtedit.getViewer().Rows[0]["fLongitude"].ToString(); String r_slat = txtedit.getViewer().Rows[0]["sLatitude"].ToString(); String r_flat = txtedit.getViewer().Rows[0]["fLatitude"].ToString(); txtedit.splitTrip(day.getName(), Module.getIndex(name).ToString(), t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))), t_pool.getFinish(t_pool.getByName(name)), t_pool); try { Assert.AreEqual(txtedit.getViewer().Rows[0]["Finish"].ToString(), t_pool.getFinish(t_pool.getByName(name)).getName().ToString()); Assert.AreEqual(txtedit.getViewer().Rows[1]["Start"].ToString(), t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))).getName().ToString()); Console.WriteLine(" >>>>>>>>>>>> Succeed to compute the correct start and finish time <<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed to compute the correct start and finish time <-----------"); fflag = false; } try { double tp1 = Module.durationConverter(txtedit.getViewer().Rows[0]["Time"].ToString()); double gap = ((Convert.ToDateTime(txtedit.getViewer().Rows[1]["Start"].ToString()) - Convert.ToDateTime(txtedit.getViewer().Rows[0]["Finish"].ToString()))).TotalSeconds; double tp2 = Module.durationConverter(txtedit.getViewer().Rows[1]["Time"].ToString()); // MessageBox.Show(Module.durationConverter(txtedit.getViewer().Rows[0]["Time"].ToString()) + " " + t.ToString() + " " + Module.durationConverter(txtedit.getViewer().Rows[1]["Time"].ToString()) + " " + Module.durationConverter(r_duration)); Assert.AreEqual(Module.durationConverter(r_duration), tp1 + gap + tp2); Console.WriteLine(" >>>>>>>>>>>> Succeed to compute the correct trip duration <<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed to compute the correct the trip duration <-----------"); fflag = false; } try { String n_slon = txtedit.getViewer().Rows[1]["sLongitude"].ToString(); String n_slat = txtedit.getViewer().Rows[1]["sLatitude"].ToString(); String n_flon = txtedit.getViewer().Rows[0]["sLongitude"].ToString(); String n_flat = txtedit.getViewer().Rows[0]["sLatitude"].ToString(); String a_slon = Module.getCoordinates(t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))))["lon"].ToString(); String a_slat = Module.getCoordinates(t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 1))))["lat"].ToString(); String a_flon = Module.getCoordinates(t_pool.getStart(t_pool.getByName(name)))["lon"].ToString(); String a_flat = Module.getCoordinates(t_pool.getStart(t_pool.getByName(name)))["lat"].ToString(); /* * MessageBox.Show(n_slon+" "+a_slon); * MessageBox.Show(n_slat + " " + a_slat); * * MessageBox.Show(n_flon + " " + a_flon); * MessageBox.Show(n_flat + " " + a_flat); * * Assert.AreEqual(n_slat.Trim(), a_slat.Trim()); * Assert.AreEqual(n_slon.Trim(), a_slon.Trim()); * * Assert.AreEqual(n_flat.Trim(), a_flat.Trim()); * Assert.AreEqual(n_flon.Trim(), a_flon.Trim()); */ Console.WriteLine(" >>>>>>>>>>>> Succeed to compute the correct start and finish coordinates <<<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed to compute the correct start and finish coordinates <----------"); fflag = false; } Assert.AreEqual(true, fflag); Console.WriteLine(" >>>>>>>>>>>> Passed the test for split the trip on file level <<<<<<<<<<<<<"); } catch { Console.WriteLine(" -----------> Failed the test for split the trip on file level <----------"); } return(gflag && fflag); }
public bool include(IKmlFolder trip, String point) { DateTime s_point = Convert.ToDateTime(getStart(trip).getName()); DateTime _point = Convert.ToDateTime(point); if (Convert.ToDateTime(getFinish(trip).getName()).CompareTo(_point) == 1 && _point.CompareTo(Convert.ToDateTime(getStart(trip).getName())) == 1) { return true; } else { return false; } }
public Boolean insert_test(String name) { String _name = "Trip_" + (Module.getIndex(name) + 1); //create a kml folder by tripname IKmlFolder temp = t_pool.getByName(name); IKmlFolder temp2 = t_pool.getByName(_name); // // get the current placemark and the pre placemark at a given index //// IKmlPlacemark sst = (IKmlPlacemark)temp.getFeatures().getChildNodes().item(index - 1); // //IKmlPlacemark st = (IKmlPlacemark)temp.getFeatures().getChildNodes().item(index); // get trip size, number of trips and number of columns(lat,long ,elapse time etc) int pt_size = temp.getFeatures().getChildNodes().getLength(); int init_size_t = t_pool.getSize(); int init_size_a = t_pool.getAttrs().Count; // //get the attribute data by trip name // String[] att = t_pool.getAttByName(name); // MessageBox.Show((Module.getIndex(name) + 1).ToString()); core.insert(name, _name); //get index + 1 of the current trip Boolean gflag = true; // Boolean fflag = true; try { int final_size_t = t_pool.getSize(); //CASE 1: compare the initial size of the t pool against the final t pool. Assert.AreEqual(init_size_t, final_size_t - 1); //Case 2: Trip is inserted between the two selected trips Assert.AreEqual(temp, t_pool.getByName(name)); Assert.AreEqual(temp2, t_pool.getByName("Trip_" + (Module.getIndex(name) + 2))); Console.WriteLine("#Passed the test for insert the trip on GUI level "); } catch { Console.WriteLine("#Failed the test for insert the trip on GUI level "); gflag = false; } try { // Test start point of newly inserted trip start pt= end pt of previous trip, finish pt = start pt of next trip String tp1_flon = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(name)))["lon"].ToString(); String tp1_flat = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(name)))["lat"].ToString(); String tp2_slon = Module.getCoordinates(t_pool.getStart(t_pool.getByName(_name)))["lon"].ToString(); String tp2_slat = Module.getCoordinates(t_pool.getStart(t_pool.getByName(_name)))["lat"].ToString(); String tp2_flon = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(_name)))["lon"].ToString(); String tp2_flat = Module.getCoordinates(t_pool.getFinish(t_pool.getByName(_name)))["lat"].ToString(); String tp3_slon = Module.getCoordinates(t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 2))))["lon"].ToString(); String tp3_slat = Module.getCoordinates(t_pool.getStart(t_pool.getByName("Trip_" + (Module.getIndex(name) + 2))))["lat"].ToString(); Assert.AreEqual(tp2_slon, tp1_flon); Assert.AreEqual(tp2_slat, tp1_flat); //Start trip 2(lon,lat) = End trip 1(lon,lat) Assert.AreEqual(tp2_flon, tp3_slon); Assert.AreEqual(tp2_flat, tp3_slat); // End trip 2(lon,lat) = Start trip 3(lon,lat) Console.WriteLine("#Passed to compute the correct start and finish coordinates"); } catch { Console.WriteLine("#Failed to compute the correct start and finish coordinates"); gflag = false; } try { Console.WriteLine("#Passed the test for Insert the trip on file level"); } catch { Console.WriteLine("#Failed the test for Insert the trip on file level"); gflag = false; } return(gflag); }
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(); }
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(); }
/* * get the coordinates of a point */ public IKmlPlacemark getStart(IKmlFolder trip) { IKmlObjectList points = trip.getFeatures().getChildNodes(); return (IKmlPlacemark)points.item(0); }
public IKmlPlacemark getFinish(IKmlFolder trip) { IKmlObjectList points = trip.getFeatures().getChildNodes(); return (IKmlPlacemark)points.item(points.getLength() - 1); }
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; }
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; }
public void insert(int index, IKmlFolder trip1, String[] att1, IKmlFolder trip2, String[] att2) { int t = getIndex(trip1.getName()); _core.RemoveAt(t-1); _attr.RemoveAt(t - 1); _core.Insert(t - 1, trip1); _attr.Insert(t - 1, att1); _core.Insert(t, trip2); _attr.Insert(t, att2); }
/* * insert a trip into trippool and remove the trip at the same index as well as the one after ( this is used by join ) */ public String insert(String name, IKmlFolder trip, String[] att, IKmlStyle sty) { de_highlight(); int index = int.Parse(name.Split('_')[1]); 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 == 0) { style = point.getComputedStyle().getIconStyle().getColor().get(); } } points = temp2.getFeatures().getChildNodes(); IKmlStyleMap sm = ge.createStyleMap(""); 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); for (int ii = 0; ii != points.getLength(); ii++) { IKmlPlacemark point = (IKmlPlacemark)points.item(ii); if (ii == 0) { _style = point.getComputedStyle().getIconStyle().getColor().get(); } if (point.getGeometry().getType() != "KmlPoint") { point.getComputedStyle().getLineStyle().setWidth((float)4); point.getComputedStyle().getLineStyle().getColor().set(style); } else { point.setStyleSelector(sm); } trip.getFeatures().appendChild(point); } _core.RemoveAt(index - 1); // _attr.RemoveAt(index - 1); // removeKMLTrip(index.ToString()); _core.RemoveAt(index - 1); //_attr.RemoveAt(index - 1); // removeKMLTrip(index.ToString()); _core.Insert(index - 1, trip); // _attr.Insert(index - 1, att); // addAtPosition(trip, index - 1); return(_style); }
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; }
/* * insert a trip into trippool and remove the trip at the same index as well as the one after ( this is used by join ) */ public String insert(String name, IKmlFolder trip, String[] att, IKmlStyle sty) { de_highlight(); int index = int.Parse(name.Split('_')[1]); 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 == 0) { style = point.getComputedStyle().getIconStyle().getColor().get(); } } points = temp2.getFeatures().getChildNodes(); IKmlStyleMap sm = ge.createStyleMap(""); 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); for (int ii = 0; ii != points.getLength(); ii++) { IKmlPlacemark point = (IKmlPlacemark)points.item(ii); if (ii == 0) { _style = point.getComputedStyle().getIconStyle().getColor().get(); } if (point.getGeometry().getType() != "KmlPoint") { point.getComputedStyle().getLineStyle().setWidth((float)4); point.getComputedStyle().getLineStyle().getColor().set(style); } else { point.setStyleSelector(sm); } trip.getFeatures().appendChild(point); } _core.RemoveAt(index - 1); // _attr.RemoveAt(index - 1); // removeKMLTrip(index.ToString()); _core.RemoveAt(index - 1); //_attr.RemoveAt(index - 1); // removeKMLTrip(index.ToString()); _core.Insert(index - 1, trip); // _attr.Insert(index - 1, att); // addAtPosition(trip, index - 1); return _style; }
public IKmlPlacemark getStart(IKmlFolder trip) { IKmlObjectList points = trip.getFeatures().getChildNodes(); // MessageBox.Show(points.getLength().ToString()); return (IKmlPlacemark)points.item(0); }
public double T_parser(IKmlFolder trip) { IKmlObjectList points = trip.getFeatures().getChildNodes(); double dis = 0; for (int ii = 0; ii != points.getLength(); ii++) { IKmlPlacemark point = (IKmlPlacemark)points.item(ii); webBrowser1.Document.InvokeScript("JSmk", new object[] { point }); if (ii != 0) { dis+=getDistance(point); } } return Math.Round(dis,3); }
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; }