示例#1
0
 public WmsRequest(Uri baseUrl, TileSchema schema, IEnumerable<string> layers, IEnumerable<string> styles, IDictionary<string, string> customParameters, string version)
 {
     // Prepare url string
     var au = baseUrl.AbsoluteUri;
     if (au.IndexOf("SERVICE=WMS", StringComparison.OrdinalIgnoreCase) == -1)
     {
         if (!au.EndsWith("?")) au += "?";
         au += "&SERVICE=WMS";
     }
     var url = new StringBuilder(au);
     if (!string.IsNullOrEmpty(version)) url.AppendFormat("&VERSION={0}", version);
     url.Append("&REQUEST=GetMap");
     url.AppendFormat("&FORMAT={0}", schema.Format);
     var crsFormat = !string.IsNullOrEmpty(version) && string.CompareOrdinal(version, "1.3.0") >= 0 ? "&CRS={0}" : "&SRS={0}";
     url.AppendFormat(crsFormat, schema.Srs);
     url.AppendFormat("&LAYERS={0}", ToCommaSeparatedValues(layers));
     url.AppendFormat("&STYLES={0}", ToCommaSeparatedValues(styles));
     url.AppendFormat("&WIDTH={0}", schema.Width);
     url.AppendFormat("&HEIGHT={0}", schema.Height);
     if (customParameters != null)
     {
         foreach (var name in customParameters.Keys)
         {
             url.AppendFormat("&{0}={1}", name, customParameters[name]);
         }
     }
     _fixedUrl = url.ToString();
 }
示例#2
0
 public void Render(Canvas canvas, TileSchema schema, ITransform transform, MemoryCache<MemoryStream> cache, List<Marker> markerCache)
 {
     CollapseAll(canvas);
     int level = BruTile.Utilities.GetNearestLevel(schema.Resolutions, transform.Resolution);
     DrawRecursive(canvas, schema, transform, cache, transform.Extent, level);
     DrawMarkers(canvas, schema, transform, markerCache, transform.Extent, level);
     RemoveCollapsed(canvas);
 }
        public static ITileSchema GetSchema()
        {
            var resolutions = new[]
                {
                    156543.033928,
                    78271.5169639999,
                    39135.7584820001,
                    19567.8792409999,
                    9783.93962049996,
                    4891.96981024998,
                    2445.98490512499,
                    1222.99245256249,
                    611.49622628138,
                    305.748113140558,
                    152.874056570411,
                    76.4370282850732,
                    38.2185141425366,
                    19.1092570712683,
                    9.55462853563415,
                    4.77731426794937,
                    2.38865713397468,
                    1.19432856685505,
                    0.597164283559817,
                    0.298582141647617
                };

            var schema = new TileSchema();

            var counter = 0;
            foreach (var resolution in resolutions)
            {
                schema.Resolutions.Add(new Resolution
                    {
                        UnitsPerPixel = resolution, 
                        Id = counter++.ToString(CultureInfo.InvariantCulture)
                    });
            }

            schema.Height = 256;
            schema.Width = 256;
            schema.Extent = new Extent(-20037507.2295943, -19971868.8804086, 20037507.2295943, 19971868.8804086);
            schema.OriginX = -20037508.342787;
            schema.OriginY = 20037508.342787;
            schema.Name = "ESRI";
            schema.Format = "JPEG";
            schema.Axis = AxisDirection.InvertedY;
            schema.Srs = string.Format("EPSG:{0}", 102100);

            return schema;
        }
示例#4
0
        public static WmsTileSource Create(WmsInfo info)
        {
            var schema = new TileSchema
            {
                Format = "image/png",
                Srs = info.CRS,
                Height = 256,
                Width = 256,
            };

            var onlineResource = info.WmsCapabilities.Capability.Request.GetCapabilities.DCPType[0].Http.Get.OnlineResource.Href;
            return new WmsTileSource(new WebTileProvider(new WmsRequest(new Uri(onlineResource), 
                schema,
                new List<string>{info.Layer.Name},
                info.Style == null? null : new List<string>{info.Style},
                info.CustomParameters, info.WmsCapabilities.Version.VersionString),
                fetchTile: d => RequestHelper.FetchImage(d, info.Credentials)
                ),
                schema);
        }
示例#5
0
 private ITileSchema CreateTileSchema()
 {
     var schema = new TileSchema();
     schema.Name = "OpenStreetMap";
     int i = 0;
     foreach (var resolution in resolutions)
     {
         schema.Resolutions.Add(new Resolution {UnitsPerPixel = resolution, Id = i++.ToString()});
     }
 
     schema.OriginX = -20037508.342789;
     schema.OriginY = 20037508.342789;
     schema.Axis = AxisDirection.InvertedY;
     schema.Extent = new Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789);
     schema.Height = 256;
     schema.Width = 256;
     schema.Format = "png";
     schema.Srs = "EPSG:900913";
     return schema;
 }
