Пример #1
0
        /// <summary>
        /// Return the inital KMZ as requested by the apsim.info web site.
        /// </summary>
        private byte[] MyDataKMZ()
        {
            kml KmlContainer = new kml();

            Document KmlDoc = new Document();

            KmlDoc.Name.Text            = "APSoil characterised soils";
            KmlDoc.Snippet.Text         = "Fully characterised soil sites for use with APSIM and Yield Prophet.";
            KmlDoc.Description.UseCDATA = true;
            KmlDoc.Description.Text     = "<p>The soil sites displayed are from APSoil</p>";
            KmlContainer.Documents.Add(KmlDoc);

            NetworkLink KmlNetworkLink = new NetworkLink("APSoil soils", "All characterised soils");

            KmlNetworkLink.Link.Href.Text         = ourPath + "/ApsoilKML.aspx?Mode=1";
            KmlNetworkLink.Link.RefreshMode.Value = refreshModeEnum.onExpire;
            KmlDoc.Features.NetworkLinks.Add(KmlNetworkLink);

            return(KmlContainer.GetKMZ("APSRU_Sites.kml"));
        }
Пример #2
0
        /// <summary>
        /// This is called directly by Google Earth when it wants KML data.
        /// </summary>
        private byte[] NetworkLinkData()
        {
            kml      KmlContent = new kml();
            Document KmlDoc     = new Document("Test", "");

            KmlContent.Documents.Add(KmlDoc);

            KML_22_Beta1.Style APSRUIcon = new KML_22_Beta1.Style();
            APSRUIcon.IconStyle.Icon.Href.Text = "http://apsimdev.apsim.info/ApsoilWeb/shovel.png";
            APSRUIcon.IconStyle.Scale.Value    = 0.7;
            APSRUIcon.LabelStyle.Scale.Value   = 0.7;
            APSRUIcon.id = "APSRUIconID";
            KmlDoc.StyleSelector.Style.Add(APSRUIcon);

            Dictionary <string, Folder> Folders = new Dictionary <string, Folder>();

            ApsoilWeb.Service SoilsDB = new Apsoil.ApsoilWeb.Service();
            foreach (string Name in SoilsDB.AllSoilNames(false))
            {
                string FolderName = Name;
                if (FolderName.Contains("/"))
                {
                    FolderName = FolderName.Substring(0, FolderName.LastIndexOf('/'));
                }

                Soil Soil = Soil.Create(SoilsDB.SoilXML(Name));
                if (Soil != null)
                {
                    string BalloonDescription = "<p><b>" + Soil.Name + "</b></p><p><i>"
                                                + Soil.Comments + "</i></p>";

                    string DataSourceComments = Soil.DataSource;
                    if (DataSourceComments != null && DataSourceComments != "")
                    {
                        BalloonDescription += "<p><i>Data source: " + DataSourceComments + "</i></p>";
                    }

                    BalloonDescription += "<img src=\"" + ourPath + "SoilChart.aspx?Name=" + Name + "\"/>";

                    BalloonDescription += "<p><a href=\"" + ourPath + "GetSoil.aspx?Name=" + Name + "\">Download soil in APSIM format (copy and paste contents to your simulation).</a></p>";
                    BalloonDescription += "<p><a name=\"link_id\" id=\"link_id\"  href=\"Download.html\" onclick=\"window.open('" + ourPath + "Excel.aspx?Name=" + Name + "');\">Download soil as an EXCEL spreadsheet</a></p>";

                    string SoilName = Soil.Name;
                    if (Soil.ApsoilNumber != "")
                    {
                        SoilName = Soil.ApsoilNumber;
                    }
                    Placemark plmMyPlaceMark = new Placemark(SoilName,
                                                             BalloonDescription,
                                                             Soil.Latitude,
                                                             Soil.Longitude,
                                                             0, altitudeModeEnum.clampToGround);
                    plmMyPlaceMark.Description.UseCDATA = true;
                    plmMyPlaceMark.Description.Text     = BalloonDescription;
                    plmMyPlaceMark.StyleUrl.Text        = "#APSRUIconID";

                    Folder F = GetFolder(FolderName, Folders, KmlDoc);
                    F.Features.Placemarks.Add(plmMyPlaceMark);
                }
            }

            KmlContent.NetworkLinkControl.Expires.Value        = DateTime.Now.AddDays(7);
            KmlContent.NetworkLinkControl.LinkDescription.Text = "Characterised sites - " + DateTime.Now.ToString("dd MMM yyyy HH:mm:ss");
            return(KmlContent.GetKMZ("NetworkData.kml"));
        }