uint32 
TileCollectionNotice::save( SharedBuffer& buf ) const
{
   // Store the m_indexByLayerID map.
   buf.writeNextBAShort( m_indexByLayerID.size() );
   for ( map<int,int>::const_iterator it = m_indexByLayerID.begin();
         it != m_indexByLayerID.end(); ++it ) {

      // Layer ID.
      buf.writeNextBAShort( it->first );

      // Index.
      buf.writeNextBAShort( it->second );
   }
  
   // Size of m_tilesForAllDetails.
   buf.writeNextBAShort( m_tilesForAllDetails.size() );

   // Store all the TilesForAllDetailsNotice. 
   
   for ( uint32 i = 0; i < m_tilesForAllDetails.size(); ++i ) {
      m_tilesForAllDetails[ i ].save( buf );
   }

   return buf.getCurrentOffset();
}
void 
TilesNotice::save( SharedBuffer& buf ) const
{
   // Offset.
   buf.writeNextBALong( m_offset );

   // start lat
   buf.writeNextBALong( m_startLatIdx );
   // end lat
   buf.writeNextBALong( m_endLatIdx );
   // start lon
   buf.writeNextBALong( m_startLonIdx );
   // end lon 
   buf.writeNextBALong( m_endLonIdx );

   // Store m_impRangeByLayerID.
   // Nbr elements.
   buf.writeNextBAShort( m_nbrLayers );
   
   for ( uint32 i = 0; i < m_nbrLayers; ++i ) {
      // Layer id.
      buf.writeNextBAShort( m_impRange[ i ].m_layerID );
      // First importance.
      buf.writeNextBALong( m_impRange[ i ].m_firstImp );
      // Last importance.
      buf.writeNextBALong( m_impRange[ i ].m_lastImp );
      
   }
}
void 
TilesForAllDetailsNotice::save( SharedBuffer& buf ) const
{
   // Start detail.
   buf.writeNextBAShort( m_startDetail );

   // The notices.
   buf.writeNextBAShort( m_tilesNotice.size() );

   for ( uint32 i = 0; i < m_tilesNotice.size(); ++i ) {
      m_tilesNotice[ i ].save( buf );
   }
}