调arcgisonline瓦片服务,在unity中生成三维地球。

基本原理

构建三维地球网格,将瓦片地图做为材质贴图赋给没有网格面。

瓦片数据获取Services:

  • NatGeo_World_Map (MapServer)
  • USA_Topo_Maps (MapServer)
  • World_Imagery (MapServer)
  • World_Physical_Map (MapServer)
  • World_Shaded_Relief (MapServer)
  • World_Street_Map (MapServer)
  • World_Terrain_Base (MapServer)
  • World_Topo_Map (MapServer)

支持以上地图读取

高德地图:

http://webst04.is.autonavi.com/appmaptile?style=6&x=0&y=0&z=1

tring Url = "http://webst04.is.autonavi.com/appmaptile?style=6&x="+ i + "&y="+ j+ "&z="+ z ;

地球创建

经度分段

    public void getEquator(float radius,float subdivisions){Quaternion quaternion = new Quaternion();Matrix4x4 matRot = new Matrix4x4();Vector3 point = new Vector3();Vector3 one = new Vector3(radius, 0, 0);float angle = 360 / (subdivisions);for (int i = 0; i < subdivisions; i++){float newAngle = angle * i;quaternion = Quaternion.Euler(new Vector3(0, newAngle, 0));matRot.SetTRS(Vector3.zero, quaternion, new Vector3(1, 1, 1));point = matRot.MultiplyPoint3x4(one);string name = i + "&" +(int)subdivisions*0.5f;points.Add(name, writeJosn(point));instancePoint(point, name);longlatCreat(one, i, newAngle);}}

纬度分段

 /// <summary>/// 墨卡托转经纬度/// </summary>/// <param name="target">赤道点</param>/// <param name="FaName">经度编号</param>/// <param name="_angle">经度</param>void longlatCreat(Vector3 target, int FaName, float _angle){double halfSub = (double)((subdivisions) * 0.5f);double unit = 20037508.3427 / (halfSub*1.0000);Quaternion quaternion = new Quaternion();Matrix4x4 matRot = new Matrix4x4();Vector3 point = new Vector3();string name;for (int i = 0; i < halfSub; i++){double mercatorY = unit * (i+1);double angle = webMercator2lonLat(mercatorY);Debug.Log(i + "=" + ( - angle)+"&"+ mercatorY);quaternion = Quaternion.Euler(new Vector3(0, _angle, float.Parse((-(angle)).ToString())));matRot.SetTRS(Vector3.zero, quaternion, new Vector3(1, 1, 1));point = matRot.MultiplyPoint3x4(target);name = FaName + "&" + (halfSub+(i+1));points.Add(name, writeJosn(point));instancePoint(point, name);quaternion = Quaternion.Euler(new Vector3(0, _angle, float.Parse((angle).ToString())));matRot.SetTRS(Vector3.zero, quaternion, new Vector3(1, 1, 1));point = matRot.MultiplyPoint3x4(target);name = FaName + "&" + (halfSub - (i + 1));points.Add(name, writeJosn(point));instancePoint(point, name);}string jsonInfo = JsonMapper.ToJson(points);Save("5_32Jmercator", jsonInfo);}
/// <summary>/// 求北纬/// </summary>/// <param name="mercator"></param>/// <returns></returns>double webMercator2lonLat(double mercatorY){double lonlat;double y = (mercatorY / 20037508.34) * 180.000;y = (180.000 / Math.PI) * (2 * Math.Atan(Math.Exp(y * Math.PI / 180.000)) - (Math.PI / 2));Debug.Log(Mathf.Exp(Mathf.PI));Debug.Log(Math.Exp(Math.PI));lonlat = y;return lonlat;}

瓦片读取

