Beispiel #1
0
        public override void statusTrimble()
        {
            base.statusTrimble();
            txtGPSStatus.Text = gpsTrimbleStatus;

            if (pos != null)
            {
                txtLat.Text = "Lat: " + Convert.ToString(pos.Latitude);
                txtLon.Text = "Lon: " + Convert.ToString(pos.Longitude);
                Poste.Lat = Convert.ToString(pos.Latitude);
                Poste.Lon = Convert.ToString(pos.Longitude);

                GpsToolsNET.Position p = new GpsToolsNET.Position();
                p.Latitude = pos.Latitude;
                p.Longitude = pos.Longitude;
                map1.Position = p;

                marcarPonto();

                //map1.Update();

                if (firstPos != null)
                {
                    firstPos.Latitude = pos.Latitude;
                    firstPos.Longitude = pos.Longitude;
                }
            }
        }
Beispiel #2
0
        private void Croqui_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'eletrocadDataSet.poste' table. You can move, or remove it, as needed.
            this.posteTableAdapter.Fill(this.eletrocadDataSet.poste);

            GpsToolsNET.Position p1 = new GpsToolsNET.Position();
            GpsToolsNET.Position p2 = new GpsToolsNET.Position();
            //GpsViewNET.Point point1 = new GpsViewNET.Point();
            //GpsViewNET.Point point2 = new GpsViewNET.Point();

            p1.Latitude  = GPS.lat;
            p1.Longitude = GPS.lon;
            p2.Latitude  = GPS.lat;
            p2.Longitude = GPS.lon;

            p1.Move(500, 45, GpsToolsNET.DistanceMethod.GREAT_CIRCLE_DISTANCE);
            p2.Move(500, 225, GpsToolsNET.DistanceMethod.GREAT_CIRCLE_DISTANCE);

            create_blank_map(p1, p2);

            nodeDatumGrid.Datum = GpsToolsNET.Datum.WGS_84;

            objShapeTrack  = new GpsShapeNET.Shape();
            objShapePostes = new GpsShapeNET.Shape();
            objShapeTrack.DatumGridTemplate  = nodeDatumGrid;
            objShapePostes.DatumGridTemplate = nodeDatumGrid;

            mapShapeTrack = map1.NewMapShape(objShapeTrack);
            mapShapePoste = map1.NewMapShape(objShapePostes);

            //track
            objTrack                   = map1.NewRectangle();
            objTrack.Brush.Blue        = 200;
            objTrack.Brush.Transparent = false;
            objTrack.Width             = 4;
            objTrack.Height            = 4;
            mapShapeTrack.NodeTemplate = objTrack;

            //poste
            objPoste                   = map1.NewEllipse();
            objPoste.Brush.Red         = 200;
            objPoste.Brush.Transparent = false;
            objPoste.Width             = 12;
            objPoste.Height            = 12;
            mapShapePoste.NodeTemplate = objPoste;

            marcarPostes();

            map1.Update();


            timer1.Enabled = true;

            Cursor.Current = Cursors.Default;
            Application.DoEvents();
        }
Beispiel #3
0
 private void zoomUpDown_ValueChanged(object sender, EventArgs e)
 {
     map1.Zoom = Convert.ToDouble(zoomUpDown.Value);
     GpsToolsNET.Position p = new GpsToolsNET.Position();
     p.Datum       = GpsToolsNET.Datum.WGS_84;
     p.Latitude    = GPS.lat;
     p.Longitude   = GPS.lon;
     map1.Position = p;
     map1.Update();
 }
Beispiel #4
0
        private void marcarOndeEstou(double lat, double lon)
        {
            GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
            objPosition.Latitude  = lat;
            objPosition.Longitude = lon;

            objTrack.Position = objPosition;

            objShapeTrack.DatumGridTemplate = objPosition;
            //objShapeTrack.DatumGridTemplate = pos1;
            //objShapeTrack.NewPart(partIndex);
            objShapeTrack.ClearShape();
            objShapeTrack.NewNode(nodeIndex);
            objShapeTrack.SetNode(objPosition);

            if (!chkNavegacao.Checked)
            {
                map1.Position = objPosition;
            }
            map1.Update();
        }
