Overlay WMS on Google in Silverlight Bing
This post talked about the way how to enable WMS ove the Google (or other Spherical Mercators) maps – http://blog.sumbera.com/2010/02/17/overlay-wms-on-google-in-openlayers/ This post is about testing this inside the Silverlight Bing map control. The quick preview is available here and below is the main routine that calls WMS request from Silverlight (thanks to DeepEarth open source project !):
http://www.sumbera.com:80/lab/silverlight/SilverlightApplication3TestPage.aspx
/// http://deepearth.codeplex.com/sourcecontrol/changeset/view/37324?projectName=deepearth#583728
/// modified to work in Bing map control
public override Uri GetUri(int tilePositionX, int tilePositionY, int tileLevel) {
int zoom = tileLevel; //SSU tileLevel would be same as zoom in Bing control
string quadKey = TileXYToQuadKey(tilePositionX, tilePositionY, zoom);// Use the quadkey to determine a bounding box for the requested tile
BBox boundingBox = QuadKeyToBBox(quadKey);
double deltaX = 0.00135; //SSU deltaX for SLP WMS
double deltaY = 0.00058; //SSU deltaY for SLP WMS
// Get the lat longs of the corners of the box
double lon = XToLongitudeAtZoom(boundingBox.x * TILE_SIZE, 18) + deltaX;
double lat = YToLatitudeAtZoom(boundingBox.y * TILE_SIZE, 18) + deltaY;
double lon2 = XToLongitudeAtZoom((boundingBox.x + boundingBox.width) * TILE_SIZE, 18) + deltaX;
double lat2 = YToLatitudeAtZoom((boundingBox.y – boundingBox.height) * TILE_SIZE, 18) + deltaY;
string wmsUrl = string.Format(this.UriFormat, lon, lat, lon2, lat2, TILE_SIZE);
return new Uri(wmsUrl);
Overlay WMS on Google in OpenLayers

Is it possible to display WMS (EPSG:4326) over the Google (EPSG:900913) in Openlayers ? Yes ! thanks to the great WMS ’feature’ that enables you to shrink/expand your return image based on defined image size. That means that if your map view is rectangular or you request WMS as tiles (rectangular too) you get proper overlay of EPSG:4326 on EPSG:900913) . Example of various image sizes follows (these are actually WMS GetMap requests):
256 x 160
256 x 256
Here is the way how to implement it in OpenLayers – very simplified:
1. read this post http://docs.openlayers.org/library/spherical_mercator.html and create your Google map:
var options = {
projection: new OpenLayers.Projection(“EPSG:900913″),
displayProjection: new OpenLayers.Projection(“EPSG:4326″),
units: “m”,
numZoomLevels: 22,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508.34)
};
map = new OpenLayers.Map(‘map’, options);
// create Google Mercator layers
var ghyb = new OpenLayers.Layer.Google(
“Google Hybrid”,
{ type: G_HYBRID_MAP, ’sphericalMercator’: true }
);
2. add your WMS layer
var gwms = new OpenLayers.Layer.TMS(“SLP”, “http://mapserver-slp.mendelu.cz/cgi-bin/mapserv?map=/var/local/slp/krtinyWMS.map&”,
{
layers: ‘obrys,typologie,hm2003′,
type: ‘png’,
visibility: true,
getURL: get_wms_url,
format: “image/png”,
opacity: 1,
isBaseLayer: false,
deltaX: 0.0013,
deltaY: 0.00058
});
3. include support for reprojection before you include OpenLayers:
<script src =”proj4js/lib/proj4js-combined.js”>script>
4. handle WMS as TMS tiles as this:
function get_wms_url(bounds) {
// recalculate bounds from Google to WGS
var proj = new OpenLayers.Projection(“EPSG:4326″);
bounds.transform(map.getProjectionObject(), proj);
// this is not necessary for most servers display overlay correctly,
//but in my case the WMS has been slightly shifted, so I had to correct this with this delta shift
bounds.left += this.deltaX;
bounds.right += this.deltaX;
bounds.top += this.deltaY;
bounds.bottom += this.deltaY;
//construct WMS request
var url = this.url;
url += “&REQUEST=GetMap”;
url += “&SERVICE=WMS”;
url += “&VERSION=1.1.1″;
url += “&LAYERS=” + this.layers;
url += “&FORMAT=” + this.format;
url += “&TRANSPARENT=TRUE”;
url += “&SRS=” + “EPSG:4326″;
url += “&BBOX=” + bounds.toBBOX();
url += “&WIDTH=” + this.tileSize.w;
url += “&HEIGHT=” + this.tileSize.h;
return url;
}
That is, live example you can see here http://www.sumbera.com/lab/wms/getcapWGS.htm
or in MapShake here : http://www.mapshake.cz/mapfs.aspx?i=464
Mapy.cz na iPhone- video
Seznam pracuje na verzi Mapy.cz pro iPhone. Prozatim ukázal pouze screenshoty… např. zde http://www.iphonetips.cz/apple-novinky/mapy-cz-pro-iphone-exkluzivni-obrazky-z-betaverze/ , které ovšem vypadají velice slibně. V rámci vývoje Whatevermap 2.0 se vyzkoušel prototyp přístupu ke zrojům mapy.cz na iPhone . Následující video předvádí mapy.cz na iPhone 3G s přístupem přes Wifi. Tahle aplikace samozřejmě není a ani nebude dostupná na AppStore, jedná se pouze o experiment, který věřím, že Seznam výkonnostně překoná…nechme se překvapit…
MapShake-v1.0
MapShake v 1.0 preview is available here (:don’t forget to put your loudspeakers at maximum and do not hesitate to ’shake your body’ while watching.. ..and yes ..shake your maps too ! :)
…Feb 2010 update covering friends maps and WMS overaly over the Google maps
OLON in MapShake
It has been a while since I have created WMSBinder.( http://www.sumbera.com/lab/wmsbinder/getcap.htm) Finally I have updated and merged it with MapShake (create new map). So you can enjoy it inside the environment that can store your open layers maps and share them with your friends. MapShake now stores all map compositions as OLON. you can even import your own OLON (but not all formats has been tested). There are many other small updates as well (new toolbar for map, WMS catalog – only for Czech so far, preview of attached layers, base maps to start from etc..)
To get a preview you can check following maps:
Cloud Made: http://www.mapshake.cz/422-CloudMaded
Catalunia – very fast and cool maps in Spain http://www.mapshake.cz/421-Catalunia
Mapy CZ (Czech based maps) http://www.mapshake.cz/416-MapyCz_a_vektor
Prague cadaster and nocie maps http://www.mapshake.cz/mapfs.aspx?i=408
best thing to try it is to login into MapShake and try to compose your own map – well if you understand Czech language – definitely this would be easier for you;)

