00001 using System;
00002 using System.Collections.Generic;
00003 using System.Linq;
00004 using System.Text;
00005 using System.IO;
00006 using System.Windows.Forms;
00007
00008 namespace UtmConvert {
00009 public class Printer {
00010
00011 string _status = "ok";
00012 public string Status {
00013 get { return _status; }
00014 }
00015
00016 string _output = "";
00017 public string Output {
00018 get { return _output; }
00019 }
00020
00021 public string writeUtmXmlFile(List<UtmPointSet> lps) {
00022 _status = "ok";
00023 try {
00024 StreamWriter sWrite = new StreamWriter("utm_" + lps[0]
00025 .LocationName + ".xml", false, Encoding.UTF8);
00026 _output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n\r\n";
00027 foreach (UtmPointSet ps in lps) {
00028 _output = _output + "<utm_point_set location=\""
00029 + ps.LocationName + "\" datum=\"" + ps.Datum + "\">\r\n";
00030 foreach (UtmPoint pt in ps.Points)
00031 _output = _output + "\t<dd_dd easting=\"" + pt.Point.X
00032 + "\" northing=\"" + pt.Point.Y + "\" zone=\""
00033 + pt.Zone + "\" note=\"" + pt.Note
00034 + "\" handle=\"" + pt.Handle + "\" />\r\n";
00035 _output = _output + "</utm_point_set>\r\n";
00036 }
00037 sWrite.Write(_output);
00038 sWrite.Close();
00039 return "utm_" + lps[0].LocationName + ".xml";
00040 } catch (Exception e) {
00041 _status = e.Message;
00042 return _status;
00043 }
00044 }
00045
00046 public string writeLatLonXmlFile(List<LatLonPointSet> lps) {
00047 _status = "ok";
00048 try {
00049 StreamWriter sWrite = new StreamWriter("lat_lon_" + lps[0]
00050 .LocationName + ".xml", false, Encoding.UTF8);
00051 _output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n\r\n";
00052 foreach (LatLonPointSet ps in lps) {
00053 _output = _output + "<lat_lon_point_set location=\"" + ps.LocationName
00054 + "\" datum=\"" + ps.Datum + "\">\r\n";
00055 foreach (LatLonPoint pt in ps.Points) {
00056 if (pt.Format == "ddd_dd")
00057 _output = _output + "\t<" + pt.Format + " " + "lat=\""
00058 + ConvertDegRad.getDegrees(Math.Abs(pt.Lat))
00059 + "\" ns=\"" + pt.Ns + "\" lon=\""
00060 + ConvertDegRad.getDegrees(Math.Abs(pt.Lon))
00061 + "\" ew=\"" + pt.Ew + "\" note=\"" + pt.Note
00062 +"\" handle=\"" + pt.Handle + "\" />\r\n";
00063 else if (pt.Format == "ddd_mm_mm")
00064 _output = _output + "\t<" + pt.Format + " " + "lat=\""
00065 + ConvertDegRad.getDegreesMin(Math.Abs(pt.Lat))
00066 + "\" ns=\"" + pt.Ns + "\" lon=\""
00067 + ConvertDegRad.getDegreesMin(Math.Abs(pt.Lon))
00068 + "\" ew=\"" + pt.Ew + "\" note=\"" + pt.Note
00069 +"\" handle=\"" + pt.Handle + "\" />\r\n";
00070 else
00071 _output = _output + "\t<" + pt.Format + " " + "lat=\""
00072 + ConvertDegRad.getDegreesMinSec(Math.Abs(pt.Lat))
00073 + "\" ns=\"" + pt.Ns + "\" lon=\""
00074 + ConvertDegRad.getDegreesMinSec(Math.Abs(pt.Lon))
00075 + "\" ew=\"" + pt.Ew + "\" note=\"" + pt.Note
00076 +"\" handle=\"" + pt.Handle + "\" />\r\n";
00077 }
00078 _output = _output + "</lat_lon_point_set>\r\n";
00079 }
00080 sWrite.Write(_output);
00081 sWrite.Close();
00082 return "lat_lon_" + lps[0].LocationName + ".xml";
00083 } catch (Exception e) {
00084 _status = e.Message;
00085 return _status;
00086 }
00087 }
00088 }
00089
00090
00091 }