code: public static double calculateGroundResolution(double latitude, long mapSize) {
          return Math.cos(latitude * (Math.PI / 180)) * EARTH_CIRCUMFERENCE / mapSize;
      }
docs: Calculates the distance on the ground that is represented by a single pixel on the map.
  
  @param latitude the latitude coordinate at which the resolution should be calculated.
  @param mapSize  precomputed size of map.
  @return the ground resolution at the given latitude and map size.