Exemplo n.º 1
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.º 2
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.º 3
0
 public void highlight(IKmlPlacemark point)
 {
     de_highlight();
     sel_style = point.getStyleUrl();
     point.setStyleUrl("");
     sel_point = point;
 }
Exemplo n.º 4
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;
            }
        }