title: How to use System.Spatial.GeographyPoint
body: <p>I need a function to calculate distance between point A and point B.</p>
  
  <p>Namespace <code>System.Spatial</code> seems to be exactly what I need, but I can't figure how to use it.</p>
  
  <p><code>IPoint</code> is an interface that provides <code>Latitude</code> and <code>Longitude</code>, both of type <code>double</code>.</p>
  
  <p>First try :</p>
  
  <pre><code>  public static double CalculateDistance(IPoint pointA, IPoint pointB)
    {
       var gp1 = GeographyPoint.Create(pointA.Latitude, pointA.Longitude);
       var gp2 = GeographyPoint.Create(pointB.Latitude, pointB.Longitude);
  
       return gp1.Distance(gp2) ?? 0;
    }
  </code></pre>
  
  <p>That ends with a <code>NotImplementedException</code>on <code>point1.Distance(point2)</code>. The message is in french, but basically it says "No operation registered. Please provide operation using property SpatialImplementation.CurrentImplementation.Operations".</p>
  
  <p>Ok, I will try this then :</p>
  
  <pre><code>public static double CalculateDistance(IPoint pointA, IPoint pointB)
  {
     var gp1 = GeographyPoint.Create(pointA.Latitude, pointA.Longitude);
     var gp2 = GeographyPoint.Create(pointB.Latitude, pointB.Longitude);
  
     return SpatialImplementation.CurrentImplementation.Operations.Distance(gp1, gp2);
  }
  </code></pre>
  
  <p>Now I got a <code>NullReferenceException</code> on <code>SpatialImplementation.CurrentImplementation.Operations</code>.</p>
  
  <p>Msdn is not much verbose about this.</p>
  
  <p>Anyone can explain how to get these implementations ?</p>