Skip to content

Instantly share code, notes, and snippets.

View mkhatib's full-sized avatar

Mohammad Khatib mkhatib

View GitHub Profile
@mkhatib
mkhatib / geopoint.py
Last active March 28, 2023 08:15
A small class that represents a basic geolocation point and have a method to generate random points around that point given a radius and count.
"""A simple GeoPoint object to generate random points nearby."""
import math
import random
class GeoPoint(object):
"""Represents a geolocation point with latitude and longitude."""
@mkhatib
mkhatib / geo.js
Created May 24, 2013 02:55
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {