Ejemplo n.º 1
0
        private void butCreateAllXYZ_Click(object sender, EventArgs e)
        {
            double SoundBlockSize = double.Parse(textBoxBlockSize.Text);

            List <CHSChart> chsChartList = new List <CHSChart>();
            List <CHSDepth> chsDepthList = new List <CHSDepth>();

            // checking if the directory exist if not should create the directory
            DirectoryInfo di = new DirectoryInfo(textBoxDirectoryPath.Text);

            if (!di.Exists)
            {
                di.Create();
            }

            using (BathymetryEntities be = new BathymetryEntities())
            {
                chsChartList = (from c in be.CHSCharts select c).OrderBy(c => c.CHSChartName).ToList <CHSChart>();
            }

            foreach (CHSChart chs in chsChartList)
            {
                StringBuilder sb = new StringBuilder();

                lblStatusTxt2.Text = "Doing " + chs.CHSChartName + " ... loading data from DB this could take a minute.";
                lblStatusTxt2.Refresh();
                Application.DoEvents();

                using (BathymetryEntities be = new BathymetryEntities())
                {
                    chsDepthList = (from cd in be.CHSDepths
                                    where cd.CHSChartID == chs.CHSChartID
                                    select cd).ToList <CHSDepth>();
                }

                int CountDepth = 0;
                foreach (CHSDepth d in chsDepthList.OrderBy(d => d.Depth))
                {
                    CountDepth += 1;
                    if (CountDepth % 1000 == 0)
                    {
                        lblStatusTxt2.Text = "Doing " + chs.CHSChartName + " --- " + CountDepth;
                        lblStatusTxt2.Refresh();
                        Application.DoEvents();
                    }

                    sb.AppendLine(string.Format("{0},{1},{2} ", d.Longitude, d.Latitude, (d.Depth * -1.0f)));
                }

                StreamWriter sw = File.CreateText(textBoxDirectoryPath.Text + chs.CHSChartName + ".xyz");
                sw.Write(sb);
                sw.Flush();
                sw.Close();
            }
        }
Ejemplo n.º 2
0
        private void KMLtoXYZ_Load(object sender, EventArgs e)
        {
            using (BathymetryEntities be = new BathymetryEntities())
            {
                List <BathName> BathyNameList = (from b in be.CHSCharts
                                                 where !b.CHSChartName.Contains("SOUNDG")
                                                 orderby b.CHSChartName
                                                 select new BathName
                {
                    ID = b.CHSChartID,
                    Name = b.CHSChartName
                }).ToList <BathName>();

                listBoxChartNames.DataSource = BathyNameList;
                ColorValList = FillColorValues();
            }
        }
Ejemplo n.º 3
0
        private string TopOfKML(StringBuilder sb, string DocName)
        {
            BathymetryEntities be = new BathymetryEntities();

            var chsDepthList = (from d in be.CHSDepths where d.LineValue > 0 select d.Depth).Distinct().ToList();

            sb.AppendLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>");
            sb.AppendLine(@"<kml xmlns=""http://www.opengis.net/kml/2.2"" xmlns:gx=""http://www.google.com/kml/ext/2.2"" xmlns:kml=""http://www.opengis.net/kml/2.2"" xmlns:atom=""http://www.w3.org/2005/Atom"">");
            sb.AppendLine(@"<Document>");
            sb.AppendLine(@"	<name>"+ DocName + "</name>");
            foreach (ColorVal ColVal in FillColorValues())
            {
                sb.AppendLine(@"	<Style id=""C_"+ ColVal.Value.ToString().Replace(".", "_") + @""">");
                sb.AppendLine(@"		<LineStyle>");
                sb.AppendLine(@"			<color>"+ ColVal.ColorHexStr + "</color>");
                sb.AppendLine(@"			<width>1</width>");
                sb.AppendLine(@"		</LineStyle>");
                sb.AppendLine(@"		<PolyStyle>");
                sb.AppendLine(@"			<color>"+ ColVal.ColorHexStr + "</color>");
                sb.AppendLine(@"			<width>1</width>");
                sb.AppendLine(@"		</PolyStyle>");
                sb.AppendLine(@"		<IconStyle>");
                sb.AppendLine(@"			<color>"+ ColVal.ColorHexStr + "</color>");
                sb.AppendLine(@"			<scale>1.3</scale>");
                sb.AppendLine(@"			<Icon>");
                sb.AppendLine(@"				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>");
                sb.AppendLine(@"			</Icon>");
                sb.AppendLine(@"			<hotSpot x=""20"" y=""2"" xunits=""pixels"" yunits=""pixels""/>");
                sb.AppendLine(@"		</IconStyle>");
                sb.AppendLine(@"		<LabelStyle>");
                sb.AppendLine(@"			<color>"+ ColVal.ColorHexStr + "</color>");
                sb.AppendLine(@"		</LabelStyle>");
                sb.AppendLine(@"	</Style>");
            }

            sb.AppendLine(@"	<Folder>");
            sb.AppendLine(@"	<name>"+ DocName + "</name>");

            return(sb.ToString());
        }
Ejemplo n.º 4
0
        private void butCreateXYZ_Click(object sender, EventArgs e)
        {
            List <CHSChart> chsChartList = new List <CHSChart>();
            List <CHSDepth> chsDepthList = new List <CHSDepth>();

            // checking if the directory exist if not should create the directory
            DirectoryInfo di = new DirectoryInfo(textBoxDirectoryPath.Text);

            if (!di.Exists)
            {
                di.Create();
            }

            foreach (BathName bn in listBoxChartNames.SelectedItems)
            {
                lblStatusTxt2.Text = "Doing " + bn.Name;
                lblStatusTxt2.Refresh();
                Application.DoEvents();

                using (BathymetryEntities be = new BathymetryEntities())
                {
                    if (checkBoxIncludeSounds.Checked == true)
                    {
                        chsChartList = (from c in be.CHSCharts
                                        where c.CHSChartName.StartsWith(bn.Name)
                                        select c).ToList <CHSChart>();
                    }
                    else
                    {
                        chsChartList = (from c in be.CHSCharts
                                        where c.CHSChartName == bn.Name
                                        select c).ToList <CHSChart>();
                    }
                }

                if (chsChartList.Count == 0)
                {
                    if (checkBoxIncludeSounds.Checked == true)
                    {
                        MessageBox.Show("Error while trying to find [" + bn.Name + "] or [" + bn.Name + "SOUNDG" + "] in CHSCharts");
                    }
                    else
                    {
                        MessageBox.Show("Error while trying to find [" + bn.Name + "] in CHSCharts");
                    }
                }

                foreach (CHSChart chs in chsChartList)
                {
                    StringBuilder sb = new StringBuilder();

                    if (chs.CHSChartName.Contains("SOUNDG"))
                    {
                        //TopOfKML(sb, chs.CHSChartName);

                        lblStatusTxt2.Text = "Doing " + chs.CHSChartName + " ... loading data from DB this could take a minute.";
                        lblStatusTxt2.Refresh();
                        Application.DoEvents();

                        using (BathymetryEntities be = new BathymetryEntities())
                        {
                            chsDepthList = (from cd in be.CHSDepths
                                            where cd.CHSChartID == chs.CHSChartID &&
                                            cd.LineValue == -999 &&
                                            cd.Depth >= 0
                                            orderby cd.Depth, cd.LineValue
                                            select cd).ToList <CHSDepth>();
                        }

                        int CountDepth = 0;
                        foreach (CHSDepth d in chsDepthList.OrderBy(d => d.Depth))
                        {
                            CountDepth        += 1;
                            lblStatusTxt2.Text = "Doing " + bn.Name + " --- " + CountDepth;
                            lblStatusTxt2.Refresh();
                            Application.DoEvents();
                            double SoundBlockSize = double.Parse(textBoxBlockSize.Text);
                            Application.DoEvents();

                            sb.AppendLine(string.Format("{0},{1},{2} ", d.Longitude, d.Latitude, (d.Depth * -1.0f)));
                        }

                        StreamWriter sw = File.CreateText(textBoxDirectoryPath.Text + bn.Name + "SOUNDG.xyz");
                        sw.Write(sb);
                        sw.Flush();
                        sw.Close();

                        richTextBoxKMLFile.Text = sb.ToString();
                    }
                    else
                    {
                        lblStatusTxt2.Text = "Doing " + chs.CHSChartName + " ... loading data from DB this could take a minute.";
                        lblStatusTxt2.Refresh();
                        Application.DoEvents();

                        using (BathymetryEntities be = new BathymetryEntities())
                        {
                            chsDepthList = (from cd in be.CHSDepths
                                            where cd.CHSChartID == chs.CHSChartID
                                            select cd).ToList <CHSDepth>();
                        }

                        int CountDepth = 0;
                        foreach (CHSDepth cd in chsDepthList)
                        {
                            CountDepth        += 1;
                            lblStatusTxt2.Text = "Doing " + bn.Name + " --- " + CountDepth;
                            lblStatusTxt2.Refresh();
                            Application.DoEvents();

                            sb.AppendLine(string.Format("{0},{1},{2} ", cd.Longitude, cd.Latitude, (cd.Depth * -1.0f)));
                        }

                        StreamWriter sw = File.CreateText(textBoxDirectoryPath.Text + bn.Name + ".xyz");
                        sw.Write(sb);
                        sw.Flush();
                        sw.Close();

                        richTextBoxKMLFile.Text = sb.ToString();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void butCreateKML_Click(object sender, EventArgs e)
        {
            List <CHSChart> chsChartList = new List <CHSChart>();
            List <CHSDepth> chsDepthList = new List <CHSDepth>();

            // checking if the directory exist if not should create the directory
            DirectoryInfo di = new DirectoryInfo(textBoxDirectoryPath.Text);

            if (!di.Exists)
            {
                di.Create();
            }

            foreach (BathName bn in listBoxChartNames.SelectedItems)
            {
                lblStatusTxt2.Text = "Doing " + bn.Name;
                lblStatusTxt2.Refresh();
                Application.DoEvents();

                using (BathymetryEntities be = new BathymetryEntities())
                {
                    if (checkBoxIncludeSounds.Checked == true)
                    {
                        chsChartList = (from c in be.CHSCharts
                                        where c.CHSChartName.StartsWith(bn.Name)
                                        select c).ToList <CHSChart>();
                    }
                    else
                    {
                        chsChartList = (from c in be.CHSCharts
                                        where c.CHSChartName == bn.Name
                                        select c).ToList <CHSChart>();
                    }
                }

                if (chsChartList.Count == 0)
                {
                    if (checkBoxIncludeSounds.Checked == true)
                    {
                        MessageBox.Show("Error while trying to find [" + bn.Name + "] or [" + bn.Name + "SOUNDG" + "] in CHSCharts");
                    }
                    else
                    {
                        MessageBox.Show("Error while trying to find [" + bn.Name + "] in CHSCharts");
                    }
                }

                foreach (CHSChart chs in chsChartList)
                {
                    StringBuilder sb = new StringBuilder();

                    if (chs.CHSChartName.Contains("SOUNDG"))
                    {
                        TopOfKML(sb, chs.CHSChartName);

                        lblStatusTxt2.Text = "Doing " + chs.CHSChartName + " ... loading data from DB this could take a minute.";
                        lblStatusTxt2.Refresh();
                        Application.DoEvents();

                        using (BathymetryEntities be = new BathymetryEntities())
                        {
                            chsDepthList = (from cd in be.CHSDepths
                                            where cd.CHSChartID == chs.CHSChartID &&
                                            cd.LineValue == -999 &&
                                            cd.Depth >= 0
                                            orderby cd.Depth, cd.LineValue
                                            select cd).ToList <CHSDepth>();
                        }

                        int CountDepth = 0;
                        foreach (CHSDepth d in chsDepthList.OrderBy(d => d.Depth))
                        {
                            CountDepth        += 1;
                            lblStatusTxt2.Text = "Doing " + bn.Name + " --- " + CountDepth;
                            lblStatusTxt2.Refresh();
                            Application.DoEvents();
                            double SoundBlockSize = double.Parse(textBoxBlockSize.Text);
                            Application.DoEvents();

                            sb.AppendLine(@"		<Placemark>");
                            sb.AppendLine(@"			<name>-"+ d.Depth + "</name>");
                            sb.AppendLine(@"			<styleUrl>#"+ GetColorStyleID((double)d.Depth, ColorValList) + "</styleUrl>");
                            sb.AppendLine(@"		    <LineString>");
                            sb.AppendLine(@"				<tessellate>1</tessellate>");
                            sb.AppendLine(@"			    <coordinates>");
                            sb.Append(string.Format("{0},{1},0 ", d.Longitude - SoundBlockSize, d.Latitude - SoundBlockSize));
                            sb.Append(string.Format("{0},{1},0 ", d.Longitude - SoundBlockSize, d.Latitude + SoundBlockSize));
                            sb.Append(string.Format("{0},{1},0 ", d.Longitude + SoundBlockSize, d.Latitude + SoundBlockSize));
                            sb.Append(string.Format("{0},{1},0 ", d.Longitude + SoundBlockSize, d.Latitude - SoundBlockSize));
                            sb.Append(string.Format("{0},{1},0 ", d.Longitude - SoundBlockSize, d.Latitude - SoundBlockSize));
                            sb.AppendLine();
                            sb.AppendLine(@"			    </coordinates>");
                            sb.AppendLine(@"	        </LineString>");
                            sb.AppendLine(@"		</Placemark>");
                        }
                        BottomOfKML(sb);

                        StreamWriter sw = File.CreateText(textBoxDirectoryPath.Text + bn.Name + "SOUNDG.kml");
                        sw.Write(sb);
                        sw.Flush();
                        sw.Close();

                        richTextBoxKMLFile.Text = sb.ToString();
                    }
                    else
                    {
                        TopOfKML(sb, chs.CHSChartName);

                        lblStatusTxt2.Text = "Doing " + chs.CHSChartName + " ... loading data from DB this could take a minute.";
                        lblStatusTxt2.Refresh();
                        Application.DoEvents();

                        using (BathymetryEntities be = new BathymetryEntities())
                        {
                            chsDepthList = (from cd in be.CHSDepths
                                            where cd.CHSChartID == chs.CHSChartID &&
                                            cd.Depth >= 0
                                            orderby cd.Depth, cd.LineValue
                                            select cd).ToList <CHSDepth>();
                        }

                        double OldLineValue = -999;
                        int    CountDepth   = 0;
                        foreach (CHSDepth cd in chsDepthList)
                        {
                            CountDepth        += 1;
                            lblStatusTxt2.Text = "Doing " + bn.Name + " --- " + CountDepth;
                            lblStatusTxt2.Refresh();
                            Application.DoEvents();
                            if (cd.LineValue != OldLineValue)
                            {
                                if (CountDepth != 1)
                                {
                                    sb.AppendLine();
                                    sb.AppendLine(@"				</coordinates>");
                                    sb.AppendLine(@"			</LineString>");
                                    sb.AppendLine(@"		</Placemark>");
                                }

                                OldLineValue = (double)cd.LineValue;

                                sb.AppendLine(@"		<Placemark>");
                                if (cd.Depth == 0)
                                {
                                    sb.AppendLine(@"			<name>"+ cd.Depth + "</name>");
                                }
                                else
                                {
                                    sb.AppendLine(@"			<name>-"+ cd.Depth + "</name>");
                                }
                                sb.AppendLine(@"			<styleUrl>#"+ GetColorStyleID((double)cd.Depth, ColorValList) + "</styleUrl>");
                                sb.AppendLine(@"			<LineString>");
                                sb.AppendLine(@"				<tessellate>1</tessellate>");
                                sb.AppendLine(@"				<coordinates>");
                            }
                            else
                            {
                                sb.Append(string.Format("{0},{1},0 ", cd.Longitude, cd.Latitude));
                            }
                        }
                        sb.AppendLine();
                        sb.AppendLine(@"				</coordinates>");
                        sb.AppendLine(@"			</LineString>");
                        sb.AppendLine(@"		</Placemark>");

                        BottomOfKML(sb);

                        StreamWriter sw = File.CreateText(textBoxDirectoryPath.Text + bn.Name + ".kml");
                        sw.Write(sb);
                        sw.Flush();
                        sw.Close();

                        richTextBoxKMLFile.Text = sb.ToString();
                    }
                }
            }
        }