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


C++ LatLng类代码示例

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


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

示例1: TEST

TEST(Transform, MoveBy) {
    Transform transform;
    transform.resize({ 1000, 1000 });

    transform.jumpTo(CameraOptions().withCenter(LatLng()).withZoom(10.0));

    LatLng trueCenter = transform.getLatLng();
    ASSERT_DOUBLE_EQ(0, trueCenter.latitude());
    ASSERT_DOUBLE_EQ(0, trueCenter.longitude());
    ASSERT_DOUBLE_EQ(10, transform.getZoom());

    for (uint8_t x = 0; x < 20; ++x) {
        bool odd = x % 2;
        bool forward = x % 10;

        LatLng coordinate = transform.screenCoordinateToLatLng({ odd ? 400. : 600., forward ? 400. : 600 });
        transform.moveBy({ odd ? 100. : -100., forward ? 100. : -100 });

        trueCenter = transform.getLatLng();
        ASSERT_NEAR(coordinate.latitude(), trueCenter.latitude(), 1e-8);
        ASSERT_NEAR(coordinate.longitude(), trueCenter.longitude(), 1e-8);
    }

    // We have ~1.1 precision loss for each coordinate for 20 rounds of moveBy.
    ASSERT_NEAR(0.0, trueCenter.latitude(), 1.1);
    ASSERT_NEAR(0.0, trueCenter.longitude(), 1.1);
}
开发者ID:mapbox,项目名称:mapbox-gl-native,代码行数:27,代码来源:transform.test.cpp

示例2: convertToLatLngStr

 static std::string convertToLatLngStr(const LatLng &loc, int prec) {
     std::string locStr = "";
     locStr += Utility::truncateDouble(loc.getLat(), prec);
     locStr += ",";
     locStr += Utility::truncateDouble(loc.getLng(), prec);
     return locStr;
 }    
开发者ID:SGTRANSPORTER,项目名称:uberPOOLMatchOpt,代码行数:7,代码来源:Utility.hpp

示例3: project_

 static Point<double> project_(const LatLng& latLng, double worldSize) {
     const double latitude = util::clamp(latLng.latitude(), -util::LATITUDE_MAX, util::LATITUDE_MAX);
     return Point<double> {
         util::LONGITUDE_MAX + latLng.longitude(),
         util::LONGITUDE_MAX - util::RAD2DEG * std::log(std::tan(M_PI / 4 + latitude * M_PI / util::DEGREES_MAX))
     } * worldSize / util::DEGREES_MAX;
 }
开发者ID:BharathMG,项目名称:mapbox-gl-native,代码行数:7,代码来源:projection.hpp

示例4: TEST

TEST(Transform, UnwrappedLatLng) {
    MockView view;
    Transform transform(view, ConstrainMode::HeightOnly);
    transform.resize({{ 1000, 1000 }});
    transform.setScale(2 << 9);
    transform.setPitch(0.9);
    transform.setLatLng(LatLng(38, -77));

    const TransformState& state = transform.getState();

    LatLng fromGetLatLng = state.getLatLng();
    ASSERT_DOUBLE_EQ(fromGetLatLng.latitude, 38);
    ASSERT_DOUBLE_EQ(fromGetLatLng.longitude, -77);

    LatLng fromScreenCoordinate = state.screenCoordinateToLatLng({ 500, 500 });
    ASSERT_NEAR(fromScreenCoordinate.latitude,   37.999999999999829, 0.0001); // 1.71E-13
    ASSERT_NEAR(fromScreenCoordinate.longitude, -76.999999999999773, 0.0001); // 2.27E-13

    LatLng wrappedForwards = state.screenCoordinateToLatLng(state.latLngToScreenCoordinate({ 38, 283 }));
    ASSERT_NEAR(wrappedForwards.latitude, 37.999999999999716, 0.0001); // 2.84E-13
    ASSERT_NEAR(wrappedForwards.longitude, 282.99999999988751, 0.0001); // 1.1249E-11
    wrappedForwards.wrap();
    ASSERT_NEAR(wrappedForwards.longitude, -77.000000000112493, 0.001); // 1.1249E-11

    LatLng wrappedBackwards = state.screenCoordinateToLatLng(state.latLngToScreenCoordinate({ 38, -437 }));
    ASSERT_NEAR(wrappedBackwards.latitude, wrappedForwards.latitude, 0.001);
    ASSERT_NEAR(wrappedBackwards.longitude, -436.99999999988728, 0.001); // 1.1272E-11
    wrappedBackwards.wrap();
    ASSERT_NEAR(wrappedBackwards.longitude, -76.99999999988728, 0.001); // 1.1272E-11
}
开发者ID:yukangguo,项目名称:mapbox-gl-native,代码行数:30,代码来源:transform.cpp

