コード例 #1
0
        private void AddLocationsFolder(Document document)
        {
            var locationFolder = new Folder
            {
                Name = "Locations"
            };

            document.AddFeature(locationFolder);

            var listStyle = new ListStyle
            {
                ItemType = ListItemType.CheckHideChildren,
            };

            listStyle.AddItemIcon(new ItemIcon
            {
                Href = new Uri("http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png", UriKind.Absolute)
            });

            locationFolder.AddStyle(new Style
            {
                List = listStyle
            });

            locationFolder.AddFeature(this.From.ToKmlPlacemark(KmlCommonElements.PlacementCircleStyleMapReferenceUri));
            locationFolder.AddFeature(this.To.ToKmlPlacemark(KmlCommonElements.PlacementCircleStyleMapReferenceUri));
        }
コード例 #2
0
        /// <summary>
        /// Creates a KML folder with the visualization settings of the link.
        /// </summary>
        /// <param name="directionVector">The direction vector to convert.</param>
        /// <returns>The KML elements for visualizing the link.</returns>
        public static Folder ToKmlLinkFolder(this IDirectionVector directionVector)
        {
            if (directionVector == null)
            {
                throw new ArgumentNullException(nameof(directionVector), "directionVector is null");
            }

            var fromAsHamnetSite = directionVector.From as IHamnetDbSite;
            var toAsHamnetSite   = directionVector.To as IHamnetDbSite;
            var linkFolder       = new Folder
            {
                Name = (fromAsHamnetSite != null) && (toAsHamnetSite != null)
                    ? $"Link between {fromAsHamnetSite.Callsign?.ToUpperInvariant()} and {toAsHamnetSite.Callsign?.ToUpperInvariant()}"
                    : $"Link between {directionVector.From.Latitude}/{directionVector.From.Longitude} and {directionVector.To.Latitude}/{directionVector.To.Longitude}",
                Visibility = true
            };

            var listStyle = new ListStyle
            {
                ItemType = ListItemType.CheckHideChildren,
            };

            listStyle.AddItemIcon(new ItemIcon
            {
                Href = new Uri("empty_icon.png", UriKind.Relative)
            });

            linkFolder.AddStyle(new Style
            {
                List = listStyle
            });

            linkFolder.AddFeature(CreateLinePlacemark(directionVector.From, directionVector.To, "Line with screen to ground", new Uri("#line", UriKind.Relative), true, string.Empty));

            // description will be added to the larger (outer) zone only - hence the 2.4 GHz zone
            string description = KmlCommonElements.BalloonCssString;

            description += (fromAsHamnetSite != null) && (toAsHamnetSite != null)
                    ? $"<h2>Link between {fromAsHamnetSite.Callsign?.ToUpperInvariant()} and {toAsHamnetSite.Callsign?.ToUpperInvariant()}</h2>"
                    : $"<h2>Link between {directionVector.From.Latitude}/{directionVector.From.Longitude} and {directionVector.To.Latitude}/{directionVector.To.Longitude}</h2>";

            description += $@"<table>
<tr><td class=""left"">distance: </td><td>{directionVector.Distance / 1000.0:F1} km</td></tr>
<tr><td class=""left"">azimuth to: </td><td>{directionVector.Bearing:F1}&#176;</td></tr>
<tr><td class=""left"">elevation to: </td><td>{directionVector.Elevation:F1}&#176;</td></tr>
<tr><td class=""left"">azimuth from: </td><td>{(directionVector.Bearing + 180.0) % 360.0:F3}&#176;</td></tr>
<tr><td class=""left""><a href=""https://en.wikipedia.org/wiki/Free-space_path_loss"">FSPL</a>: </td><td>{directionVector.Distance.FreeSpacePathloss(2.4e9):F1} dB @ 2.4 GHz<br>{directionVector.Distance.FreeSpacePathloss(5.8e9):F1} dB @ 5.8 GHz</td></tr>
</table>";
            linkFolder.AddFeature(CreateFresnelPlacemark(directionVector, "2.4 GHz fresnel zone", 2.4e9, KmlCommonElements.PolygonStyleTransparentReferenceUri, description));
            linkFolder.AddFeature(CreateFresnelPlacemark(directionVector, "5.8 GHz fresnel zone", 5.8e9, KmlCommonElements.PolygonStyleReferenceUri, string.Empty));

            return(linkFolder);
        }