
#include "ros/ros.h"
#include "ros/console.h"
#include "map_server/map_server.h"

#define USAGE "\nUSAGE: map_server <map.yaml>\n"                  \
              "  map.yaml: map description file\n"                \
              "DEPRECATED USAGE: map_server <map> <resolution>\n" \
              "  map: image file to load\n"                       \
              "  resolution: map resolution [meters/pixel]"

int main(int argc, char** argv)
{
  ros::init(argc, argv, "map_server", ros::init_options::AnonymousName);
  // ros::init(argc, argv, "map_server");
  ros::NodeHandle nh("~");
  if (argc != 3 && argc != 2)
  {
    ROS_ERROR("%s", USAGE);
    exit(-1);
  }
  if (argc != 2)
  {
    ROS_WARN("Using deprecated map server interface. Please switch to new interface.");
  }
  std::string fname(argv[1]);
  double res = (argc == 2) ? 0.0 : atof(argv[2]);
  try
  {
    map_server::MapServer* map_sever_ptr = new map_server::MapServer(fname, res);
    ros::spin();
  }
  catch (std::runtime_error& e)
  {
    ROS_ERROR("map_server exception: %s", e.what());
    return -1;
  }

  return 0;
}