示例#6
0
        private static ITileSchema CreateSchema()
        {
            var resoltions = new[] { 
                    0.3515625,
                    0.17578125,
                    0.087890625,
                    0.0439453125,
                    0.02197265625,
                    0.010986328125,
                    0.0054931640625,
                    0.00274658203125,
                    0.001373291015625,
                    0.0006866455078125,
                    0.00034332275390625,
                    0.000171661376953125,
                    0.0000858306884765629,
                    0.0000429153442382814,
                    0.0000214576721191407,
                    0.0000107288360595703 };

            const string format = "jpeg";

            var schema = new TileSchema();
            var count = 0;
            foreach (double resolution in resoltions)
            {
                var levelId = count.ToString();
                schema.Resolutions[levelId] = new Resolution { Id = levelId, UnitsPerPixel = resolution};
                count++;
            }
            schema.Height = 512;
            schema.Width = 512;
            schema.Extent = new Extent(-180, -90, 180, 90);
            schema.OriginX = -180;
            schema.OriginY = 90;
            schema.Name = "ESRI";
            schema.Format = format;
            schema.YAxis = YAxis.OSM;
            schema.Srs = "EPSG:4326";
            return schema;
        }
示例#7
0
 private void InitializeTransform( TileSchema schema )
 {
     map.Transform.Center = new Point( 16384d, -16384d );
     map.Transform.Resolution = schema.Resolutions.Last();
     schema.Resolutions.Add( 2 );
     schema.Resolutions.Add( 1 );
 }
示例#8
0
        private ITileSchema CreateTileSchema()
        {
            var resolutions = new[] { 
                156543.033900000, 78271.516950000, 39135.758475000, 19567.879237500, 9783.939618750, 
                4891.969809375, 2445.984904688, 1222.992452344, 611.496226172, 305.748113086, 
                152.874056543, 76.437028271, 38.218514136, 19.109257068, 9.554628534, 4.777314267,
                2.388657133, 1.194328567, 0.597164283};

            var tileSchema = new TileSchema {Name = "OpenStreetMap"};
            foreach (float resolution in resolutions)
            {
                tileSchema.Resolutions.Add(resolution);
            }

            tileSchema.OriginX = -20037508.342789;
            tileSchema.OriginY = 20037508.342789;
            tileSchema.Axis = AxisDirection.InvertedY;
            tileSchema.Extent = new Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789);
            tileSchema.Height = 256;
            tileSchema.Width = 256;
            tileSchema.Format = "png";
            tileSchema.Srs = "EPSG:900913";
            return tileSchema;
        }
        private ITileSchema RestoreSchema()
        {
            var schema = new TileSchema
                {
                    YAxis = _axis,
                    Extent = new Extent(_minX, _minY, _maxX, _maxY),
                    Format = _format,
                    /*
                    Height = _height,
                    Width = _width,
                     */
                    Name = _schemaName,
                    OriginX = _originX,
                    OriginY = _originY,
                    Srs = _srs
                };

            foreach (var resolution in _resolutions)
            {
                schema.Resolutions.Add(resolution);
            }
            return schema;
        }
示例#10
0
        /// <summary>
        /// Generate BruTile TileSchema based on ArcGIS Capabilities
        /// </summary>
        /// <returns>TileSchema, returns null if service is not tiled</returns>
        public static ITileSchema GetTileSchema(ArcGISDynamicCapabilities arcGisDynamicCapabilities)
        {
            //TODO: Does this belong in Mapsui.Providers?

            if (arcGisDynamicCapabilities.tileInfo == null)
                return null;

            var schema = new TileSchema();
            var count = 0;

            foreach (var lod in arcGisDynamicCapabilities.tileInfo.lods)
            {
                var levelId = count.ToString();
                schema.Resolutions[levelId] = new Resolution { Id = levelId, UnitsPerPixel = lod.resolution };
                count++;
            }

            schema.Height = arcGisDynamicCapabilities.tileInfo.cols;
            schema.Width = arcGisDynamicCapabilities.tileInfo.rows;
            schema.Extent = new BruTile.Extent(arcGisDynamicCapabilities.fullExtent.xmin, arcGisDynamicCapabilities.fullExtent.ymin, arcGisDynamicCapabilities.fullExtent.xmax, arcGisDynamicCapabilities.fullExtent.ymax);
            schema.OriginX = arcGisDynamicCapabilities.tileInfo.origin.x;
            schema.OriginY = arcGisDynamicCapabilities.tileInfo.origin.y;

            schema.Name = "ESRI";
            schema.Format = arcGisDynamicCapabilities.tileInfo.format;
            schema.YAxis = YAxis.OSM;
            schema.Srs = string.Format("EPSG:{0}", arcGisDynamicCapabilities.tileInfo.spatialReference.wkid);

            return schema;
        }
        /// <summary>
        /// Generate BruTile TileSchema based on ArcGIS Capabilities
        /// </summary>
        /// <returns>TileSchema, returns null if service is not tiled</returns>
        public static ITileSchema GetTileSchema(Capabilities capabilities)
        {
            //TODO: Does this belong in Mapsui.Providers?

            if (capabilities.tileInfo == null)
                return null;

            var schema = new TileSchema();
            var count = 0;

            foreach (var lod in capabilities.tileInfo.lods)
            {
                schema.Resolutions.Add(new Resolution { Id = count.ToString(), UnitsPerPixel = lod.resolution });
                count++;
            }

            schema.Height = capabilities.tileInfo.cols;
            schema.Width = capabilities.tileInfo.rows;
            schema.Extent = new BruTile.Extent(capabilities.fullExtent.xmin, capabilities.fullExtent.ymin, capabilities.fullExtent.xmax, capabilities.fullExtent.ymax);
            schema.OriginX = capabilities.tileInfo.origin.x;
            schema.OriginY = capabilities.tileInfo.origin.y;
            schema.Name = "ESRI";
            schema.Format = capabilities.tileInfo.format;            
            schema.Axis = AxisDirection.InvertedY;
            schema.Srs = string.Format("EPSG:{0}", capabilities.tileInfo.spatialReference.wkid);

            return schema;
        }