示例5: constrain

 LatLng constrain(const LatLng& p) const {
     if (contains(p)) {
         return p;
     }
     return LatLng {
         util::clamp(p.latitude(), sw.latitude(), ne.latitude()),
         util::clamp(p.longitude(), sw.longitude(), ne.longitude())
     };
 }
开发者ID:1SpatialGroupLtd,项目名称:mapbox-gl-native,代码行数:9,代码来源:geo.hpp

示例6: QObject

webViewBridge::webViewBridge(LatLng latLng, int zoom, QString maptype, QObject *parent)
 : QObject(parent)
{
 this->_latLng = latLng;
 this->_lat = latLng.lat();
 this->_lon = latLng.lon();
 this->_zoom = zoom;
 this->maptype = maptype;
 _instance = this;
}
开发者ID:allenck,项目名称:mapper,代码行数:10,代码来源:webviewbridge.cpp

示例7: latLngToScreenCoordinate

ScreenCoordinate Transform::latLngToScreenCoordinate(const LatLng& latLng) const {
    // If the center and point longitudes are not in the same side of the
    // antimeridian, we unwrap the point longitude so it would be seen if
    // e.g. the next antimeridian side is visible.
    LatLng unwrappedLatLng = latLng.wrapped();
    unwrappedLatLng.unwrapForShortestPath(getLatLng());
    ScreenCoordinate point = state.latLngToScreenCoordinate(unwrappedLatLng);
    point.y = state.height - point.y;
    return point;
}
开发者ID:HaasRosholt,项目名称:mapbox-gl-native,代码行数:10,代码来源:transform.cpp

示例8: projectedMetersForLatLng

    static ProjectedMeters projectedMetersForLatLng(const LatLng& latLng) {
        const double constrainedLatitude = util::clamp(latLng.latitude(), -util::LATITUDE_MAX, util::LATITUDE_MAX);
        const double constrainedLongitude = util::clamp(latLng.longitude(), -util::LONGITUDE_MAX, util::LONGITUDE_MAX);

        const double m = 1 - 1e-15;
        const double f = util::clamp(std::sin(util::DEG2RAD * constrainedLatitude), -m, m);

        const double easting  = util::EARTH_RADIUS_M * constrainedLongitude * util::DEG2RAD;
        const double northing = 0.5 * util::EARTH_RADIUS_M * std::log((1 + f) / (1 - f));

        return ProjectedMeters(northing, easting);
    }
开发者ID:BharathMG,项目名称:mapbox-gl-native,代码行数:12,代码来源:projection.hpp

示例9: computePickupDistance_savingsConstr

 // compute pick up distance
 static double computePickupDistance_savingsConstr(
         const time_t masterETA, const double masterOrigLat, const double masterOrigLng, 
         const time_t masterETD, const double masterDestLat, const double masterDestLng, 
         const time_t minionReqTime, const double minionOrigLat, const double minionOrigLng, 
         int inclInitDistExtendedMatches
 ) {                
     double pickupDist = 0.0;
     
     bool isExtended = (masterETA <= minionReqTime);
     
     // case 1: non-extended match
     if( !isExtended ) {
         pickupDist = Utility::computeGreatCircleDistance(masterOrigLat, masterOrigLng, minionOrigLat, minionOrigLng);
     }
     
     // case 2: extended match
     else {
         // get the master location at time of minion request
         LatLng estLocAtMinReq = Utility::estLocationByLinearProxy(minionReqTime, masterETA, masterOrigLat, masterOrigLng, masterETD, masterDestLat, masterDestLng);
         
         // compute dist between master origin and curr location
         const double distFromOrigToCurrLoc = (inclInitDistExtendedMatches) ? Utility::computeGreatCircleDistance(masterOrigLat, masterOrigLng, estLocAtMinReq.getLat(), estLocAtMinReq.getLng()) : 0.0;
         
         // compute dist between curr location and minion origin
         const double distFromCurrLocToMinion = Utility::computeGreatCircleDistance(estLocAtMinReq.getLat(), estLocAtMinReq.getLng(), minionOrigLat, minionOrigLng);
         
         pickupDist = distFromOrigToCurrLoc + distFromCurrLocToMinion;               
     }
     
     return pickupDist;
 }
开发者ID:SGTRANSPORTER,项目名称:uberPOOLMatchOpt,代码行数:32,代码来源:ModelUtils.hpp

示例10: assert

void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::Callback> callback) {
    map.renderStill([this, callback = std::move(callback)] (std::exception_ptr error) mutable {

        // Create lambda that captures the current transform state
        // and can be used to translate for geographic to screen
        // coordinates
        assert (frontend.getTransformState());
        PointForFn pointForFn { [=, center=map.getLatLng(), transformState = *frontend.getTransformState()] (const LatLng& latLng) {
            LatLng unwrappedLatLng = latLng.wrapped();
            unwrappedLatLng.unwrapForShortestPath(center);
            Transform transform { transformState };
            return transform.latLngToScreenCoordinate(unwrappedLatLng);
        }};

        // Create lambda that captures the current transform state
        // and can be used to translate for geographic to screen
        // coordinates
        assert (frontend.getTransformState());
        LatLngForFn latLngForFn { [=, transformState = *frontend.getTransformState()] (const ScreenCoordinate& screenCoordinate) {
            Transform transform { transformState };
            return transform.screenCoordinateToLatLng(screenCoordinate);
        }};

        // Collect all source attributions
        std::vector<std::string> attributions;
        for (auto source : map.getStyle().getSources()) {
            auto attribution = source->getAttribution();
            if (attribution) {
                attributions.push_back(*attribution);
            }
        }

        // Invoke callback
        callback.invoke(
                &MapSnapshotter::Callback::operator(),
                error,
                error ? PremultipliedImage() : frontend.readStillImage(),
                std::move(attributions),
                std::move(pointForFn),
                std::move(latLngForFn)
        );
    });
}
开发者ID:BharathMG,项目名称:mapbox-gl-native,代码行数:43,代码来源:map_snapshotter.cpp

示例11: setLatLngZoom

void TransformState::setLatLngZoom(const LatLng& latLng, double zoom) {
    LatLng constrained = latLng;
    if (bounds) {
        constrained = bounds->constrain(latLng);
    }

    double newScale = util::clamp(zoomScale(zoom), min_scale, max_scale);
    const double newWorldSize = newScale * util::tileSize;
    Bc = newWorldSize / util::DEGREES_MAX;
    Cc = newWorldSize / util::M2PI;

    const double m = 1 - 1e-15;
    const double f = util::clamp(std::sin(util::DEG2RAD * constrained.latitude()), -m, m);

    ScreenCoordinate point = {
        -constrained.longitude() * Bc,
        0.5 * Cc * std::log((1 + f) / (1 - f)),
    };
    setScalePoint(newScale, point);
}
开发者ID:jingsam,项目名称:mapbox-gl-native,代码行数:20,代码来源:transform_state.cpp

