ToKML() public method

Return a byte array that is the final KML file.
public ToKML ( ) : byte[]
return byte[]
Beispiel #1
0
        public static string AsKML(this SqlGeography geog, string docname, string pname, string description)
        {
            Utilities u = new Utilities();

            if (u.IsNullOrEmpty(geog))
                return "";

            geDocument doc = u.SqlGeogInstanceToKmlDoc(geog, docname, pname, description);
            geKML kml = new geKML(doc);
            return System.Text.Encoding.ASCII.GetString(kml.ToKML());
        }
Beispiel #2
0
        public void Generate(string path,ProgressBar pBar)
        {
            //generates document at path. shows progress using progressbar pBar

            this.Path = path;
            kmlDocument.Name = System.IO.Path.GetFileName(path);;
            kmlDocument.StyleSelectors.Add(defaultStyle);

            //create a step in the progressbar for each layer
            int nrLayers = kmlLayers.Count;
            pBar.Minimum = 0;
            pBar.Maximum = nrLayers+1;
            pBar.Step = 1;
            //should generate a kml document at path...
            //first, iterate layers. Each layer makes a folder
            foreach (LayerProperties lp in kmlLayers)
            {
                //create a folder for the layer
                geFolder folder = new geFolder();
                folder.Name = lp.name;
                folder.Open = true;
                folder.Description = lp.Layeru.Name;

                processLayerProperties(lp,folder);

                kmlDocument.Features.Add(folder);
                pBar.PerformStep();
            }

            //no more layers, get document :)
            geKML kml = new geKML(kmlDocument);

            File.WriteAllBytes(path, kml.ToKML());
            pBar.PerformStep();
            //ProcessStartInfo psInfNotepad = new ProcessStartInfo("notepad.exe", path);
            //Process.Start(psInfNotepad);
        }