public string toUtmString(double lon, double lat, double elev) { string ret = ""; // UTM = 11S 0433603E 3778359N LonLatPt lonlat = new LonLatPt(); lonlat.Lat = lat; lonlat.Lon = lon; UtmPt utmpt = Projection.LonLatPtToUtmNad83Pt(lonlat); ret = "" + utmpt.Zone + "S " + string.Format("{0:d07}", (int)Math.Round(utmpt.X)) + "E " + string.Format("{0:d07}", (int)Math.Round(utmpt.Y)) + "N"; return(ret); }
/// <summary> /// this is complete cut-and-paste from the above - keep them in sync /// </summary> /// <param name="obj"></param> private void listQueryDisconnected(Hashtable list) { int xStart = 0; int yStart = 0; int xEnd = 0; int yEnd = 0; int m_lastFactor = 0; GeoCoord covTL = m_coverageTopLeft; GeoCoord covBR = m_coverageBottomRight; double marginY = 0.0d; double marginX = 0.0d; double covTL_Lng = covTL.Lng - marginX; double covTL_Lat = covTL.Lat + marginY; double covBR_Lng = covBR.Lng + marginX; double covBR_Lat = covBR.Lat - marginY; int currentZone = TileSetTerra.getZone(m_coverageCenter); LonLatPt lonlat = new LonLatPt(); lonlat.Lat = covTL_Lat; lonlat.Lon = covTL_Lng; UtmPt utmptTL = Projection.LonLatPtToUtmNad83Pt(lonlat); // can be in other than currentZone lonlat.Lat = covBR_Lat; lonlat.Lon = covBR_Lng; UtmPt utmptBR = Projection.LonLatPtToUtmNad83Pt(lonlat); // can be in other than currentZone if (utmptTL.Zone != currentZone) { lonlat.Lat = m_coverageCenter.Lat; lonlat.Lon = m_coverageCenter.Lng; UtmPt utmptCam = Projection.LonLatPtToUtmNad83Pt(lonlat); // can be in other than currentZone double dX = utmptBR.X - utmptCam.X; utmptTL.X = utmptCam.X - dX; utmptTL.Zone = currentZone; } else if (utmptBR.Zone != currentZone) { lonlat.Lat = m_coverageCenter.Lat; lonlat.Lon = m_coverageCenter.Lng; UtmPt utmptCam = Projection.LonLatPtToUtmNad83Pt(lonlat); // can be in other than currentZone double dX = utmptCam.X - utmptTL.X; utmptBR.X = utmptCam.X + dX; utmptBR.Zone = currentZone; } int iScale = (int)m_tileScale; int metersPerPixel = (1 << ((int)iScale - 10)); int factor = 200 * metersPerPixel; if (xEnd - xStart == 0 || m_lastFactor == 0) { xStart = (int)Math.Floor(utmptTL.X / factor); yStart = (int)Math.Ceiling(utmptTL.Y / factor); xEnd = (int)Math.Ceiling(utmptBR.X / factor); yEnd = (int)Math.Floor(utmptBR.Y / factor); m_lastFactor = factor; } else { xStart = xStart * m_lastFactor / factor; yStart = yStart * m_lastFactor / factor; xEnd = xEnd * m_lastFactor / factor; yEnd = yEnd * m_lastFactor / factor; } int numTilesX = xEnd - xStart; int numTilesY = yStart - yEnd; int hCount = numTilesX; int vCount = numTilesY; UtmPt utmpt = new UtmPt(); utmpt.X = xStart * factor; utmpt.Y = yStart * factor; utmpt.Zone = currentZone; lonlat = Projection.UtmNad83PtToLonLatPt(utmpt); double topLeftLat = lonlat.Lat; double topLeftLng = lonlat.Lon; utmpt.X = (xStart + numTilesX) * factor; utmpt.Y = (yStart - numTilesY) * factor; lonlat = Projection.UtmNad83PtToLonLatPt(utmpt); double bottomRightLat = lonlat.Lat; double bottomRightLng = lonlat.Lon; int themeCode = getThemeCode(); int xx = (int)xStart; for (int hhh = 0; hhh < hCount; hhh++) { int yy = (int)yStart; for (int vvv = 0; vvv < vCount; vvv++) { utmpt.X = xx * factor; utmpt.Y = (yy) * factor; utmpt.Zone = currentZone; lonlat = Projection.UtmNad83PtToLonLatPt(utmpt); double tllat = lonlat.Lat; double tllng = lonlat.Lon; utmpt.X = (xx + 1) * factor; utmpt.Y = (yy - 1) * factor; lonlat = Projection.UtmNad83PtToLonLatPt(utmpt); double brlat = lonlat.Lat; double brlng = lonlat.Lon; GeoCoord tileTopLeft = new GeoCoord(tllng, tllat); GeoCoord tileBottomRight = new GeoCoord(brlng, brlat); String baseName = String.Format("T{0}-S{1}-Z{2}-X{3}-Y{4}", themeCode, (Int32)m_tileScale, currentZone, xx, (yy - 1)); if (!list.ContainsKey(baseName)) { list.Add(baseName, null); } #if DEBUG //LibSys.StatusBar.Trace("[" + vvv + "," + hhh + "] " + baseName); //LibSys.StatusBar.Trace(" -- topLeft=" + tileTopLeft + " bottomRight=" + tileBottomRight); #endif yy--; } xx++; } }
/// <summary> /// this is somewhat cut-and-paste from its namesake from the TileSetTerra.cs keep them in sync /// </summary> /// <param name="obj"></param> private void _queryDisconnected(object obj) { int xStart = 0; int yStart = 0; int xEnd = 0; int yEnd = 0; int m_lastFactor = 0; GeoCoord covTL = m_coverageTopLeft; GeoCoord covBR = m_coverageBottomRight; double marginY = 0.0d; double marginX = 0.0d; double covTL_Lng = covTL.Lng - marginX; double covTL_Lat = covTL.Lat + marginY; double covBR_Lng = covBR.Lng + marginX; double covBR_Lat = covBR.Lat - marginY; int currentZone = TileSetTerra.getZone(m_coverageCenter); LonLatPt lonlat = new LonLatPt(); lonlat.Lat = covTL_Lat; lonlat.Lon = covTL_Lng; UtmPt utmptTL = Projection.LonLatPtToUtmNad83Pt(lonlat); // can be in other than currentZone lonlat.Lat = covBR_Lat; lonlat.Lon = covBR_Lng; UtmPt utmptBR = Projection.LonLatPtToUtmNad83Pt(lonlat); // can be in other than currentZone if (utmptTL.Zone != currentZone) { lonlat.Lat = m_coverageCenter.Lat; lonlat.Lon = m_coverageCenter.Lng; UtmPt utmptCam = Projection.LonLatPtToUtmNad83Pt(lonlat); // can be in other than currentZone double dX = utmptBR.X - utmptCam.X; utmptTL.X = utmptCam.X - dX; utmptTL.Zone = currentZone; } else if (utmptBR.Zone != currentZone) { lonlat.Lat = m_coverageCenter.Lat; lonlat.Lon = m_coverageCenter.Lng; UtmPt utmptCam = Projection.LonLatPtToUtmNad83Pt(lonlat); // can be in other than currentZone double dX = utmptCam.X - utmptTL.X; utmptBR.X = utmptCam.X + dX; utmptBR.Zone = currentZone; } int iScale = (int)m_tileScale; int metersPerPixel = (1 << ((int)iScale - 10)); int factor = 200 * metersPerPixel; if (xEnd - xStart == 0 || m_lastFactor == 0) { xStart = (int)Math.Floor(utmptTL.X / factor); yStart = (int)Math.Ceiling(utmptTL.Y / factor); xEnd = (int)Math.Ceiling(utmptBR.X / factor); yEnd = (int)Math.Floor(utmptBR.Y / factor); m_lastFactor = factor; } else { xStart = xStart * m_lastFactor / factor; yStart = yStart * m_lastFactor / factor; xEnd = xEnd * m_lastFactor / factor; yEnd = yEnd * m_lastFactor / factor; } int numTilesX = xEnd - xStart; int numTilesY = yStart - yEnd; int hCount = numTilesX; int vCount = numTilesY; UtmPt utmpt = new UtmPt(); utmpt.X = xStart * factor; utmpt.Y = yStart * factor; utmpt.Zone = currentZone; lonlat = Projection.UtmNad83PtToLonLatPt(utmpt); double topLeftLat = lonlat.Lat; double topLeftLng = lonlat.Lon; utmpt.X = (xStart + numTilesX) * factor; utmpt.Y = (yStart - numTilesY) * factor; lonlat = Projection.UtmNad83PtToLonLatPt(utmpt); double bottomRightLat = lonlat.Lat; double bottomRightLng = lonlat.Lon; int themeCode = getThemeCode(); int xx = (int)xStart; for (int hhh = 0; hhh < hCount; hhh++) { int yy = (int)yStart; for (int vvv = 0; vvv < vCount; vvv++) { utmpt.X = xx * factor; utmpt.Y = (yy) * factor; utmpt.Zone = currentZone; lonlat = Projection.UtmNad83PtToLonLatPt(utmpt); double tllat = lonlat.Lat; double tllng = lonlat.Lon; utmpt.X = (xx + 1) * factor; utmpt.Y = (yy - 1) * factor; lonlat = Projection.UtmNad83PtToLonLatPt(utmpt); double brlat = lonlat.Lat; double brlng = lonlat.Lon; GeoCoord tileTopLeft = new GeoCoord(tllng, tllat); GeoCoord tileBottomRight = new GeoCoord(brlng, brlat); String baseName = String.Format("T{0}-S{1}-Z{2}-X{3}-Y{4}", themeCode, (Int32)m_tileScale, currentZone, xx, (yy - 1)); if (TerraserverCache.TileNamesCollection != null) { if (!TerraserverCache.TileNamesCollection.ContainsKey(baseName)) { TerraserverCache.TileNamesCollection.Add(baseName, null); } } lock (m_duplicates) { if (!m_duplicates.ContainsKey(baseName)) { TerraserverCache.downloadIfMissing(baseName); m_duplicates.Add(baseName, null); } } #if DEBUG //LibSys.StatusBar.Trace("[" + vvv + "," + hhh + "] " + baseName); //LibSys.StatusBar.Trace(" -- topLeft=" + tileTopLeft + " bottomRight=" + tileBottomRight); #endif yy--; } xx++; } int totalCount = TileSetTerraLayout.DuplicatesCount; int newCount = ThreadPool2.WaitingCallbacks; if (newCount == 0) { LibSys.StatusBar.Trace("*Preload tiles: nothing to download - all " + totalCount + " tiles already in cache."); } else { if (newCount <= totalCount) { LibSys.StatusBar.Trace("*Preload tiles: trying to download " + newCount + " new of total " + totalCount + " tiles"); } else { LibSys.StatusBar.Trace("*Preload tiles: trying to download " + newCount + " new tiles"); } } }