All Projects → grumlimited → Geocalc

grumlimited / Geocalc

Licence: bsd-3-clause
Helper classes to calculate Earth distances, bearing, etc.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Geocalc

erkir
Երկիր (Erkir) - a C++ library for geodesic and trigonometric calculations
Stars: ✭ 26 (-70.45%)
Mutual labels:  distance, earth
Haversine
Calculate the distance bewteen 2 points on Earth
Stars: ✭ 166 (+88.64%)
Mutual labels:  earth, distance
Geolocator
A utility for getting geo-location information via HTML5 and IP look-ups, geocoding, address look-ups, distance and durations, timezone information and more...
Stars: ✭ 598 (+579.55%)
Mutual labels:  distance
Sweet
Official repository for Semantic Web for Earth and Environmental Terminology (SWEET) Ontologies
Stars: ✭ 69 (-21.59%)
Mutual labels:  earth
Distance
This Distance PHP class can calculate the distance between two latitude/longitude locations using Math functions in PHP. No external API's are called.
Stars: ✭ 33 (-62.5%)
Mutual labels:  distance
Webglobe
基于HTML5原生WebGL实现的轻量级Google Earth三维地图引擎
Stars: ✭ 685 (+678.41%)
Mutual labels:  earth
Himawari 8 Chrome
🛰 Experience the latest image from the Himawari, GOES, Meteosat, and DSCOVR satellites
Stars: ✭ 48 (-45.45%)
Mutual labels:  earth
Whereami
Uses WiFi signals 📶 and machine learning to predict where you are
Stars: ✭ 4,878 (+5443.18%)
Mutual labels:  distance
Himawari Bg
🌏 Set the latest image from Himawari 8 as your desktop background.
Stars: ✭ 81 (-7.95%)
Mutual labels:  earth
Nlp xiaojiang
自然语言处理(nlp),小姜机器人(闲聊检索式chatbot),BERT句向量-相似度(Sentence Similarity),XLNET句向量-相似度(text xlnet embedding),文本分类(Text classification), 实体提取(ner,bert+bilstm+crf),数据增强(text augment, data enhance),同义句同义词生成,句子主干提取(mainpart),中文汉语短文本相似度,文本特征工程,keras-http-service调用
Stars: ✭ 954 (+984.09%)
Mutual labels:  distance
Earthlab.github.io
A site dedicated to tutorials, course and other learning materials and resources developed by the Earth Lab team
Stars: ✭ 62 (-29.55%)
Mutual labels:  earth
Foucluster
FouCluster compute distance among songs in frequency domains, and operate with clusters
Stars: ✭ 15 (-82.95%)
Mutual labels:  distance
Dtw
DTW (Dynamic Time Warping) python module
Stars: ✭ 770 (+775%)
Mutual labels:  distance
Geo Maps
🗺 High Quality GeoJSON maps programmatically generated.
Stars: ✭ 1,098 (+1147.73%)
Mutual labels:  earth
Webworldwind
The NASA WorldWind Javascript SDK (WebWW) includes the library and examples for creating geo-browser web applications and for embedding a 3D globe in HTML5 web pages.
Stars: ✭ 628 (+613.64%)
Mutual labels:  earth
Ahrs
Attitude and Heading Reference Systems in Python
Stars: ✭ 75 (-14.77%)
Mutual labels:  earth
Worldwindjava
The NASA WorldWind Java SDK (WWJ) is for building cross-platform 3D geospatial desktop applications in Java.
Stars: ✭ 526 (+497.73%)
Mutual labels:  earth
Distance.js
🚗 Small Library for calculating distances between points.
Stars: ✭ 10 (-88.64%)
Mutual labels:  distance
Deepdiff
Deep Difference and search of any Python object/data.
Stars: ✭ 985 (+1019.32%)
Mutual labels:  distance
Stopwords
Removes most frequent words (stop words) from a text content. Based on a Curated list of language statistics.
Stars: ✭ 83 (-5.68%)
Mutual labels:  distance

Java Geocalc travis

Geocalc is a simple java library aimed at doing arithmetics with Earth coordinates. It is designed to be simple to embed in your existing applications and easy to use.

Geocalc can:

  1. Calculate the distance between two coordinates (law of cosines, haversine and vincenty)
  2. Find a point at X distance from a standpoint, given a bearing
  3. Calculate coordinates of a rectangular area around a point
  4. Determine whether a Point is contained within that area
  5. Calculate the azimuth, initial and final bearings between two points (vincenty)

This library is being used on rentbarometer.com.

This library implements in Java lots of ideas from Movable-Type. Many thanks.

Embed

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>


<dependency>
    <groupId>com.github.grumlimited</groupId>
    <artifactId>geocalc</artifactId>
    <version>0.6</version>
</dependency>

Please refer to jitpack.io/#grumlimited/geocalc/0.6 for more information

API

can be found here:

grumlimited.co.uk/geocalc/0.6

Usage

Creating a Point

//Kew, London
Coordinate lat = Coordinate.fromDegrees(51.4843774);
Coordinate lng = Coordinate.fromDegrees(-0.2912044);
Point kew = Point.at(lat, lng);

Converting between systems

Allows conversion of a coordinate between degrees, radians, D-M-s and GPS systems,

double radians = degreeCoordinate.toRadianCoordinate().radians;

double minutes = degreeCoordinate.toDMSCoordinate().minutes;
double seconds = degreeCoordinate.toDMSCoordinate().seconds;
double wholeDegrees = degreeCoordinate.toDMSCoordinate().wholeDegrees;

minutes = degreeCoordinate.toGPSCoordinate().minutes;
seconds = degreeCoordinate.toGPSCoordinate().seconds; // always 0
wholeDegrees = degreeCoordinate.toGPSCoordinate().wholeDegrees;

