public IEnumerator CreateTerrainZoom(int zoom) { Terrain t1 = GetComponent <Terrain>(); t1.basemapDistance = 10000; Latlong RBLl = HarvenSin.pixelToLatlong(new Vector2(512 * 16, 512 * 16), latlongLT, zoom); ElevationData evData = new ElevationData(); //string ElvURL = "http://dev.virtualearth.net/REST/v1/Elevation/Bounds?bounds="+ RBLl.lati+","+latlongLT.longti+","+latlongLT.lati+","+ RBLl.longti+"&rows=32&cols=32&heights=ellipsoid&key="+bingKey; //yield return StartCoroutine(evData.GetDataFormUrl(ElvURL)); yield return(StartCoroutine(evData.GetElv(latlongLT, zoom))); float[,] heightmap = evData.GetHeightMap(); //float[,] heightmap = evData.GetHeightMap(32, 32); t1.terrainData.heightmapResolution = evData.size; t1.terrainData.SetHeights(0, 0, heightmap); //yield return StartCoroutine(GetImageFormTile(latlongLT,16,16,19)); yield return(StartCoroutine(ImageDataP.GetImageFormUrl(latlongLT, 16, 16, zoom))); SplatPrototype[] sp = new SplatPrototype[1]; t1.terrainData.size = new Vector3((float)HarvenSin.Distance(latlongLT.lati, latlongLT.longti, latlongLT.lati, RBLl.longti) * 1000, 10000f, (float)HarvenSin.Distance(RBLl.lati, latlongLT.longti, latlongLT.lati, latlongLT.longti) * 1000f); sp[0] = CreateSplatPrototype(imageCombined, new Vector2(t1.terrainData.size.x, t1.terrainData.size.z), new Vector2(0f, 0f)); File.WriteAllBytes("Assets/TerrainTexture/test.jpg", imageCombined.EncodeToJPG());//output Texture t1.terrainData.splatPrototypes = sp; }
public IEnumerator GetElv(Latlong latlong, int zoom) { size = 32; size = zoom >= 18 ? 32 : (int)(Math.Pow(2.0, (18 - zoom)) * 32.0); int tileX = size / 32; int tileY = size / 32; Latlong RBLl = HarvenSin.pixelToLatlong(new Vector2(512 * 16, 512 * 16), latlongLT, zoom); if (zoom >= 18) { string ElvURL = "http://dev.virtualearth.net/REST/v1/Elevation/Bounds?bounds=" + RBLl.lati + "," + latlongLT.longti + "," + latlongLT.lati + "," + RBLl.longti + "&rows=32&cols=32&heights=ellipsoid&key=" + bingKey; WWW www = new WWW(ElvURL); yield return(www); JsonData EData = JsonMapper.ToObject(www.text); zoomLevel = int.Parse(EData["resourceSets"][0]["resources"][0]["zoomLevel"].ToString()); Debug.Log(EData["resourceSets"][0]["resources"][0]["zoomLevel"]); ElevaList.Clear(); //Update ElevaList to WWW foreach (JsonData e in EData["resourceSets"][0]["resources"][0]["elevations"]) { float eF = float.Parse(e.ToString()); ElevaList.Add(eF); } www.Dispose(); } else { Latlong LB = new Latlong(RBLl.lati, latlongLT.longti); int pixelDis = 8192 / tileX; WWW[] www = new WWW[tileX * tileY]; ElevaList.Clear(); for (int i = 0; i < tileX; ++i) { for (int j = 0; j < tileY; ++j) { Latlong tileLB = HarvenSin.pixelToLatlong(new Vector2(pixelDis * j, pixelDis * -i), LB, zoom); Latlong tileRT = HarvenSin.pixelToLatlong(new Vector2(pixelDis, -pixelDis), tileLB, zoom); string ElvURL = "http://dev.virtualearth.net/REST/v1/Elevation/Bounds?bounds=" + tileLB.lati + "," + tileLB.longti + "," + tileRT.lati + "," + tileRT.longti + "&rows=32&cols=32&heights=ellipsoid&key=" + bingKey; //Debug.Log(ElvURL); www[i * tileX + j] = new WWW(ElvURL); } for (int j = 0; j < tileY; ++j) { yield return(www[i * tileX + j]); JsonData EData = JsonMapper.ToObject(www[i * tileX + j].text); zoomLevel = int.Parse(EData["resourceSets"][0]["resources"][0]["zoomLevel"].ToString()); Debug.Log("elv" + i + " " + j); //Update ElevaList to WWW foreach (JsonData e in EData["resourceSets"][0]["resources"][0]["elevations"]) { float eF = float.Parse(e.ToString()); ElevaList.Add(eF); } www[i * tileX + j].Dispose(); } } } }
void Update() { if (UIControl.CreatTerrain) { if (latlongLT.lati < latlongRB.lati || latlongLT.longti > latlongRB.longti) { Debug.Log("非法输入");//illegal input UIControl.CreatTerrain = false; } else { int zoom = 19; for (zoom = 19; zoom >= 12; --zoom) { Mappixel LT = HarvenSin.latlongToPixel(latlongLT, zoom); Mappixel RB = HarvenSin.latlongToPixel(latlongRB, zoom); double x = RB.y - LT.y; double y = RB.x - LT.x; if (x <= 8192 && y <= 8192) { StartCoroutine(CreateTerrainZoom(zoom)); UIControl.CreatTerrain = false; break; } } Debug.Log(zoom); if (zoom == 11) { Debug.Log("选择区域过大");//oversize } } } }
public static IEnumerator GetImageFormUrl(Latlong latlong, int tilex, int tiley, double zoom) { Mappixel startMapP = HarvenSin.latlongToPixel(latlong, zoom); startMapP.x += 256; startMapP.y += 256; Texture2D Img = new Texture2D(tilex * 512, tiley * 512); WWW[] www = new WWW[16 * 16]; for (int i = 0; i < tilex; ++i) { for (int j = 0; j < tiley; ++j) { Mappixel mpTmp = new Mappixel(startMapP.x + 512 * i, startMapP.y + 512 * j); Latlong ll = HarvenSin.pixelToLatlong(mpTmp, zoom); string url = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Aerial/" + ll.lati + "," + ll.longti + "/" + zoom + "?&mapSize=512,544&key=" + bingKey; //string url = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/47.619048,-122.35384/15?mapSize=500,500&pp=47.620495,-122.34931;21;AA&pp=47.619385,-122.351485;;AB&pp=47.616295,-122.3556;22&key=BingMapsKey"+bingKey; //Debug.Log(url); www[i * 16 + j] = new WWW(url); } for (int j = 0; j < 16; j++) { yield return(www[i * 16 + j]); Color[] color = www[i * 16 + j].texture.GetPixels(0, 16, 512, 512); Img.SetPixels(i * 512, 512 * (tiley - 1 - j), 512, 512, color); www[i * 16 + j].Dispose(); Debug.Log(i + " " + j); } } Img.Apply(); imageCombined = Img; }
/// <summary> /// 查询所有驾校信息 按当前位置坐标距离最近排序 /// </summary> /// <param name="para"></param> /// <returns></returns> public List <SchoolEntity> GetAllShoolList(SchoolEntity para) { var list = SchoolBLL.Instance.GetList(para); list.ForEach((o) => { if (o.Lat != null && o.Lng != null && para.Lat != null && para.Lng != null) { o.HowLong = HarvenSin.GetDistance( new Point2D() { Lng = (double)para.Lng, Lat = (double)para.Lat }, new Point2D() { Lng = (double)o.Lng, Lat = (double)o.Lat }).ToString("f2"); } else { o.HowLong = "未知"; } }); //list = list.OrderByDescending(d => d.HowLong).ToList(); list = list.OrderBy(i => i.HowLong).ThenBy(i => i.SortNum).ToList(); return(list); }
public void OnClick(string message) { if (message == "distance") { double widthD = HarvenSin.Distance(GetTerrain.latlongLT.lati, GetTerrain.latlongLT.longti, GetTerrain.latlongLT.lati, GetTerrain.latlongRB.longti); double heightD = HarvenSin.Distance(GetTerrain.latlongLT.lati, GetTerrain.latlongLT.longti, GetTerrain.latlongRB.lati, GetTerrain.latlongLT.longti); width.text = widthD.ToString("0.000"); height.text = heightD.ToString("0.000"); } if (message == "CreateTerrain") { CreatTerrain = true; } }
public JsonResult GetList(string queryJson) { var result = new ReturnMessage(false) { Message = "加载列表失败!" }; try { int type = 1; InsuranceCommpayEntity para = new InsuranceCommpayEntity(); if (!string.IsNullOrWhiteSpace(queryJson)) { var queryParam = queryJson.ToJObject(); if (!queryParam["lat"].IsEmpty()) { para.Lat = decimal.Parse(queryParam["lat"].ToString()); } if (!queryParam["lng"].IsEmpty()) { para.Lng = decimal.Parse(queryParam["lng"].ToString()); } if (!queryParam["type"].IsEmpty()) { type = int.Parse(queryParam["type"].ToString()); } } para.Status = (int)Model.Enums.UseStatus.启用; var pageList = InsuranceCommpayBLL.Instance.GetList(para).OrderBy(o => o.SortNum).ToList(); if (pageList != null) { pageList.ForEach((page) => { if (page.FaceImage != null) { var imageHost = System.Configuration.ConfigurationManager.AppSettings["ImageHost"] == "" ? string.Format("http://{0}{1}", Request.Url.Host, Request.Url.Port == 80 ? "" : ":" + Request.Url.Port) : System.Configuration.ConfigurationManager.AppSettings["ImageHost"]; page.FaceImage = imageHost + page.FaceImage; } if (page.ProvinceId != null) { page.ProvinceName = AreaBLL.Instance.GetEntity(page.ProvinceId).AreaName; } if (page.CityId != null) { page.CityName = AreaBLL.Instance.GetEntity(page.CityId).AreaName; } if (page.CountyId != null) { page.CountyName = AreaBLL.Instance.GetEntity(page.CountyId).AreaName; } page.AddressInfo = page.ProvinceName + page.CityName + page.CountyName + page.AddressInfo; if (page.Lat != null && page.Lng != null && para.Lat != null && para.Lng != null) { page.HowLong = HarvenSin.GetDistance( new Point2D() { Lng = (double)para.Lng, Lat = (double)para.Lat }, new Point2D() { Lng = (double)page.Lng, Lat = (double)page.Lat }).ToString("f2"); } else { page.HowLong = "未知"; } }); } switch (type) { case 1: //按距离 pageList = pageList.OrderBy(i => i.HowLong).ThenBy(i => i.HowLong).ToList(); break; case 2: //按默认排序 pageList = pageList.OrderBy(i => i.CreateTime).ThenBy(i => i.CreateTime).ToList(); break; } result.IsSuccess = true; result.Message = "加载列表成功!"; result.ResultData["List"] = pageList; } catch (Exception ex) { ex.Data["Method"] = "VsInsuranceController>>List"; new ExceptionHelper().LogException(ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult GetList(int?pageIndex, string queryJson) { var result = new ReturnMessage(false) { Message = "加载列表失败!" }; try { ShopEntity para = new ShopEntity(); if (!string.IsNullOrWhiteSpace(queryJson)) { var queryParam = queryJson.ToJObject(); if (!queryParam["keyword"].IsEmpty()) { para.Name = queryParam["keyword"].ToString(); } if (!queryParam["provinceid"].IsEmpty()) { para.ProvinceId = queryParam["provinceid"].ToString(); } if (!queryParam["cityid"].IsEmpty()) { para.CityId = queryParam["cityid"].ToString(); } if (!queryParam["countyid"].IsEmpty()) { para.CountyId = queryParam["countyid"].ToString(); } if (!queryParam["priceid"].IsEmpty()) { para.PriceRange = queryParam["priceid"].ToString(); } if (!queryParam["brandid"].IsEmpty()) { para.BrandRange = queryParam["brandid"].ToString(); } if (!queryParam["distanceid"].IsEmpty()) { para.DistanceRange = (QX360.Model.Enums.DistanceRange) int.Parse(queryParam["distanceid"].ToString()); } if (!queryParam["lat"].IsEmpty()) { para.Lat = decimal.Parse(queryParam["lat"].ToString()); } if (!queryParam["lng"].IsEmpty()) { para.Lng = decimal.Parse(queryParam["lng"].ToString()); } } para.Status = (int)Model.Enums.UseStatus.启用; Pagination pagination = new Pagination(); pagination.page = pageIndex ?? 1; pagination.rows = 10; var pageList = ShopBLL.Instance.GetPageList(para, ref pagination).OrderBy(o => o.SortNum).ToList(); if (pageList != null) { pageList.ForEach((page) => { if (page.ShopId != null) { page.ShopCarList = ShopCarBLL.Instance.GetList(new ShopCarEntity() { ShopId = page.ShopId, Status = (int)Model.Enums.UseStatus.启用 }).OrderBy(o => o.SortNum).ToList(); if (page.ShopCarList != null) { if (para.PriceRange != null) { switch ((QX360.Model.Enums.CarPriceRange) int.Parse(para.PriceRange)) { case Enums.CarPriceRange.十万以内: page.ShopCarList = page.ShopCarList.FindAll(o => o.MaxPrice <= 10).ToList(); break; case Enums.CarPriceRange.十万到二十万: page.ShopCarList = page.ShopCarList.Where((o) => { return(o.LimitPrice >= 10 && o.MaxPrice <= 20); }).ToList(); break; case Enums.CarPriceRange.二五到三十万: page.ShopCarList = page.ShopCarList.Where(o => o.LimitPrice >= 20 && o.MaxPrice <= 30).ToList(); break; case Enums.CarPriceRange.十到五十: page.ShopCarList = page.ShopCarList.Where(o => o.LimitPrice >= 30 && o.MaxPrice <= 50).ToList(); break; case Enums.CarPriceRange.五十万以上: page.ShopCarList = page.ShopCarList.Where(o => o.LimitPrice >= 50).ToList(); break; } } if (para.BrandRange != null) { page.ShopCarList = page.ShopCarList.Where(o => o.BrandId == para.BrandRange).ToList(); } if (para.Name != null) { page.ShopCarList = page.ShopCarList.Where((o) => { return(o.Name.IndexOf(para.Name) > -1); }).ToList(); } page.ShopCarList.Foreach((o) => { if (o.FaceImage != null) { var imageHost = System.Configuration.ConfigurationManager.AppSettings["ImageHost"] == "" ? string.Format("http://{0}{1}", Request.Url.Host, Request.Url.Port == 80 ? "" : ":" + Request.Url.Port) : System.Configuration.ConfigurationManager.AppSettings["ImageHost"]; o.FaceImage = imageHost + o.FaceImage; } }); } } if (page.Lat != null && page.Lng != null && para.Lat != null && para.Lng != null) { page.HowLong = HarvenSin.GetDistance( new Point2D() { Lng = (double)para.Lng, Lat = (double)para.Lat }, new Point2D() { Lng = (double)page.Lng, Lat = (double)page.Lat }).ToString("f2"); } else { page.HowLong = "未知"; } }); } result.IsSuccess = true; result.Message = "加载列表成功!"; result.ResultData["IsEndPage"] = (pagination.total == (pageIndex ?? 1)); result.ResultData["List"] = pageList; } catch (Exception ex) { ex.Data["Method"] = "ShopController>>List"; new ExceptionHelper().LogException(ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult List(string queryJson) { var result = new ReturnMessage(false) { Message = "加载列表失败!" }; try { int trainingtype = 1; SchoolEntity para = new SchoolEntity(); if (!string.IsNullOrWhiteSpace(queryJson)) { var queryParam = queryJson.ToJObject(); if (!queryParam["keyword"].IsEmpty()) { para.Name = queryParam["keyword"].ToString(); } if (!queryParam["provinceid"].IsEmpty()) { para.ProvinceId = queryParam["provinceid"].ToString(); } if (!queryParam["cityid"].IsEmpty()) { para.CityId = queryParam["cityid"].ToString(); } if (!queryParam["countyid"].IsEmpty()) { para.CountyId = queryParam["countyid"].ToString(); } if (!queryParam["priceid"].IsEmpty()) { para.TrainingPriceRange = (RCHL.Model.Enums.PriceRange) int.Parse(queryParam["priceid"].ToString()); } if (!queryParam["distanceid"].IsEmpty()) { para.DistanceRange = (RCHL.Model.Enums.DistanceRange) int.Parse(queryParam["distanceid"].ToString()); } if (!queryParam["lat"].IsEmpty()) { para.Lat = decimal.Parse(queryParam["lat"].ToString()); } if (!queryParam["lng"].IsEmpty()) { para.Lng = decimal.Parse(queryParam["lng"].ToString()); } if (!queryParam["schoolid"].IsEmpty()) { para.SchoolId = queryParam["schoolid"].ToString(); } if (!queryParam["istraining"].IsEmpty()) { para.IsTraining = int.Parse(queryParam["istraining"].ToString()); } if (!queryParam["trainingtype"].IsEmpty()) { trainingtype = int.Parse(queryParam["trainingtype"].ToString()); } } para.IsTraining = 1; para.Status = (int)Model.Enums.UseStatus.启用; var newlist = new List <SchoolEntity>(); var flag = false; para.sidx = "sortnum"; para.sord = "asc"; var list = SchoolBLL.Instance.GetList(para); if (list != null) { foreach (var page in list) { if (page.SchoolId != null) { page.TagList = TagBLL.Instance.GetList(new TagEntity() { ObjectId = page.SchoolId }); int count = SubjectBLL.Instance.GetList(new SubjectEntity() { SchoolId = page.SchoolId, ItemId = trainingtype.ToString() }).Count(); if (count > 0) { flag = true; } else { continue; } } if (page.FaceImage != null) { var imageHost = System.Configuration.ConfigurationManager.AppSettings["ImageHost"] == "" ? string.Format("http://{0}{1}", Request.Url.Host, Request.Url.Port == 80 ? "" : ":" + Request.Url.Port) : System.Configuration.ConfigurationManager.AppSettings["ImageHost"]; page.FaceImage = imageHost + page.FaceImage; } if (page.Lat != null && page.Lng != null && para.Lat != null && para.Lng != null) { page.HowLong = HarvenSin.GetDistance( new Point2D() { Lng = (double)para.Lng, Lat = (double)para.Lat }, new Point2D() { Lng = (double)page.Lng, Lat = (double)page.Lat }).ToString("f2"); } else { page.HowLong = "未知"; } //添加数据 if (flag) { newlist.Add(page); } } } result.IsSuccess = true; result.Message = "加载列表成功!"; result.ResultData["List"] = newlist; } catch (Exception ex) { ex.Data["Method"] = "ExamPlaceController>>List"; new ExceptionHelper().LogException(ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult List(int?pageIndex, string queryJson) { var result = new ReturnMessage(false) { Message = "加载列表失败!" }; try { SchoolEntity para = new SchoolEntity(); if (!string.IsNullOrWhiteSpace(queryJson)) { var queryParam = queryJson.ToJObject(); if (!queryParam["keyword"].IsEmpty()) { para.Name = queryParam["keyword"].ToString(); } if (!queryParam["provinceid"].IsEmpty()) { para.ProvinceId = queryParam["provinceid"].ToString(); } if (!queryParam["cityid"].IsEmpty()) { para.CityId = queryParam["cityid"].ToString(); } if (!queryParam["countyid"].IsEmpty()) { para.CountyId = queryParam["countyid"].ToString(); } if (!queryParam["priceid"].IsEmpty()) { para.TrainingPriceRange = (RCHL.Model.Enums.PriceRange) int.Parse(queryParam["priceid"].ToString()); } if (!queryParam["distanceid"].IsEmpty()) { para.DistanceRange = (RCHL.Model.Enums.DistanceRange) int.Parse(queryParam["distanceid"].ToString()); } if (!queryParam["lat"].IsEmpty()) { para.Lat = decimal.Parse(queryParam["lat"].ToString()); } if (!queryParam["lng"].IsEmpty()) { para.Lng = decimal.Parse(queryParam["lng"].ToString()); } if (!queryParam["schoolid"].IsEmpty()) { para.SchoolId = queryParam["schoolid"].ToString(); } if (!queryParam["istraining"].IsEmpty()) { para.IsTraining = int.Parse(queryParam["istraining"].ToString()); } } para.Status = (int)Model.Enums.UseStatus.启用; Pagination pagination = new Pagination(); pagination.page = pageIndex ?? 1; pagination.rows = 10; pagination.sidx = "SortNum"; pagination.sord = "asc"; var pageList = SchoolBLL.Instance.GetPageList(para, ref pagination); if (pageList != null) { pageList.ForEach((page) => { if (page.FaceImage != null) { var imageHost = System.Configuration.ConfigurationManager.AppSettings["ImageHost"] == "" ? string.Format("http://{0}{1}", Request.Url.Host, Request.Url.Port == 80 ? "" : ":" + Request.Url.Port) : System.Configuration.ConfigurationManager.AppSettings["ImageHost"]; page.FaceImage = imageHost + page.FaceImage; } if (page.SchoolId != null) { page.TagList = TagBLL.Instance.GetList(new TagEntity() { ObjectId = page.SchoolId }); page.TeacherList = TeacherBLL.Instance.GetList(new TeacherEntity() { SchoolId = page.SchoolId, Status = (int)Model.Enums.UseStatus.启用 }).OrderBy(o => o.SortNum).ToList(); if (page.TeacherList != null) { page.TeacherList.Foreach((o) => { if (o.FaceImage != null) { var imageHost = System.Configuration.ConfigurationManager.AppSettings["ImageHost"] == "" ? string.Format("http://{0}{1}", Request.Url.Host, Request.Url.Port == 80 ? "" : ":" + Request.Url.Port) : System.Configuration.ConfigurationManager.AppSettings["ImageHost"]; o.FaceImage = imageHost + o.FaceImage; } }); } } if (page.Lat != null && page.Lng != null && para.Lat != null && para.Lng != null) { page.HowLong = HarvenSin.GetDistance( new Point2D() { Lng = (double)para.Lng, Lat = (double)para.Lat }, new Point2D() { Lng = (double)page.Lng, Lat = (double)page.Lat }).ToString("f2"); } else { page.HowLong = "未知"; } }); } result.IsSuccess = true; result.Message = "加载列表成功!"; result.ResultData["IsEndPage"] = (pagination.total == (pageIndex ?? 1)); result.ResultData["List"] = pageList; } catch (Exception ex) { ex.Data["Method"] = "ApplyController>>List"; new ExceptionHelper().LogException(ex); } return(Json(result, JsonRequestBehavior.AllowGet)); }