Skip to content

Commit

Permalink
English comments
Browse files Browse the repository at this point in the history
  • Loading branch information
agafonoff2000 committed Feb 9, 2016
1 parent be8d510 commit 342114f
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 74 deletions.
8 changes: 4 additions & 4 deletions ExampleForms/Controls/MapCtl.cs
Expand Up @@ -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!");
}
}
}
Expand All @@ -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);
}
}
Expand Down
9 changes: 1 addition & 8 deletions Framework/GraphicLayer.cs
Expand Up @@ -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;
}

/// <summary>
/// Ïàðàìåòðû ñîáûòèÿ, ñðàáàòûâàåò íà èçìåíåíèå îòðèñîâêè ñëîÿ
/// </summary>
public class InvalidateLayerEventArgs : OwnerEventArgs
{
public InvalidateLayerEventArgs()
Expand Down Expand Up @@ -232,10 +228,7 @@ public void Resize(int pWidth, int pHeight)

virtual protected void TranslateCoords()
{
//îïðåäåëÿåì âèäèìóþ îáëàñòü â öåëî÷èñëåííûõ êîîðäèíàòàõ ãóãëà
//îòíîñèòåëüíî çàäàííîé öåíòðàëüíîé òî÷êè
_screenView = _centerCoordinate.GetScreenViewFromCenter(Width, Height, _level);
//îïðåäåëÿåì âèäèìóþ îáëàñòü â øèðîòå è äîëãîòå
_coordinateView = ScreenView;
}

Expand Down
3 changes: 1 addition & 2 deletions Layers/MapLayer.cs
Expand Up @@ -66,7 +66,6 @@ override protected void TranslateCoords()
{
base.TranslateCoords();

// Определяем видимый блок битмапа по оси X Y
_blockView = ScreenView.BlockView;
}

Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion Layers/MapObjects/TreeNodes/BuildingNode.cs
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Layers/MapObjects/TreeNodes/CableNode.cs
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Layers/MapObjects/TreeNodes/VertexNode.cs
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Layers/NetLayer.cs
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
Expand Down
62 changes: 30 additions & 32 deletions Map/Google/GoogleMapUtilities.cs
Expand Up @@ -5,9 +5,9 @@ namespace ProgramMain.Map.Google
{
internal class GoogleMapUtilities
{
#region Âñïîìîãàòåëüíûå ôóíêöèèè äëÿ ïðåîáðàçîâàíèå ãåîãðàôè÷åñêèõ êîîðäèíàò â êîîðäèíàòû GoggleMaps
#region Helpers to work with Google Coordinate system
/// <summary>
/// Îïðåäåëÿåì êîëè÷åñòâî áëîêîâ âäîëü îäíîé ñòîðîíû áèòìàïà óðîâíÿ level
/// Block count on the side of google level
/// </summary>
/// <param name="level"></param>
/// <returns></returns>
Expand All @@ -17,18 +17,18 @@ public static long NumTiles(int level)
}

/// <summary>
/// Îïðåäåëÿåì êîëè÷åñòâî áëîêîâ áèòìàïà óðîâíÿ level
/// Block count on the google level
/// </summary>
/// <param name="level"></param>
/// <returns></returns>
public static long CountTiles(int level)
{
long numTiles = NumTiles(level);
var numTiles = NumTiles(level);
return numTiles * numTiles;
}

/// <summary>
/// Îïðåäåëÿåì óðîâíåíü áèòìàïà ïî êîëëè÷åñòâó áëîêîâ â level
/// Translate block count to google level
/// </summary>
/// <param name="countTiles"></param>
/// <returns></returns>
Expand All @@ -38,7 +38,7 @@ public static long NumLevel(int countTiles)
}

/// <summary>
/// Îïðåäåëÿåì ðàçìåð â ïèêñåëÿõ îäíîé ñòîðîíû áèòìàïà óðîâíÿ level
/// Pixel count on the side of google level bitmap
/// </summary>
/// <param name="level"></param>
/// <returns></returns>
Expand All @@ -48,7 +48,7 @@ public static long BitMapSize(int level)
}

/// <summary>
/// Îïðåäåëÿåì êîîðäèíàòû â ïèêñåëàõ ñåðåäèíû Áèòìàïà óðîâíÿ level
/// Pixel count on the google level bitmap
/// </summary>
/// <param name="level"></param>
/// <returns></returns>
Expand All @@ -58,73 +58,73 @@ public static long BitmapOrigo(int level)
}

