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

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

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

            lookAt.set(Latitude, Longitude, Altitude, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, Range);
            ge.getView().setAbstractView(lookAt);

            ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, 1);


            //create a point
            KmlPointCoClass point = ge.createPoint("");

            point.setLatitude(lookAt.getLatitude());
            point.setLongitude(lookAt.getLongitude());

            //create a placemark
            KmlPlacemarkCoClass placemark = ge.createPlacemark("");

            placemark.setName("Start Position");
            placemark.setGeometry(point);

            ge.getFeatures().appendChild(placemark);
        }
Exemplo n.º 3
0
        public IKmlCamera allocate()
        {
            double         lat = 0, lon = 0;
            IKmlObjectList days  = ge.getFeatures().getChildNodes();
            IKmlDocument   day   = (IKmlDocument)days.item(0);
            IKmlObjectList trips = day.getFeatures().getChildNodes();

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

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

            vw.set(lat, lon, 25000.0, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 0);
            return(vw);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Remove the feature with the given id from the plugin
 /// </summary>
 /// <param name="ge">The plugin instance</param>
 /// <param name="id">The id of the element to remove</param>
 public static void RemoveFeatureById(IGEPlugin ge, string id)
 {
     while (Convert.ToBoolean(ge.getFeatures().hasChildNodes()))
     {
         if (ge.getFeatures().getFirstChild().getId() == id)
         {
             ge.getFeatures().removeChild(ge.getFeatures().getFirstChild());
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Remove all features from the plugin 
 /// </summary>
 /// <param name="ge">The plugin instance</param>
 public static void RemoveAllFeatures(IGEPlugin ge)
 {
     IGEFeatureContainer features = ge.getFeatures();
     IKmlObject feature = features.getFirstChild();
     while (feature != null)
     {
         features.removeChild(feature);
     }
 }
Exemplo n.º 6
0
        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);
        }