opengl – Incorrect generation of UV sphere mesh

I am following the same algorithm to generate the mesh of a UV Sphere as described in this wiki: http://wiki.unity3d.com/index.php/ProceduralPrimitives#C.23_-_Sphere

My implementation is in C ++. I am not sure what is wrong with my implementation. The indexes appear to be incorrect. Does anyone know what I am doing wrong?

The render:UV procedure sphere

Mesh Generation Code:

struct Sphere {
    float radius_; 
    math::Vec3f center_; 
}; 

struct Vertex {
    math::Vec3f position_;
    math::Vec3f normal_;
    math::Vec2f texture_coordinate_;
};

void MeshGenerator::Generate(const math::Sphere& sphere,
                             std::vector& vertices,
                             std::vector& indices) {

    constexpr uint32_t latitude_count = 16;
    constexpr uint32_t longitude_count = 24;

    vertices.clear();
    indices.clear();

    const uint32_t vertex_count = (longitude_count + 1) * latitude_count + 2;
    vertices.resize(vertex_count);

    // Generate Vertices
    vertices(0).normal_ = math::Vec3f::Up();
    vertices(0).position_ = (vertices(0).normal_ * sphere.radius_) + sphere.center_;
    vertices(0).texture_coordinate_ = math::Vec2f(0.0F, 1.0F);
    for(uint32_t lat = 0; lat < latitude_count; ++lat) {
        float a1 = math::kPi * static_cast(lat + 1) / (latitude_count + 1);
        float sin1 = math::Sin(a1);
        float cos1 = math::Cos(a1);
        for(uint32_t lon = 0; lon <= longitude_count; ++lon) {
            float a2 = math::kTwoPi * static_cast(lon == longitude_count ? 0 : lon) / longitude_count;
            float sin2 = math::Sin(a2);
            float cos2 = math::Cos(a2);
            Vertex vertex{};
            vertex.normal_.x_ = sin1 * cos2;
            vertex.normal_.y_ = cos1;
            vertex.normal_.z_ = sin1 * sin2;
            vertex.position_ = (vertex.normal_ * sphere.radius_) + sphere.center_;
            vertex.texture_coordinate_.x_ = static_cast(lon) / longitude_count;
            vertex.texture_coordinate_.y_ = static_cast(lat) / latitude_count;
            vertices(lon + lat * (longitude_count + 1) + 1) = vertex;
        }
    }
    vertices(vertex_count - 1).normal_ = math::Vec3f::Down();
    vertices(vertex_count - 1).position_ = (vertices(vertex_count - 1).normal_ * sphere.radius_) + sphere.center_;
    vertices(vertex_count - 1).texture_coordinate_ = math::Vec2f::Zero();

    // Generate Indices
    // Top
    for (uint32_t lon = 0; lon < longitude_count; ++lon) {
        indices.push_back(lon + 2);
        indices.push_back(lon + 1);
        indices.push_back(0);
    }

    // Middle
    for(uint32_t lat = 0; lat < latitude_count - 1; ++lat) {
        for(uint32_t lon = 0; lon < longitude_count; ++lon) {
            const uint32_t current = lon + lat * (longitude_count + 1) + 1;
            const uint32_t next = current + longitude_count + 1;

            indices.push_back(current);
            indices.push_back(current + 1);
            indices.push_back(next + 1);

            indices.push_back(current);
            indices.push_back(next + 1);
            indices.push_back(next);
        }
    }

    // Bottom
    for (uint32_t lon = 0; lon < longitude_count; ++lon) {
        indices.push_back(vertex_count - 1);
        indices.push_back(vertex_count - (lon + 2) - 1);
        indices.push_back(vertex_count - (lon + 1) - 1);
    }
}

The following is the OpenGL mesh rendering code. I have omitted the shader program and the configuration code.

... set view port ... 
... clear color/depth/stencil buffers ... 
... create/use shader program and set uniforms ... 
glGenVertexArrays(1, &vao_);
glGenBuffers(1, &vbo_);
glGenBuffers(1, &ebo_);

glBindVertexArray(vao_);

// Set vertex data
glBindBuffer(GL_ARRAY_BUFFER, vbo_);
glBufferData(GL_ARRAY_BUFFER,
             vertices_.size() * sizeof(decltype(vertices_)::value_type),
             vertices_.data(),
             GL_STATIC_DRAW);

// Set index data
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo_);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
             indices_.size() * sizeof(decltype(indices_)::value_type),
             indices_.data(),
             GL_STATIC_DRAW);

// Set vertex attribute pointers
// Position
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position_));
// Normal
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, normal_));
// Texture Coordinate
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, texture_coordinate_));

glDrawArrays(GL_TRIANGLES, 0, indices_.size());