/*
 * Copyright (c) Oona Räisänen
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 */
#ifndef TMC_LOCATIONDB_H_
#define TMC_LOCATIONDB_H_

#include <cstdint>
#include <map>
#include <string>

namespace redsea::tmc {

struct Point {
  std::uint16_t lcd{};
  std::string name1;
  std::string road_name;
  std::uint16_t roa_lcd{};
  std::uint16_t seg_lcd{};
  std::uint16_t neg_off{};
  std::uint16_t pos_off{};
  float lon{};
  float lat{};
};

struct Segment {
  std::uint16_t lcd{};
  std::uint16_t roa_lcd{};
};

struct Road {
  std::uint16_t lcd{};
  std::string road_number;
  std::string name;
  std::string name1;
};

struct AdminArea {
  std::uint16_t lcd{};
  std::string name;
};

struct LocationDatabase {
  std::uint16_t ltn{};
  std::map<std::uint16_t, Point> points;
  std::map<std::uint16_t, Road> roads;
  std::map<int, std::string> names;
  std::map<std::uint16_t, Segment> segments;
  std::map<std::uint16_t, AdminArea> admin_areas;

  [[nodiscard]] std::string toString() const;
};

LocationDatabase loadLocationDatabase(const std::string& directory);

// Read and return the location table number of a location database
std::uint16_t readLTN(const std::string& directory);

}  // namespace redsea::tmc

#endif  // TMC_LOCATIONDB_H_
