C.for($idx = 1; $idx < STOP_AT; $idx *= 2)

11.考虑如下代码片段:

复制PHP内容到剪贴板

PHP代码:

 

<?php

define("STOP_AT", 1024);

$result = array();

/* 在此处填入代码 */

{

        $result[] = $idx;

}

print_r($result);

?>

 

标记处填入什么代码才能产生如下数组输出?

 

Array

{

[0] => 1

[1] => 2

[2] => 4

[3] => 8

[4] => 16

[5] => 32

[6] => 64

[7] => 128

[8] => 256

[9] => 512

}

 

Aforeach($result as $key => $val)

Bwhile($idx *= 2)

Cfor($idx = 1; $idx < STOP_AT; $idx *= 2)

Dfor($idx *= 2; STOP_AT >= $idx; $idx = 0)

Ewhile($idx < STOP_AT) do $idx *= 2


void SdNavigationHighway::GetHarborStopInfo() { auto sd_map_info = INTERNAL_PARAMS.sd_map_data.GetSDRouteInfoPtr(); if (!sd_map_info) { AWARN << "[SDNOA] Failed: sd_map_info is null!"; return; } uint64_t ego_section_id = sd_map_info->navi_start.section_id; double ego_s_offset = sd_map_info->navi_start.s_offset; #ifdef ENABLE_DEBUG_SDNAVIGATION AINFO << "[SDNOA] Ego section ID: " << ego_section_id << ", Ego s_offset: " << ego_s_offset; #endif int ego_section_index = -1; for (size_t i = 0; i < sd_map_info->mpp_sections.size(); ++i) { if (sd_map_info->mpp_sections[i].id == ego_section_id) { ego_section_index = static_cast<int>(i); break; } } if (ego_section_index == -1) { AWARN << "[SDNOA] Failed: ego_section not found!"; return; } // 计算自车的全局 s 坐标 double ego_global_s = 0.0; for (int i = 0; i < ego_section_index; ++i) { ego_global_s += sd_map_info->mpp_sections[i].length; } ego_global_s += ego_s_offset; #ifdef ENABLE_DEBUG_SDNAVIGATION AINFO << "[SDNOA] Ego global s: " << ego_global_s; #endif double min_s = rear_distance_; // -100.0 double max_s = front_distance_; // 300.0 sd_harbor_stop_info_.exists = false; sd_harbor_stop_info_.is_left_most = false; sd_harbor_stop_info_.is_right_most = false; sd_harbor_stop_info_.ranges.clear(); std::vector<std::pair<double, double>> harbor_stop_ranges; bool current_leftmost = false; bool current_rightmost = false; double current_s = 0.0; for (size_t i = 0; i < sd_map_info->mpp_sections.size(); ++i) { const auto &section = sd_map_info->mpp_sections[i]; double section_start_s = current_s; double section_end_s = current_s + section.length; if (section_end_s < ego_global_s + min_s || section_start_s > ego_global_s + max_s) { current_s += section.length; continue; } #ifdef ENABLE_DEBUG_SDNAVIGATION AINFO << "[SDNOA] Section ID: " << section.id << " start from s: " << section_start_s << " to s: " << section_end_s; #endif // 遍历 Section 中的 LaneGroup for (const auto &lg_idx : section.lane_group_idx) { const auto *lane_group = INTERNAL_PARAMS.sd_map_data.GetSDLaneGroupInfoById(lg_idx.id); if (lane_group && !lane_group->lane_info.empty()) { double lg_start_s = section_start_s + lg_idx.start_range_offset; double lg_end_s = section_start_s + lg_idx.end_range_offset; #ifdef ENABLE_DEBUG_SDNAVIGATION AINFO << " [SDNOA] LaneGroup ID: " << lg_idx.id << " start from s: " << lg_start_s << " to s: " << lg_end_s << ", lanes: " << lane_group->lane_info.size(); #endif // 检测港湾停靠站 for (const auto &lane : lane_group->lane_info) { if (lane.type == cem::message::env_model::LaneType::LANE_HARBOR_STOP) { double lane_start_s = std::max(lg_start_s - ego_global_s, min_s); double lane_end_s = std::min(lg_end_s - ego_global_s, max_s); if (lane_start_s < lane_end_s) { // 动态合并港湾停靠站区间 if (!harbor_stop_ranges.empty() && lane_start_s <= harbor_stop_ranges.back().second) { harbor_stop_ranges.back().second = std::max(harbor_stop_ranges.back().second, lane_end_s); } else { harbor_stop_ranges.emplace_back(lane_start_s, lane_end_s); } SD_COARSE_MATCH_LOG << " Harbor stop lane detected, range: [" << lane_start_s << ", " << lane_end_s << "]"; } } } size_t lane_count = lane_group->lane_info.size(); // 检测港湾车道并记录位置 for (size_t idx = 0; idx < lane_count; ++idx) { if (lane_group->lane_info[idx].type == cem::message::env_model::LaneType::LANE_HARBOR_STOP) { // 记录首尾位置 if (idx == 0) { current_leftmost = true; } if (idx == lane_count - 1) { current_rightmost = true; } } } } } current_s += section.length; } sd_harbor_stop_info_.ranges = harbor_stop_ranges; sd_harbor_stop_info_.exists = !harbor_stop_ranges.empty(); sd_harbor_stop_info_.is_left_most = current_leftmost; sd_harbor_stop_info_.is_right_most = current_rightmost; if (sd_harbor_stop_info_.exists) { SD_COARSE_MATCH_LOG << "[GetHarborStopInfo] Harbor stop exists in merged ranges:"; for (const auto &range : sd_harbor_stop_info_.ranges) { SD_COARSE_MATCH_LOG << " [" << range.first << ", " << range.second << "] " << " is_left_most: " << sd_harbor_stop_info_.is_left_most << " is_right_most: " << sd_harbor_stop_info_.is_right_most; } } else { SD_COARSE_MATCH_LOG << "[GetHarborStopInfo] No harbor stop found."; } }把这个函数也把sd_map_data替换为ld_map_data进行适配,生成此函数。
最新发布
08-28
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值