Beispiel #1
0
        //private GpsToolsNET.Position pos1 = new GpsToolsNET.Position();

        private void create_blank_map(GpsToolsNET.Position p1, GpsToolsNET.Position p2)
        {
            // Create a blank map named "blank"
            GpsViewNET.Point     point1, point2, point3;
            GpsToolsNET.Position position1, position2, position3;

            position1 = p1;
            position2 = p2;

            this.map_pos = new GpsToolsNET.Position();

            position1.Datum = GpsToolsNET.Datum.WGS_84;
            position2.Datum = GpsToolsNET.Datum.WGS_84;

            map_pos.Datum     = GpsToolsNET.Datum.WGS_84;
            map_pos.Longitude = p1.Longitude + (p2.Longitude - p1.Longitude) / 2;
            map_pos.Latitude  = p2.Latitude + (p1.Latitude - p2.Latitude) / 2;

            int width  = map1.Width;
            int height = map1.Height;

            point1   = new GpsViewNET.Point();
            point1.X = 0;
            point1.Y = 0;

            point2   = new GpsViewNET.Point();
            point2.X = width;
            point2.Y = height;

            // Creates and activates map, MapLib.NewMapData can also be used
            GpsViewNET.MapData objMapData = map1.ActiveMapData("blank");


            // Scales blank Map
            objMapData.SetScale(position1, point1, position2, point2, null, null);

            // Center map in middle of shape
            map1.Position = map_pos;
        }
Beispiel #2
0
        private void map1_OnMouseDown(MouseButtons Button, short Shift, 
            GpsToolsNET.Position objPosition, GpsViewNET.Point objPoint)
        {
            GpsViewNET.Pen objPen;
            GpsViewNET.Brush objBrush;

            if (objPosition == null)
            {
                lInfo.Text = "Invalid position.";
                return;
            }

            //lInfo.Text = objPosition.LongitudeString(0) + ", " + objPosition.LatitudeString(0);

            //cadastro
            if (ddAction.SelectedIndex == 3)
            {
                if (firstPos == null)
                {
                    firstPos = objPosition;
                    lInfo.Text = "Click para marcar o próximo ponto";
                }
                else
                {
                    shapeFile.SelectByBoundingBoxAndResolution(firstPos.Longitude,
                        objPosition.Longitude, firstPos.Latitude, objPosition.Latitude, -1);

                    GpsShapeNET.Shape shapeTmp;
                    GpsShapeNET.Shape shapeUsual = null;

                    int quantShape = 0;
                    while ((shapeTmp = shapeFile.Read()) != null)
                    {
                        quantShape++;
                        if (quantShape > 1)
                        {
                            break;
                        }
                        shapeUsual = shapeTmp;
                        //lInfo.Text = "Shape ID: " + shapeTmp.ShapeID;
                    }

                    if (quantShape > 1)
                    {
                        MessageBox.Show("Selecione apenas um ponto no mapa");
                        firstPos = null;
                        lInfo.Text = "";
                    } else if (quantShape == 1)
                    {
                        try
                        {
                            GpsShapeNET.DataRecord rec = shapeFile.GetAttribute(shapeUsual.ShapeID);
                            GpsShapeNET.DataField f = rec.GetFieldByIndex(2);
                            string coluna = rec.GetColumnNameByIndex(2);
                            //lInfo.Text = coluna + ": " + f.NumberField;
                            int id = Convert.ToInt32(f.NumberField);
                            //MessageBox.Show("" + id);
                            ModeloEnergisa me = new ModeloEnergisa(id);
                            me.ShowDialog();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Não foi possível abrir as informações do ponto selecionado: " + ex.Message);
                        }
                    }

                    firstPos = null;
                    lInfo.Text = "";
                }
                //GpsShapeNET.DataField f = rec.GetFieldByIndex(2);
                ////string coluna = rec.GetColumnNameByIndex(2);
                //try
                //{
                //    int id = Convert.ToInt32(f.NumberField);
                //    MessageBox.Show("" + id);
                //    ModeloEnergisa me = new ModeloEnergisa(id);
                //    me.ShowDialog();
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show("Não foi possível abrir as informações do ponto selecionado: " + ex.Message);
                //}
            }

            // Center on mouse click

            if (ddAction.SelectedIndex == 0)
            {
                //GpsViewNET.Ellipse objEllipse;
                //// Find ellipse on map (that marks clicked position)
                //objEllipse = (GpsViewNET.Ellipse)map1.GetByID(2);

                //if (objEllipse == null)
                //{
                //    // Use ellipse to mark clicked position
                //    objEllipse = map1.NewEllipse();
                //    objEllipse.Width = 4;
                //    objEllipse.Height = 4;

                //    objPen = new GpsViewNET.Pen();
                //    objPen.Red = 255;
                //    objPen.Width = 4;

                //    objEllipse.Pen = objPen;

                //    objEllipse.ID = 2;	// Set to known ID so we can find it with GetByID()
                //}
                map_pos = objPosition;
                map1.Position = map_pos;
                //objEllipse.Position = objPosition;

                map1.Update();

                firstPos = null;
            }

            if (ddAction.SelectedIndex == 1)
            {
                //GpsViewNET.Ellipse objEllipse;
                //// Find ellipse on map (that marks clicked position)
                //objEllipse = (GpsViewNET.Ellipse)map1.GetByID(666);
                //// Use ellipse to mark clicked position
                //objEllipse = map1.NewEllipse();
                //objEllipse = make_ellipseMark();
                //objEllipse.ID = 666;	// Set to known ID so we can find it with GetByID()

                if (pos != null)
                {
                    GpsToolsNET.Position position = new GpsToolsNET.Position();
                    position.Latitude = pos.Latitude;
                    position.Longitude = pos.Longitude;
                    map1.Position = position;
                    //objEllipse.Position = position;
                }

                firstPos = null;

                map1.Update();
            }

            // Draw line

            //if (ddAction.SelectedIndex == 2)
            //{
            //    if (firstPos == null)
            //    {
            //        firstPos = objPosition;
            //        lInfo.Text = "Click to set endpoint for line";
            //    }
            //    else
            //    {
            //        GpsViewNET.Line objLine = map1.NewLine();

            //        objLine.Position1 = firstPos;
            //        objLine.Position2 = objPosition;

            //        // Pen
            //        objPen = new GpsViewNET.Pen();
            //        objPen.Width = 4;
            //        objLine.Pen = objPen;

            //        map1.Update();

            //        firstPos = null;
            //    }
            //}

            // Draw Ellipse

            //if (ddAction.SelectedIndex == 3)
            //{
            //    GpsViewNET.Ellipse objEllipse = map1.NewEllipse();

            //    objEllipse.Position = objPosition;
            //    objEllipse.Width = 20;
            //    objEllipse.Height = 20;

            //    objBrush = new GpsViewNET.Brush();

            //    objBrush.Blue = 255;
            //    objBrush.Transparent = false;
            //    objEllipse.Brush = objBrush;

            //    map1.Update();
            //    firstPos = null;
            //}

            // Draw Icon

            if (ddAction.SelectedIndex == 4)
            {
                findMoreLatLon();

                GpsToolsNET.Position upperLeft = new GpsToolsNET.Position();
                upperLeft.Latitude = moreNorthLat;
                upperLeft.Longitude = moreWestLon;

                GpsToolsNET.Position lowerRight = new GpsToolsNET.Position();
                lowerRight.Latitude = moreSouthLat;
                lowerRight.Longitude = moreEastLon;

                map1.ZoomByBoundingBox(upperLeft, lowerRight);
            }

            if (ddAction.SelectedIndex == 2)
            {
                if (firstPoint == null)
                {
                    firstPoint = map1.Position2Point(objPosition);
                    lInfo.Text = "Clique no próximo canto";
                }
                else
                {
                    map1.ZoomByBoundingBox(firstPoint, map1.Position2Point(objPosition));
                    //GpsViewNET.Rectangle objRect = map1.NewRectangle();

                    //objPen = new GpsViewNET.Pen();
                    //objPen.Width = 3;
                    //objRect.Pen = objPen;

                    //objRect.Position1 = firstPos;
                    //objRect.Position2 = objPosition;

                    map1.Update();
                    firstPoint = null;
                }
            }
        }
