/// <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() + " )"); } }
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 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 Boolean undo(Hashtable mem) { try { if (mem["opt"] == "del") { ArrayList rev = (ArrayList)mem["data"]; IKmlFolder _trip = (IKmlFolder)rev[1]; _trip.setVisibility(1); t_pool.add((String)rev[0], _trip, (String[])rev[2]); } else if (mem["opt"] == "spl") { ArrayList rev = (ArrayList)mem["data"]; IKmlFolder trip = (IKmlFolder)rev[1]; t_pool.insert((String)rev[0], trip, (String[])rev[2], ge.createStyle("")); trip.setVisibility(1); IKmlObjectList days = ge.getFeatures().getChildNodes(); IKmlDocument day = (IKmlDocument)days.item(0); day.getFeatures().appendChild(trip); } else if (mem["opt"] == "joi") { ArrayList rev = (ArrayList)mem["data"]; IKmlFolder temp = ge.createFolder(""); String name = (String)rev[0]; IKmlFolder[] sub = split(int.Parse((name.Split('_')[1])), t_pool.getByName(name), (IKmlPlacemark)rev[1], (String)rev[4]); IKmlObjectList days = ge.getFeatures().getChildNodes(); IKmlDocument day = (IKmlDocument)days.item(0); day.getFeatures().appendChild(sub[0]); day.getFeatures().appendChild(sub[1]); t_pool.insert(int.Parse((name.Split('_')[1])), sub[0], (String[])rev[2], sub[1], (String[])rev[3]); } else if (mem["opt"] == "ins") { String rev = (String)mem["data"]; IKmlFolder trip = t_pool.getByName(rev); trip.setVisibility(0); t_pool.remove(rev); } else if (mem["opt"] == "crt") { IKmlPlacemark pt = (IKmlPlacemark)mem["data"]; ge.getFeatures().removeChild(pt); } else if (mem["opt"] == "mk_start" || mem["opt"] == "mk_finish") { ArrayList rev = (ArrayList)mem["data"]; IKmlPlacemark pt = (IKmlPlacemark)rev[1]; IKmlFolder trip = t_pool.getByName((String)rev[0]); //trip.getFeatures().removeChild(pt); //ge.getFeatures().appendChild(pt); } else if (mem["opt"] == "tm_start") { ArrayList rev = (ArrayList)mem["data"]; IKmlFolder trip = t_pool.getByName((String)rev[0]); IKmlObjectList points = trip.getFeatures().getChildNodes(); // MessageBox.Show(points.getLength().ToString()+" "+rev.Count.ToString()); for (int i = rev.Count - 1; i != 0; i--) { points = trip.getFeatures().getChildNodes(); trip.getFeatures().insertBefore(rev[i], points.item(0)); } } else if (mem["opt"] == "tm_finish") { ArrayList rev = (ArrayList)mem["data"]; IKmlFolder trip = t_pool.getByName((String)rev[0]); IKmlObjectList points = trip.getFeatures().getChildNodes(); // MessageBox.Show(points.getLength().ToString()+" "+rev.Count.ToString()); for (int i = rev.Count - 1; i != 0; i--) { points = trip.getFeatures().getChildNodes(); trip.getFeatures().insertBefore(rev[i], points.item(points.getLength() - 1)); } } else if (mem["opt"] == "ch_color") { ArrayList rev = (ArrayList)mem["data"]; t_pool.ch_col((String)rev[0], (String)rev[1]); } return(true); } catch { return(false); } }
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); } }