public byte[] LoadTile(int zoom, int x, int y)
        {
            int size;

            byte[] array = null;
            try
            {
                if (TMDLLWrapper.GetTileSize(out int width, out int height) != 1)
                {
                    throw new FaultException <DataServerFault>(new DataServerFault("Error in Function 'DGDataController.LoadTile'", "Returned error"));
                }

                size  = width * height * 3; // determine size
                array = new byte[size];     // allocate buffer

                if (TMDLLWrapper.GetNumTiles(zoom, out int across, out int down) != 1)
                {
                    throw new FaultException <DataServerFault>(new DataServerFault("Error in Function 'DGDataController.LoadTile'", "Invalid Zoom Parameter"));
                }

                if (x < across && y < down)// check if coordinates are valid
                {
                    if (TMDLLWrapper.GetTileImageAsRawJPG(zoom, x, y, array, size, ref size) != 1)
                    {
                        throw new FaultException <DataServerFault>(new DataServerFault("Error in Function 'DGDataController.LoadTile'", "Error retrieving tiles"));
                    }
                }
            }
            catch (DllNotFoundException e)
            {
                Console.WriteLine(e.Message);
                throw new FaultException <DataServerFault>(new DataServerFault("Error in Function 'DGDataController.LoadTile'", "TrueMarbleDLL.dll is missing"));
            }
            return(array);   // will be null if failure
        }
        public byte[] LoadTile(int zoom, int x, int y)
        {
            int iBufSize, iRetSize;

            byte[] newBuf;                                                                          //Buffer to hold the raw JPEG data.
            iBufSize = GetTileWidth() * GetTileHeight() * 3;
            newBuf   = new byte[iBufSize];                                                          //Allocating enough size for the buffer to hold the JPEG tile.
            if (TMDLLWrapper.GetTileImageAsRawJPG(zoom, x, y, newBuf, iBufSize, out iRetSize) == 0) //checks whether any fault has occured in loading the tile.if fault occurs 0 is returned else 1.
            {
                throw new FaultException("Could not get tile -zoom , x or y are probably out of range");
            }
            return(newBuf);
        }
示例#3
0
        public byte[] LoadTile(int zoom, int x, int y)
        {
            int h;
            int w;

            TMDLLWrapper.GetTileSize(out w, out h);
            byte[] imageBuf;
            int    jpgSize;
            int    buffsize = w * h * 3;

            imageBuf = new byte[buffsize];
            TMDLLWrapper.GetTileImageAsRawJPG(zoom, x, y, imageBuf, buffsize, out jpgSize);
            return(imageBuf);
        }
        public byte[] LoadTile(int zoom, int x, int y)
        {
            int h, w, jpgSize;

            byte[] imageBuf;

            //gets the size of the tile
            TMDLLWrapper.GetTileSize(out w, out h);
            int buffsize = w * h * 3;

            imageBuf = new byte[buffsize];

            //gets the raw jpg file
            TMDLLWrapper.GetTileImageAsRawJPG(zoom, x, y, imageBuf, buffsize, out jpgSize);
            return(imageBuf);
        }
示例#5
0
        //This methods selects the particular tile at a partcular zoom level and coordinates.
        //Then puts the image in a buffer and returns it.
        public byte[] LoadTiles(int zoom, int x, int y)
        {
            int buffSize, imgSize;
            int height = 0;
            int width  = 0;

            try
            {
                TMDLLWrapper.GetTileSize(out width, out height);
            }
            //If cannot access the dll function
            catch (DllNotFoundException)
            {
                System.Console.WriteLine("Unable to serve client - Could not find the dll");
            }

            //Overestimating buffer size to make sure it's big enough to hold tile
            buffSize = width * height * 3;

            //Creating a buffer to holf raw JPEG data
            byte[] rawJPEG = new byte[buffSize];

            try
            {
                if (TMDLLWrapper.GetTileImageAsRawJPG(zoom, x, y, rawJPEG, buffSize, out imgSize) == 0)
                {
                    System.Console.WriteLine("Possible navigation for tiles out of range detected");
                }
            }
            //If cannot access the dll function
            catch (DllNotFoundException)
            {
                System.Console.WriteLine("Unable to serve client - Could not find the dll");
            }

            return(rawJPEG);
        }