import StringHelper from "./stringHelper";

export default class OSMNamesResponse {
  lat;
  lon;
  boundingBox;
  city;
  street;
  type;
  wikipedia;
  name;
  name_suffix;
  processed_name;

  constructor(init) {
    if (init !== undefined) {
      this.lat = Number(init.lat);
      this.lon = Number(init.lon);
      this.boundingBox = !!init.boundingbox
        ? new L.LatLngBounds(
            [init.boundingbox[1], init.boundingbox[0]],
            [init.boundingbox[3], init.boundingbox[2]],
          )
        : null;
      this.city = init.city;
      this.street = init.street;
      this.type = init.type;
      this.wikipedia = init.wikipedia;
      this.name = init.name;
      this.name_suffix = init.name_suffix;
      this.processed_name = StringHelper.createAutocompleteName(this);
    }
  }
}
