Exemple #1
0
        /// <summary>
        /// Load the default browser map for this server, from either the cache or the server
        /// </summary>
        protected void LoadBrowserMap()
        {
            string strBrowserMapFile = Path.Combine(m_strCacheDir, BROWSERMAP_FILE);

            try
            {
                if (File.Exists(strBrowserMapFile))
                {
                    m_oBrowserMap = new XmlDocument();
                    m_oBrowserMap.Load(strBrowserMapFile);
                }
                else
                {
                    Geosoft.Dap.Common.Format      oFormat      = new Geosoft.Dap.Common.Format();
                    Geosoft.Dap.Common.Resolution  oResolution  = new Geosoft.Dap.Common.Resolution();
                    Geosoft.Dap.Common.BoundingBox oBoundingBox = new Geosoft.Dap.Common.BoundingBox(m_oServerBoundingBox);

                    oFormat.Type = "image/png24";

                    oResolution.Width  = 600;
                    oResolution.Height = 600;


                    // --- Calculate the best resolution for this image, so that it is not distorted ---

                    double dWidth  = oBoundingBox.MaxX - oBoundingBox.MinX;
                    double dHeight = oBoundingBox.MaxY - oBoundingBox.MinY;

                    if (dWidth == 0 || dHeight == 0)
                    {
                        throw new Exception("Fix this");
                    }

                    double dPictureRatio = oResolution.Height / oResolution.Width;
                    double dBoxRatio     = dHeight / dWidth;

                    if (dBoxRatio > dPictureRatio)
                    {
                        // --- width is smaller than it should be ---

                        oResolution.Width = Convert.ToInt32(oResolution.Height / dBoxRatio);
                    }
                    else if (dBoxRatio < dPictureRatio)
                    {
                        // --- height is smaller than it should be ---

                        oResolution.Height = Convert.ToInt32(oResolution.Width * dBoxRatio);
                    }

                    m_oBrowserMap = m_oCommand.GetImageEx(oFormat, oBoundingBox, oResolution, true, false, new ArrayList(), null);
                    m_oBrowserMap.Save(strBrowserMapFile);
                }
            }
            catch (Exception e)
            {
                m_oBrowserMap = new XmlDocument();
                GetDapError.Instance.Write("Get Server Browser Map (" + m_strUrl + ") - " + e.Message);
            }
        }
Exemple #2
0
        protected override HttpWebRequest BuildRequest()
        {
            string strURL;

            System.Xml.XmlDocument oRequestDoc = null;

            try
            {
                System.IO.StringWriter hRequest = new StringWriter(CultureInfo.InvariantCulture);

                Geosoft.Dap.Common.Format oFormat = new Geosoft.Dap.Common.Format();
                oFormat.Type        = "image/" + m_oImageStore.ImageExtension;
                oFormat.Transparent = true;
                Geosoft.Dap.Common.Resolution oRes = new Geosoft.Dap.Common.Resolution();
                oRes.Height = m_oImageStore.TextureSizePixels;
                oRes.Width  = m_oImageStore.TextureSizePixels;
                ArrayList oArr = new ArrayList();
                if (m_oImageStore.DataSet == null) // Base layers don't have tiling enabled
                {
                    oRequestDoc = m_oImageStore.Server.Command.GetImageRequestDocument(oFormat, new Geosoft.Dap.Common.BoundingBox(m_oTile.East, m_oTile.North, m_oTile.West, m_oTile.South), oRes, true, false, oArr, out strURL);
                }
                else
                {
                    oRequestDoc = m_oImageStore.Server.Command.GetTileRequestDocument(m_oImageStore.DataSet, m_oTile.Level, m_oTile.Row, m_oTile.Col, out strURL);
                }

                // Create the request object.
                request           = (HttpWebRequest)WebRequest.Create(strURL);
                request.UserAgent = UserAgent;
                request.Pipelined = false;

                request.Proxy = ProxyHelper.DetermineProxyForUrl(
                    strURL,
                    WorldWind.Net.WebDownload.useWindowsDefaultProxy,
                    WorldWind.Net.WebDownload.useDynamicProxy,
                    WorldWind.Net.WebDownload.proxyUrl,
                    WorldWind.Net.WebDownload.proxyUserName,
                    WorldWind.Net.WebDownload.proxyPassword);


                // --- Encode the document into ascii ---

                System.Text.UTF8Encoding hRequestEncoding = new System.Text.UTF8Encoding();

                oRequestDoc.Save(hRequest);
                byte[] byte1 = hRequestEncoding.GetBytes(hRequest.GetStringBuilder().ToString());


                // --- Setup the HTTP Request ---

                request.Method = "POST";

                if (WorldWind.Net.WebDownload.useProto == WorldWind.Net.WebDownload.HttpProtoVersion.HTTP1_1)
                {
                    request.ProtocolVersion = HttpVersion.Version11;
                }
                else
                {
                    request.ProtocolVersion = HttpVersion.Version10;
                }

                request.KeepAlive     = false;
                request.ContentType   = "application/x-www-form-urlencoded";
                request.ContentLength = byte1.Length;
                request.Timeout       = WebDownload.DownloadTimeout;

                // --- Serialize the XML document request onto the wire ---

                System.IO.Stream hRequestStream = request.GetRequestStream();
                hRequestStream.Write(byte1, 0, byte1.Length);
                hRequestStream.Close();

                // --- Turn off connection keep-alives. ---

                request.KeepAlive = false;
            }
            finally
            {
                m_oImageStore.Server.Command.ReleaseImageRequestDocument(oRequestDoc);
            }

            return(request);
        }
