Пример #1
0
 /// <summary>
 /// Creates an instance of this class
 /// </summary>
 internal MapViewPortGuard(Size size, double minZoom, double maxZoom)
 {
     Size = size;
     MinimumZoom = minZoom;
     MaximumZoom = maxZoom;
     PixelAspectRatio = 1d;
 }
Пример #2
0
            /// <summary>
            /// Returns an url for obtaining a map from WMS.
            /// </summary>
            /// <param name="locationRect">Extent of the map</param>
            /// <param name="actualSize">Size of the map in pixel</param>
            /// <param name="layers">List of layers to view</param>
            /// <param name="useCache">If set to true, use the current cache</param>
            /// <returns>Url to be called</returns>
            public virtual string GetMapRequest(Extent locationRect, Size actualSize, IEnumerable<string> layers, bool useCache = true)
            {
                StringBuilder b = InternalGetMapRequest(actualSize, layers, useCache);

                var extentMercatore = ProjectionConversion.ConvertToMercatore(locationRect);

                b.Append("&bbox=");

                b.Append(string.Format(CultureInfo.InvariantCulture, "{0}", extentMercatore.MinX));
                b.Append(",");
                b.Append(string.Format(CultureInfo.InvariantCulture, "{0}", extentMercatore.MinY));
                b.Append(",");
                b.Append(string.Format(CultureInfo.InvariantCulture, "{0}", extentMercatore.MaxX));
                b.Append(",");
                b.Append(string.Format(CultureInfo.InvariantCulture, "{0}", extentMercatore.MaxY));

                return b.ToString();
            }
Пример #3
0
            private StringBuilder InternalGetMapRequest(Size actualSize, IEnumerable<string> layers, bool useCache = true)
            {
                if (_serviceUrl == "")
                    throw new Exception("Missing property WMSUrl");

                var b = new StringBuilder();
                b.Append(_serviceUrl);
                b.Append(_serviceUrlContainsQuestionMark ? "&" : "?");
                b.Append("request=getmap");
                b.Append("&width=");
                b.Append(actualSize.Width.ToString());
                b.Append("&height=");
                b.Append(actualSize.Height.ToString());
                b.Append("&");

                if ((layers == null) || (layers.Count() == 0))
                {
                    b.Append("layers=");
                }
                else
                {
                    b.Append("layers=");
                    foreach (var layer in layers)
                    {
                        b.Append(layer);
                        b.Append(",");
                    }

                    b.Remove(b.Length - 1, 1);
                }

                b.Append("&SRS=EPSG:" + MERCATOR_EPSG);

                b.Append("&format=" + IMAGE_FORMAT);
                b.Append("&transparent=true");
                b.Append("&transparentcolor=0xFFFFFF");

                if (!useCache)
                    //passando i ticks, viene artificialmente modificata la url, quindi 
                    //la cache viene ignorata
                    b.Append("&" + DateTime.Now.Ticks.ToString());

                //NO, c'è un limite di 2047 nell'URL, e per tanti elementi selezionati (> circa 200-300), 
                //si raggiunge facilmente questo limite
                /*
                if ((gis.SelectedElements != null) && (gis.SelectedElements.Count > 0))
                {
                    b.Append("&selecteditems=");

                    for (int i = 0; i < gis.SelectedElements.Count; i++)
                    {
                        b.Append((gis.SelectedElements[i].Geometry as SMS.Core.Entities.Geometry).UID);
                        if (i < (gis.SelectedElements.Count - 1))
                            b.Append("+");
                    }
                }
                 */

                return b;
            }
Пример #4
0
            /// <summary>
            /// Initiates a getfeatureinfo request.
            /// </summary>
            /// <param name="x">Position x on the screen</param>
            /// <param name="y">Position y on the screen</param>
            /// <param name="queryLayer">Layer where to do the query</param>
            /// <param name="actualSize">Size on the screen</param>
            /// <param name="locationRect">extent</param>
            public void GetFeatureInfo(int x, int y, Size actualSize, Extent locationRect)
            {
                if (OnGetFeatureInfoCompleted == null)
                    throw new Exception("OnGetFeatureInfoCompleted cannot be null");

                BusyState = true;
                if (_webClient == null)
                {
                    _webClient = new WebClient();
                    _webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(GetFeatureInfoCompleted);
                }
                string requesturl = GetFeatureInfoRequest(x, y, actualSize, locationRect);
                _webClient.DownloadStringAsync(new Uri(requesturl, UriKind.RelativeOrAbsolute));
            }