瓦片细分

  void  CreateMeshAll_samll (int x,int y,int z){string one = x + "&" + y + "&"+ (z-1);Debug.Log(one);string two = (x+1) + "&" + y + "&" + (z - 1); string three = x + "&" + (y+1) + "&" + (z - 1); string four = (x + 1) + "&" + (y + 1) + "&" + (z - 1); string name_00 = (x * 2) + "&" + (y * 2)+"&"+z;string name_01 = (x * 2) + "&" + ((y * 2)+1) + "&" + z;string name_02 = (x * 2) + "&" + ((y * 2) + 2) + "&" + z;string name_10 = ((x * 2)+1) + "&" + (y * 2) + "&" + z;string name_11 = ((x * 2) + 1) + "&" + ((y * 2) + 1) + "&" + z;string name_12 = ((x * 2) + 1) + "&" + ((y * 2) + 2) + "&" + z;string name_20 = ((x * 2) + 2) + "&" + (y * 2) + "&" + z;string name_21 = ((x * 2) + 2) + "&" + ((y * 2) + 1) + "&" + z;string name_22 = ((x * 2) + 2) + "&" + ((y * 2) + 2) + "&" + z;Vector3 _one = printAll[one];Vector3 _two = printAll[two];Vector3 _three=printAll[three];Vector3 _four = printAll[four];addDic(name_00, _one);addDic(name_01, (_one+ _three) *0.5f);addDic(name_02, _three);addDic(name_10, (_one + _two) * 0.5f);addDic(name_11, (_one + _two+ _three+ _four) * 0.25f);addDic(name_12, (_three + _four) * 0.5f);addDic(name_20, _two);addDic(name_21, (_two + _four) * 0.5f);addDic(name_22, _four);}
  public void CreateMeshAll(int beginX, int beginY, int times, Material mat, GameObject Fa, string name){int z=5;if (!have.ContainsKey(name)){//  JsonData Points = JsonMapper.ToObject(Json);List<Vector3> PosList = new List<Vector3>();List<int> Triangles = new List<int>();List<Vector2> uvs = new List<Vector2>();Mesh mesh = new Mesh();int offet = (int)Mathf.Pow(2, (z - times));//z是根据json128定的,2的z次方是128if (offet < 1){offet = 1;z = times;}Debug.Log(offet);string one;if ((beginX + 1) * offet < Mathf.Pow(2, z))//2的7次方{one = (beginX * offet) + "&" + (beginY * offet) + "&" + z;string two = ((1 + beginX) * offet) + "&" + (beginY * offet) + "&" + z;string three = (beginX * offet) + "&" + ((1 + beginY) * offet) + "&" + z;string four = ((1 + beginX) * offet) + "&" + ((1 + beginY) * offet) + "&" + z;// Debug.Log(one + "," + two + "," + three + "," + four);PosList.Add(printAll[one]);PosList.Add(printAll[two]);PosList.Add(printAll[three]);PosList.Add(printAll[four]);}else{one = (beginX * offet) + "&" + (beginY * offet) + "&" + z;string two = 0 + "&" + (beginY * offet) + "&" + z;string three = (beginX * offet) + "&" + ((1 + beginY) * offet) + "&" + z;string four = (0) + "&" + ((1 + beginY) * offet) + "&" + z;PosList.Add(printAll[one]);PosList.Add(printAll[two]);PosList.Add(printAll[three]);PosList.Add(printAll[four]);}Triangles.Add(0);Triangles.Add(2);Triangles.Add(1);Triangles.Add(1);Triangles.Add(2);Triangles.Add(3);uvs.Add(new Vector2(1, 1));uvs.Add(new Vector2(0, 1));uvs.Add(new Vector2(1, 0));uvs.Add(new Vector2(0, 0));GameObject go = new GameObject();MeshFilter filter = go.AddComponent<MeshFilter>();filter.sharedMesh = mesh;mesh.vertices = PosList.ToArray();mesh.triangles = Triangles.ToArray();mesh.uv = uvs.ToArray();mesh.RecalculateNormals();mesh.RecalculateBounds();MeshRenderer renderer = go.AddComponent<MeshRenderer>();renderer.material = mat;go.name = name;go.AddComponent<MeshCollider>();go.transform.parent = Fa.transform;have.Add(name, go);}}

瓦片读取

这里的服务地址可以切换。demo中只到9级

比如

http://server.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer/tile/12/0/0

到12级

http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/10/0/0

到10级

也可以使用其他瓦片服务

 IEnumerator getEartALL(int Count, int x, int y, int z, string date, GameObject Fa, int All){for (int i = x; i < Count + x; i++){for (int j = y; j < Count + y; j++){string Url = "http://server.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/" + z + "/" + j + "/" + i;//影像地图Debug.Log(Url);                                                                                         using (var webRequest = UnityWebRequestTexture.GetTexture(Url)){yield return webRequest.SendWebRequest();if (webRequest.isNetworkError || webRequest.isHttpError){Debug.LogError(webRequest.error);}else{Texture2D texture = DownloadHandlerTexture.GetContent(webRequest);Texture2D texture_h;Material mat = new Material(MAT);string name = i + "&" + j + "&" + z;mat.mainTexture = texture;CreateMeshAll( (All - i), j, z, mat, Fa,name);}}}}}

demo下载(本demo只完成框架部分,具体展示方法需要自己完善)demo下载地址https://download.csdn.net/download/dxs1990/85011867

注:

本demo读取瓦片http://server.arcgisonline.com/arcgis/rest/services/USA_Topo_Maps/MapServer/tile/0/0/0注意是否服务还可以使用

unity三维地球实现方法相关推荐

  1. Unity WebGL三维地球

    1.支持arcgis,天地图,bingmap,谷歌地图,高德地图等影像加载 2.支持高程三维地形加载 3.支持在线,离线数据加载 4.支持unity坐标和经纬度坐标互相转换 5.支持fbx模型放置在地 ...

  2. 开源三维地球_用开源拯救地球

    开源三维地球 直到最近,我们亲爱的地球一直在叹息,4月22日是人类为庆祝地球上的家而指定的日子. 让我们谈谈我们可以通过开源观察,保存,重用和重新利用目的的方法. 并且,让我们以两个故事作为结尾:有关 ...

  3. wms地图绘制工具_三维离线地图-三维地图开发,三维地球,三维可视化开发

    一.软件介绍 BIGEMAP离线地图服务器,提供一站式搭建离线/在线地图数据服务器,支持40多种地图离线发布:提供快速WEB应用.WMTS.TMS.WMS等地图服务:支持二次开发调用:支持数据集管理. ...

  4. 用Excel玩转三维地球!

    文章目录 基础功能 启动三维地图 三维地图的界面 添加场景 播放演示 保存演示 样式配置 图层配置 位置信息配置 符号和样式配置 柱状图 饼状图 热力图 区块图 时间信息配置 场景配置 地图主题 二三 ...

  5. unity三维地图的经纬度如何在二维地图上表示_三维GIS与游戏引擎的跨界融合,打造数字化孪生的平行世界...

    ▲点击关注,收获更多GIS精彩 游戏地图在游戏中起基础和关键作用,它承载游戏中的各种资源,是游戏系统中非常重要的组成部分(图1),所以游戏通常具有明显的地理意义.因此,虽然三维GIS与游戏引擎是两个不 ...

  6. 民航客机空中观光游览虚拟三维实景应用方法及系统

    民航客机空中观光游览虚拟三维实景应用方法及系统 李基伟(中国民航大学 天津300300) (一)背景技术: 这是一项提升民航旅客飞行体验的一种新的应用,根据目前国内民航旅客飞行体验状况分析,旅客在飞行 ...

  7. 山体计算机科学与技术,三维山体建模方法初探

    论文导读:随着信息技术的逐步发展和社会要求的逐步提高,虚拟现实的研究领域开始转向山体.水域等不规则形态的实体.本文以山体为例就不规则形体的可视化过程进行研究,探讨一种不需要实体数据,计算机可视化技术与 ...

  8. 如何利用免费地图数据构建一个离线三维地球

    1. 概述 我们之前发布了"免费从网盘下载的卫星影像和高程DEM如何使用? "一文[,其中以"北京"数据为例,详细讲解了卫星影像与高程DEM在微图中的查看导出方 ...

  9. cesium 文本标注被遮挡_Cesium三维地球标注

    1.三维地球上添加图层 添加的图层会覆盖该区域的地图信息 //添加图层 var layers = viewer.scene.imageryLayers; layers.addImageryProvid ...

  10. Cesium三维开发笔记(一、加载三维地球)

    目前WebGIS的方向逐渐在从二维地球像三维地球转变,作为一个GISer,三维开发技术也是必须要掌握的一门技术了,Cesium是一个开源的三维地图开发包,是目前市面上用的非常多的一个包,接下来我们就一 ...

最新文章

  1. R语言为散点图添加凸包(convex hull):数据预处理(创建一个包含每组数据凸包边界的数据集)、ggplot2使用geom_polygon函数为可视化图像添加凸包(convex hull)
  2. MATLAB APPbase,使用HTTPD做内部访问转向
  3. 循环神经网络(RNN, Recurrent Neural Networks)介绍
  4. PageOffice实现js执行在线编辑时Word文档中的宏命令
  5. RMI(Remote Method Invocation,远程方法调用)
  6. 面试官 | 讲一下如何给高并发系统做限流?
  7. 分布式消息中间件rocketmq的原理与实践
  8. 8.14 few-shot learning——幻想数据
  9. 非广告,运维派送红包,参与就有!
  10. 软件开发团队的脓包(1-3)皇帝的新装、口号党、废话迷
  11. php 汉字unico编码范围,汉字 Unicode 编码范围
  12. sql server 2000 版本及sp4补丁说明
  13. 微信突然限制,你的小程序链接还好吗?
  14. 如何使模糊的图片变清晰?
  15. iFunk执政官游戏本,不仅仅是游戏本
  16. 我喜欢这首歌......
  17. 课程学习:让神经机器翻译模型像人类一样学习
  18. 混沌数学之Duffing(杜芬)振子
  19. Android视频流解码
  20. RNN结构,双向LSTM,Transformer, BERT对比分析

热门文章

  1. 淘宝/天猫优惠券获取API 接口
  2. 普林斯顿陈丹琦团队最新论文:受GPT-3启发,用小样本学习给语言模型做微调,性能最高提升30% | AI 日报...
  3. 向日葵远程控制软件——使用方法(含MacOS)
  4. 如何对接小发猫的伪原创API
  5. 电脑桌面底部显示计算机图标怎么隐藏,电脑底部的任务栏如何隐藏
  6. 如何在知网下载PDF文件
  7. ImageAI 学习
  8. 安卓studio加载HTML文件,Android Studio 加载本地Assets中的html文件
  9. 字节跳动面试真题- 整数反转
  10. 如何下载会议论文集?如何将整个网站的资源离线到本地?