当前位置: 首页>>代码示例>>C++>>正文


C++ osmium::Location类代码示例

本文整理汇总了C++中osmium::Location的典型用法代码示例。如果您正苦于以下问题:C++ Location类的具体用法?C++ Location怎么用?C++ Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: contains

 /**
  * Check whether the location is inside the box.
  *
  * @pre Location must be defined.
  * @pre Box must be defined.
  */
 bool contains(const osmium::Location& location) const noexcept {
     assert(bottom_left());
     assert(top_right());
     assert(location);
     return location.x() >= bottom_left().x() && location.y() >= bottom_left().y() &&
            location.x() <= top_right().x() && location.y() <= top_right().y();
 }
开发者ID:Project-OSRM,项目名称:osrm-backend,代码行数:13,代码来源:box.hpp

示例2: Box

 /**
  * Create box from bottom left and top right locations.
  *
  * @pre Either both locations must be defined or neither.
  * @pre If both locations are defined, the
  *      bottom left location must actually be to the left and below
  *      the top right location. Same coordinates for bottom/top or
  *      left/right are also okay.
  */
 Box(const osmium::Location& bottom_left, const osmium::Location& top_right) :
     m_bottom_left(bottom_left),
     m_top_right(top_right) {
     assert(
         (!!bottom_left && !!top_right) ||
         (bottom_left.x() <= top_right.x() && bottom_left.y() <= top_right.y())
     );
 }
开发者ID:Project-OSRM,项目名称:osrm-backend,代码行数:17,代码来源:box.hpp

示例3: operator

            Coordinates operator()(osmium::Location location) const {
                Coordinates c {location.lon(), location.lat()};

                if (m_epsg != 4326) {
                    c = transform(m_crs_wgs84, m_crs_user, Coordinates(deg_to_rad(location.lon()), deg_to_rad(location.lat())));
                    if (m_crs_user.is_latlong()) {
                        c.x = rad_to_deg(c.x);
                        c.y = rad_to_deg(c.y);
                    }
                }

                return c;
            }
开发者ID:7ute,项目名称:osrm-backend,代码行数:13,代码来源:projection.hpp

示例4: Tile

 /**
  * Create a tile with the given zoom level that contains the given
  * location.
  *
  * The values are not checked for validity.
  *
  * @pre @code location.valid() && zoom <= 30 @endcode
  */
 explicit Tile(uint32_t zoom, const osmium::Location& location) :
     z(zoom) {
     assert(zoom <= 30u);
     assert(location.valid());
     const auto coordinates = lonlat_to_mercator(location);
     x = mercx_to_tilex(zoom, coordinates.x);
     y = mercy_to_tiley(zoom, coordinates.y);
 }
开发者ID:KnockSoftware,项目名称:osrm-backend,代码行数:16,代码来源:tile.hpp

示例5: write_location

 void write_location(const osmium::Location& location, const char x, const char y) {
     if (location) {
         output_formatted(" %c%.7f %c%.7f", x, location.lon_without_check(), y, location.lat_without_check());
     } else {
         *m_out += ' ';
         *m_out += x;
         *m_out += ' ';
         *m_out += y;
     }
 }
开发者ID:7ute,项目名称:osrm-backend,代码行数:10,代码来源:opl_output_format.hpp

示例6: Tile

 /**
  * Create a tile with the given zoom level that contains the given
  * location.
  *
  * The values are not checked for validity.
  *
  * @pre @code location.valid() && zoom <= 30 @endcode
  */
 explicit Tile(uint32_t zoom, const osmium::Location& location) :
     z(zoom) {
     assert(zoom <= 30u);
     assert(location.valid());
     const osmium::geom::Coordinates c = lonlat_to_mercator(location);
     const int32_t n = 1 << zoom;
     const double scale = detail::max_coordinate_epsg3857 * 2 / n;
     x = uint32_t(detail::restrict_to_range<int32_t>(int32_t((c.x + detail::max_coordinate_epsg3857) / scale), 0, n-1));
     y = uint32_t(detail::restrict_to_range<int32_t>(int32_t((detail::max_coordinate_epsg3857 - c.y) / scale), 0, n-1));
 }
开发者ID:hydrays,项目名称:osrm-backend,代码行数:18,代码来源:tile.hpp

