random Latitude - Android Map

Android examples for Map:Location

Description

random Latitude

Demo Code


//package com.java2s;

import java.util.Random;

public class Main {
    public static Double randomLat(Random rand) {
        return doubleRandomInclusive(-90.0, 90.0, rand);
    }//from  w ww .ja v a  2  s. c  o m

    public static Double doubleRandomInclusive(double min, double max,
            Random rand) {
        double num = rand.nextDouble();
        if (num < 0.5) {
            return ((1 - rand.nextDouble()) * (max - min) + min);
        }
        return (rand.nextDouble() * (max - min) + min);
    }
}

Related Tutorials