Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sample.hpp « search_quality « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4614d8f8b18bff117b1819879a579a0efac7b34e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once

#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"

#include "base/string_utils.hpp"

#include "3party/jansson/myjansson.hpp"

#include <string>
#include <vector>

class FeatureType;

namespace search
{
class SearchParams;

struct Sample
{
  struct Result
  {
    enum class Relevance
    {
      Irrelevant,
      Relevant,
      Vital
    };

    static Result Build(FeatureType & ft, Relevance relevance);

    bool operator<(Result const & rhs) const;

    bool operator==(Result const & rhs) const;

    m2::PointD m_pos = m2::PointD(0, 0);

    strings::UniString m_name;
    std::string m_houseNumber;
    std::vector<std::string> m_types;  // MAPS.ME types, not OSM types.
    Relevance m_relevance = Relevance::Irrelevant;
  };

  bool DeserializeFromJSON(std::string const & jsonStr);
  my::JSONPtr SerializeToJSON() const;

  static bool DeserializeFromJSONLines(std::string const & lines, std::vector<Sample> & samples);
  static void SerializeToJSONLines(std::vector<Sample> const & samples, std::string & lines);

  bool operator<(Sample const & rhs) const;

  bool operator==(Sample const & rhs) const;

  void DeserializeFromJSONImpl(json_t * root);
  void SerializeToJSONImpl(json_t & root) const;

  void FillSearchParams(search::SearchParams & params) const;

  strings::UniString m_query;
  std::string m_locale;
  m2::PointD m_pos = m2::PointD(0, 0);
  bool m_posAvailable = false;
  m2::RectD m_viewport = m2::RectD(0, 0, 0, 0);
  std::vector<Result> m_results;
};

void FromJSONObject(json_t * root, string const & field, Sample::Result::Relevance & relevance);
void ToJSONObject(json_t & root, string const & field, Sample::Result::Relevance relevance);

void FromJSON(json_t * root, Sample::Result & result);
my::JSONPtr ToJSON(Sample::Result const & result);

string DebugPrint(Sample::Result::Relevance r);

string DebugPrint(Sample::Result const & r);

string DebugPrint(Sample const & s);
}  // namespace search