Beispiel #3
0
        private void create_blank_map(double Xmin, double Xmax, double Ymin, double Ymax, bool bIsDatum)
        {
            // Create a blank map named "blank"
            GpsViewNET.Point point1, point2, point3;
            GpsToolsNET.Position position1, position2, position3;

            position1 = new GpsToolsNET.Position();
            position2 = new GpsToolsNET.Position();
            position3 = new GpsToolsNET.Position();

            this.map_pos = new GpsToolsNET.Position();

            if (bIsDatum)
            {
                // Datum
                position1.Datum = GpsToolsNET.Datum.WGS_84;
                position1.Longitude = Xmin;
                position1.Latitude = Ymax;

                position2.Datum = GpsToolsNET.Datum.WGS_84;
                position2.Longitude = Xmax;
                position2.Latitude = Ymax;

                position3.Datum = GpsToolsNET.Datum.WGS_84;
                position3.Longitude = Xmax;
                position3.Latitude = Ymin;

                map_pos.Datum = GpsToolsNET.Datum.WGS_84;
                map_pos.Longitude = Xmin + (Xmax - Xmin) / 2;
                map_pos.Latitude = Ymin + (Ymax - Ymin) / 2;
            }
            else
            {
                // Grid
                position1.Grid = GpsToolsNET.Grid.UTM_NORTH;
                position1.Zone = "15";
                position1.Easting = Xmin;
                position1.Northing = Ymax;

                position2.Grid = GpsToolsNET.Grid.UTM_NORTH;
                position2.Zone = "15";
                position2.Easting = Xmax;
                position2.Northing = Ymax;

                position3.Grid = GpsToolsNET.Grid.UTM_NORTH;
                position3.Zone = "15";
                position3.Easting = Xmax;
                position3.Northing = Ymin;

                map_pos.Grid = GpsToolsNET.Grid.UTM_NORTH;
                map_pos.Zone = "15";
                map_pos.Easting = Xmin + (Xmax - Xmin) / 2;
                map_pos.Northing = Ymin + (Ymax - Ymin) / 2;
            }

            int width = map1.Width - 20;
            int height = map1.Height - 20;

            double Xdiff = (Xmax - Xmin) / (double)width;
            double Ydiff = (Ymax - Ymin) / (double)height;

            if (Xdiff > Ydiff)
            {
                height = (int)((Ydiff / Xdiff) * (double)height);
            }
            else
            {
                width = (int)((Xdiff / Ydiff) * (double)width);
            }

            point1 = new GpsViewNET.Point();
            point1.X = 0;
            point1.Y = 0;

            point2 = new GpsViewNET.Point();
            point2.X = width;
            point2.Y = 0;

            point3 = new GpsViewNET.Point();
            point3.X = width;
            point3.Y = height;

            // Creates and activates map, MapLib.NewMapData can also be used
            GpsViewNET.MapData objMapData = map1.ActiveMapData("blank");

            // Scales blank Map
            objMapData.SetScale(position1, point1, position2, point2, position3, point3);

            // Center map in middle of shape
            map1.Position = map_pos;
        }
