map_service.h 2.7 KB
Newer Older
S
siyangy 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/******************************************************************************
 * Copyright 2017 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

/**
 * @file
 */

21 22
#ifndef MODULES_DREAMVIEW_BACKEND_MAP_MAP_SERVICE_H_
#define MODULES_DREAMVIEW_BACKEND_MAP_MAP_SERVICE_H_
S
siyangy 已提交
23 24 25

#include <string>
#include <vector>
S
siyangy 已提交
26
#include "modules/map/pnc_map/pnc_map.h"
S
siyangy 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#include "third_party/json/json.hpp"

/**
 * @namespace apollo::dreamview
 * @brief apollo::dreamview
 */
namespace apollo {
namespace dreamview {

struct MapElementIds {
  std::vector<std::string> lane;
  std::vector<std::string> crosswalk;
  std::vector<std::string> junction;
  std::vector<std::string> signal;
  std::vector<std::string> stop_sign;
  std::vector<std::string> yield;
  std::vector<std::string> overlap;

S
siyangy 已提交
45
  MapElementIds() = default;
S
siyangy 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  explicit MapElementIds(const nlohmann::json &json_object);

  void LogDebugInfo() const {
    AINFO << "Lanes: " << lane.size();
    AINFO << "Crosswalks: " << crosswalk.size();
    AINFO << "Junctions: " << junction.size();
    AINFO << "Signals: " << signal.size();
    AINFO << "StopSigns: " << stop_sign.size();
    AINFO << "YieldSigns: " << yield.size();
    AINFO << "Overlaps: " << overlap.size();
  }

  size_t Hash() const;
  nlohmann::json Json() const;
};

class MapService {
 public:
  explicit MapService(const std::string &map_filename);
65 66
  MapElementIds CollectMapElementIds(const apollo::common::PointENU &point,
                                     double raidus) const;
S
siyangy 已提交
67

S
siyangy 已提交
68 69 70 71
  bool GetPointsFromRouting(
      const apollo::routing::RoutingResponse &routing,
      std::vector<apollo::hdmap::MapPathPoint> *points) const;

S
siyangy 已提交
72 73 74 75 76
  // The returned value is of a ::apollo::hdmap::Map proto. This
  // makes it easy to convert to a JSON object and to send to the
  // javascript clients.
  ::apollo::hdmap::Map RetrieveMapElements(const MapElementIds &ids) const;

S
siyangy 已提交
77 78
  const ::apollo::hdmap::HDMap *hdmap() const {
    return pnc_map_.HDMap();
S
siyangy 已提交
79 80 81
  }

 private:
S
siyangy 已提交
82
  ::apollo::hdmap::PncMap pnc_map_;
S
siyangy 已提交
83 84 85 86 87
};

}  // namespace dreamview
}  // namespace apollo

88
#endif  // MODULES_DREAMVIEW_BACKEND_MAP_MAP_SERVICE_H_