OLON for this map follows:
{
“layers”: [
{
"name": "OverView",
"url": "/MapShake/j/img/blank.gif",
"params": {
"LAYERS": "doprava",
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"STYLES": "",
"EXCEPTIONS": "application/vnd.ogc.se_inimage",
"FORMAT": "image/jpeg",
"SRS": "epsg:102067"
},
"singleTile": true,
"tileSize": {
"w": 1095,
"h": 525,
"CLASS_NAME": "OpenLayers.Size"
},
"buffer": 2,
"reproject": false,
"numZoomLevels": 14,
"maxResolution": 705.5551745557614,
"minResolution": 0.035277758727788065,
"maxExtent": {
"left": -905000,
"bottom": -1230000,
"right": -400000,
"top": -900000,
"CLASS_NAME": "OpenLayers.Bounds"
},
"wrapDateLine": false,
"displayOutsideMaxExtent": false,
"isBaseLayer": true,
"displayInLayerSwitcher": false,
"visibility": true,
"opacity": null,
"alwaysInRange": true,
"CLASS_NAME": "OpenLayers.Layer.WMS"
},
{
"name": "Základní mapa ČR ",
"url": "http://apps.esdi-humboldt.cz/data/tilecache/",
"layername": "topoJTSK/2M",
"displayOutsideMaxExtent": false,
"singleTile": false,
"tileSize": {
"w": 256,
"h": 256,
"CLASS_NAME": "OpenLayers.Size"
},
"buffer": 0,
"reproject": false,
"numZoomLevels": 14,
"maxResolution": 705.5551745557614,
"minResolution": 0.035277758727788065,
"maxExtent": {
"left": -905000,
"bottom": -1230000,
"right": -400000,
"top": -900000,
"CLASS_NAME": "OpenLayers.Bounds"
},
"wrapDateLine": false,
"isBaseLayer": false,
"displayInLayerSwitcher": true,
"visibility": true,
"opacity": null,
"alwaysInRange": true,
"CLASS_NAME": "OpenLayers.Layer.TileCache"
},
{
"name": "Základní mapa ČR detail ",
"url": "http://apps.esdi-humboldt.cz/cgi-bin/tilecache/tilecache.cgi",
"params": {
"LAYERS": "ceniaTopoJTSK",
"FORMAT": "image/png",
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"STYLES": "",
"EXCEPTIONS": "application/vnd.ogc.se_inimage",
"SRS": "epsg:102067"
},
"singleTile": false,
"tileSize": {
"w": 256,
"h": 256,
"CLASS_NAME": "OpenLayers.Size"
},
"buffer": 0,
"reproject": false,
"numZoomLevels": 14,
"maxResolution": 705.5551745557614,
"minResolution": 0.035277758727788065,
"maxExtent": {
"left": -905000,
"bottom": -1230000,
"right": -400000,
"top": -900000,
"CLASS_NAME": "OpenLayers.Bounds"
},
"wrapDateLine": false,
"displayOutsideMaxExtent": false,
"isBaseLayer": false,
"displayInLayerSwitcher": true,
"visibility": true,
"opacity": null,
"alwaysInRange": true,
"CLASS_NAME": "OpenLayers.Layer.WMS"
},
{
"name": "Letecký snímek ČR ",
"url": "http://apps.esdi-humboldt.cz/cgi-bin/tilecache/tilecache.cgi",
"params": {
"LAYERS": "ceniaJTSK",
"FORMAT": "image/jpeg",
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"STYLES": "",
"EXCEPTIONS": "application/vnd.ogc.se_inimage",
"SRS": "epsg:102067"
},
"singleTile": false,
"tileSize": {
"w": 256,
"h": 256,
"CLASS_NAME": "OpenLayers.Size"
},
"buffer": 0,
"reproject": false,
"numZoomLevels": 14,
"maxResolution": 705.5551745557614,
"minResolution": 0.035277758727788065,
"maxExtent": {
"left": -905000,
"bottom": -1230000,
"right": -400000,
"top": -900000,
"CLASS_NAME": "OpenLayers.Bounds"
},
"wrapDateLine": false,
"displayOutsideMaxExtent": false,
"isBaseLayer": false,
"displayInLayerSwitcher": true,
"visibility": true,
"opacity": null,
"alwaysInRange": true,
"CLASS_NAME": "OpenLayers.Layer.WMS"
},
{
"name": "mapy KN - inverzni",
"url": "http://wms.cuzk.cz/wms.asp?",
"params": {
"LAYERS": "KN-I",
"TRANSPARENT": true,
"FORMAT": "image/png",
"SRS": "epsg:102067",
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"STYLES": "",
"EXCEPTIONS": "application/vnd.ogc.se_inimage"
},
"singleTile": true,
"tileSize": {
"w": 1095,
"h": 525,
"CLASS_NAME": "OpenLayers.Size"
},
"buffer": 2,
"reproject": false,
"numZoomLevels": 14,
"maxResolution": 705.5551745557614,
"minResolution": 0.035277758727788065,
"maxExtent": {
"left": -764972.5503759343,
"bottom": -1054780.0332965641,
"right": -713467.0226333638,
"top": -1030085.6021871124,
"CLASS_NAME": "OpenLayers.Bounds"
},
"wrapDateLine": false,
"displayOutsideMaxExtent": false,
"isBaseLayer": false,
"displayInLayerSwitcher": true,
"visibility": true,
"opacity": null,
"alwaysInRange": true,
"CLASS_NAME": "OpenLayers.Layer.WMS"
},
{
"name": "Praha - hladiny hlukoveho ukazatele Ldvn (dB)",
"url": "http://castor.cenia.cz:80/wmsconnector/com.esri.wms.Esrimap/cenia_hluk_pbol?",
"params": {
"LAYERS": "40",
"TRANSPARENT": true,
"FORMAT": "image/png",
"SRS": "epsg:102067",
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"STYLES": "",
"EXCEPTIONS": "application/vnd.ogc.se_inimage"
},
"singleTile": true,
"tileSize": {
"w": 1095,
"h": 525,
"CLASS_NAME": "OpenLayers.Size"
},
"buffer": 2,
"reproject": false,
"numZoomLevels": 14,
"maxResolution": 705.5551745557614,
"minResolution": 0.035277758727788065,
"maxExtent": {
"left": -742465.3403076057,
"bottom": -1044817.9470094242,
"right": -741950.2850301799,
"top": -1044571.0026983297,
"CLASS_NAME": "OpenLayers.Bounds"
},
"wrapDateLine": false,
"displayOutsideMaxExtent": false,
"isBaseLayer": false,
"displayInLayerSwitcher": true,
"visibility": true,
"opacity": null,
"alwaysInRange": true,
"CLASS_NAME": "OpenLayers.Layer.WMS"
},
{
"name": "Editable Vectors",
"features": [
],
“numZoomLevels”: 14,
“maxResolution”: 705.5551745557614,
“minResolution”: 0.035277758727788065,
“maxExtent”: {
“left”: -905000,
“bottom”: -1230000,
“right”: -400000,
“top”: -900000,
“CLASS_NAME”: “OpenLayers.Bounds”
},
“wrapDateLine”: false,
“displayOutsideMaxExtent”: false,
“isBaseLayer”: false,
“displayInLayerSwitcher”: true,
“visibility”: true,
“opacity”: null,
“alwaysInRange”: true,
“CLASS_NAME”: “OpenLayers.Layer.Vector”
}
],
“center”: {
“lon”: -742207.8126688928,
“lat”: -1044694.474853877,
“CLASS_NAME”: “OpenLayers.LonLat”
},
“resolution”: 0.7055551745557613,
“resolutions”: [
705.5551745557614,
352.7775872778807,
176.38879363894034,
70.55551745557612,
35.27775872778806,
17.63887936389403,
7.055551745557612,
3.527775872778806,
1.763887936389403,
0.7055551745557613,
0.35277758727788,
0.17638879363,
0.07055551745557613,
0.035277758727788065
],
“bounds”: {
“left”: -742465.3403076057,
“bottom”: -1044817.9470094242,
“right”: -741950.2850301799,
“top”: -1044571.0026983297,
“CLASS_NAME”: “OpenLayers.Bounds”
},
“projection”: “epsg:102067″,
“units”: “m”,
“maxResolution”: “auto”,
“numZoomLevels”: 20,
“zoom”: 9,
“CLASS_NAME”: “OpenLayers.Map”
}
Comparing iPhone GPS
As a follow up of this post : http://blog.sumbera.com/2009/10/22/gps-bluetooth-iphone-navigon/ about Holux 1200 external GPS used with iPhone2G we have done little experiment. We took 3 iPhones generations (2G, 3G and 3GS) to compare their performance for turn-by-turn navigation. We have used Navigon and for 2G external bluetooth GPS Holux 1200 and Roqy BT stack.So 2G is jailbreaked.We have also used Trimble Recon to have precise reference GPS. Results can be seen in the following youtube video. Winner is 2G with external GPS ! 3GS and 3G are not serious GPS receivers for turn-by-turn navigation, although 3GS was better and kept the signal longer than 3G it was usualy behind the actual position of the car. 3G was poor most of the time and without the GPS signal.
One fun more thing: I have tried to use Roqy BT GPS inside the train with Navigon to get the information when train is approaching my destination.
iPhone and HOLUX1200 GPS bluetooth with Navigon
I have bought recently Navigon for iPhone for Europe and tested this in various conditions in Czech Republic. Despite overall great ratings I was disappointed. The GPS signal was weak and was occasionally lost. When I drive on a road that is parallel to another road than the GPS point was jumping from one to another road (curiously ! ). Even strange was behavior like driving 130km/h on highway and Navigon jumped my position to side road ! In short weak GPS hardware in iPhone, bad weather conditions, dense urban areas makes this navigation unusable, or only working on 50%. GPS first lock takes sometimes more than 10 minutes if driving fast.
Navigon software is fantastic, no question about this, but what smash the quality down is GPS hardware. Now there is a solution to improve GPS in your iPhone – Use external GPS. One solution comes from TomTom with their iPhone holder. Another one is to use your own external GPS Bluetooth module and some trick how to enable iPhone to communicate with it. Actually to enable GPS BT module to work with iPhone you will need to jailbreak your iPhone and use something like Roqy GPS http://www.roqy-bluetooth.net/roqyGPS.html
I have bought Roqy GPS license (8 EUR), and Holux 1200 GPS (40 EUR), I have used my first iPhone (2G) with OS 3.0 Jailbreaked. You have to install MobileSubstrat via Cydia, install roqyGPS, do obscure and obtrusive license registration with 32 digits (you will get license after paying over the PayPal and waiting up to 48 hours), turn off internal iPhone Bluetooth and switch on RoqyGPS Bluetooth stack and voila you can use this in many iPhone applications using GPS. Even Whatever map, can use it. Nice thing is that Roqy GPS behaves as ‘first-class citizen’ on iPhone – thta is other applications on iPhone can use GPS information comming from third part devices. It is completely transparent form userpoint of view. Nice is that iPhone 2G has no GPS support so with this RoqyGPS hack you can learn youl old appliance to the new features.
So all works fine untill you try to turn-off screen (with upper iPhone button) then in my case external GPS connection has been lost and i had to switch off RoqyBT stack and connect device again. Also unfortunately you can’t use too much Wi-Fi with the RoqyGPS , somehow it is blocked . After some tesitng with Navigon on my trip to Bratislava it also crashed once the application. So there is still lot of places for improvments of it, but considering this is verison 0.9 I think it works very well in cases where you have pre-downloaded maps (like in Navigon) and you do not need to often go away from the external GPS . Also bad thing is that license for Roqy GPS is only for one concrete iPhone hardware, you can’t move it to another iPhone (this is more restrictive than Apple Store !)
iPhone Aplication tested:
Navigon Europe: Holux1200 works with Navigon perfectly, it is like night and day in comparision to embedded GPS performance. When just showing map (without navigaiton where it predicts position) it precisely shows location of my car
OffMaps: I just get trouble downloading tiles over the Wi-fi.
Whatevermap: works fine, nice to see detailed cadastral maps precise position (HOLUX 1200 is about 3-5m precise)
Last note: the picture used above is from perspective – it looks like Holux is bigg, in reality it looks like little bit bigger flash drive…
In summary: having paid for Navigon 139 USD and experiencing poor GPS performance- it is worth to use this RoqyGPS and invest cca 50 USD for external BT GPS and RoqyGPS driver . Consider this as real reason to jailbreak your iPhone to get most of this device. Works fine with Navigon although it is sometimes obtrusive to re-pair devices if you move away from GPS BT device or you turn-off screen.
Update: in this follow-up post here http://blog.sumbera.com/2009/11/12/comparing-iphone-gps/ you can find video of GPS performance for 3 iPhones (2G with Holux, 3G and 3GS)
Apple-like image carousel for Microsoft Power Point
here is the ultimate Power Point “technology” that I have used in my previous blog for animation of pictures (check here: http://blog.sumbera.com/2009/06/15/whatevermap-alpha/ ). Yes ! it is just powerpoint animated and captured by video capture software. I believe you might find this useful too when you need to present multiple screenshots (and impress audience) with your cool image carousel . You can easily customize it and use for your own presentations. Each image is self contained animation so you can copy/paste/change picture and possible sync by mouse clicking. But deafult is that each image is waiting for cca 2 seconds in the front and then fade out and zoom out from the screen (while the next one is zooming in an fading-out)
In the following ‘image carousel pptx’ you can change images by right clicking on any image and selecting “change picture” menu option.
http://www.sumbera.com/blog/ImageCarouselPowerPoint.pptx
More Whatevermap screenshots
WhateverMap on Apple Store
WhateverMap Lite v1.0, developed by Jiri Kaminek has been today accepted for distribution through Apple Store . You can download it here (iTunes and iPhone requiered):
tms://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=326649571&mt=8&s=143441
WhateverMap is similar to Google Maps but you can use different branch-specific map sources. Those sources should be more interesting and valuable in non-navigation filed of map using. WhateverMap use Web Map Services (WMS). WMS standard specification was created by the Open Geospatial Consortium (OGC). WMS may provide any geospatial data. There are many WMS severs and most of them are available for free. You can find servers with ortophoto, cadastral, soil types, migration of white storks, … simply WHATEVER.
You can add any WMS server by typing an URL address or simply use built-in catalog. There are some servers with interesting data as NASA Earth satellite photos, Mars satellite photos and many others. There is a rich list of Czech WMS servers.
You can browse a map using zoom-in, zoom-out or move. For better orientation it is possible to use actual position provided by built-in GPS module. Each WMS should map only limited area so there is a boundary of each map. It is possible to display whole map with boundary too.
It is possible to consume many sources in this application. So there is an easy way to change a source while browsing the map. You can easily compare the same area in different map sources. For example you can find out any building and then you can choose soil type map to determine stability of building’s foundation.
For better control of map there is a movement history. Sometimes GPS get lost a signal and display non-precision region. In this case it is posible to use undo and get more precision area before you get lost a signal. There is another interesting way to use the history. You can move around an area in first map layer and then use the same movements in different layers. For example you can follow a road and then you can use map layer with water or soil pollution to find out effect of road to water or soil quality.
MAP CONTROL:
・ZOOM-IN – double tap
・ZOOM-OUT – triple tap
・MOVEMENT – swipe on map
FEATURES:
- Consume any WMS server map data (ortofoto, cadastral, mars, … WHATEVER)
- Map browsing (move, zoom)
- Support history in map movements (UNDO, REDO)
- Display your current location
- Display map boundary
- Change background color
- Movement history(UNDO, REDO)
- favourite list of WMS
WHAT TO EXPECT IN THE NEXT RELEASES:
- searching by location name (city, roads, country, …) – geocoding
- caching
- saving for offline use
- better catalog
- landmarks
WHAT’S NEW IN THIS VERSION:
first release
LANGUAGES:
English
REQUIREMENTS:
Compatible with iPhone and iPod Touch
Requires iPhone OS 2.2.1 or later
What’s new
English













