示例7: to_left_of

                bool to_left_of(const osmium::Location& location) const {
    //                std::cerr << "segment " << first() << "--" << second() << " to_left_of(" << location << "\n";

                    if (first().location() == location || second().location() == location) {
                        return false;
                    }

                    const std::pair<osmium::Location, osmium::Location> mm = std::minmax(first().location(), second().location(), [](const osmium::Location a, const osmium::Location b) {
                        return a.y() < b.y();
                    });

                    if (mm.first.y() >= location.y() || mm.second.y() < location.y() || first().location().x() > location.x()) {
    //                    std::cerr << "  false\n";
                        return false;
                    }

                    int64_t ax = mm.first.x();
                    int64_t bx = mm.second.x();
                    int64_t lx = location.x();
                    int64_t ay = mm.first.y();
                    int64_t by = mm.second.y();
                    int64_t ly = location.y();
                    return ((bx - ax)*(ly - ay) - (by - ay)*(lx - ax)) <= 0;
                }
开发者ID:dforsi,项目名称:libosmium,代码行数:24,代码来源:node_ref_segment.hpp

示例8: extend

 /**
  * Extend the bounding box by the given location. If the
  * location is undefined, the bounding box is unchanged.
  */
 Bounds& extend(const Location& location) noexcept {
     if (location) {
         if (m_bottom_left) {
             if (location.x() < m_bottom_left.x()) {
                 m_bottom_left.x(location.x());
             }
             if (location.x() > m_top_right.x()) {
                 m_top_right.x(location.x());
             }
             if (location.y() < m_bottom_left.y()) {
                 m_bottom_left.y(location.y());
             }
             if (location.y() > m_top_right.y()) {
                 m_top_right.y(location.y());
             }
         } else {
             m_bottom_left = location;
             m_top_right = location;
         }
     }
     return *this;
 }
开发者ID:gijs,项目名称:libosmium,代码行数:26,代码来源:bounds.hpp

示例9: vec

 constexpr explicit vec(const osmium::Location& l) noexcept :
     x(l.x()),
     y(l.y()) {
 }
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:4,代码来源:vector.hpp

示例10: TEST_CASE

#include "catch.hpp"

#include <sstream>
#include <type_traits>

#include <osmium/osm/location.hpp>

TEST_CASE("Location") {

// fails on MSVC and doesn't really matter
// static_assert(std::is_literal_type<osmium::Location>::value, "osmium::Location not literal type");

    SECTION("instantiation_with_default_parameters") {
        osmium::Location loc;
        REQUIRE(!loc);
        REQUIRE_THROWS_AS(loc.lon(), osmium::invalid_location);
        REQUIRE_THROWS_AS(loc.lat(), osmium::invalid_location);
    }

    SECTION("instantiation_with_double_parameters") {
        osmium::Location loc1(1.2, 4.5);
        REQUIRE(!!loc1);
        REQUIRE(12000000 == loc1.x());
        REQUIRE(45000000 == loc1.y());
        REQUIRE(1.2 == loc1.lon());
        REQUIRE(4.5 == loc1.lat());

        osmium::Location loc2(loc1);
        REQUIRE(4.5 == loc2.lat());

        osmium::Location loc3 = loc1;
开发者ID:Mapotempo,项目名称:osrm-backend,代码行数:31,代码来源:test_location.cpp

示例11: write_location

 void write_location(const osmium::Location& location, const char x, const char y) {
     *m_out += ' ';
     *m_out += x;
     if (location) {
         osmium::detail::append_location_coordinate_to_string(std::back_inserter(*m_out), location.x());
     }
     *m_out += ' ';
     *m_out += y;
     if (location) {
         osmium::detail::append_location_coordinate_to_string(std::back_inserter(*m_out), location.y());
     }
 }
开发者ID:Cultrarius,项目名称:libosmium,代码行数:12,代码来源:opl_output_format.hpp

示例12: Coordinates

 Coordinates(const osmium::Location& location) : x(location.lon()), y(location.lat()) {
 }
开发者ID:Gozhack,项目名称:osrm-backend,代码行数:2,代码来源:coordinates.hpp

示例13: hash

 inline size_t hash(const osmium::Location& location) noexcept {
     return location.x() ^ location.y();
 }
开发者ID:tomhughes,项目名称:libosmium,代码行数:3,代码来源:location.hpp

示例14:

 inline size_t hash<8>(const osmium::Location& location) noexcept {
     uint64_t h = location.x();
     h <<= 32;
     return static_cast<size_t>(h ^ location.y());
 }
开发者ID:tomhughes,项目名称:libosmium,代码行数:5,代码来源:location.hpp

示例15: update

 void update(const osmium::Location& location) {
     update_int32(location.x());
     update_int32(location.y());
 }
开发者ID:knowname,项目名称:libosmium,代码行数:4,代码来源:crc.hpp


注:本文中的osmium::Location类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。