Beispiel #5
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 #6
0
        private void marcarPostes()
        {
            foreach (db.eletrocadDataSet.posteRow row in eletrocadDataSet.poste.Rows)
            {
                GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
                objPosition.Datum     = GpsToolsNET.Datum.WGS_84;
                objPosition.Latitude  = row.lat;
                objPosition.Longitude = row.lon;

                //map1.Position = objPosition;

                objPoste.Position = objPosition;

                GpsViewNET.Label label = make_label(row.sequencia.ToString());
                label.Position = objPosition;

                objShapePostes.DatumGridTemplate = nodeDatumGrid;
                objShapePostes.NewPart(partIndex);
                objShapePostes.NewNode(nodeIndex);
                objShapePostes.SetNode(objPosition);
            }

            map1.Update();
        }
Beispiel #7
0
        private void button4_Click(object sender, EventArgs e)
        {
            DataRowView row =
                (DataRowView)clienteBindingSource.Current;

            GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
            base.errorCode = ssfWriter.EndFeature("cliente:" + row["id"].ToString());
            MessageBox.Show("SSF " + "cliente:" + row["id"].ToString() + " coletado");
        }
Beispiel #8
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 #9
0
        private void marcarTransformador()
        {
            if (pos != null)
            {
                GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
                objPosition.Latitude = pos.Latitude;
                objPosition.Longitude = pos.Longitude;

                objTrackTransformadores.Position = objPosition;

                //objLabel.Position = objPosition;
                //objLabel.Text = "ID: " + i;
                //objShapeTransformadores.NewPart(-1);
                objShapeTransformadores.NewNode(-1);
                objShapeTransformadores.SetNode(objPosition);

                //objShapeLabels.NewNode(-1);
                //objShapeLabels.Position = objPosition;

                map1.Position = objPosition;
                map1.Update();
            }
        }
Beispiel #10
0
        private void button3_Click(object sender, EventArgs e)
        {
            DataRowView row =
                (DataRowView)clienteBindingSource.Current;

            GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
            objPosition.Latitude = Convert.ToDouble(row["lat"]);
            objPosition.Longitude = Convert.ToDouble(row["lon"]);

            map1.Position = objPosition;
            map1.Update();
            tabControl1.SelectedIndex = 0;
        }
Beispiel #11
0
        private void marcarPoste(double lat, double lon, int sequencia)
        {
            GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
            objPosition.Latitude = lat;
            objPosition.Longitude = lon;

            objTrackPoste.Position = objPosition;

            objShapePoste.DatumGridTemplate = nodeDatumGrid;
            //objShapePoste.NewPart(nodeIndex);
            objShapePoste.NewNode(nodeIndex);
            objShapePoste.SetNode(objPosition);

            //objLabel.Position = objPosition;
            //objLabel.Text = ""+sequencia;

            //objShapePosteLabels.NewNode(nodeIndex);
            //objShapePosteLabels.SetNode(objPosition);

            map1.Position = objPosition;
            map1.Update();
        }
Beispiel #12
0
        private void marcarResidencia(double lat, double lon, string nome)
        {
            try
            {
                GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
                objPosition.Latitude = lat;
                objPosition.Longitude = lon;

                objTrackResidencia.Position = objPosition;

                //objLabel.Position = objPosition;
                //objLabel.Text = nome;

                objShapeResidencia.DatumGridTemplate = nodeDatumGrid;
                //objShapeResidencia.NewPart(nodeIndex);
                objShapeResidencia.NewNode(nodeIndex);
                objShapeResidencia.SetNode(objPosition);

                GpsViewNET.Label label = make_label(nome);
                label.Position = objPosition;

                //objShapeLabels.NewPart(partIndex);
                //objShapeLabels.NewNode(nodeIndex);
                //objShapeLabels.Position = objPosition;

                //GpsViewNET.Label label = make_label(nome);
                //label.Position = objPosition;

                map1.Position = objPosition;
                map1.Update();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Não foi possível plotar as residências: "+ex.Message);
            }
        }
Beispiel #13
0
        private void marcarPontoSig(double lat, double lon, string nome)
        {
            GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
            objPosition.Latitude = lat;
            objPosition.Longitude = lon;

            objTrackPontoSig.Position = objPosition;

            objShapePontoSig.DatumGridTemplate = nodeDatumGrid;
            //objShapePontoSig.NewPart(nodeIndex);
            objShapePontoSig.NewNode(nodeIndex);
            objShapePontoSig.SetNode(objPosition);

            GpsViewNET.Label label = make_label(nome);
            label.Position = objPosition;

            map1.Position = objPosition;
            map1.Update();
        }
