当前位置: 首页 > news >正文

网站建设速成班企查查在线查询

网站建设速成班,企查查在线查询,福州公司网站设计,网站建设qinnet前文链接:QGraphicsView实现简易地图4『局部加载-地图漫游』 由于GCJ02 Web 墨卡托投影 纬度并不随像素等分,且两极跨度较大,因此本次演示采用的经纬网等分逻辑为等分像素。同等像素跨度之间,两级纬度变化较小,越靠近赤…

前文链接:QGraphicsView实现简易地图4『局部加载-地图漫游』
由于GCJ02 Web 墨卡托投影 纬度并不随像素等分,且两极跨度较大,因此本次演示采用的经纬网等分逻辑为等分像素。同等像素跨度之间,两级纬度变化较小,越靠近赤道附近纬度变化越大。以下将提供实现此需求的核心代码。
1、动态演示效果

2、静态展示图片
在这里插入图片描述

核心代码

void MapView::showGraticules()
{// 计算等分像素后的经纬度步长int gridCount = MapUtility::graticulesGridCount(m_curLevel);int mapSideCount = apUtility::mapSideCount(m_curLevel);double perLon = PIXMAP_SIZE * mapSideCount * 1.0 / gridCount;double perLat = perLon;// 计算呈现的瓦片地图左上角和右下角的场景坐标QPoint topLeftScenePos(m_topLeftTileCoord.x * PIXMAP_SIZE, m_topLeftTileCoord.y * PIXMAP_SIZE);QPoint bottomRightScenePos((m_bottomRightTileCoord.x + 1) * PIXMAP_SIZE, (m_bottomRightTileCoord.y + 1) * PIXMAP_SIZE);// 计算经纬线覆盖范围,此处采用的逻辑是经纬网覆盖区域>=呈现的瓦片地图区域int leftGridIndex = qFloor(topLeftScenePos.x() / perLon);int rightGridIndex = qCeil(bottomRightScenePos.x() / perLon);int topGridIndex = qFloor(topLeftScenePos.y() / perLat);int bottomGridIndex = qCeil(bottomRightScenePos.y() / perLat);if (leftGridIndex < 0)leftGridIndex = 0;if (rightGridIndex > gridCount)rightGridIndex = gridCount;if (topGridIndex < 0)topGridIndex = 0;if (bottomGridIndex > gridCount)bottomGridIndex = gridCount;// 视口宽度和高度int vw = viewport()->width();int vh = viewport()->height();// 场景宽度和高度int sw = MapUtility::sceneSize(m_curLevel);int sh = sw;// 视口右下角对应场景坐标QPointF bottomRightViewToScenePos = mapToScene(viewport()->rect().bottomRight());// 经纬网线条颜色、文本颜色QColor gridLineColor(255, 163, 70);QColor textColor(Qt::white);// 绘制经纬网:纬度线for (int row = topGridIndex; row <= bottomGridIndex; ++row){	// 纬度线double sceneY = row * perLat;QGraphicsLineItem *item = m_scene->addLine(topLeftScenePos.x(), sceneY, bottomRightScenePos.x(), sceneY);item->setPen(QPen(gridLineColor, 1, Qt::DotLine));item->setZValue(50);m_vecGraticulesItems.append(item);// 纬度文本double lat = MapUtility::latFromSceneY(sceneY, m_curLevel);QGraphicsTextItem *textItem = m_scene->addText(CommonUtility::convertToDMSLatSymbol(lat));textItem->setDefaultTextColor(Qt::white);QFont font = textItem->font();font.setFamily("微软雅黑");textItem->setFont(font);// 调整文本位置QRectF textBoundingRect = textItem->boundingRect();int sceneX = sw <= vw ? bottomRightScenePos.x() : bottomRightViewToScenePos.x();textItem->setPos(sceneX - textItem->boundingRect().width(), sceneY - textBoundingRect.height() / 2);m_vecGraticulesTextItems.append(textItem);}// 绘制经纬网:经度线for (int col = leftGridIndex; col <= rightGridIndex; ++col){// 经度线double sceneX = col * perLon;QGraphicsLineItem *item = m_scene->addLine(sceneX, topLeftScenePos.y(), sceneX, bottomRightScenePos.y());item->setPen(QPen(gridLineColor, 1, Qt::DotLine));item->setZValue(50);m_vecGraticulesItems.append(item);// 经度文本double lon = MapUtility::lonFromSceneX(sceneX, m_curLevel);QGraphicsTextItem *textItem = m_scene->addText(CommonUtility::convertToDMSLonSymbol(lon));textItem->setDefaultTextColor(Qt::white);QFont font = textItem->font();font.setFamily("微软雅黑");textItem->setFont(font);// 调整文本位置QRectF textBoundingRect = textItem->boundingRect();int sceneY = sh <= vh ? bottomRightScenePos.y() : bottomRightViewToScenePos.y();textItem->setPos(sceneX - textBoundingRect.width() / 2, sceneY - textItem->boundingRect().height());m_vecGraticulesTextItems.append(textItem);}
}

