Friday, May 27, 2011

Bing Maps and Google Maps are off in the Bahamas

I was pretty blown away when I started debugging an issue for one of our users.


He reported that he would mark a way point on the web (using Google Maps), and when it went over to the phone (using Bing Maps), it showed up in the wrong place.  Now this is a pretty serious claim since that's pretty much the one thing that we should never mess up.


I started by asking our Q.A. team to confirm the issue.  They reported back that they couldn't reproduce the issue (which was some relief), but the user seemed pretty sure so I hit him up for some more specific details.  He provided a latitude and longitude, and when I retested with that, I was able to reproduce.


The point was in the Bahamas, so I started trying to brainstorm the things that could be different about the map there:


The Map Projection (Nope)
Maybe there is some funny rule for the area because Cylindrical Mercator projection doesn't work well there?  That couldn't be because that projection is the basis of the tile system that everyone uses.


Google:

Google Maps uses a variant of the Mercator projection for its map images


(Google) Maps uses Mercator because it preserves angles


Bing
We chose to use the Mercator projection



The Datum (Nope)
Maybe there is a special datum that people use here? --Maybe.  Most of the world uses WGS84/NAD83, and our apps support that plus NAD27, but there are plenty of other datums out there.


Google:
Google Maps are the GPS coordinates based on the WGS 84 datum


Bing:
The latitude and longitude are assumed to be on the WGS 84 datum




The Map Data


This can't be wrong right?  It's Bing and Google... No way either of these guys get this wrong... they can't afford to get this stuff wrong... Right?



After looking at it pretty closely, it looks like it's just a pretty simple problem: The Google Maps and Bing Maps are offset from eachother.  I don't know who is more right, but they just don't match, and all other things seem to match up, so I'm sold.  I think one of them is just plain wrong.  I tried a number of other sources, and it looks most likely that BING is wrong, but since I'm not sitting in the Bhamas with a GPS unit, I'm not sure :-)


UPDATE: The guys on the bing forums looked into this and found compelling evidence that Bing Maps are right and Google Maps are wrong.   The best way to see this is by checking out this map:http://maps.google.com/maps?t=k&ie=UTF8&ll=25.228858,-76.272143&spn=0.00757,0.013937&z=17
Here you can see that the tiles just stop stitching correctly on Google's Maps.  When you turn on the Street layer you can see that even the vector data doesn't line up correctly.
Thanks for helping identify the guilty part  



So far this is the only place I've seen bad data from bing, but I'll keep my eye out for it now :-)

Thanks to our LizardLeg for spotting the issue.

Wednesday, May 25, 2011

Convert.ToInt32(DateTime) is a Lie

Warning, this is a bit of a rant, I'm just blown away.

I'm building some new features into our C# REST API that all of our phone apps talk to and I wanted to send down a Date in the form of an integer.  I noticed that there was a surprising helper method in the Convert class called ToInt32(DateTime).  That sounded perfect for what I needed, but I really wan't sure what the format would be since you can't really squeeze a DateTime object into 32 bits.  I figured they probably had some standard though, maybe the number of seconds since 1/1/1970 (like Unix/POSIX) or something like that.  So I opened up the documentation and low and behold I find:


Convert.ToInt32 Method (DateTime)

.NET Framework 4


Calling this method always throws InvalidCastException.


http://msdn.microsoft.com/en-us/library/ch56d3w9.aspx

Using this doesn't result in a compiler error.  It doesn't even result in any warnings at compile time.  It just results in a runtime exception if you were naive enough to assume it would do something good.  What are we developing in VB?

In my mind, the biggest benefit to strongly typed languages like c# is that they should expose the fact that you did something stupid at compile time so you don't need to wait for it to crash on your when it's released... (OK: there are probably a million different reasons why strongly type languages make sense, but that's one of them ;-) )


Sorry for the Rant-- Back to being productive.

Tuesday, May 24, 2011

Windows 7: SMTP server running on localhost


I recently migrated my development machine to Windows 7 64-bit, and I didn't run into too many issues that weren't already on Google :-)

I did hit one that I didn't find a good solution for on Google though: How to install the windows SMTP component.

I figured they must have removed that component, but It turned out that they didn't remove it, they just stopped listing it under IIS in the add/remove windows components section of the control panel.

To add it you just have to (unintuitively) select the following:

Control Panel > Programs > Turn Windows feature On/Off > Internet Information Systems > World Wide Web Services > Application Development features > Turn On ASP.

It's not intuitive, but it works.

You'll now see SMTP in your IIS Manager console: