#ifndef MAPPROBLEM_H
#define MAPPROBLEM_H

#include <filereader.h>
#include <string.h>
#include "world.h"

class SonarData;

class MapProblem {
private:

public:
  SonarData *D;
  Robot *R; // a robot is used only to show current location on screen
  string problemName;
  Bbox boundary;
  double cellSize;

  MapProblem(const char* fname);

};


class SonarData {
private:
  ifstream *F;
  int _numSonars;
  double *sonarOrientations;
  double sonarRingRadius;
  double sonarConeWidth;
  bool doneWithFile;

  double *currentReadings;
  double x, y, th;

public:
  SonarData(const char* fname, bool verbose=false);
  ~SonarData();

  int numSonars() const { return _numSonars; }
  double ringRadius() const { return sonarRingRadius; } // in meters

  // returns orientation of given sonar (zero indexed) in radians
  double sonarOrientation(int j) const { return sonarOrientations[j]; }

  // returns angular width of the sonar cone (in radians)
  double sonarWidth() const { return sonarConeWidth; }

  // returns the current position (in meters) and the orientation (in radians)
  void getConfig(double *x, double *y, double *th);
		   
  // get the current sonar readings
  // "readings" must be an existing array with room for "numSonars" elements
  void getReadings(double *readings);

  // set the current sonar readings to the next scan in the file
  // returns "true" if successful (i.e. end of file not reached)
  bool next(bool verbose=false);
  bool endOfFile() const { return doneWithFile; }

};



#endif
