public void GenerateMaptile()
        {
            // Cannot create a map for a nonexistant heightmap
            if (m_scene.Heightmap == null)
            {
                return;
            }

            //create a texture asset of the terrain
            IMapImageGenerator terrain = m_scene.RequestModuleInterface <IMapImageGenerator>();

            if (terrain == null)
            {
                return;
            }

            byte[] data = terrain.WriteJpeg2000Image();
            if (data == null)
            {
                return;
            }

            UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID;

            m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE");

            m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random();

            AssetBase asset = new AssetBase(
                m_scene.RegionInfo.RegionSettings.TerrainImageID,
                "terrainImage_" + m_scene.RegionInfo.RegionID.ToString(),
                (sbyte)AssetType.Texture,
                m_scene.RegionInfo.RegionID.ToString());

            asset.Data        = data;
            asset.Description = m_scene.RegionInfo.RegionName;
            asset.Temporary   = false;
            asset.Flags       = AssetFlags.Maptile;

            // Store the new one
            m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID);
            m_scene.AssetService.Store(asset);
            m_scene.RegionInfo.RegionSettings.Save();

            // Delete the old one
            m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastMapRegionUUID);
            m_scene.AssetService.Delete(lastMapRegionUUID.ToString());
        }