Exemple #3
0
        protected override HttpWebRequest BuildRequest()
        {
            string strURL;
            System.Xml.XmlDocument oRequestDoc = null;

            try
            {
                System.IO.StringWriter hRequest = new StringWriter(CultureInfo.InvariantCulture);

                Geosoft.Dap.Common.Format oFormat = new Geosoft.Dap.Common.Format();
                oFormat.Type = "image/" + m_oImageStore.ImageExtension;
                oFormat.Transparent = true;
                Geosoft.Dap.Common.Resolution oRes = new Geosoft.Dap.Common.Resolution();
                oRes.Height = m_oImageStore.TextureSizePixels;
                oRes.Width = m_oImageStore.TextureSizePixels;
                ArrayList oArr = new ArrayList();
            if (m_oImageStore.DataSet == null)
            {
               oRequestDoc = m_oImageStore.Server.Command.GetImageRequestDocument(oFormat, m_hBB, oRes, true, false, oArr, out strURL);
            }
            else
            {
               oArr.Add(m_oImageStore.DataSet.Name);
               oRequestDoc = m_oImageStore.Server.Command.GetImageRequestDocument(oFormat, m_hBB, oRes, false, false, oArr, out strURL);
            }

                // Create the request object.
                request = (HttpWebRequest)WebRequest.Create(strURL);
                request.UserAgent = UserAgent;
                request.Pipelined = false;

                request.Proxy = ProxyHelper.DetermineProxyForUrl(
                                  strURL,
                                  WorldWind.Net.WebDownload.useWindowsDefaultProxy,
                                  WorldWind.Net.WebDownload.useDynamicProxy,
                                  WorldWind.Net.WebDownload.proxyUrl,
                                  WorldWind.Net.WebDownload.proxyUserName,
                                  WorldWind.Net.WebDownload.proxyPassword);

                // --- Encode the document into ascii ---

                System.Text.UTF8Encoding hRequestEncoding = new System.Text.UTF8Encoding();

                oRequestDoc.Save(hRequest);
                byte[] byte1 = hRequestEncoding.GetBytes(hRequest.GetStringBuilder().ToString());

                // --- Setup the HTTP Request ---

                request.Method = "POST";

                if (WorldWind.Net.WebDownload.useProto == WorldWind.Net.WebDownload.HttpProtoVersion.HTTP1_1)
                    request.ProtocolVersion = HttpVersion.Version11;
                else
                    request.ProtocolVersion = HttpVersion.Version10;

                request.KeepAlive = false;
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = byte1.Length;
                request.Timeout = WebDownload.DownloadTimeout;

                // --- Serialize the XML document request onto the wire ---

                System.IO.Stream hRequestStream = request.GetRequestStream();
                hRequestStream.Write(byte1, 0, byte1.Length);
                hRequestStream.Close();

                // --- Turn off connection keep-alives. ---

                request.KeepAlive = false;
            }
            finally
            {
                m_oImageStore.Server.Command.ReleaseImageRequestDocument(oRequestDoc);
            }

            return request;
        }