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

网站建设未来趋势天津市建设教育培训网

网站建设未来趋势,天津市建设教育培训网,淄博网站推广,wordpress切换语言 语言包前文链接#xff1a;QGraphicsView实现简易地图4『局部加载-地图漫游』 由于GCJ02 Web 墨卡托投影 纬度并不随像素等分#xff0c;且两极跨度较大#xff0c;因此本次演示采用的经纬网等分逻辑为等分像素。同等像素跨度之间#xff0c;两级纬度变化较小#xff0c;越靠近赤…前文链接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.hkea.cn/news/14358943/

相关文章:

  • 宁津华企动力做网站的电话多少wordpress标题换行
  • 网站 板块 栏目在线代理网页版 proxy
  • 大连零基础网站建设培训电话太平阳建设集团网站
  • 长春seo网站排名优化wordpress文章分多列排
  • 扬州建设工程信息网站深圳培训网站建设
  • 自己做链接网站江西 商城网站开发
  • 网站界面要素房地产信息管理系统软件
  • 外贸网站谷歌推广做网站不给提供ftp
  • 商业摄影网站福州大型网站建设
  • 一个人做网站现实吗滨州网站设计
  • 奖励软件下载网站网站后台维护费用
  • 仿朋友圈网站建设成都有哪些网站建设的公司
  • 网站怎么做英文版的it培训机构费用
  • 网站建设域名申请挂马网站教程
  • 深圳华强北营业时间网站页面优化方法有哪些
  • 济南做网站费用南海营销网站建设
  • 网站建设龙头企业网站建设 济南
  • 网站架构图用什么做织梦模板国外网站
  • 中扶建设网站做sns网站要多大空间
  • 网站建设与管理自考本全国卷网页设计与制作教程书
  • 手机网站编程语言商城网站建设论坛
  • 7年级微机课做网站的软件社区微网站建设方案
  • 好的文化网站模板下载psd模板免费下载网站
  • 建设通网站上线网上商城平台建设
  • 襄阳做公司网站的软件公司学历提升图片
  • 专门做985招聘信息的网站地方志网站群建设
  • 网站页面设计特点app拉新推广平台代理
  • 网站做301跳转的好处dede网站模板下载
  • 学校建设网站的作用wordpress添加语系
  • 手表网站错误怎么办苏州网站建设情况