/// <summary>
/// Îïðåäåëÿåì êîëè÷åñòâî ïèêñåëåé, ïðèõîäÿùååñÿ íà îäèí ãðàäóñ äîëãîòû íà Áèòìàïå óðîâíÿ level
/// Pixel count per degree on the google level bitmap
/// </summary>
/// <param name="level"></param>
/// <returns></returns>
public static double PixelsPerLonDegree(int level)
public static double PixelsPerDegree(int level)
{
return (double)BitMapSize(level) / 360;
}

/// <summary>
/// Îïðåäåëÿåì êîëè÷åñòâî ïèêñåëåé, ïðèõîäÿùååñÿ íà îäèí ðàäèàí äîëãîòû íà Áèòìàïå óðîâíÿ level
/// Pixel count per radian on the google level bitmap
/// </summary>
/// <param name="level"></param>
/// <returns></returns>
public static double PixelsPerLonRadian(int level)
public static double PixelsPerRadian(int level)
{
const double p2 = 2 * Math.PI;
return BitMapSize(level) / p2;
}

/// <summary>
/// Ïðåîáðàçîâàíèå ãåîãðàôè÷åñêîé äîëãîòû â êîîðäèíàòó X Googl-a
/// Translate longitude to X coordinate of the google level bitmap
/// </summary>
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)));
}

/// <summary>
/// Ïðåîáðàçîâàíèå ãåîãðàôè÷åñêîé øèðîòû â êîîðäèíàòó Y Googl-a
/// Translate latitude to Y coordinate of the google level bitmap
/// </summary>
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)));
}

/// <summary>
/// Ïðåîáðàçîâàíèå êîîðäèíàòû X Googl-a â ãåîãðàôè÷åñêóþ äîëãîòó
/// Translate X coordinate of the google level bitmap to longitude
/// </summary>
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);
}

/// <summary>
/// Ïðåîáðàçîâàíèå êîîðäèíàòû Y Googl-a â ãåîãðàôè÷åñêóþ øèðîòó
/// Translate Y coordinate of the google level bitmap to latitude
/// </summary>
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);
}

/// <summary>
/// Íîìåð áëîêà äëÿ êîîðäèíàòû X Googl-a ïî øèðîòå
/// Get google bitmap block number X by longitude
/// </summary>
public static long GetNumBlockX(Coordinate coordinate, int level)
{
return (long)Math.Floor((double)GetGoogleX(coordinate, level) / GoogleBlock.BlockSize);
}

/// <summary>
/// Íîìåð áëîêà äëÿ êîîðäèíàòû Y Googl-a ïî äîëãîòå
/// Get google bitmap block number Y by latitude
/// </summary>
public static long GetNumBlockY(Coordinate coordinate, int level)
{
Expand All @@ -133,7 +133,7 @@ public static long GetNumBlockY(Coordinate coordinate, int level)
#endregion

/// <summary>
/// Ïåðåñå÷åíèå îòðåçêîâ c çàäàííûìè êîîðäèíàòàìè
/// Line cross
/// </summary>
public static bool CheckLinesInterseption(CoordinateRectangle line1, CoordinateRectangle line2)
{
Expand All @@ -152,14 +152,12 @@ public static bool CheckLinesInterseption(CoordinateRectangle line1, CoordinateR
}

/// <summary>
/// Öåíòðàëüíàÿ òî÷êà íà îòðåçêå
/// Ïåðåäàâàåìûå øèðîòà/äîëãîòà â ãðàäóñàõ è ñîòûõ äîëÿõ
/// Line middle point
/// </summary>
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);
Expand All @@ -174,21 +172,21 @@ public static Coordinate GetMiddlePoint(Coordinate c1, Coordinate c2)
}

/// <summary>
/// Ñîçäàòü URL äëÿ çàïðîñà êàðòèíêè ó Googl-a c çàäàííûìè êîîðäèíàòàìè
/// Create Url to get bitmap block from google bitmap cache
/// </summary>
public static string CreateUrl(GoogleBlock block)
{
return String.Format(Properties.Settings.Default.GoogleUrl, block.X, block.Y, block.Level - 1);
}

/// <summary>
/// Ñîçäàòü çàïðîñ êàðòèíêè ó Googl-a c çàäàííûìè êîîðäèíàòàìè
/// Create web request to get bitmap block from google bitmap cache
/// </summary>
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;
}
}
Expand Down
4 changes: 3 additions & 1 deletion Map/Google/GoogleRectangle.cs
Expand Up @@ -122,7 +122,9 @@ public int CompareTo(Object obj)
return new CoordinateRectangle(google.LeftTop, google.RightBottom);
}

//Ñòàðòîâûé è êîíå÷íûé(âèäèìûé) áëîê áèòìàïà ïî îñè X Y
/// <summary>
/// Google bitmap block count for (X, Y)
/// </summary>
public Rectangle BlockView
{
get
Expand Down

0 comments on commit 342114f

Please sign in to comment.