示例12: getPickupDistanceAtTimeOfMinionRequest_maxPickupConstr

 //static double getPickupDistanceAtTimeOfMinionRequest(Request * pRequest, OpenTrip * pOpenTrip) {
 static double getPickupDistanceAtTimeOfMinionRequest_maxPickupConstr(
         const time_t minionReqTime,         // request time
         const double minionPickupLat,       // request lat
         const double minionPickupLng,       // request lng
         const time_t masterPickupTime,      // previous event time
         const double masterPickupLat,       // previous event start lat
         const double masterPickupLng,       // previous event start lng
         const time_t masterDropoffTime,     // next event time
         const double masterDropLat,         // next event end lat
         const double masterDropLng,         // next event end lng
         const time_t masterDispatchTime,    // dispatch time
         const double masterDispatchLat,     // dispatch lat
         const double masterDispatchLng      // dispatch lng
         ) {
     
     // case 1: pickup has NOT occurred (non-extended)
     if( minionReqTime <= masterPickupTime ) {
         
         // pickup distance from current location to minion origin
         LatLng estMasterLocation = Utility::estLocationByLinearProxy(minionReqTime, masterDispatchTime, masterDispatchLat, masterDispatchLng, masterPickupTime, masterPickupLat, masterPickupLng);
         double pickupDistance_driverToMaster = Utility::computeGreatCircleDistance(estMasterLocation.getLat(), estMasterLocation.getLng(), masterPickupLat, masterPickupLng);
         
         // pickup distance from master to minion
         double pickupDistance_masterToMinion = Utility::computeGreatCircleDistance(masterPickupLat, masterPickupLng, minionPickupLat, minionPickupLng);
         
         double pickupDistance_total = pickupDistance_driverToMaster + pickupDistance_masterToMinion;
         return pickupDistance_total;
     }
     
     // case 2: pickup HAS occurred (extended)
     else {
         // estimate location     
         LatLng estLocAtTimeOfRequest = Utility::estLocationByLinearProxy(minionReqTime, masterPickupTime, masterPickupLat, masterPickupLng, masterDropoffTime, masterDropLat, masterDropLng);
         
         // pickup distance is 
         double pickupDistance = Utility::computeGreatCircleDistance(estLocAtTimeOfRequest.getLat(), estLocAtTimeOfRequest.getLng(), minionPickupLat, minionPickupLng);
         
         return pickupDistance;
     }                
 }
开发者ID:SGTRANSPORTER,项目名称:uberPOOLMatchOpt,代码行数:41,代码来源:ModelUtils.hpp

示例13: getPickupDistance_maxPickupConstr_route

 static double getPickupDistance_maxPickupConstr_route(Route * pRoute, Request * pRequest, int pickupOrder) {
     
     // ensure there are two existing pickups
     assert( pRoute->getPickupEvents()->size() == 2 );
     
     const time_t reqTime = pRequest->getReqTime();
             
     const Event * pDispatch = pRoute->getDispatchEvent();
     RouteEvent * pFirstSchedPick  = pRoute->getPickupEvents()->front();
     RouteEvent * pSecondSchedPick = pRoute->getPickupEvents()->back();
     
     // case 1: the request is to be the first pickup in the new route
     if ( pickupOrder == 1 ) {
         // 1.A the request occurs BEFORE the first sched pickup
         if( reqTime < pFirstSchedPick->getEventTime() ) {
             LatLng currLoc = Utility::estLocationByLinearProxy(reqTime, pDispatch->timeT, pDispatch->lat, pDispatch->lng, pFirstSchedPick->getEventTime(), pFirstSchedPick->getLat(), pFirstSchedPick->getLng());
             double distToCurrReq = Utility::computeGreatCircleDistance(currLoc.getLat(), currLoc.getLng(), pRequest->getActualPickupEvent()->lat, pRequest->getActualPickupEvent()->lng);
             return distToCurrReq;
         }
         // 1.B the request already occurred and request is in between first and second scheduled pickup
         else if( (pFirstSchedPick->getEventTime() <= reqTime) && (reqTime <= pSecondSchedPick->getEventTime()) ) {
             LatLng currLoc = Utility::estLocationByLinearProxy(reqTime, pFirstSchedPick->getEventTime(), pFirstSchedPick->getLat(), pFirstSchedPick->getLng(), pSecondSchedPick->getEventTime(), pSecondSchedPick->getLat(), pSecondSchedPick->getLng());
             double distToCurrReq = Utility::computeGreatCircleDistance(currLoc.getLat(), currLoc.getLng(), pRequest->getActualPickupEvent()->lat, pRequest->getActualPickupEvent()->lng);
             return distToCurrReq;
         }
     }
     
     // case 2: the request is not to be the first pickup in the new route
     else {
         // get prior pickup event
         RouteEvent * pPriorPickup = pRoute->getPickupEvents()->at(pickupOrder-2); // e.g. if the 2nd pickup, then the prior is the 1st pickup which is index 0
         
         // 2.A: the request occurs BEFORE the pickup of the prior event
         if( reqTime < pPriorPickup->getEventTime() ) {
             double distToCurrReq = Utility::computeGreatCircleDistance(pPriorPickup->getLat(), pPriorPickup->getLng(), pRequest->getActualPickupEvent()->lat, pRequest->getActualPickupEvent()->lng);
             return distToCurrReq;
         }
         
         // 2.B: the requests occurs AFTER pickup of the prior event
         else {
             RouteEvent * pNextEvent = (pickupOrder == 2) ? pRoute->getPickupEvents()->back() : pRoute->getDropoffEvents()->front();
             LatLng currLoc = Utility::estLocationByLinearProxy(reqTime, pPriorPickup->getEventTime(), pPriorPickup->getLat(), pPriorPickup->getLng(), pNextEvent->getEventTime(), pNextEvent->getLat(), pNextEvent->getLng());
             double distToCurrReq = Utility::computeGreatCircleDistance(currLoc.getLat(), currLoc.getLng(), pRequest->getActualPickupEvent()->lat, pRequest->getActualPickupEvent()->lng);
             return distToCurrReq;
         }
         
     }
     
     cout << "** unhandled case when checking for pickup distance to minion req **\n" << endl;
     exit(1);
     return 0.0;
 }