Beispiel #14
0
        private void GeoRedeProject_Load(object sender, EventArgs e)
        {
            //datum
            GpsToolsNET.Position nodeDatumGrid = new GpsToolsNET.Position();
            nodeDatumGrid.Datum = GpsToolsNET.Datum.WGS_84;

            //carrega shapeCasas
            shapeCasas = new GpsShapeNET.Shape();
            shapeCasas.DatumGridTemplate = nodeDatumGrid;
            //mapShapeCasas = map1.NewMapShape(shapeCasas);
            double Xmin, Xmax, Ymin, Ymax, Zmin, Zmax, Mmin, Mmax = 0;
            shapeCasas.GetBoundingBox(out Xmin, out Xmax, out Ymin, out Ymax, out Zmin, out Zmax, out Mmin, out Mmax);

            Xmin_ = Xmin;
            Xmax_ = Xmax;
            Ymin_ = Ymin;
            Ymax_ = Ymax;

            create_blank_map(Xmin, Xmax, Ymin, Ymax, false);

            string layerName = String.Format("main", layerID);
            map1.ActiveLayer(layerName);

            Cursor.Current = Cursors.Default;
            Application.DoEvents();
        }
Beispiel #15
0
        private void display_shape_file()
        {
            int totalShapeCount = 0;
            int totalNodeCount = 0;
            GpsViewNET.Ellipse objEllipse = null;
            GpsViewNET.Rectangle objRectangle = null;
            GpsViewNET.Brush objBrush = null;
            //GpsViewNET.Label objLabel = null;

            try
            {
                shapeFile = new GpsShapeNET.ShapeFile();

                // Open the shapefile

                shapeFile.Open(shapefilepath, GpsShapeNET.FileMode.FILE_READ);

                double Xmin, Xmax, Ymin, Ymax, Zmin, Zmax, Mmin, Mmax = 0;

                // Read bounding values specified for whole shapefile and create a blank map
                // scaled with these bounding values.
                shapeFile.GetBoundingBox(out Xmin, out Xmax, out Ymin, out Ymax, out Zmin, out Zmax, out Mmin, out Mmax);

                Xmin_ = Xmin;
                Xmax_ = Xmax;
                Ymin_ = Ymin;
                Ymax_ = Ymax;

                bool bIsDatum = false;
                if (Ymax <= 90 && Ymin >= -90 && Xmax <= 180 && Xmin >= -180)
                {
                    bIsDatum = true;
                }

                create_blank_map(Xmin, Xmax, Ymin, Ymax, bIsDatum);

                // Create a new layer for this shapefile.
                // We like draw all shapes from a certain shapefile on a seperate layer.
                string layerName = String.Format("main", layerID);
                map1.ActiveLayer(layerName);

                layerID++;

                // We create an ellipse object and using it to draw all nodes.
                int width = Convert.ToInt32(map1.Zoom);
                int height = Convert.ToInt32(map1.Zoom);

                // We create a brush object and using it for drawing polygon shapes.
                objBrush = make_brush();

                // Get shape type.
                // All shape types supported by ESRI are defined in enum GpsShapeNET.ShapeFileType.
                GpsShapeNET.ShapeFileType shapeFileType = shapeFile.ShapeFileType;

                // Define a position object to calculate nodes position
                // according to it.
                // NOTE! Shapes may use different coordinate system than mapshape's.
                GpsToolsNET.Position nodePosition = new GpsToolsNET.Position();
                if (bIsDatum)
                {
                    nodePosition.Datum = GpsToolsNET.Datum.WGS_84;
                }
                else
                {
                    nodePosition.Grid = GpsToolsNET.Grid.UTM_NORTH;
                    nodePosition.Zone = "15";
                }

                // Start to read all shapes from shapefile.
                // NOTE: Even Seek() can be used to access a certain shape.
                int shapeId = 0;
                while ((shape = shapeFile.Read()) != null)
                {
                    shape.ShapeID = shapeId++;
                    objEllipse = make_ellipse();
                    // Calculate number of shapes and total number of nodes.
                    int nodeCount = shape.TotalNodeCount;
                    if (nodeCount == 0)
                    {
                        // Nothing to draw. Get next shape.
                        continue;
                    }

                    totalNodeCount += nodeCount;
                    totalShapeCount++;

                    shape.DatumGridTemplate = nodePosition;

                    shape.GetBoundingBox(out Xmin, out Xmax, out Ymin, out Ymax, out Zmin, out Zmax, out Mmin, out Mmax);

                    // Create a mapshape to handle drawing for this shape.
                    mapShape = map1.NewMapShape(shape);
                    //mapShapeLabels = map1.NewMapShape(shape);
                    //mapShape.ID = 666;

                    switch (shapeFileType)
                    {
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POINT:
                            mapShape.NodeTemplate = objEllipse;
                            //mapShapeLabels.NodeTemplate = make_label(shape.ShapeID.ToString());
                            //mapShape.NodeTemplate = objRectangle;
                            break;
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POINT_Z:
                            mapShape.NodeTemplate = objEllipse;
                            break;
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POINT_M:
                            mapShape.NodeTemplate = objEllipse;
                            break;

                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_MULTIPOINT:
                            mapShape.NodeTemplate = objEllipse;
                            mapShape.Border.Width = 0;
                            mapShape.Background.Transparent = true;
                            break;
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_MULTIPOINT_Z:
                            mapShape.NodeTemplate = objEllipse;
                            mapShape.Border.Width = 0;
                            mapShape.Background.Transparent = true;
                            break;
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_MULTIPOINT_M:
                            // Set an ellipse as a nodetemplate.
                            // All nodes in the shape will drawn/marked with this object.
                            mapShape.NodeTemplate = objEllipse;
                            mapShape.Border.Width = 0;
                            mapShape.Background.Transparent = true;
                            break;

                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POLYLINE:
                            mapShape.Border.Width = 1;
                            break;
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POLYLINE_Z:
                            mapShape.Border.Width = 1;
                            break;
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POLYLINE_M:
                            // Set pen width to 1 to draw lines with. Default value is 0.
                            mapShape.Border.Width = 1;
                            break;

                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POLYGON:
                            mapShape.Background = objBrush;
                            break;
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POLYGON_Z:
                            mapShape.Background = objBrush;
                            break;
                        case GpsShapeNET.ShapeFileType.SHAPE_TYPE_POLYGON_M:
                            mapShape.Background = objBrush;

                            // NOTE! Background object could also be defined by directly
                            // setting it's properties. Following example defines a blue brush object
                            // for drawing polygons.
                            // mapShape.Background.Transparent = false;
                            // mapShape.Background.Blue  = 255;
                            break;
                    }
                }

                bFileLoaded = true;

                //lbTotalNodeNumber.Text = totalNodeCount.ToString();
                //lbNumberOfShapes.Text = totalShapeCount.ToString();
                //shapeFile.Close();

                // View all shapes on the map.
                map1.Update();
            }
            catch (Exception exp)
            {
                shapeFile.Close();
                bFileLoaded = false;
                MessageBox.Show(exp.Message);
                return;
            }
        }
Beispiel #16
0
        private void marcarPonto()
        {
            if (pos != null)
            {
                GpsToolsNET.Position position = new GpsToolsNET.Position();
                position.Latitude = pos.Latitude;
                position.Longitude = pos.Longitude;
                //if (!chkNavegacao.Checked)
                //{
                //    map1.Position = position;
                //}
                objEllipseMark.Position = position;
                map1.Update();

            }
        }
Beispiel #17
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;
                }
            }
        }
Beispiel #18
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 #19
0
        private void marcarOndeEstou(double lat, double lon)
        {
            GpsToolsNET.Position objPosition = new GpsToolsNET.Position();
            objPosition.Latitude = lat;
            objPosition.Longitude = lon;

            objTrack.Position = objPosition;

            objShapeTrack.DatumGridTemplate = nodeDatumGrid;
            //objShapeTrack.NewPart(partIndex);
            objShapeTrack.NewNode(nodeIndex);
            objShapeTrack.SetNode(objPosition);

            if (!chkNavegacao.Checked)
            {
                map1.Position = objPosition;
            }
            map1.Update();
        }