{"id":28203911,"url":"https://github.com/gujarats/generatelocation","last_synced_at":"2025-06-10T14:30:45.171Z","repository":{"id":61627542,"uuid":"83192097","full_name":"Gujarats/GenerateLocation","owner":"Gujarats","description":"Generate New Latitude and Longitude from given Location.","archived":false,"fork":false,"pushed_at":"2017-05-07T09:56:15.000Z","size":41,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"v1","last_synced_at":"2025-05-17T03:15:21.654Z","etag":null,"topics":["algorithm","generator","latitude-and-longitude","location"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gujarats.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-26T07:48:05.000Z","updated_at":"2017-05-23T05:59:29.000Z","dependencies_parsed_at":"2022-10-18T17:45:31.429Z","dependency_job_id":null,"html_url":"https://github.com/Gujarats/GenerateLocation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gujarats%2FGenerateLocation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gujarats%2FGenerateLocation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gujarats%2FGenerateLocation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gujarats%2FGenerateLocation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gujarats","download_url":"https://codeload.github.com/Gujarats/GenerateLocation/tar.gz/refs/heads/v1","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gujarats%2FGenerateLocation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259092520,"owners_count":22804029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","generator","latitude-and-longitude","location"],"created_at":"2025-05-17T03:16:07.822Z","updated_at":"2025-06-10T14:30:45.155Z","avatar_url":"https://github.com/Gujarats.png","language":"Go","readme":"# Generate Random Location [![Build Status](https://secure.travis-ci.org/Gujarats/GenerateLocation.png)](http://travis-ci.org/Gujarats/GenerateLocation) [![GoDoc](https://godoc.org/gopkg.in/gujarats/GenerateLocation?status.svg)](https://godoc.org/gopkg.in/gujarats/GenerateLocation.v1)\nThis Library is creating random location from given location. the result will be in decimal degree.\nfor example if you have a base location like `48.8588377,2.2775176`. You can generate new location using this library.\n\n## How To Use It\n\nFirst Download the repository\n```shell\n$ go get gopkg.in/gujarats/GenerateLocation.v1\n```\n\nAnd Import to your project \n```go\nimport \"gopkg.in/gujarats/GenerateLocation.v1\" // refers as location\n```\n\n### Example 1\nAnother way to Genereate new latitude longitude : \n```go\n\n// insert dummy location from latitude and longitude.\nfunc insertDummyMarkLocation(cityName string, city *cityModel.City) {\n\t// some location in Bandung\n\tlat := -6.8647721\n\tlon := 107.553501\n        loc := location.New(lat,lon)\n\n\t// geneerate location with distance 1 km in every point and limit lenght 50 km.\n\t// so it will be (50/1)^2 = 2500 district\n\tnewLocations = loc.GenerateLocation(1, 50)\n}\n\n```\n\n### Example 2\nlet's say we wanted to generate new location based on the following latitude and longitude : `48.8588377,2.2775176` we can do this by using this code snippet : \n```go\npackage driver\n\nimport (\n    \"gopkg.in/gujarats/GenerateLocation.v1\"\n\t\"github.com/icrowley/fake\" // used for generate random names.\n)\n\n// We created Driver struct in this case for creating driver data with random names and location.\ntype Driver struct {\n\tName   string  `json:\"name\"`\n\tLat    float64 `json:\"lat\"`\n\tLon    float64 `json:\"lon\"`\n\tStatus bool    `json:\"status\"`\n}\n\n// Generate dummy drivers this will return []Driver with given sum.\n// with new location from latitude and longitude given.\nfunc GenereateDriver(lat, lon float64, sum int) []Driver {\n\tvar drivers []Driver\n\tloc := location.New(lat, lon)\n\n\t// get 50 % of the sum data\n\tsmallPercentage := (50.0 / 100.0) * float64(sum)\n\tpercentData := int(smallPercentage)\n\n\t// random lat lon based on seconds\n\tfor i := 0; i \u003c= sum; i++ {\n\t\tif sum-i \u003c= percentData {\n\t\t\t// generate lat and lon using minute. from specific number 1-3\n\t\t\tlat, lon := loc.RandomLatLongMinute(4)\n\t\t\tdummyDriver := Driver{\n\t\t\t\tName:   fake.FullName(),\n\t\t\t\tLat:    lat,\n\t\t\t\tLon:    lon,\n\t\t\t\tStatus: false,\n\t\t\t}\n\t\t\tdrivers = append(drivers, dummyDriver)\n\t\t} else {\n\t\t\t// generate lat and lon using seconds. from specific number 1-6\n\t\t\tlat, lon := loc.RandomLatLongSeconds(7)\n\t\t\tdummyDriver := Driver{\n\t\t\t\tName:   fake.FullName(),\n\t\t\t\tLat:    lat,\n\t\t\t\tLon:    lon,\n\t\t\t\tStatus: true,\n\t\t\t}\n\t\t\tdrivers = append(drivers, dummyDriver)\n\t\t}\n\n\t}\n\n\treturn drivers\n}\n```\n\n## Contribution\nI'm open to any improvement so please give your pull request if you have one :D.\n### thanks to\n* [Rolfl](http://codereview.stackexchange.com/a/156380/80799)\nfor his review.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgujarats%2Fgeneratelocation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgujarats%2Fgeneratelocation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgujarats%2Fgeneratelocation/lists"}