Interaction of the solar wind with a localized magnetic barrier: application to lunar surface magnetic fields