コード例 #1
0
        public double distance(KmlCoordinate p0, KmlCoordinate p1, KmlCoordinate p2)
        {
            double u, result = 0.0;

                if (p1.Latitude == p2.Latitude
                          && p1.Longitude == p2.Longitude) {
                    result = Math.Sqrt(Math.Pow(p2.Latitude - p0.Latitude, 2)
                              + Math.Pow(p2.Longitude - p0.Longitude, 2));
                } else {
                    u = ((p0.Latitude - p1.Latitude)
                              * (p2.Latitude - p1.Latitude) + (p0
                              .Longitude - p1.Longitude)
                              * (p2.Longitude - p1.Longitude))
                              / (Math.Pow(p2.Latitude - p1.Latitude, 2) + Math
                                         .Pow(p2.Longitude - p1.Longitude, 2));

                    if (u <= 0) {
                        result = Math.Sqrt(Math.Pow(p0.Latitude - p1.Latitude,
                                  2)
                                  + Math.Pow(p0.Longitude - p1.Longitude, 2));
                    } else if (u >= 1) {
                        result = Math.Sqrt(Math.Pow(p0.Latitude - p2.Latitude,
                                  2)
                                  + Math.Pow(p0.Longitude - p2.Longitude, 2));
                    } else if (0 < u && u < 1) {
                        result = Math.Sqrt(Math.Pow(p0.Latitude - p1.Latitude
                                  - u * (p2.Latitude - p1.Latitude), 2)
                                  + Math.Pow(p0.Longitude - p1.Longitude - u
                                             * (p2.Longitude - p1.Longitude), 2));
                    }
                }
                return result;
        }
コード例 #2
0
 void node_NodeActivated(LayerUITreeNode node)
 {
     if (node != null && node.Tag is KmlFeature)
     {
         KmlFeature feature = (KmlFeature)node.Tag;
         if (feature.LookAt != null)
         {
             if (feature.sky)
             {
                 Earth3d.MainWindow.GotoTarget(new TourPlace(feature.Name, feature.LookAt.latitude, (feature.LookAt.longitude + 180) / 15, Classification.Unidentified, "", ImageSetType.Sky, .8), false, false, true);
             }
             else
             {
                 GotoLookAt(feature);
             }
         }
         else if (node.Tag is KmlPlacemark)
         {
             KmlPlacemark placemark = (KmlPlacemark)node.Tag;
             if (placemark.geometry != null)
             {
                 KmlCoordinate point = placemark.geometry.GetCenterPoint();
                 if (placemark.sky)
                 {
                     Earth3d.MainWindow.GotoTarget(new TourPlace(placemark.Name, point.Lat, (point.Lng + 180) / 15, Classification.Unidentified, "", ImageSetType.Sky, .8), false, false, true);
                 }
                 else
                 {
                     Earth3d.MainWindow.GotoTarget(new TourPlace(placemark.Name, point.Lat, point.Lng, Classification.Unidentified, "", ImageSetType.Earth, .8), false, false, true);
                 }
             }
             //if (placemark.geometry is KmlPoint)
             //{
             //    KmlPoint point = (KmlPoint)placemark.geometry;
             //    if (placemark.sky)
             //    {
             //        Earth3d.MainWindow.GotoTarget(new TourPlace(placemark.Name, point.latitude, (point.longitude + 180) / 15, Classification.Unidentified, "", ImageSetType.Sky, .8), false, false, true);
             //    }
             //    else
             //    {
             //        Earth3d.MainWindow.GotoTarget(new TourPlace(placemark.Name, point.latitude, point.longitude, Classification.Unidentified, "", ImageSetType.Earth, .8), false, false, true);
             //    }
             //}
         }
     }
 }