Esempio n. 1
0
        public bool Intersects(double lat, double lon)
        {
            var coord = new NetTopologySuite.Geometries.Coordinate(lat, lon);
            var point = GeometryFactory.Default.CreatePoint(coord);

            return(Feature.Geometry.Contains(point));/* ||
                                                      * point.Touches(Feature.Geometry) ||
                                                      * point.Within(Feature.Geometry) ||
                                                      * point.CoveredBy(Feature.Geometry);*/
        }
Esempio n. 2
0
        ToNtsCoordinate(this CoreSpatial.BasicGeometrys.Coordinate coordinate)
        {
            var coord = new Coordinate(coordinate.X, coordinate.Y);

            if (!double.IsNaN(coordinate.Z))
            {
                coord.Z = coordinate.Z;
            }

            return(coord);
        }
Esempio n. 3
0
 TcsGeometry(this Coordinate coordinate)
 {
     if (double.IsNaN(coordinate.Z))
     {
         var gp = new GeoPoint(coordinate.X, coordinate.Y);
         return(gp);
     }
     else
     {
         var gp = new GeoPoint(coordinate.X, coordinate.Y, coordinate.Z);
         return(gp);
     }
 }
Esempio n. 4
0
        /// <summary>
        ///     Converts a Microsoft.Spatial GeographyPoint to an NTS Point.
        /// </summary>
        /// <param name="geographyPoint">The Microsoft.Spatial GeographyPoint.</param>
        /// <returns></returns>
        public static Point ToNtsPoint(this GeographyPoint geographyPoint)
        {
            if (geographyPoint == null)
            {
                return(null);
            }

            var lat   = geographyPoint.Latitude;
            var lon   = geographyPoint.Longitude;
            var coord = new Coordinate(lon, lat);

            return((Point)GeographyFactory.CreatePoint(coord));
        }
Esempio n. 5
0
        } // End Function toCounterClockWise

        public static NetTopologySuite.Geometries.Coordinate[] ToNetTopologyCoordinates(System.Collections.Generic.IEnumerable <OSM.API.v0_6.GeoPoint> coords) //, int z)
        {
            NetTopologySuite.Geometries.Coordinate[] coordinates = new NetTopologySuite.Geometries.Coordinate[coords.Count()];

            int i = 0;

            foreach (OSM.API.v0_6.GeoPoint thisCoordinate in coords)
            {
                coordinates[i] = new NetTopologySuite.Geometries.Coordinate((double)thisCoordinate.Latitude, (double)thisCoordinate.Longitude);
                ++i;
            }

            return(coordinates);
        } // End Function ToNetTopologyCoordinates
Esempio n. 6
0
        private void MapImage_MouseMove(object sender, MouseEventArgs e)
        {
            if (_map != null)
            {
                Point p = _map.ImageToWorld(new System.Drawing.Point(e.X, e.Y), true);

                if (MouseMove != null)
                {
                    MouseMove(p, e);
                }

                if (Image != null && e.Location != _mousedrag && !_mousedragging && (e.Button == MouseButtons.Left || e.Button == MouseButtons.Middle))
                {
                    _mousedragImg  = Image.Clone() as Image;
                    _mousedragging = true;
                    _dragImg1      = new Bitmap(Size.Width, Size.Height);
                    _dragImg2      = new Bitmap(Size.Width, Size.Height);
                }

                if (_mousedragging)
                {
                    if (MouseDrag != null)
                    {
                        MouseDrag(p, e);
                    }

                    if (ActiveTool == Tools.Pan || ActiveTool == Tools.PanOrQuery)
                    {
                        Graphics g = Graphics.FromImage(_dragImg1);
                        g.Clear(Color.Transparent);
                        g.DrawImageUnscaled(_mousedragImg,
                                            new System.Drawing.Point(e.Location.X - _mousedrag.X,
                                                                     e.Location.Y - _mousedrag.Y));
                        g.Dispose();
                        _dragImgSupp     = _dragImg2;
                        _dragImg2        = _dragImg1;
                        _dragImg1        = _dragImgSupp;
                        Image            = _dragImg2;
                        _panOrQueryIsPan = true;
                        base.Refresh();
                    }
                    else if (ActiveTool == Tools.ZoomIn || ActiveTool == Tools.ZoomOut)
                    {
                        Image    img = new Bitmap(Size.Width, Size.Height);
                        Graphics g   = Graphics.FromImage(img);
                        g.Clear(Color.Transparent);
                        float scale;
                        if (e.Y - _mousedrag.Y < 0) //Zoom out
                        {
                            scale = (float)Math.Pow(1 / (float)(_mousedrag.Y - e.Y), 0.5);
                        }
                        else //Zoom in
                        {
                            scale = 1 + (e.Y - _mousedrag.Y) * 0.1f;
                        }
                        RectangleF rect = new RectangleF(0, 0, Width, Height);
                        if (_map.Zoom / scale < _map.MinimumZoom)
                        {
                            scale = (float)Math.Round(_map.Zoom / _map.MinimumZoom, 4);
                        }
                        rect.Width  *= scale;
                        rect.Height *= scale;
                        rect.Offset(Width / 2f - rect.Width / 2f, Height / 2f - rect.Height / 2);
                        g.DrawImage(_mousedragImg, rect);
                        g.Dispose();
                        Image = img;
                        if (MapZooming != null)
                        {
                            MapZooming(scale);
                        }
                    }
                }
            }
        }