开发者ID:SGTRANSPORTER,项目名称:uberPOOLMatchOpt,代码行数:52,代码来源:ModelUtils.hpp

示例14: TEST

TEST(Projection, Boundaries) {
    LatLng sw { -90.0, -180.0 };
    LatLng ne { 90.0, 180.0 };

    const double minScale = std::pow(2, 0);
    const double maxScale = std::pow(2, util::DEFAULT_MAX_ZOOM);

    Point<double> projected {};
    LatLng unprojected {};

    projected = Projection::project(sw, minScale);
    EXPECT_DOUBLE_EQ(projected.x, 0.0);
    EXPECT_DOUBLE_EQ(projected.y, util::tileSize);

    unprojected = Projection::unproject(projected, minScale);
    EXPECT_DOUBLE_EQ(unprojected.latitude(), -util::LATITUDE_MAX);
    EXPECT_DOUBLE_EQ(unprojected.longitude(), sw.longitude());

    projected = Projection::project(sw, maxScale);
    EXPECT_DOUBLE_EQ(projected.x, 0.0);
    EXPECT_DOUBLE_EQ(projected.y, util::tileSize * maxScale);

    unprojected = Projection::unproject(projected, maxScale);
    EXPECT_DOUBLE_EQ(unprojected.latitude(), -util::LATITUDE_MAX);
    EXPECT_DOUBLE_EQ(unprojected.longitude(), sw.longitude());

    projected = Projection::project(ne, minScale);
    EXPECT_DOUBLE_EQ(projected.x, util::tileSize);
    ASSERT_NEAR(projected.y, 0.0, 1e-10);

    unprojected = Projection::unproject(projected, minScale);
    EXPECT_DOUBLE_EQ(unprojected.latitude(), util::LATITUDE_MAX);
    EXPECT_DOUBLE_EQ(unprojected.longitude(), ne.longitude());

    projected = Projection::project(ne, maxScale);
    EXPECT_DOUBLE_EQ(projected.x, util::tileSize * maxScale);
    ASSERT_NEAR(projected.y, 0.0, 1e-6);

    unprojected = Projection::unproject(projected, maxScale);
    EXPECT_DOUBLE_EQ(unprojected.latitude(), util::LATITUDE_MAX);
    EXPECT_DOUBLE_EQ(unprojected.longitude(), ne.longitude());
}
开发者ID:BharathMG,项目名称:mapbox-gl-native,代码行数:42,代码来源:projection.test.cpp

示例15: LatLng

const std::array<float, 2> RenderHillshadeLayer::getLatRange(const UnwrappedTileID& id) {
   const LatLng latlng0 = LatLng(id);
   const LatLng latlng1 = LatLng(UnwrappedTileID(id.canonical.z, id.canonical.x, id.canonical.y + 1));
   return {{ (float)latlng0.latitude(), (float)latlng1.latitude() }};
}
开发者ID:mapbox,项目名称:mapbox-gl-native,代码行数:5,代码来源:render_hillshade_layer.cpp


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