#include "GeneratorBase.h"

#include <QGeoCoordinate>

#include "SettingsFact.h"

class MeasurementArea;
class SafeArea;

namespace routing {

class LinearGenerator : public GeneratorBase {
  Q_OBJECT
public:
  LinearGenerator(QObject *parent = nullptr);
  LinearGenerator(Data d, QObject *parent = nullptr);

  Q_PROPERTY(Fact *distance READ distance CONSTANT)
  Q_PROPERTY(Fact *alpha READ alpha CONSTANT)
  Q_PROPERTY(Fact *minLength READ minLength CONSTANT)

  virtual QString editorQml() const override;
  virtual QString mapVisualQml() const override;

  virtual QString abbreviation() const override;
  virtual QString type() const override;

  virtual bool get(Work &generator) override;

  //!
  //! \brief save Saves the generator.
  //! \param obj Json object for saveing.
  //! \return Returns true on success, false either.
  //!
  //! Saves distance, alpha and minLength.
  //! \note This methode does not save the data.
  //!
  virtual bool save(QJsonObject &obj) const override;
  virtual bool load(const QJsonObject &obj, QString &errorString) override;

  Fact *distance();
  Fact *alpha();
  Fact *minLength();

  static const char *settingsGroup;
  static const char *typeString;

private slots:
  void onAreaListChanged();
  void onDataChanged();

private:
  void init();
  void setMeasurementArea(MeasurementArea *area);

  QMap<QString, FactMetaData *> _metaDataMap;
  SettingsFact _distance;
  SettingsFact _alpha;
  SettingsFact _minLength;
  MeasurementArea *_measurementArea;
  SafeArea *_safeArea;
};

} // namespace routing
