private void UpdateShowChildren(KmlFeature oldNode, KmlFeature newNode)
		{ 
			if(oldNode != null)
			{
				oldNode.PropertyChanged -= KmlFeature_PropertyChanged;
			}
			if(newNode != null)
			{
				newNode.PropertyChanged += KmlFeature_PropertyChanged;
			}
			UpdateShowChildren();
		}
Beispiel #2
0
 private void UpdateShowChildren(KmlFeature oldNode, KmlFeature newNode)
 {
     if (oldNode != null)
     {
         oldNode.PropertyChanged -= KmlFeature_PropertyChanged;
     }
     if (newNode != null)
     {
         newNode.PropertyChanged += KmlFeature_PropertyChanged;
     }
     UpdateShowChildren();
 }
Beispiel #3
0
        //todo this stuff below is too tightly coupled to implementtion for winforms
        public static void GotoLookAt(KmlFeature feature)
        {
            //todo add sky support
            CameraParameters camera = new CameraParameters();

            camera.Lat      = feature.LookAt.latitude;
            camera.Lng      = feature.LookAt.longitude;
            camera.Rotation = feature.LookAt.heading / 180 * Math.PI;
            camera.Angle    = -feature.LookAt.tilt / 180 * Math.PI;
            camera.Zoom     = UiTools.MetersToZoom(feature.LookAt.range);
            TourPlace p = new TourPlace(feature.Name, camera, Classification.Unidentified, "", ImageSetType.Earth, SolarSystemObjects.Earth);

            Earth3d.MainWindow.GotoTarget(p, false, false, true);
        }
Beispiel #4
0
 private static void CheckAllChildren(LayerUITreeNode node)
 {
     // deep check children
     foreach (LayerUITreeNode child in node.Nodes)
     {
         child.Checked = true;
         KmlFeature childFeature = child.Tag as KmlFeature;
         if (childFeature != null)
         {
             childFeature.visibility = true;
         }
         CheckAllChildren(child);
     }
 }
Beispiel #5
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);
             //    }
             //}
         }
     }
 }
        public virtual GeoJsonObject ConvertFeature(KmlFeature feature, IStyleProvider provider)
        {
            switch (feature)
            {
            case KmlDocument document:
                throw new NotImplementedException();
            //return ConvertDocument(document, provider ?? document.StyleSelectors);

            case KmlFolder folder:
                return(ConvertFolder(folder, provider));

            case KmlPlacemark placemark:
                return(ConvertPlacemark(placemark, provider));

            default:
                throw new KmlException("Unsupported feature " + feature.GetType());
            }
        }
		private void OnFeatureDoubleTapped(object sender, KmlFeature feature)
		{
			var vp = feature.Viewpoint;
			if(vp != null)
			{
				if (vm.Is3D)
				{
					sceneView.SetViewAsync(vp, 2, true);
					sceneView.Focus(FocusState.Keyboard);
				}
				else
				{
					mapView.Focus(FocusState.Keyboard);
					mapView.SetViewAsync(vp);
				}
				if (highlightedFeature != null)
					highlightedFeature.IsHighlighted = false;
				feature.IsHighlighted = true;
				highlightedFeature = feature;
			}
		}
		private void ShowMapTip(KmlFeature feature, MapPoint location = null)
		{
			ViewBase view = vm.Is3D ? (ViewBase)sceneView : (ViewBase)mapView;
			var border = (Border)view.Overlays.Items.First();
			if (feature == null || feature.BalloonStyle == null || string.IsNullOrWhiteSpace(feature.BalloonStyle.FormattedText) ||
				feature.Viewpoint == null || feature.Viewpoint.TargetGeometry == null)
			{
				border.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
				currentMaptip = null;
				return;
			}
			var grid = (Grid)border.Child;
			var webview = grid.Children.OfType<WebView>().First();
			webview.NavigateToString(feature.BalloonStyle.FormattedText);
			ViewBase.SetViewOverlayAnchor(border, location ?? feature.Viewpoint.TargetGeometry.Extent.GetCenter());
			border.Visibility = Windows.UI.Xaml.Visibility.Visible;
			currentMaptip = border;
		}
		private void HighlightFeature(KmlFeature feature)
		{
			if (highlightedFeature != null)
				highlightedFeature.IsHighlighted = false;
			if (highlightedFeature == feature)
			{
				highlightedFeature = null;
				return;
			}
			if (feature != null)
				feature.IsHighlighted = true;
			
			highlightedFeature = feature;
		}
		private void OnFeatureTapped(object sender, KmlFeature feature)
		{
			HighlightFeature(feature);
		}
        protected virtual void ConvertFolder(KmlFolder folder, GeoJsonFeatureCollection collection, KmlFeature feature, IStyleProvider provider)
        {
            switch (feature)
            {
            case KmlPlacemark placemark:

                collection.Add(ConvertPlacemark(placemark, provider));

                break;

            case KmlDocument document:
            // Why would you have a document in a folder? (although it seems legal according to the specification)

            case KmlFolder childFolder:
            // Why would you have folder in another folder? (although it seems legal according to the specification)

            default:
                throw new KmlException("Unsupported feature " + feature.GetType());
            }
        }
 public virtual GeoJsonObject ConvertFeature(KmlFeature feature)
 {
     return(ConvertFeature(feature, null));
 }