Beispiel #4
0
        private void map1_OnMouseDown(MouseButtons Button, short Shift,
            GpsToolsNET.Position objPosition, GpsViewNET.Point objPoint)
        {
            GpsViewNET.Pen objPen;
            GpsViewNET.Brush objBrush;

            if (objPosition == null)
            {
                lInfo.Text = "Invalid position.";
                return;
            }

            //lInfo.Text = objPosition.LongitudeString(0) + ", " + objPosition.LatitudeString(0);

            //cadastro
            if (ddAction.SelectedIndex == 3)
            {
                if (firstPos == null)
                {
                    firstPos = objPosition;
                    lInfo.Text = "Click para marcar o próximo ponto";
                }
                else
                {
                    shapeFile.SelectByBoundingBoxAndResolution(firstPos.Longitude,
                        objPosition.Longitude, firstPos.Latitude, objPosition.Latitude, -1);

                    GpsShapeNET.Shape shapeTmp;
                    GpsShapeNET.Shape shapeUsual = null;

                    int quantShape = 0;
                    while ((shapeTmp = shapeFile.Read()) != null)
                    {
                        quantShape++;
                        if (quantShape > 1)
                        {
                            break;
                        }
                        shapeUsual = shapeTmp;
                        //lInfo.Text = "Shape ID: " + shapeTmp.ShapeID;
                    }

                    if (quantShape > 1)
                    {
                        MessageBox.Show("Selecione apenas um ponto no mapa");
                        firstPos = null;
                        lInfo.Text = "";
                    }
                    else if (quantShape == 1)
                    {
                        try
                        {
                            GpsShapeNET.DataRecord rec = shapeFile.GetAttribute(shapeUsual.ShapeID);
                            GpsShapeNET.DataField f = rec.GetFieldByIndex(2);
                            string coluna = rec.GetColumnNameByIndex(2);
                            //lInfo.Text = coluna + ": " + f.NumberField;
                            int id = Convert.ToInt32(f.NumberField);
                            //MessageBox.Show("" + id);
                            ModeloEnergisa me = new ModeloEnergisa(id);
                            me.ShowDialog();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Não foi possível abrir as informações do ponto selecionado: " + ex.Message);
                        }
                    }

                    firstPos = null;
                    lInfo.Text = "";
                }

            }

            // Center on mouse click
            if (ddAction.SelectedIndex == 0)
            {
                map_pos = objPosition;
                map1.Position = map_pos;
                //objEllipse.Position = objPosition;

                map1.Update();

                firstPos = null;
            }

            if (ddAction.SelectedIndex == 1)
            {
                if (pos != null)
                {
                    GpsToolsNET.Position position = new GpsToolsNET.Position();
                    position.Latitude = pos.Latitude;
                    position.Longitude = pos.Longitude;
                    map1.Position = position;
                    //objEllipse.Position = position;
                }

                firstPos = null;

                map1.Update();
            }

            if (ddAction.SelectedIndex == 2)
            {
                if (firstPoint == null)
                {
                    firstPoint = map1.Position2Point(objPosition);
                    lInfo.Text = "Clique no próximo canto";
                }
                else
                {
                    map1.ZoomByBoundingBox(firstPoint, map1.Position2Point(objPosition));
                    //GpsViewNET.Rectangle objRect = map1.NewRectangle();

                    //objPen = new GpsViewNET.Pen();
                    //objPen.Width = 3;
                    //objRect.Pen = objPen;

                    //objRect.Position1 = firstPos;
                    //objRect.Position2 = objPosition;

                    map1.Update();
                    firstPoint = null;
                }
            }
        }