Exemplo n.º 1
0
        public bool AddVertex(IDisplay display, gView.Framework.Geometry.IPoint point)
        {
            double distance;
            IPoint snapped = gView.Framework.SpatialAlgorithms.Algorithm.NearestPointToPath(
                _geometry, point, out distance, true);

            return(snapped != null);
        }
Exemplo n.º 2
0
        public HitPositions HitTest(IDisplay display, gView.Framework.Geometry.IPoint point)
        {
            if (_geometry == null)
            {
                return(null);
            }

            IPointCollection pColl = gView.Framework.SpatialAlgorithms.Algorithm.GeometryPoints(_geometry, true);

            if (pColl == null || pColl.PointCount == 0)
            {
                return(null);
            }

            double tol = 5.0 * display.mapScale / (display.dpi / 0.0254);  // [m]

            if (display.SpatialReference != null &&
                display.SpatialReference.SpatialParameters.IsGeographic)
            {
                tol = 180.0 * tol / Math.PI / 6370000.0;
            }

            for (int i = 0; i < pColl.PointCount; i++)
            {
                IPoint p = pColl[i];
                if (p == null)
                {
                    continue;
                }

                if (gView.Framework.SpatialAlgorithms.Algorithm.PointDistance(p, point) < tol)
                {
                    return(new HitPosition(HitPosition.VertexCursor, i));
                }
            }

            List <IPath> paths = gView.Framework.SpatialAlgorithms.Algorithm.GeometryPaths(_geometry);

            if (paths == null || paths.Count == 0)
            {
                return(null);
            }

            Polyline pLine = new Polyline(paths);

            if (gView.Framework.SpatialAlgorithms.Algorithm.IntersectBox(pLine, new Envelope(
                                                                             point.X - tol / 2, point.Y - tol / 2,
                                                                             point.X + tol / 2, point.Y + tol / 2)))
            {
                return(new HitPosition(System.Windows.Forms.Cursors.Default, -1));
            }
            return(null);
        }
Exemplo n.º 3
0
 private string PointToString(gView.Framework.Geometry.IPoint p, ISpatialReference sRef)
 {
     if (sRef != null &&
         (sRef.Gml3AxisX == AxisDirection.North || sRef.Gml3AxisX == AxisDirection.South) &&
         (sRef.Gml3AxisY == AxisDirection.West || sRef.Gml3AxisY == AxisDirection.East))
     {
         return(p.Y.ToString(_nhi) + " " + p.X.ToString(_nhi));
     }
     else
     {
         return(p.X.ToString(_nhi) + " " + p.Y.ToString(_nhi));
     }
 }
Exemplo n.º 4
0
 public bool TrySelect(IDisplay display, gView.Framework.Geometry.IPoint point)
 {
     return(false);
 }
Exemplo n.º 5
0
        public ICursor PointQuery(gView.Framework.Carto.IDisplay display, gView.Framework.Geometry.IPoint point, ISpatialReference sRef, IUserData userdata)
        {
            if (display == null || point == null)
            {
                return(null);
            }

            IEnvelope dispEnvelope = display.Envelope;

            if (sRef != null)
            {
                ISpatialReference mySRef = SpatialReference.FromID(_srs.Srs[_srs.SRSIndex]);
                if (mySRef != null && !mySRef.Equals(sRef))
                {
                    // TODO:
                    // Stimmt net ganz, eigentlich wird beim Projezieren aus dem
                    // Envelope ein Polygon, auch der Punkt, der als X-Pixel, Y-Pixel
                    // übergeben wird, sollte sich ändern...
                    // --> World2Image stimmt nicht 100%
                    //
                    dispEnvelope = GeometricTransformer.Transform2D(dispEnvelope, sRef, mySRef).Envelope;
                }
            }
            double x = point.X, y = point.Y;

            display.World2Image(ref x, ref y);

            StringBuilder request = new StringBuilder("VERSION=1.1.1&REQUEST=GetFeatureInfo");

            request.Append("&QUERY_LAYERS=" + this.Name);
            request.Append("&QUERYLAYERS=" + this.Name);
            request.Append("&LAYERS=" + this.Name);
            //request.Append("&LAYERS=" + this.Name);
            request.Append("&EXCEPTIONS=" + _exceptions.Formats[0]);
            request.Append("&SRS=" + _srs.Srs[_srs.SRSIndex]);
            request.Append("&WIDTH=" + display.iWidth);
            request.Append("&HEIGHT=" + display.iHeight);
            request.Append("&INFOFORMAT=" + _getFeatureInfo.Formats[_getFeatureInfo.FormatIndex]);
            request.Append("&INFO_FORMAT=" + _getFeatureInfo.Formats[_getFeatureInfo.FormatIndex]);
            request.Append("&BBOX=" + dispEnvelope.minx.ToString(_nhi) + "," +
                           dispEnvelope.miny.ToString(_nhi) + "," +
                           dispEnvelope.maxx.ToString(_nhi) + "," +
                           dispEnvelope.maxy.ToString(_nhi));
            request.Append("&X=" + (int)x);
            request.Append("&Y=" + (int)y);

            string response;

            if (_getFeatureInfo.Formats[_getFeatureInfo.FormatIndex].ToLower().StartsWith("xsl/"))
            {
                return(new UrlCursor(WMSDataset.Append2Url(_getFeatureInfo.Get_OnlineResource, request.ToString())));
            }
            else
            {
                switch (_getFeatureInfo.Formats[_getFeatureInfo.FormatIndex].ToLower())
                {
                case "text/plain":
                    response = WebFunctions.HttpSendRequest(WMSDataset.Append2Url(_getFeatureInfo.Get_OnlineResource, request.ToString()));
                    return(new TextCursor(response));

                case "text/html":
                    return(new UrlCursor(WMSDataset.Append2Url(_getFeatureInfo.Get_OnlineResource, request.ToString())));

                case "text/xml":
                    response = WebFunctions.HttpSendRequest(WMSDataset.Append2Url(_getFeatureInfo.Get_OnlineResource, request.ToString()));
                    return(new RowCursor(Xml2Rows(response)));

                case "application/vnd.ogc.gml":
                    response = WebFunctions.HttpSendRequest(WMSDataset.Append2Url(_getFeatureInfo.Get_OnlineResource, request.ToString()));
                    return(new RowCursor(Gml2Rows(response)));
                }
            }
            return(null);
        }