Joint Energy Detection and Massive Array Design for Localization and Mapping