Exemplo n.º 1
0
        public XmlDocument getKML(int connID)
        {
            String serverPath = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":"
                + HttpContext.Current.Request.ServerVariables["SERVER_PORT"];

            //create new connection a populate fields to get the connection name for KMLGenerator
            Connection conn = new Connection(connID);
            conn.populateFields();
            string name = conn.getConnInfo().getConnectionName();

            //create a new kml genereator with the connection name as the placemark name
            KMLGenerator kmlGen = new KMLGenerator(name, serverPath);

            string kml = "";
            //generate the kml for the given connID
            try
            {
                kml = kmlGen.generateKML(connID);
            }
            catch (Exception e)
            {
                //if there was an error generating kml, return a kml file that contains only a screen overlay that states there was an error generating kml
                kml = "<ScreenOverlay>	<name>KML Error</name>	<Icon>		<href>" + serverPath + "/graphics/kml-error.png</href>	</Icon>	<overlayXY x=\"0.5\" y=\"0.5\" xunits=\"fraction\" yunits=\"fraction\"/>	<screenXY x=\"0.5\" y=\"0.5\" xunits=\"fraction\" yunits=\"fraction\"/>	<rotationXY x=\"0\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>	<size x=\"1\" y=\"0.2\" xunits=\"fraction\" yunits=\"fraction\"/></ScreenOverlay>";
            }
            //add the kml to an XMLDoc and return
            XmlDocument kmlDoc = new XmlDocument();
            kmlDoc.LoadXml(kml);
            return kmlDoc;
        }
Exemplo n.º 2
0
        protected void genKMLFunction(object sender, EventArgs e)
        {
            try
            {
                //Generate the KML from the connection
                ImageButton  sendBtn    = (ImageButton)sender;
                String       serverPath = "http://" + Request.ServerVariables["SERVER_NAME"] + ":" + Request.ServerVariables["SERVER_PORT"];
                string       args       = sendBtn.CommandArgument.ToString();
                KMLGenerator kml        = new KMLGenerator(ConnInfo.getConnInfo(Convert.ToInt32(args)).getConnectionName(), serverPath);


                //Generate the KML string based on the connection id
                String     kmlString = kml.generateKML(int.Parse(args));
                Connection conn      = new Connection(int.Parse(args));
                conn.populateFields();

                //Write the KML string to a downloadable file
                Response.ClearHeaders();
                Response.ClearContent();
                Response.ContentType = "application/vnd.google-earth.kml+xml kml";
                Response.AddHeader("Content-Disposition", "attachment; filename=\"" + (conn.getConnInfo()).getConnectionName() + ".kml");
                Response.Write(kmlString);
                Response.End();
                return;
            }
            catch (ODBC2KMLException ex)
            {
                ErrorHandler err = new ErrorHandler(ex.errorText, errorPanel1);
                err.displayError();
                return;
            }

            //Response.Redirect("Main.aspx", true);
        }
Exemplo n.º 3
0
        protected void genKMLFunction(object sender, EventArgs e)
        {
            try
            {
                //Generate the KML from the connection
                ImageButton sendBtn = (ImageButton)sender;
                String serverPath = "http://" + Request.ServerVariables["SERVER_NAME"] + ":" + Request.ServerVariables["SERVER_PORT"];
                string args = sendBtn.CommandArgument.ToString();
                KMLGenerator kml = new KMLGenerator(ConnInfo.getConnInfo(Convert.ToInt32(args)).getConnectionName(), serverPath);

                //Generate the KML string based on the connection id
                String kmlString = kml.generateKML(int.Parse(args));
                Connection conn = new Connection(int.Parse(args));
                conn.populateFields();

                //Write the KML string to a downloadable file
                Response.ClearHeaders();
                Response.ClearContent();
                Response.ContentType = "application/vnd.google-earth.kml+xml kml";
                Response.AddHeader("Content-Disposition", "attachment; filename=\"" + (conn.getConnInfo()).getConnectionName() + ".kml");
                Response.Write(kmlString);
                Response.End();
                return;
            }
            catch (ODBC2KMLException ex)
            {
                ErrorHandler err = new ErrorHandler(ex.errorText, errorPanel1);
                err.displayError();
                return;
            }

            //Response.Redirect("Main.aspx", true);
        }