示例#12
0
 public TileSource(FileTileProvider tileProvider, TileSchema tileSchema)
 {
     this.tileProvider = tileProvider;
     this.tileSchema = tileSchema;
 }
示例#13
0
 public TileSource(FileTileProvider tileProvider, TileSchema tileSchema)
 {
     this.tileProvider = tileProvider;
     this.tileSchema   = tileSchema;
 }
示例#14
0
        private void DrawMarkers(Canvas canvas, TileSchema schema, ITransform transform, List<Marker> cache, Extent extent, int level)
        {

            foreach (Marker m in cache)
            {
                if (m.UIElement == null)
                {
                    if (!m.Visible) continue;

                    if (m.Points != null)
                    {
                        MarkerControl2 c = new MarkerControl2();
                        c.Over += new RoutedEventHandler(c_Over);
                        c.Leave += new RoutedEventHandler(c_Leave);
                        c.Points = new PointCollection(m.Points);

                        c.Text = m.Text;
                        c.Description = m.Description;

                        m.UIElement = c;
                    }
                    else 
                    {
                        MarkerControl c = new MarkerControl();
                        c.Over += new RoutedEventHandler(c_Over);
                        c.Leave += new RoutedEventHandler(c_Leave);
                        if (markerImages != null)
                        {
                            if (markerImages.ContainsKey(m.ImageIndex))
                            {
                                c.Image = markerImages[m.ImageIndex];
                            }
                            else if (markerImages.ContainsKey(-1))
                            {
                                c.Image = markerImages[-1];
                            }
                        }

                        c.Text = m.Text;
                        c.Description = m.Description;

                        m.UIElement = c;                    
                    }
                }

                //MarkerControl marker = m.UIElement as MarkerControl;
                UIElement marker = m.UIElement as UIElement;
                marker.Visibility = Visibility.Collapsed;

                if (!m.Visible)
                {
                    continue;
                }
                    
                if (!canvas.Children.Contains(marker))
                {
                    canvas.Children.Add(marker);
                }

                Rect dest = MapTransformHelper.WorldToMap(extent, transform);
                Point p = transform.WorldToMap(m.X, m.Y);
                if (dest.Contains(p))
                {
                    Canvas.SetZIndex(marker, m.ZIndex);
                    Canvas.SetLeft(marker, p.X);
                    Canvas.SetTop(marker, p.Y);

                    if (m.Points != null)
                    {
                        if (!(marker.RenderTransform is ScaleTransform))
                        {
                            marker.RenderTransform = new ScaleTransform(1.0 / transform.Resolution, 1.0 / transform.Resolution);
                        }
                        else
                        {
                            ((ScaleTransform)marker.RenderTransform).ScaleX = 1.0 / transform.Resolution;
                            ((ScaleTransform)marker.RenderTransform).ScaleY = 1.0 / transform.Resolution;
                        }
                    }
                    /*
                    double factor = 4;
                    if (!(marker.RenderTransform is ScaleTransform))
                    {
                        marker.RenderTransform = new ScaleTransform(1.0 / transform.Resolution * factor, 1.0 / transform.Resolution * factor);
                    }
                    else {
                        ((ScaleTransform)marker.RenderTransform).ScaleX = 1.0 / transform.Resolution * factor;
                        ((ScaleTransform)marker.RenderTransform).ScaleY = 1.0 / transform.Resolution * factor;
                    }
                    */

                    marker.Visibility = Visibility.Visible;
                }
            }
        }
示例#15
0
        private void DrawRecursive(Canvas canvas, TileSchema schema, ITransform transform, MemoryCache<MemoryStream> memoryCache, Extent extent, int level)
        {
            IList<TileInfo> tiles = schema.GetTilesInView(extent, level);

            foreach (TileInfo tile in tiles)
            {
                MemoryStream image = memoryCache.Find(tile.Index);
                if (image == null)
                {
                    if (level > 0) DrawRecursive(canvas, schema, transform, memoryCache, tile.Extent.Intersect(extent), level - 1);
                }
                else
                {
                    Rect dest = MapTransformHelper.WorldToMap(tile.Extent, transform);
                    double opacity = DrawImage(canvas, image, dest, tile);
                    if ((opacity < 1) && (level > 0)) DrawRecursive(canvas, schema, transform, memoryCache, tile.Extent.Intersect(extent), level - 1);
                }
            }
        }