Пример #5
0
            /// <summary>
            /// Returns the url for requesting e getfeatureinfo.
            /// </summary>
            private string GetFeatureInfoRequest(int x, int y, Size actualSize, Extent locationRect)
            {
                //ReQuEsT=GetFeatureInfo&WiDtH=100&X=50&Y=50&HeIgHt=100&QuErY_LaYeRs=streets&BbOx=-2,2,2,6&StYlEs=&InFo_fOrMaT=text/gml&SrS=EPSG:4326&LaYeRs=streets

                if (_serviceUrl == "")
                    throw new Exception("Missing property WMSUrl");

                if (!ForceWgs84ForFeatureInfo)
                    locationRect = ProjectionConversion.ConvertToMercatore(locationRect);

                var b = new StringBuilder();
                b.Append(_serviceUrl);
                b.Append(_serviceUrlContainsQuestionMark ? "&" : "?");
                b.Append("request=getfeatureinfo");

                b.Append("&SRS=EPSG:" + MERCATOR_EPSG);

                b.Append("&info_format=application/vnd.ogc.gml&styles=");

                b.Append("&query_layers=");
                b.Append(_queryLayers);

                b.Append("&layers=");
                b.Append(_layers);

                b.Append("&width=");
                b.Append(actualSize.Width);

                b.Append("&height=");
                b.Append(actualSize.Height);

                b.Append("&bbox=");

                b.Append(string.Format(CultureInfo.InvariantCulture, "{0}", locationRect.MinX));
                b.Append(",");
                b.Append(string.Format(CultureInfo.InvariantCulture, "{0}", locationRect.MinY));
                b.Append(",");
                b.Append(string.Format(CultureInfo.InvariantCulture, "{0}", locationRect.MaxX));
                b.Append(",");
                b.Append(string.Format(CultureInfo.InvariantCulture, "{0}", locationRect.MaxY));

                b.Append("&x=");
                b.Append(x);

                b.Append("&y=");
                b.Append(y);

                return b.ToString();
            }
Пример #6
0
 public string GetMapRequest(Extent extent, Size actualSize, IEnumerable<string> layers)
 {
     return wmsService.GetMapRequest(extent, actualSize, layers);
 }
Пример #7
0
 public string GetMapRequest(Size actualSize, IEnumerable<string> layers)
 {
     return wmsService.GetMapRequest(BoundingBox, actualSize, layers);
 }
Пример #8
0
 public void GetFeatureInfo(int screenX, int screenY, Size actualSize, Extent locationRect)
 {
     wmsService.GetFeatureInfo(screenX, screenY, actualSize, locationRect);
 }
Пример #9
0
 /// <summary>
 /// Initializes a new LabelStyle
 /// </summary>
 public LabelStyle()
 {
     _Font = new Font() { FontFamily = "Times New Roman", Size = 12 };
     _Offset = new Offset() { X = 0, Y = 0 };
     _CollisionDetection = false;
     _CollisionBuffer = new Size() { Width = 0, Height = 0 };
     _ForeColor = Color.Black;
     _HorisontalAlignment = HorizontalAlignmentEnum.Center;
     _VerticalAlignment = VerticalAlignmentEnum.Middle;
 }
Пример #10
0
 /// <summary>
 /// Initializes a new map
 /// </summary>
 /// <param name="size">Size of map in pixels</param>
 public Map(Size size)
 {
     _mapViewportGuard = new MapViewPortGuard(size, 0d, Double.MaxValue);
     this.Layers = new List<SharpMap.Layers.ILayer>();
     this.BackColor = Color.White;
 }