{"id":26285615,"url":"https://github.com/grumlimited/geocalc","last_synced_at":"2025-05-07T14:41:25.195Z","repository":{"id":56694099,"uuid":"5372062","full_name":"grumlimited/geocalc","owner":"grumlimited","description":"Helper classes to calculate Earth distances, bearing, etc.","archived":false,"fork":false,"pushed_at":"2020-10-24T18:36:16.000Z","size":132,"stargazers_count":110,"open_issues_count":3,"forks_count":39,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-31T11:02:19.117Z","etag":null,"topics":["azimuth","bearing","distance","earth","geocalc","geodesy","haversine","haversine-formula","java","meters","midpoint","standpoint","vincenty","vincenty-formula"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grumlimited.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-10T17:08:49.000Z","updated_at":"2025-01-11T17:50:55.000Z","dependencies_parsed_at":"2022-08-15T23:30:51.955Z","dependency_job_id":null,"html_url":"https://github.com/grumlimited/geocalc","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grumlimited%2Fgeocalc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grumlimited%2Fgeocalc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grumlimited%2Fgeocalc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grumlimited%2Fgeocalc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grumlimited","download_url":"https://codeload.github.com/grumlimited/geocalc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252897355,"owners_count":21821427,"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":["azimuth","bearing","distance","earth","geocalc","geodesy","haversine","haversine-formula","java","meters","midpoint","standpoint","vincenty","vincenty-formula"],"created_at":"2025-03-14T19:34:58.349Z","updated_at":"2025-05-07T14:41:25.160Z","avatar_url":"https://github.com/grumlimited.png","language":"Java","readme":"Java Geocalc ![travis](https://travis-ci.org/grumlimited/geocalc.svg?branch=master \"build\")\n=======\n\nGeocalc is a simple java library aimed at doing arithmetics with Earth coordinates. \nIt is designed to be simple to embed in your existing applications and easy to use. \n\nGeocalc can:\n\n1. Calculate the distance between two coordinates (law of cosines, haversine and vincenty)\n2. Find a point at X distance from a standpoint, given a bearing\n3. Calculate coordinates of a rectangular area around a point\n4. Determine whether a Point is contained within that area\n5. Calculate the azimuth, initial and final bearings between two points (vincenty)\n\nThis library is being used on [rentbarometer.com](https://www.rentbarometer.com).\n\nThis library implements in Java lots of ideas from [Movable-Type](http://www.movable-type.co.uk/scripts/latlong.html). Many thanks.\n\n### Embed\n\n    \u003crepositories\u003e\n        \u003crepository\u003e\n            \u003cid\u003ejitpack.io\u003c/id\u003e\n            \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n        \u003c/repository\u003e\n    \u003c/repositories\u003e\n\n\n    \u003cdependency\u003e\n\t    \u003cgroupId\u003ecom.github.grumlimited\u003c/groupId\u003e\n\t    \u003cartifactId\u003egeocalc\u003c/artifactId\u003e\n\t    \u003cversion\u003e0.6\u003c/version\u003e\n\t\u003c/dependency\u003e\n\t\nPlease refer to [jitpack.io/#grumlimited/geocalc/0.6](https://jitpack.io/#grumlimited/geocalc/0.6) for more information\n\n## API\n\ncan be found here:\n\n[grumlimited.co.uk/geocalc/0.6](https://www.grumlimited.co.uk/geocalc/0.6)\n\n## Usage\n\n### Creating a Point\n\n    //Kew, London\n    Coordinate lat = Coordinate.fromDegrees(51.4843774);\n    Coordinate lng = Coordinate.fromDegrees(-0.2912044);\n    Point kew = Point.at(lat, lng);\n\n### Converting between systems\n\nAllows conversion of a coordinate between degrees, radians, D-M-s and GPS systems,\n\n    double radians = degreeCoordinate.toRadianCoordinate().radians;\n    \n    double minutes = degreeCoordinate.toDMSCoordinate().minutes;\n    double seconds = degreeCoordinate.toDMSCoordinate().seconds;\n    double wholeDegrees = degreeCoordinate.toDMSCoordinate().wholeDegrees;\n    \n    minutes = degreeCoordinate.toGPSCoordinate().minutes;\n    seconds = degreeCoordinate.toGPSCoordinate().seconds; // always 0\n    wholeDegrees = degreeCoordinate.toGPSCoordinate().wholeDegrees;\n    \nback and forth\n\n    Coordinate.fromDegrees(-46.5456)\n        .toDMSCoordinate()\n        .toGPSCoordinate()\n        .toRadianCoordinate()\n        .decimalDegrees // toGPSCoordinate() implied loss of precision\n\n### Distance between 2 points\n\n#### Spherical law of cosines\n\n    //Kew, London\n    Coordinate lat = Coordinate.fromDegrees(51.4843774);\n    Coordinate lng = Coordinate.fromDegrees(-0.2912044);\n    Point kew = Point.at(lat, lng);\n\n    //Richmond, London\n    lat = Coordinate.fromDegrees(51.4613418);\n    lng = Coordinate.fromDegrees(-0.3035466);\n    Point richmond = Point.at(lat, lng);\n\n    double distance = EarthCalc.gcd.distance(richmond, kew); //in meters\n    \n#### Haversine formula\n\n    //Kew, London\n    Coordinate lat = Coordinate.fromDegrees(51.4843774);\n    Coordinate lng = Coordinate.fromDegrees(-0.2912044);\n    Point kew = Point.at(lat, lng);\n\n    //Richmond, London\n    lat = Coordinate.fromDegrees(51.4613418);\n    lng = Coordinate.fromDegrees(-0.3035466);\n    Point richmond = Point.at(lat, lng);\n\n    double distance = EarthCalc.haversine.distance(richmond, kew); //in meters\n    \n#### Vincenty formula\n    \n    //Kew, London\n    Coordinate lat = Coordinate.fromDegrees(51.4843774);\n    Coordinate lng = Coordinate.fromDegrees(-0.2912044);\n    Point kew = Point.at(lat, lng);\n\n    //Richmond, London\n    lat = Coordinate.fromDegrees(51.4613418);\n    lng = Coordinate.fromDegrees(-0.3035466);\n    Point richmond = Point.at(lat, lng);\n\n    double distance = EarthCalc.vincenty.distance(richmond, kew); //in meters\n    \n    \n### Finding a point at 'distance in meters away' from a standpoint, given a bearing\n\n`otherPoint` will be 1000m away from Kew\n\n    //Kew\n    Coordinate lat = Coordinate.fromDegrees(51.4843774);\n    Coordinate lng = Coordinate.fromDegrees(-0.2912044);\n    Point kew = Point.at(lat, lng);\n    \n    //Distance away point, bearing is 45deg\n    Point otherPoint = EarthCalc.gcd.pointAt(kew, 45, 1000);\n    \n### BoundingArea\n\n#### Calculating a rectangular area (BoundingArea) around a point\n\nThis is useful when, having a reference point, and a large set of \nother points, you need to figure out which ones are at most, say, 3000 meters away.\n\nWhile this only gives an approximation, it is several order of magnitude faster\nthan calculating the distances from each point in the set to the reference point.\n\n      BoundingArea area = EarthCalc.gcd.boundingArea(kew, 3000);\n      Point nw = area.northWest;\n      Point se = area.southEast;\n      \nNow, given that rectangle delimited by 'nw' and 'se', you can determine which points in your set are within these boundaries.\n\n#### Determining whether a Point is contained within a BoundingArea\n\nNow say you have a BoundingArea,\n\n      //somewhere in Europe, not sure where ;-)\n      Point northEast = Point.at(Coordinate.fromDegrees(70), Coordinate.fromDegrees(145));\n      Point southWest = Point.at(Coordinate.fromDegrees(50), Coordinate.fromDegrees(110));\n      BoundingArea boundingArea = BoundingArea.at(northEast, southWest);\n      \nyou can determine whether a point is contained within that area using:\n      \n      Point point1 = Point.at(Coordinate.fromDegrees(60), Coordinate.fromDegrees(120));\n      assertTrue(boundingArea.contains(point1)); //true\n      \n      Point point2 = Point.at(Coordinate.fromDegrees(45), Coordinate.fromDegrees(120));\n      assertFalse(boundingArea.contains(point2)); //false\n\n### Bearing between two points\n\n#### Azimuth bearing - great circle path\n\n    //Kew\n    Coordinate lat = Coordinate.fromDegrees(51.4843774);\n    Coordinate lng = Coordinate.fromDegrees(-0.2912044);\n    Point kew = Point.at(lat, lng);\n    \n    //Richmond, London\n    lat = Coordinate.fromDegrees(51.4613418);\n    lng = Coordinate.fromDegrees(-0.3035466);\n    Point richmond = Point.at(lat, lng);\n    \n    double bearing = EarthCalc.gcd.bearing(kew, richmond); //in decimal degrees\n\n#### Azimuth bearing - Vincenty formula\n\n    //Kew\n    Coordinate lat = Coordinate.fromDegrees(51.4843774);\n    Coordinate lng = Coordinate.fromDegrees(-0.2912044);\n    Point kew = Point.at(lat, lng);\n    \n    //Richmond, London\n    lat = Coordinate.fromDegrees(51.4613418);\n    lng = Coordinate.fromDegrees(-0.3035466);\n    Point richmond = Point.at(lat, lng);\n    \n    double bearing = EarthCalc.vincenty.bearing(kew, richmond); //in decimal degrees\n    \n#### Final bearing - Vincenty formula\n\n    //Kew\n    Coordinate lat = Coordinate.fromDegrees(51.4843774);\n    Coordinate lng = Coordinate.fromDegrees(-0.2912044);\n    Point kew = Point.at(lat, lng);\n    \n    //Richmond, London\n    lat = Coordinate.fromDegrees(51.4613418);\n    lng = Coordinate.fromDegrees(-0.3035466);\n    Point richmond = Point.at(lat, lng);\n    \n    double bearing = EarthCalc.vincenty.finalBearing(kew, richmond); //in decimal degrees\n\n#### Mid point - This is the half-way point along a great circle path between the two points.\n\n    //Kew\n    Point kew = Point.at(Coordinate.fromDegrees(51.4843774), Coordinate.fromDegrees(-0.2912044));\n\n    //Richmond, London\n    Point richmond = Point.at(Coordinate.fromDegrees(51.4613418), Coordinate.fromDegrees(-0.3035466));\n    \n    Point midPoint = EarthCalc.gcd.midPoint(richmond, kew) // Point{latitude=51.47285976194266, longitude=-0.2973770580524634}\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrumlimited%2Fgeocalc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrumlimited%2Fgeocalc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrumlimited%2Fgeocalc/lists"}