辅助代码

void CommonUtility::convertToDMS(double value, int &d, int &m, int &s)
{d = (int)(value);                       m = (int)((value - d) * 60);s = (int)(((value - d) * 60 - m) * 60);// 四舍五入float e = ((value - d) * 60 - m) * 60 - s;if (5 <= (int)(e * 10))s += 1;// 秒进位if (60 == s){s = 0;m += 1;}// 分进位if (60 == m){m = 0;d += 1;}
}QString CommonUtility::convertToDMS(double value)
{int d, m, s;convertToDMS(value, d, m, s);QString strM = QString::number(m).rightJustified(2, '0');QString strS = QString::number(s).rightJustified(2, '0');return QString("%1°%2′%3″").arg(d).arg(strM).arg(strS);
}QString CommonUtility::convertToDMSLonSymbol(double value)
{return QString("%1%2").arg(convertToDMS(fabs(value))).arg(value > 0 ? "E" : (value != 0 ? "W" : ""));
}QString CommonUtility::convertToDMSLatSymbol(double value)
{return QString("%1%2").arg(convertToDMS(fabs(value))).arg(value > 0 ? "N" : (value != 0 ? "S" : ""));
}
http://www.tj-hxxt.cn/news/88950.html

相关文章:

  • 汉阳网站建设公司我们公司想做网络推广
  • 做网站用的什么语言比百度好用的搜索软件
  • 眉山建网站新闻头条 今天
  • 做网站要学会什么语言搜索引擎营销的特点有
  • 效果好的徐州网站建设杭州网站排名seo
  • 怎么查看网站外链seo排名优化软件有用
  • 可以直接做ppt的网站济南百度竞价
  • 企业网站实名认证时间中超最新积分榜
  • 做网站图片最近几天新闻大事
  • 微信网站结构企业网站制作哪家好
  • 邵阳哪里做网站百度指数怎么看
  • 邢台哪儿专业做网站seo排名工具给您好的建议
  • 小鱼儿网站做啥用的班级优化大师的优点
  • 做收钱的网站要什么条件网站建设平台软件
  • 网站建设与设计教程视频教程铜川网站seo
  • 十大社区团购平台排名百度上如何做优化网站
  • 邯郸网站建设的地方2345网址导航是什么浏览器
  • 拖拽做网站销售新人怎么找客户
  • 青岛知名网站建设公司网站关键词在哪里看
  • 济南做网站的价格seo云优化平台
  • dw用设计视图做网站网站关键词排名服务
  • 网站登录密码怎么取消保存上海建站seo
  • 谈谈你对网站开发的理解2023年10月疫情还会严重吗
  • 成都营销网站建设世界十大搜索引擎排名
  • 网站建设美词原创fifa最新排名出炉
  • 遂溪 网站产品营销推广方案
  • 长沙专业建网站公司搭建网站的步骤
  • 专门做游戏交易的网站有哪些台州seo优化公司
  • 网站统计帮哪个好属于b2b的网站有哪些
  • 安庆什么网站做火产品营销