Beispiel #13
0
        void node_NodeChecked(LayerUITreeNode node, bool newState)
        {
            layer.RetainedVisualsDirty = true;
            KmlFeature item = node.Tag as KmlFeature;

            if (item != null)
            {
                KmlFeature feature = node.Tag as KmlFeature;
                if (node.Tag is KmlFeature)
                {
                    // todo wire up true selection
                    bool selected = false;

                    KmlFeature parent      = node.Parent.Tag as KmlFeature;
                    bool       radioFolder = false;


                    radioFolder = parent == null ? false : parent.Style.GetStyle(selected).ListStyle.ListItemType == KmlListItemTypes.RadioFolder;
                    if (radioFolder)
                    {
                        // Radio folders can't uncheck themselves
                        if (feature.visibility && !node.Checked)
                        {
                            node.Checked = true;
                        }
                        else
                        {
                            feature.visibility = node.Checked;
                        }
                    }
                    else
                    {
                        // Radio folders can't uncheck themselves
                        feature.visibility = node.Checked;
                    }


                    if (feature.visibility)
                    {
                        if (feature.Style.GetStyle(selected).ListStyle.ListItemType != KmlListItemTypes.CheckOffOnly)
                        {
                            if (feature.Style.GetStyle(selected).ListStyle.ListItemType != KmlListItemTypes.RadioFolder)
                            {
                                CheckAllChildren(node);
                            }
                        }

                        // Uncheck siblings if we are a radio button
                        if (node.Parent.Tag is KmlFeature)
                        {
                            if (radioFolder)
                            {
                                foreach (LayerUITreeNode sibling in node.Parent.Nodes)
                                {
                                    if (sibling != node)
                                    {
                                        sibling.Checked = false;
                                        KmlFeature siblingFeature = sibling.Tag as KmlFeature;
                                        if (siblingFeature != null)
                                        {
                                            siblingFeature.visibility = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #14
0
        private void AddFeatureToTree(KmlFeature feature, LayerUITreeNode parent)
        {
            feature.Dirty = false;
            string text = feature.Name;

            //if (!string.IsNullOrEmpty(feature.description))
            //{
            //    text += Environment.NewLine + feature.description;
            //}
            bool bold = false;

            if (text.Contains("<b>"))
            {
                bold = true;
                text = text.Replace("<b>", "").Replace("</b>", "");
            }

            LayerUITreeNode node = null;

            if (!(feature is KmlNetworkLink))
            {
                node                = parent.Add(text);
                node.Tag            = feature;
                node.Checked        = feature.visibility;
                node.Opened         = feature.open;
                node.NodeChecked   += new LayerUITreeNodeCheckedDelegate(node_NodeChecked);
                node.NodeUpdated   += new LayerUITreeNodeUpdatedDelegate(node_NodeUpdated);
                node.NodeActivated += new LayerUITreeNodeActivatedDelegate(node_NodeActivated);
                node.NodeSelected  += new LayerUITreeNodeSelectedDelegate(node_NodeSelected);
                if (bold)
                {
                    node.Bold = true;
                }
            }

            if (feature is KmlContainer)
            {
                KmlContainer container = (KmlContainer)feature;
                if (container.children != null)
                {
                    //  if (feature.Style.GetStyle(false).ListStyle.ListItemType != KmlListItemTypes.CheckHideChildren)
                    {
                        foreach (KmlFeature child in container.children)
                        {
                            AddFeatureToTree(child, node);
                        }
                    }
                }
            }
            else
            {
                if (feature is KmlNetworkLink)
                {
                    KmlNetworkLink netLink = (KmlNetworkLink)feature;
                    if (netLink.LinkRoot != null)
                    {
                        AddRootToTree(netLink.LinkRoot, parent);
                    }
                }
            }
        }
Beispiel #15
0
        private void AddFeatureToDisplay(KmlFeature feature, bool sky)
        {
            KmlDocument doc = feature as KmlDocument;

            if (doc != null)
            {
                sky = doc.sky;
            }
            if (!(feature is KmlNetworkLink))
            {
                if (feature.visibility == false)
                {
                    return;
                }
                else if (feature is KmlPlacemark)
                {
                    KmlPlacemark placemark = (KmlPlacemark)feature;
                    KmlStyle     style     = placemark.Style.GetStyle(placemark.Selected);
                    Color        lineColor = Color.White;
                    if (style != null)
                    {
                        lineColor = style.LineStyle.Color;
                    }
                    if (placemark.geometry is KmlPoint)
                    {
                        placemark.Point = (KmlPoint)placemark.geometry;
                        AddPlacemark(placemark);
                    }
                    else if (placemark.geometry is KmlMultiGeometry)
                    {
                        KmlMultiGeometry geo = (KmlMultiGeometry)placemark.geometry;
                        AddMultiGeometry(sky, placemark, (float)style.LineStyle.Width, style.PolyStyle.Color, lineColor, geo);
                    }
                    else if (placemark.geometry is KmlPolygon)
                    {
                        KmlPolygon geo = (KmlPolygon)placemark.geometry;
                        if (geo.OuterBoundary != null)
                        {
                            AddLines(sky, geo.OuterBoundary as KmlLineList, (float)style.LineStyle.Width, style.PolyStyle.Color, lineColor, geo.extrude);
                            // to do 3d work and subtract inner rings
                        }
                    }
                    else if (placemark.geometry is KmlLineString)
                    {
                        KmlLineString geo = (KmlLineString)placemark.geometry;

                        List <Vector3d> vertexList = new List <Vector3d>();
                        for (int i = 0; i < (geo.PointList.Count); i++)
                        {
                            vertexList.Add(Coordinates.GeoTo3dDouble(geo.PointList[i].Lat, geo.PointList[i].Lng, 1 + (geo.PointList[i].Alt / geo.MeanRadius)));
                        }
                        for (int i = 0; i < (geo.PointList.Count - 1); i++)
                        {
                            if (sky)
                            {
                                lines.AddLine(Coordinates.RADecTo3d(-(180.0 - geo.PointList[i].Lng) / 15 + 12, geo.PointList[i].Lat, 1), Coordinates.RADecTo3d(-(180.0 - geo.PointList[i + 1].Lng) / 15 + 12, geo.PointList[i + 1].Lat, 1), lineColor, new Dates());
                            }
                            else
                            {
                                lines.AddLine(vertexList[i], vertexList[i + 1], lineColor, new Dates());
                            }
                        }
                    }
                }
                if (feature is KmlGroundOverlay && feature.visibility)
                {
                    AddGroundOverlay(feature as KmlGroundOverlay);
                }

                if (feature is KmlScreenOverlay && feature.visibility)
                {
                    AddScreenOverlay(feature as KmlScreenOverlay);
                }
            }
            if (feature.visibility)
            {
                if (feature is KmlContainer)
                {
                    KmlContainer container = (KmlContainer)feature;
                    if (container.children != null)
                    {
                        foreach (KmlFeature child in container.children)
                        {
                            AddFeatureToDisplay(child, sky);
                        }
                    }
                }
                else
                {
                    if (feature is KmlNetworkLink)
                    {
                        KmlNetworkLink netLink = (KmlNetworkLink)feature;
                        if (netLink.LinkRoot != null)
                        {
                            foreach (KmlFeature child in netLink.LinkRoot.children)
                            {
                                AddFeatureToDisplay(child, sky);
                            }
                        }
                    }
                }
            }
        }