@@ -54,56 +54,56 @@ public class TiledWmsLayer : SharpMap.Layers.Layer, ILayer
5454 private int _TimeOut ;
5555 private SortedList < string , TileSet > _TileSets = new SortedList < string , TileSet > ( ) ;
5656 private Collection < string > _TileSetsActive = new Collection < string > ( ) ;
57-
57+
5858 #endregion
5959
6060 #region Constructors
6161 /// <summary>
62- /// Initializes a new layer, and downloads and parses the service description
63- /// </summary>
64- /// <remarks>In and ASP.NET application the service description is automatically cached for 24 hours when not specified</remarks>
65- /// <param name="layername">Layername</param>
66- /// <param name="url">Url of WMS server's Capabilties</param>
62+ /// Initializes a new layer, and downloads and parses the service description
63+ /// </summary>
64+ /// <remarks>In and ASP.NET application the service description is automatically cached for 24 hours when not specified</remarks>
65+ /// <param name="layername">Layername</param>
66+ /// <param name="url">Url of WMS server's Capabilties</param>
6767 public TiledWmsLayer ( string layername , string url )
68- : this ( layername , url , new TimeSpan ( 24 , 0 , 0 ) )
69- {
70- }
71-
68+ : this ( layername , url , new TimeSpan ( 24 , 0 , 0 ) )
69+ {
70+ }
71+
7272 /// <summary>
73- /// Initializes a new layer, and downloads and parses the service description
74- /// </summary>
75- /// <param name="layername">Layername</param>
76- /// <param name="url">Url of WMS server's Capabilties</param>
77- /// <param name="cachetime">Time for caching Service Description (ASP.NET only)</param>
73+ /// Initializes a new layer, and downloads and parses the service description
74+ /// </summary>
75+ /// <param name="layername">Layername</param>
76+ /// <param name="url">Url of WMS server's Capabilties</param>
77+ /// <param name="cachetime">Time for caching Service Description (ASP.NET only)</param>
7878 public TiledWmsLayer ( string layername , string url , TimeSpan cachetime )
79- : this ( layername , url , cachetime , null )
80- {
81- }
79+ : this ( layername , url , cachetime , null )
80+ {
81+ }
82+
83+ /// <summary>
84+ /// Initializes a new layer, and downloads and parses the service description
85+ /// </summary>
86+ /// <remarks>In and ASP.NET application the service description is automatically cached for 24 hours when not specified</remarks>
87+ /// <param name="layername">Layername</param>
88+ /// <param name="url">Url of WMS server's Capabilties</param>
89+ /// <param name="proxy">Proxy</param>
90+ public TiledWmsLayer ( string layername , string url , System . Net . WebProxy proxy )
91+ : this ( layername , url , new TimeSpan ( 24 , 0 , 0 ) , proxy )
92+ {
93+ }
8294
8395 /// <summary>
84- /// Initializes a new layer, and downloads and parses the service description
85- /// </summary>
86- /// <remarks>In and ASP.NET application the service description is automatically cached for 24 hours when not specified</remarks>
87- /// <param name="layername">Layername</param>
88- /// <param name="url">Url of WMS server's Capabilties</param>
89- /// <param name="proxy">Proxy</param>
90- public TiledWmsLayer ( string layername , string url , System . Net . WebProxy proxy )
91- : this ( layername , url , new TimeSpan ( 24 , 0 , 0 ) , proxy )
92- {
93- }
94-
95- /// <summary>
96- /// Initializes a new layer, and downloads and parses the service description
97- /// </summary>
98- /// <param name="layername">Layername</param>
99- /// <param name="url">Url of WMS server's Capabilties</param>
100- /// <param name="cachetime">Time for caching Service Description (ASP.NET only)</param>
101- /// <param name="proxy">Proxy</param>
96+ /// Initializes a new layer, and downloads and parses the service description
97+ /// </summary>
98+ /// <param name="layername">Layername</param>
99+ /// <param name="url">Url of WMS server's Capabilties</param>
100+ /// <param name="cachetime">Time for caching Service Description (ASP.NET only)</param>
101+ /// <param name="proxy">Proxy</param>
102102 public TiledWmsLayer ( string layername , string url , TimeSpan cachetime , System . Net . WebProxy proxy )
103- {
104- _Proxy = proxy ;
105- _TimeOut = 10000 ;
106- this . LayerName = layername ;
103+ {
104+ _Proxy = proxy ;
105+ _TimeOut = 10000 ;
106+ this . LayerName = layername ;
107107 _ContinueOnError = true ;
108108
109109 if ( System . Web . HttpContext . Current != null && System . Web . HttpContext . Current . Cache [ "SharpMap_WmsClient_" + url ] != null )
@@ -122,9 +122,9 @@ public TiledWmsLayer(string layername, string url, TimeSpan cachetime, System.Ne
122122 }
123123
124124 #endregion
125-
125+
126126 #region Properties
127-
127+
128128 /// <summary>
129129 /// Provides the base authentication interface for retrieving credentials for Web client authentication.
130130 /// </summary>
@@ -156,7 +156,7 @@ public Collection<string> TileSetsActive
156156 {
157157 get { return _TileSetsActive ; }
158158 }
159-
159+
160160 /// <summary>
161161 /// Gets the collection of TileSets that will be rendered
162162 /// </summary>
@@ -183,7 +183,7 @@ public Collection<string> OutputFormats
183183 }
184184
185185 #endregion
186-
186+
187187 #region ILayer Members
188188
189189 // <summary>
@@ -217,7 +217,7 @@ public override void Render(System.Drawing.Graphics g, Map map)
217217 else
218218 {
219219 bitmap = WmsGetMap ( tileExtent , tileSet ) ;
220- if ( ( tileSet . TileCache != null ) && ( bitmap != null ) )
220+ if ( ( tileSet . TileCache != null ) && ( bitmap != null ) )
221221 {
222222 tileSet . TileCache . AddTile ( tileExtent , bitmap ) ;
223223 }
@@ -246,8 +246,12 @@ public override void Render(System.Drawing.Graphics g, Map map)
246246
247247 //TODO: Allow custom image attributes for each TileSet.
248248
249- g . DrawImage ( bitmap ,
250- new Rectangle ( ( int ) Math . Round ( destMin . X ) , ( int ) Math . Round ( destMax . Y ) , ( int ) Math . Ceiling ( destMax . X - destMin . X ) , ( int ) Math . Ceiling ( destMin . Y - destMax . Y ) ) ,
249+ int x = ( int ) Math . Round ( destMin . X ) ;
250+ int y = ( int ) Math . Round ( destMax . Y ) ;
251+ int width = ( int ) Math . Round ( destMax . X - x ) ;
252+ int height = ( int ) Math . Round ( destMin . Y - y ) ;
253+
254+ g . DrawImage ( bitmap , new Rectangle ( x , y , width , height ) ,
251255 srcRect . Left , srcRect . Top , srcRect . Width , srcRect . Height ,
252256 GraphicsUnit . Pixel , _ImageAttributes ) ;
253257
@@ -264,18 +268,18 @@ public override void Render(System.Drawing.Graphics g, Map map)
264268 }
265269 }
266270 }
267-
268- /// <summary>
269- /// Returns the extent of the layer
270- /// </summary>
271- /// <returns>Bounding box corresponding to the extent of the features in the layer</returns>
272- public override SharpMap . Geometries . BoundingBox Envelope
273- {
274- get
275- {
271+
272+ /// <summary>
273+ /// Returns the extent of the layer
274+ /// </summary>
275+ /// <returns>Bounding box corresponding to the extent of the features in the layer</returns>
276+ public override SharpMap . Geometries . BoundingBox Envelope
277+ {
278+ get
279+ {
276280 return _WmsClient . Layer . LatLonBoundingBox ; //TODO: no box is allowed in capabilities so check for it
277- }
278- }
281+ }
282+ }
279283
280284 #endregion
281285
@@ -314,7 +318,7 @@ private string GetRequestUrl(SharpMap.Geometries.BoundingBox box, TileSet tileSe
314318 strReq . Append ( "?" ) ;
315319 if ( ! strReq . ToString ( ) . EndsWith ( "&" ) && ! strReq . ToString ( ) . EndsWith ( "?" ) )
316320 strReq . Append ( "&" ) ;
317-
321+
318322 strReq . AppendFormat ( SharpMap . Map . numberFormat_EnUS , "&REQUEST=GetMap&BBOX={0},{1},{2},{3}" ,
319323 box . Min . X , box . Min . Y , box . Max . X , box . Max . Y ) ;
320324 strReq . AppendFormat ( "&WIDTH={0}&Height={1}" , tileSet . Width , tileSet . Height ) ;
@@ -326,13 +330,13 @@ private string GetRequestUrl(SharpMap.Geometries.BoundingBox box, TileSet tileSe
326330 strReq . Remove ( strReq . Length - 1 , 1 ) ;
327331 }
328332 strReq . AppendFormat ( "&FORMAT={0}" , tileSet . Format ) ;
329-
333+
330334 if ( _WmsClient . WmsVersion == "1.3.0" )
331335 strReq . AppendFormat ( "&CRS={0}" , tileSet . Srs ) ;
332336 else
333337 strReq . AppendFormat ( "&SRS={0}" , tileSet . Srs ) ;
334338 strReq . AppendFormat ( "&VERSION={0}" , _WmsClient . WmsVersion ) ;
335-
339+
336340 if ( tileSet . Styles != null && tileSet . Styles . Count > 0 )
337341 {
338342 strReq . Append ( "&STYLES=" ) ;
@@ -368,7 +372,7 @@ private Bitmap WmsGetMap(BoundingBox extent, TileSet tileSet)
368372 if ( this . Credentials != null )
369373 webRequest . Credentials = this . Credentials ;
370374 else
371- webRequest . Credentials = System . Net . CredentialCache . DefaultCredentials ;
375+ webRequest . Credentials = System . Net . CredentialCache . DefaultCredentials ;
372376
373377 if ( this . Proxy != null )
374378 webRequest . Proxy = this . Proxy ;
@@ -434,31 +438,31 @@ private void HandleGetMapException(string message, Exception ex)
434438 }
435439 }
436440
437- private SharpMap . Web . Wms . Client . WmsOnlineResource GetPreferredMethod ( )
438- {
439- //We prefer posting. Seek for supported post method
440- for ( int i = 0 ; i < _WmsClient . GetMapRequests . Length ; i ++ )
441- if ( _WmsClient . GetMapRequests [ i ] . Type . ToLower ( ) == "post" )
442- return _WmsClient . GetMapRequests [ i ] ;
443- //Next we prefer the 'get' method
444- for ( int i = 0 ; i < _WmsClient . GetMapRequests . Length ; i ++ )
445- if ( _WmsClient . GetMapRequests [ i ] . Type . ToLower ( ) == "get" )
446- return _WmsClient . GetMapRequests [ i ] ;
447- return _WmsClient . GetMapRequests [ 0 ] ;
448- }
449-
450- #region ICloneable Members
451-
452- /// <summary>
453- /// Clones the object
454- /// </summary>
455- /// <returns></returns>
456- public override object Clone ( )
457- {
458- throw new NotImplementedException ( ) ;
459- }
460-
461- #endregion
441+ private SharpMap . Web . Wms . Client . WmsOnlineResource GetPreferredMethod ( )
442+ {
443+ //We prefer posting. Seek for supported post method
444+ for ( int i = 0 ; i < _WmsClient . GetMapRequests . Length ; i ++ )
445+ if ( _WmsClient . GetMapRequests [ i ] . Type . ToLower ( ) == "post" )
446+ return _WmsClient . GetMapRequests [ i ] ;
447+ //Next we prefer the 'get' method
448+ for ( int i = 0 ; i < _WmsClient . GetMapRequests . Length ; i ++ )
449+ if ( _WmsClient . GetMapRequests [ i ] . Type . ToLower ( ) == "get" )
450+ return _WmsClient . GetMapRequests [ i ] ;
451+ return _WmsClient . GetMapRequests [ 0 ] ;
452+ }
453+
454+ #region ICloneable Members
455+
456+ /// <summary>
457+ /// Clones the object
458+ /// </summary>
459+ /// <returns></returns>
460+ public override object Clone ( )
461+ {
462+ throw new NotImplementedException ( ) ;
463+ }
464+
465+ #endregion
462466
463467
464468 }
0 commit comments