From 342114f653094105e58fe6c3c4ae9490e9fbfd23 Mon Sep 17 00:00:00 2001 From: agafonoff2000 Date: Tue, 9 Feb 2016 18:03:12 +0300 Subject: [PATCH] English comments --- ExampleForms/Controls/MapCtl.cs | 8 +-- Framework/GraphicLayer.cs | 9 +-- Layers/MapLayer.cs | 3 +- Layers/MapObjects/TreeNodes/BuildingNode.cs | 1 - Layers/MapObjects/TreeNodes/CableNode.cs | 1 - Layers/MapObjects/TreeNodes/VertexNode.cs | 1 - Layers/NetLayer.cs | 6 +- Map/Google/GoogleMapUtilities.cs | 62 ++++++++++----------- Map/Google/GoogleRectangle.cs | 4 +- Map/Spatial/SpatialSheet.cs | 22 +++----- Map/Spatial/SpatialSheetBase.cs | 4 +- Map/Spatial/SpatialTree.cs | 11 ++-- 12 files changed, 58 insertions(+), 74 deletions(-) diff --git a/ExampleForms/Controls/MapCtl.cs b/ExampleForms/Controls/MapCtl.cs index 3721a0b..c1e3707 100644 --- a/ExampleForms/Controls/MapCtl.cs +++ b/ExampleForms/Controls/MapCtl.cs @@ -286,12 +286,12 @@ private void MapCtl_MouseDown(object sender, MouseEventArgs e) if (vertexRows.Length > 0) { var vertex = _netLayer.GetVertex(vertexRows[0].Value); - if (vertex != null) MessageBox.Show(vertex.Caption, "Vertex found!"); + if (vertex != null) MessageBox.Show(vertex.Caption, @"Vertex found!"); } else if (cableRows.Length > 0) { var cable = _netLayer.GetCable(cableRows[0].Value); - if (cable != null) MessageBox.Show(cable.Caption, "Cable found!"); + if (cable != null) MessageBox.Show(cable.Caption, @"Cable found!"); } } } @@ -316,14 +316,14 @@ private void MapCtl_MouseDown(object sender, MouseEventArgs e) { _menuObjectId = vertexRows[0].Value; var c = new ContextMenu(); - c.MenuItems.Add("Delete Vertex", MapCtl_DeleteVertexClick); + c.MenuItems.Add(@"Delete Vertex", MapCtl_DeleteVertexClick); c.Show(this, e.Location); } else if (cableRows.Length > 0) { _menuObjectId = cableRows[0].Value; var c = new ContextMenu(); - c.MenuItems.Add("Delete Cable", MapCtl_DeleteCableClick); + c.MenuItems.Add(@"Delete Cable", MapCtl_DeleteCableClick); c.Show(this, e.Location); } } diff --git a/Framework/GraphicLayer.cs b/Framework/GraphicLayer.cs index 1efa094..79931d4 100644 --- a/Framework/GraphicLayer.cs +++ b/Framework/GraphicLayer.cs @@ -78,19 +78,15 @@ protected CoordinateRectangle CoordinateView Width = pWidth; Height = pHeight; - _centerCoordinate = centerCoordinate; // Географическая широта, Географическая долгота, Масштаб (Zoom) GoogleMap-а + _centerCoordinate = centerCoordinate; _level = pLevel; PiFormat = piFormat; Resize(false); - //событие на отрисовку слоя _drawLayerEvent += OnIvalidateLayer; } - /// - /// Параметры события, срабатывает на изменение отрисовки слоя - /// public class InvalidateLayerEventArgs : OwnerEventArgs { public InvalidateLayerEventArgs() @@ -232,10 +228,7 @@ public void Resize(int pWidth, int pHeight) virtual protected void TranslateCoords() { - //определяем видимую область в целочисленных координатах гугла - //относительно заданной центральной точки _screenView = _centerCoordinate.GetScreenViewFromCenter(Width, Height, _level); - //определяем видимую область в широте и долготе _coordinateView = ScreenView; } diff --git a/Layers/MapLayer.cs b/Layers/MapLayer.cs index 6b7db90..0038a8b 100644 --- a/Layers/MapLayer.cs +++ b/Layers/MapLayer.cs @@ -66,7 +66,6 @@ override protected void TranslateCoords() { base.TranslateCoords(); - // Определяем видимый блок битмапа РїРѕ РѕСЃРё X Y _blockView = ScreenView.BlockView; } @@ -129,7 +128,7 @@ private bool DrawImages(Rectangle localBlockView, GoogleRectangle localScreenVie private static bool PointContains(Point pt, Rectangle rect) { - //!!!стандартная функция РЅРµ работает РЅР° граничных условиях + //!!!standard function doesnt work on borders return pt.X >= rect.Left && pt.X <= rect.Right && pt.Y >= rect.Top && pt.Y <= rect.Bottom; } diff --git a/Layers/MapObjects/TreeNodes/BuildingNode.cs b/Layers/MapObjects/TreeNodes/BuildingNode.cs index 9364af3..e0afafc 100644 --- a/Layers/MapObjects/TreeNodes/BuildingNode.cs +++ b/Layers/MapObjects/TreeNodes/BuildingNode.cs @@ -2,7 +2,6 @@ using System.Data; using ProgramMain.ExampleDb; using ProgramMain.Map; -using ProgramMain.Map.Spatial; using ProgramMain.Map.Spatial.Types; namespace ProgramMain.Layers.MapObjects.TreeNodes diff --git a/Layers/MapObjects/TreeNodes/CableNode.cs b/Layers/MapObjects/TreeNodes/CableNode.cs index d9c34f3..6b20f9a 100644 --- a/Layers/MapObjects/TreeNodes/CableNode.cs +++ b/Layers/MapObjects/TreeNodes/CableNode.cs @@ -2,7 +2,6 @@ using System.Data; using ProgramMain.ExampleDb; using ProgramMain.Map; -using ProgramMain.Map.Spatial; using ProgramMain.Map.Spatial.Types; namespace ProgramMain.Layers.MapObjects.TreeNodes diff --git a/Layers/MapObjects/TreeNodes/VertexNode.cs b/Layers/MapObjects/TreeNodes/VertexNode.cs index ffc64fd..041409c 100644 --- a/Layers/MapObjects/TreeNodes/VertexNode.cs +++ b/Layers/MapObjects/TreeNodes/VertexNode.cs @@ -2,7 +2,6 @@ using System.Data; using ProgramMain.ExampleDb; using ProgramMain.Map; -using ProgramMain.Map.Spatial; using ProgramMain.Map.Spatial.Types; namespace ProgramMain.Layers.MapObjects.TreeNodes diff --git a/Layers/NetLayer.cs b/Layers/NetLayer.cs index f8c2cd7..94b24d5 100644 --- a/Layers/NetLayer.cs +++ b/Layers/NetLayer.cs @@ -90,14 +90,14 @@ override protected void TranslateCoords() { base.TranslateCoords(); - // Определяем погрешность для попадания РІ объекты + //Fault distance on mouse click to detect click on objects CoordinateTolerance = CenterCoordinate.Distance( CenterCoordinate + new GoogleCoordinate(HalfVertexSize.Width, 0/*HalfVertexSize.Height*/, Level)); } protected override bool DispatchThreadEvents(WorkerEvent workerEvent) { - bool res = base.DispatchThreadEvents(workerEvent); + var res = base.DispatchThreadEvents(workerEvent); if (!res && workerEvent is NetWorkerEvent) { @@ -125,7 +125,7 @@ override protected void DrawLayer(Rectangle clipRectangle) { SwapDrawBuffer(); - //рисовать РІСЃРµ объекты РЅР° карте независимо РѕС‚ ClipRectangle, С‚.Рє. FillTransparent! + //!!!Draw all objects after FillTransparent (*ClipRectangle) FillTransparent(); var localScreenView = (GoogleRectangle)ScreenView.Clone(); diff --git a/Map/Google/GoogleMapUtilities.cs b/Map/Google/GoogleMapUtilities.cs index 44c4e7b..1c7bc21 100644 --- a/Map/Google/GoogleMapUtilities.cs +++ b/Map/Google/GoogleMapUtilities.cs @@ -5,9 +5,9 @@ namespace ProgramMain.Map.Google { internal class GoogleMapUtilities { - #region Вспомогательные функциии для преобразование географических координат в координаты GoggleMaps + #region Helpers to work with Google Coordinate system /// - /// Определяем количество блоков вдоль одной стороны битмапа уровня level + /// Block count on the side of google level /// /// /// @@ -17,18 +17,18 @@ public static long NumTiles(int level) } /// - /// Определяем количество блоков битмапа уровня level + /// Block count on the google level /// /// /// public static long CountTiles(int level) { - long numTiles = NumTiles(level); + var numTiles = NumTiles(level); return numTiles * numTiles; } /// - /// Определяем уровнень битмапа по колличеству блоков в level + /// Translate block count to google level /// /// /// @@ -38,7 +38,7 @@ public static long NumLevel(int countTiles) } /// - /// Определяем размер в пикселях одной стороны битмапа уровня level + /// Pixel count on the side of google level bitmap /// /// /// @@ -48,7 +48,7 @@ public static long BitMapSize(int level) } /// - /// Определяем координаты в пикселах середины Битмапа уровня level + /// Pixel count on the google level bitmap /// /// /// @@ -58,65 +58,65 @@ public static long BitmapOrigo(int level) } /// - /// Определяем количество пикселей, приходящееся на один градус долготы на Битмапе уровня level + /// Pixel count per degree on the google level bitmap /// /// /// - public static double PixelsPerLonDegree(int level) + public static double PixelsPerDegree(int level) { return (double)BitMapSize(level) / 360; } /// - /// Определяем количество пикселей, приходящееся на один радиан долготы на Битмапе уровня level + /// Pixel count per radian on the google level bitmap /// /// /// - public static double PixelsPerLonRadian(int level) + public static double PixelsPerRadian(int level) { const double p2 = 2 * Math.PI; return BitMapSize(level) / p2; } /// - /// Преобразование географической долготы в координату X Googl-a + /// Translate longitude to X coordinate of the google level bitmap /// public static long GetGoogleX(Coordinate coordinate, int level) { - return (long)(Math.Floor(BitmapOrigo(level) + coordinate.Longitude * PixelsPerLonDegree(level))); + return (long)(Math.Floor(BitmapOrigo(level) + coordinate.Longitude * PixelsPerDegree(level))); } /// - /// Преобразование географической широты в координату Y Googl-a + /// Translate latitude to Y coordinate of the google level bitmap /// public static long GetGoogleY(Coordinate coordinate, int level) { - const double d2R = Math.PI / 180; // Константа для преобразования градусов в радианы + const double d2R = Math.PI / 180; var z = (1 + Math.Sin(coordinate.Latitude * d2R)) / (1 - Math.Sin(coordinate.Latitude * d2R)); - return (long)(Math.Floor(BitmapOrigo(level) - 0.5 * Math.Log(z) * PixelsPerLonRadian(level))); + return (long)(Math.Floor(BitmapOrigo(level) - 0.5 * Math.Log(z) * PixelsPerRadian(level))); } /// - /// Преобразование координаты X Googl-a в географическую долготу + /// Translate X coordinate of the google level bitmap to longitude /// public static double GetLongitude(GoogleCoordinate google) { - return Math.Round((google.X - BitmapOrigo(google.Level)) / PixelsPerLonDegree(google.Level), 5); + return Math.Round((google.X - BitmapOrigo(google.Level)) / PixelsPerDegree(google.Level), 5); } /// - /// Преобразование координаты Y Googl-a в географическую широту + /// Translate Y coordinate of the google level bitmap to latitude /// public static double GetLatitude(GoogleCoordinate google) { - const double r2D = 180 / Math.PI; // Константа для преобразования радиан в градусы + const double r2D = 180 / Math.PI; const double p2 = Math.PI / 2; - var z = (google.Y - BitmapOrigo(google.Level)) / (-1 * PixelsPerLonRadian(google.Level)); + var z = (google.Y - BitmapOrigo(google.Level)) / (-1 * PixelsPerRadian(google.Level)); return Math.Round((2 * Math.Atan(Math.Exp(z)) - p2) * r2D, 5); } /// - /// Номер блока для координаты X Googl-a по широте + /// Get google bitmap block number X by longitude /// public static long GetNumBlockX(Coordinate coordinate, int level) { @@ -124,7 +124,7 @@ public static long GetNumBlockX(Coordinate coordinate, int level) } /// - /// Номер блока для координаты Y Googl-a по долготе + /// Get google bitmap block number Y by latitude /// public static long GetNumBlockY(Coordinate coordinate, int level) { @@ -133,7 +133,7 @@ public static long GetNumBlockY(Coordinate coordinate, int level) #endregion /// - /// Пересечение отрезков c заданными координатами + /// Line cross /// public static bool CheckLinesInterseption(CoordinateRectangle line1, CoordinateRectangle line2) { @@ -152,14 +152,12 @@ public static bool CheckLinesInterseption(CoordinateRectangle line1, CoordinateR } /// - /// Центральная точка на отрезке - /// Передаваемые широта/долгота в градусах и сотых долях + /// Line middle point /// public static Coordinate GetMiddlePoint(Coordinate c1, Coordinate c2) { - // Константы, используемые для вычисления смещения и расстояния - const double d2R = Math.PI / 180; // Константа для преобразования градусов в радианы - const double r2D = 180 / Math.PI; // Константа для преобразования радиан в градусы + const double d2R = Math.PI / 180; + const double r2D = 180 / Math.PI; var dLon = d2R * (c2.Longitude - c1.Longitude); var c1Rlat = d2R * (c1.Latitude); @@ -174,7 +172,7 @@ public static Coordinate GetMiddlePoint(Coordinate c1, Coordinate c2) } /// - /// Создать URL для запроса картинки у Googl-a c заданными координатами + /// Create Url to get bitmap block from google bitmap cache /// public static string CreateUrl(GoogleBlock block) { @@ -182,13 +180,13 @@ public static string CreateUrl(GoogleBlock block) } /// - /// Создать запрос картинки у Googl-a c заданными координатами + /// Create web request to get bitmap block from google bitmap cache /// public static HttpWebRequest CreateGoogleWebRequest(GoogleBlock block) { var urlGoogle = CreateUrl(block); var oRequest = (HttpWebRequest)WebRequest.Create(urlGoogle); - oRequest.UserAgent = "www.simplemap.ru"; //Это обязательно, иначе Google не вернет картинку! + oRequest.UserAgent = "www.simplemap.ru"; //!!!must have to retrieve image from google return oRequest; } } diff --git a/Map/Google/GoogleRectangle.cs b/Map/Google/GoogleRectangle.cs index e12d659..cecf81e 100644 --- a/Map/Google/GoogleRectangle.cs +++ b/Map/Google/GoogleRectangle.cs @@ -122,7 +122,9 @@ public int CompareTo(Object obj) return new CoordinateRectangle(google.LeftTop, google.RightBottom); } - //Стартовый и конечный(видимый) блок битмапа по оси X Y + /// + /// Google bitmap block count for (X, Y) + /// public Rectangle BlockView { get diff --git a/Map/Spatial/SpatialSheet.cs b/Map/Spatial/SpatialSheet.cs index 9df6429..7ca95bc 100644 --- a/Map/Spatial/SpatialSheet.cs +++ b/Map/Spatial/SpatialSheet.cs @@ -19,7 +19,7 @@ public enum SheetActionType { Insert, Delete }; internal void SheetAction(TNode node, SheetActionType actionType) { - //вставка элемента в индекс, или его удаление из индекса + //Insert node to spatial index or remove node from spatial index if (!IsBottomSheet) { switch (node.NodeType) @@ -40,7 +40,7 @@ internal void SheetAction(TNode node, SheetActionType actionType) } else { - //если дошли до нижнего уровня, то добавить/удалить элемент + //Just do it on bottom level lock (this) { switch (actionType) @@ -61,7 +61,7 @@ private void PointSheetAction(TNode node, SheetActionType actionType) var block = node.Coordinate.GetGoogleBlock(NextGoogleLevel); lock (this) { - //поиск для точки дочернего элемента в индексе + //point search in daughter sheet var sheet = Sheets[block]; sheet.SheetAction(node, actionType); @@ -80,7 +80,7 @@ private void LineSheetAction(TNode node, SheetActionType actionType) var deltaX = (rect.Left <= rect.Right) ? 1 : -1; var deltaY = (rect.Top <= rect.Bottom) ? 1 : -1; - //поиск для линии дочерних элементов в индексе(линия может входить в несколько элементов индекса) + //line search in daughter sheet for (var x = rect.Left; (deltaX == 1 && x <= rect.Right) || (deltaX == -1 && x >= rect.Right); x += deltaX) { for (var y = rect.Top; (deltaY == 1 && y <= rect.Bottom) || (deltaY == -1 && y >= rect.Bottom); y += deltaY) @@ -88,7 +88,6 @@ private void LineSheetAction(TNode node, SheetActionType actionType) var block = new GoogleBlock(x, y, blockViewLevel); var googleRect = (GoogleRectangle)block; - //проверка вхождения линии в каждый из потенциальных дочерних элементов индекса if (googleRect.LineContains(line) != InterseptResult.None) { lock (this) @@ -113,7 +112,7 @@ private void RectangleSheetAction(TNode node, SheetActionType actionType) var deltaX = (rect.Left <= rect.Right) ? 1 : -1; var deltaY = (rect.Top <= rect.Bottom) ? 1 : -1; - //поиск для прямоугольника дочерних элементов в индексе(прямоугольник может входить в несколько элементов индекса) + //rectangle search in daughter sheet for (var x = rect.Left; (deltaX == 1 && x <= rect.Right) || (deltaX == -1 && x >= rect.Right); x += deltaX) { for (var y = rect.Top; (deltaY == 1 && y <= rect.Bottom) || (deltaY == -1 && y >= rect.Bottom); y += deltaY) @@ -141,7 +140,7 @@ private void PoligonSheetAction(TNode node, SheetActionType actionType) var deltaX = (rect.Left <= rect.Right) ? 1 : -1; var deltaY = (rect.Top <= rect.Bottom) ? 1 : -1; - //поиск для линии дочерних элементов в индексе(линия может входить в несколько элементов индекса) + //poligon search in daughter sheet for (var x = rect.Left; (deltaX == 1 && x <= rect.Right) || (deltaX == -1 && x >= rect.Right); x += deltaX) { for (var y = rect.Top; (deltaY == 1 && y <= rect.Bottom) || (deltaY == -1 && y >= rect.Bottom); y += deltaY) @@ -149,7 +148,6 @@ private void PoligonSheetAction(TNode node, SheetActionType actionType) var block = new GoogleBlock(x, y, blockViewLevel); var googleRect = (GoogleRectangle)block; - //проверка вхождения линии в каждый из потенциальных дочерних элементов индекса if (googleRect.PoligonContains(poligon) != InterseptResult.None) { lock (this) @@ -171,7 +169,7 @@ private void PostSheetAction(GoogleBlock block, SpatialSheet sheet, Sheet { case SheetActionType.Delete: { - //при удалении объектов удалить текущюю ветку идекса, если она пустая + //delete sheet from index without elements if (sheet.IsEmpty) Sheets.Remove(block); } break; @@ -180,7 +178,7 @@ private void PostSheetAction(GoogleBlock block, SpatialSheet sheet, Sheet public void Query(HashSet hashSet, CoordinateRectangle rectangle, InterseptResult parentResult, SpatialQueryIterator i) { - //запрос на поиск элементов в индексе в заданном квадрате координат + //Query elements on the map by coordinate ractengle(indexed search) lock (this) { if (!IsBottomSheet) @@ -214,7 +212,6 @@ public void Query(HashSet hashSet, CoordinateRectangle rectang { i.Next(); - //проверка на вхождение текущего элемента в индексе в заданном квадрате координат switch (node.NodeType) { case SpatialTreeNodeTypes.Point: @@ -242,7 +239,7 @@ public void Query(HashSet hashSet, CoordinateRectangle rectang public void Distance(HashSet hashSet, Coordinate coordinate, double variance, SpatialQueryIterator i) { - //запрос на поиск элементов в индексе удаленных на определенное растояние (в метрах) от заданной точки + //Query elements on the map close to coordinate (indexed search) lock (this) { if (!IsBottomSheet) @@ -266,7 +263,6 @@ public void Distance(HashSet hashSet, Coordinate coordinate, d { i.Next(); - //расчет растояния для текущего элемента (в метрах) от заданной точки double distance = -1; switch (node.NodeType) { diff --git a/Map/Spatial/SpatialSheetBase.cs b/Map/Spatial/SpatialSheetBase.cs index a3ed5e0..83d9782 100644 --- a/Map/Spatial/SpatialSheetBase.cs +++ b/Map/Spatial/SpatialSheetBase.cs @@ -9,10 +9,10 @@ internal class SpatialSheetBase where TNode : ISpatialTreeNode public int Level { get; private set; } public int GoogleLevel { get; private set; } - //массив для хранения дочерних уровней в индекса + //Daughter index sheets public readonly SpatialSheetIndexer Sheets; - //массив для храрения элементов (поддерживаются точки, линии и прямоугольники) + //Content array of index elemets on bottom index sheets public readonly SpatialContentIndexer Content; public bool IsEmpty diff --git a/Map/Spatial/SpatialTree.cs b/Map/Spatial/SpatialTree.cs index 6f966d6..38a3f48 100644 --- a/Map/Spatial/SpatialTree.cs +++ b/Map/Spatial/SpatialTree.cs @@ -7,10 +7,10 @@ namespace ProgramMain.Map.Spatial { public class SpatialTree where TNode : ISpatialTreeNode { - //ссылка на главный уровень в индексе - //по умолчанию индекс содержит 4 уровня, не включая главного, но при желании может быть увеличен + //Spatial index depth count, can be > 4 internal readonly int SpatialDepth = 4; - + + //Root spatial index sheet includes all daughter indexed sheets private SpatialSheet _root; public int NodeCount { get; private set; } public readonly SpatialLevelPowerIndexer Power; @@ -50,10 +50,10 @@ protected void SetLevels(SpatialSheetPowerTypes level1, SpatialSheetPowerTypes l { Power[i] = SpatialSheetPowerTypes.Low; } - //rootLevel включает в себя все элементы дерева, поэтому координаты границы не задаются + //Root spatial index sheet includes whole world _root = new SpatialSheet(this, 1, 1, CoordinateRectangle.Empty); - //нужен для тюнинга индекса, содержит количество ветвей индекса на каждом уровне + //Array to grab index stats for tuning NodeDimension = new int[Power.Length - 1]; } @@ -112,7 +112,6 @@ public void Clear() NodeCount = 0; _root.Clear(); - //нужен для тюнинга индекса, содержит количество ветвей индекса на каждом уровне NodeDimension = new int[Power.Length - 1]; } }