Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2498 | - | 1 | |
2 | namespace GMap.NET.MapProviders |
||
3 | { |
||
4 | using System; |
||
5 | using GMap.NET.Projections; |
||
6 | |||
7 | public abstract class WikiMapiaMapProviderBase : GMapProvider |
||
8 | { |
||
9 | public WikiMapiaMapProviderBase() |
||
10 | { |
||
11 | MaxZoom = 22; |
||
12 | RefererUrl = "http://wikimapia.org/"; |
||
13 | Copyright = string.Format("© WikiMapia.org - Map data ©{0} WikiMapia", DateTime.Today.Year); |
||
14 | } |
||
15 | |||
16 | #region GMapProvider Members |
||
17 | |||
18 | public override Guid Id |
||
19 | { |
||
20 | get |
||
21 | { |
||
22 | throw new NotImplementedException(); |
||
23 | } |
||
24 | } |
||
25 | |||
26 | public override string Name |
||
27 | { |
||
28 | get |
||
29 | { |
||
30 | throw new NotImplementedException(); |
||
31 | } |
||
32 | } |
||
33 | |||
34 | public override PureProjection Projection |
||
35 | { |
||
36 | get |
||
37 | { |
||
38 | return MercatorProjection.Instance; |
||
39 | } |
||
40 | } |
||
41 | |||
42 | public override GMapProvider[] Overlays |
||
43 | { |
||
44 | get |
||
45 | { |
||
46 | throw new NotImplementedException(); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | public override PureImage GetTileImage(GPoint pos, int zoom) |
||
51 | { |
||
52 | throw new NotImplementedException(); |
||
53 | } |
||
54 | |||
55 | #endregion |
||
56 | |||
57 | public static int GetServerNum(GPoint pos) |
||
58 | { |
||
59 | return (int)(pos.X % 4 + (pos.Y % 4) * 4); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | /// <summary> |
||
64 | /// WikiMapiaMap provider, http://wikimapia.org/ |
||
65 | /// </summary> |
||
66 | public class WikiMapiaMapProvider : WikiMapiaMapProviderBase |
||
67 | { |
||
68 | public static readonly WikiMapiaMapProvider Instance; |
||
69 | |||
70 | WikiMapiaMapProvider() |
||
71 | { |
||
72 | } |
||
73 | |||
74 | static WikiMapiaMapProvider() |
||
75 | { |
||
76 | Instance = new WikiMapiaMapProvider(); |
||
77 | } |
||
78 | |||
79 | #region GMapProvider Members |
||
80 | |||
81 | readonly Guid id = new Guid("7974022B-1AA6-41F1-8D01-F49940E4B48C"); |
||
82 | public override Guid Id |
||
83 | { |
||
84 | get |
||
85 | { |
||
86 | return id; |
||
87 | } |
||
88 | } |
||
89 | |||
90 | readonly string name = "WikiMapiaMap"; |
||
91 | public override string Name |
||
92 | { |
||
93 | get |
||
94 | { |
||
95 | return name; |
||
96 | } |
||
97 | } |
||
98 | |||
99 | GMapProvider[] overlays; |
||
100 | public override GMapProvider[] Overlays |
||
101 | { |
||
102 | get |
||
103 | { |
||
104 | if(overlays == null) |
||
105 | { |
||
106 | overlays = new GMapProvider[] { this }; |
||
107 | } |
||
108 | return overlays; |
||
109 | } |
||
110 | } |
||
111 | |||
112 | public override PureImage GetTileImage(GPoint pos, int zoom) |
||
113 | { |
||
114 | string url = MakeTileImageUrl(pos, zoom, string.Empty); |
||
115 | return GetTileImageUsingHttp(url); |
||
116 | } |
||
117 | |||
118 | #endregion |
||
119 | |||
120 | string MakeTileImageUrl(GPoint pos, int zoom, string language) |
||
121 | { |
||
122 | return string.Format(UrlFormat, GetServerNum(pos), pos.X, pos.Y, zoom); |
||
123 | } |
||
124 | |||
125 | static readonly string UrlFormat = "http://i{0}.wikimapia.org/?x={1}&y={2}&zoom={3}"; |
||
126 | } |
||
127 | } |