back and forth

Coordinate.fromDegrees(-46.5456)
    .toDMSCoordinate()
    .toGPSCoordinate()
    .toRadianCoordinate()
    .decimalDegrees // toGPSCoordinate() implied loss of precision

Distance between 2 points

Spherical law of cosines

//Kew, London
Coordinate lat = Coordinate.fromDegrees(51.4843774);
Coordinate lng = Coordinate.fromDegrees(-0.2912044);
Point kew = Point.at(lat, lng);

//Richmond, London
lat = Coordinate.fromDegrees(51.4613418);
lng = Coordinate.fromDegrees(-0.3035466);
Point richmond = Point.at(lat, lng);

double distance = EarthCalc.gcd.distance(richmond, kew); //in meters

Haversine formula

//Kew, London
Coordinate lat = Coordinate.fromDegrees(51.4843774);
Coordinate lng = Coordinate.fromDegrees(-0.2912044);
Point kew = Point.at(lat, lng);

//Richmond, London
lat = Coordinate.fromDegrees(51.4613418);
lng = Coordinate.fromDegrees(-0.3035466);
Point richmond = Point.at(lat, lng);

double distance = EarthCalc.haversine.distance(richmond, kew); //in meters

Vincenty formula

//Kew, London
Coordinate lat = Coordinate.fromDegrees(51.4843774);
Coordinate lng = Coordinate.fromDegrees(-0.2912044);
Point kew = Point.at(lat, lng);

//Richmond, London
lat = Coordinate.fromDegrees(51.4613418);
lng = Coordinate.fromDegrees(-0.3035466);
Point richmond = Point.at(lat, lng);

double distance = EarthCalc.vincenty.distance(richmond, kew); //in meters

Finding a point at 'distance in meters away' from a standpoint, given a bearing

otherPoint will be 1000m away from Kew

//Kew
Coordinate lat = Coordinate.fromDegrees(51.4843774);
Coordinate lng = Coordinate.fromDegrees(-0.2912044);
Point kew = Point.at(lat, lng);

//Distance away point, bearing is 45deg
Point otherPoint = EarthCalc.gcd.pointAt(kew, 45, 1000);

BoundingArea

Calculating a rectangular area (BoundingArea) around a point

This is useful when, having a reference point, and a large set of other points, you need to figure out which ones are at most, say, 3000 meters away.

While this only gives an approximation, it is several order of magnitude faster than calculating the distances from each point in the set to the reference point.

  BoundingArea area = EarthCalc.gcd.boundingArea(kew, 3000);
  Point nw = area.northWest;
  Point se = area.southEast;

Now, given that rectangle delimited by 'nw' and 'se', you can determine which points in your set are within these boundaries.

Determining whether a Point is contained within a BoundingArea

Now say you have a BoundingArea,

  //somewhere in Europe, not sure where ;-)
  Point northEast = Point.at(Coordinate.fromDegrees(70), Coordinate.fromDegrees(145));
  Point southWest = Point.at(Coordinate.fromDegrees(50), Coordinate.fromDegrees(110));
  BoundingArea boundingArea = BoundingArea.at(northEast, southWest);

you can determine whether a point is contained within that area using:

  Point point1 = Point.at(Coordinate.fromDegrees(60), Coordinate.fromDegrees(120));
  assertTrue(boundingArea.contains(point1)); //true
  
  Point point2 = Point.at(Coordinate.fromDegrees(45), Coordinate.fromDegrees(120));
  assertFalse(boundingArea.contains(point2)); //false

Bearing between two points

Azimuth bearing - great circle path

//Kew
Coordinate lat = Coordinate.fromDegrees(51.4843774);
Coordinate lng = Coordinate.fromDegrees(-0.2912044);
Point kew = Point.at(lat, lng);

//Richmond, London
lat = Coordinate.fromDegrees(51.4613418);
lng = Coordinate.fromDegrees(-0.3035466);
Point richmond = Point.at(lat, lng);

double bearing = EarthCalc.gcd.bearing(kew, richmond); //in decimal degrees

Azimuth bearing - Vincenty formula

//Kew
Coordinate lat = Coordinate.fromDegrees(51.4843774);
Coordinate lng = Coordinate.fromDegrees(-0.2912044);
Point kew = Point.at(lat, lng);

//Richmond, London
lat = Coordinate.fromDegrees(51.4613418);
lng = Coordinate.fromDegrees(-0.3035466);
Point richmond = Point.at(lat, lng);

double bearing = EarthCalc.vincenty.bearing(kew, richmond); //in decimal degrees

Final bearing - Vincenty formula

//Kew
Coordinate lat = Coordinate.fromDegrees(51.4843774);
Coordinate lng = Coordinate.fromDegrees(-0.2912044);
Point kew = Point.at(lat, lng);

//Richmond, London
lat = Coordinate.fromDegrees(51.4613418);
lng = Coordinate.fromDegrees(-0.3035466);
Point richmond = Point.at(lat, lng);

double bearing = EarthCalc.vincenty.finalBearing(kew, richmond); //in decimal degrees

Mid point - This is the half-way point along a great circle path between the two points.

//Kew
Point kew = Point.at(Coordinate.fromDegrees(51.4843774), Coordinate.fromDegrees(-0.2912044));

//Richmond, London
Point richmond = Point.at(Coordinate.fromDegrees(51.4613418), Coordinate.fromDegrees(-0.3035466));

Point midPoint = EarthCalc.gcd.midPoint(richmond, kew) // Point{latitude=51.47285976194266, longitude=-0.2973770580524634}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].