An easy-to-implement library for the GeoHash algorithm

Overview

Overview

build status Coverage Status open issues license apache2 Donate

An easy-to-implement library that can assist Java developers in using the GeoHash algorithm in order to create geocodes based on custom latitude and longitude values.

With the help of jGeohash, Java developers will be able to quickly and easily generate a geohash code using user-defined latitude and longitude values. By using the GeoHash algorithm, the space can be divided into multiple grid shapes.

This library is a basic implementation from the GeoHash algorithm written in the java and can be applied to generate from the latitude and longitude a geohash code and reverse.

The library is kept simple and have no dependencies to other libraries.

Please support this project by simply putting a Github Star . Share this library with friends on Twitter and everywhere else you can. If you love this project donation

Note

No animals were harmed in the making of this library.

Donations

If you like this library, please consider a donation through paypal: PayPal this

or over bitcoin or bitcoin-cash with:

36JxRRDfRazLNqUV6NsywCw1q7TK38ukpC

or over ether with:

0x588Aa02De98B1Ef70afeDC3ec5290130a3E5e273

or over flattr:

Flattr this

Key features:

  1. Very small size (<35Kb)
  2. Can get the adjacent geohash area from the given direction
  3. Can get the geohash from an ip address
  4. Can calculate distance between two geohash values in various measuring units like miles, km, meters
  5. Can get the geohash cells around from the first, second or thrird ring from a given geohash cell

License

The source code comes under the liberal Apache License V2.0, making jgeohash great for all types of applications.

Maven Central

Maven Central jgeohash-core

Maven Central jgeohash-geoip

javadoc

Javadocs jgeohash-core

Javadocs jgeohash-geoip

Maven dependency

Maven dependency is now on sonatype. Check out sonatype repository for latest snapshots and releases.

You can add the following maven dependencies to your project pom.xml if you want to import the library.

You can first define the version properties:

<properties>
	...
	<!-- JGEOHASH version -->
	<jgeohash.version>2.5.2</jgeohash.version>
	<jgeohash-core.version>${jgeohash.version}</jgeohash-core.version>
	<jgeohash-geoip.version>${jgeohash.version}</jgeohash-geoip.version>
	...
</properties>

Add the following maven dependency to your project pom.xml if you want to import the core functionality of jgeohash:

	<dependencies>
		...
        <!-- JGEOHASH-CORE DEPENDENCY -->
		<dependency>
			<groupId>de.alpharogroup</groupId>
			<artifactId>jgeohash-core</artifactId>
			<version>${jgeohash-core.version}</version>
		</dependency>
	</dependencies>

Add the following maven dependency to your project pom.xml if you want to import the geoip functionality of jgeohash:

	<dependencies>
		...
        <!-- JGEOHASH-GEOIP DEPENDENCY -->
		<dependency>
			<groupId>de.alpharogroup</groupId>
			<artifactId>jgeohash-geoip</artifactId>
			<version>${jgeohash-geoip.version}</version>
		</dependency>
	</dependencies>

Semantic Versioning

The versions of jgeohash are maintained with the Semantic Versioning guidelines.

Release version numbers will be incremented in the following format:

<major>.<minor>.<patch>

For detailed information on versioning for this project you can visit this wiki page.

Want to Help and improve it?

The source code for jGeohash are on GitHub. Please feel free to fork and send pull requests!

Create your own fork of astrapi69/jgeohash/fork

To share your changes, submit a pull request.

Don't forget to add new units tests on your changes.

Contacting the Developer

Do not hesitate to contact the jgeohash developers with your questions, concerns, comments, bug reports, or feature requests.

  • Feature requests, questions and bug reports can be reported at the issues page.

Examples

Similar projects

Here is a list of awesome projects that uses geohash:

  • geohash-java Another implementation of Geohashes in pure Java.
  • geo Geohash utitlies in java

Blogs

Useful links

Change log

The changelog is moved in its own file. It can be found on following page

Credits

Travis CI
Travis CI
build status
Special thanks to Travis CI for providing a free continuous integration service for open source projects
Nexus Sonatype repositories
sonatype repository jgeohash-core
sonatype repository jgeohash-geoip
Special thanks to sonatype repository for providing a free maven repository service for open source projects
coveralls.io
Coverage Status
Special thanks to coveralls.io for providing a free code coverage for open source projects
javadoc.io
Javadoc jgeohash-core
Javadoc jgeohash-geoip
Special thanks to javadoc.io for providing a free javadoc documentation for open source projects
Comments
  • Dependency issue with version 2.5

    Dependency issue with version 2.5

    Upgrading from version 2.4.0 to 2.5, it is giving me a compile time issue.

    [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception. [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong: [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':game:transformResourcesWithMergeJavaResForNightlyDebug'. [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > More than one file was found with OS independent path 'log4j.properties' [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try: [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 1m 33s

    I also tried adding this without any luck as this creates another similar issue without ending:

    packagingOptions{ exclude 'log4j.properties' }

    checking my project dependencies I notices that the dependencies from version 2.4.0 and 2.5 are quite substantial:

    2.4.0

    +--- de.alpharogroup:jgeohash-core:2.4.0 | +--- com.maxmind.geoip:geoip-api:1.2.14 | +--- org.projectlombok:lombok:1.16.16 | +--- org.slf4j:slf4j-log4j12:1.6.4 | | +--- org.slf4j:slf4j-api:1.6.4 | | --- log4j:log4j:1.2.16 | +--- org.slf4j:slf4j-api:1.6.4 | --- log4j:log4j:1.2.16

    2.5

    +--- de.alpharogroup:jgeohash-core:2.5 | +--- de.alpharogroup:jobject-merge:1.11 | | +--- de.alpharogroup:jobject-copy:1.11 | | | +--- commons-beanutils:commons-beanutils:1.9.3 | | | | +--- commons-logging:commons-logging:1.2 | | | | --- commons-collections:commons-collections:3.2.2 | | | +--- de.alpharogroup:jobject-core:1.11 | | | | +--- org.projectlombok:lombok:1.16.20 | | | | +--- org.slf4j:slf4j-api:1.7.25 | | | | +--- org.slf4j:slf4j-log4j12:1.7.25 | | | | | --- org.slf4j:slf4j-api:1.7.25 | | | | +--- org.apache.logging.log4j:log4j-api:2.11.0 | | | | --- org.apache.logging.log4j:log4j-core:2.11.0 | | | | --- org.apache.logging.log4j:log4j-api:2.11.0 | | | +--- org.projectlombok:lombok:1.16.20 | | | +--- org.slf4j:slf4j-api:1.7.25 | | | +--- org.slf4j:slf4j-log4j12:1.7.25 () | | | +--- org.apache.logging.log4j:log4j-api:2.11.0 | | | --- org.apache.logging.log4j:log4j-core:2.11.0 () | | +--- de.alpharogroup:jobject-core:1.11 () | | +--- commons-beanutils:commons-beanutils:1.9.3 () | | +--- org.projectlombok:lombok:1.16.20 | | +--- org.slf4j:slf4j-api:1.7.25 | | +--- org.slf4j:slf4j-log4j12:1.7.25 () | | +--- org.apache.logging.log4j:log4j-api:2.11.0 | | --- org.apache.logging.log4j:log4j-core:2.11.0 () | +--- com.maxmind.geoip:geoip-api:1.2.14 | +--- de.alpharogroup:jcommons-lang:4.34 | | +--- org.apache.commons:commons-collections4:4.1 | | +--- commons-io:commons-io:2.6 | | +--- commons-codec:commons-codec:1.11 | | +--- org.apache.commons:commons-lang3:3.7 | | +--- joda-time:joda-time:2.10 | | +--- de.alpharogroup:silly-collections:4.29 | | | +--- org.apache.commons:commons-collections4:4.1 | | | +--- de.alpharogroup:jobject-compare:1.11 | | | | +--- commons-beanutils:commons-beanutils:1.9.3 () | | | | +--- org.projectlombok:lombok:1.16.20 | | | | +--- org.slf4j:slf4j-api:1.7.25 | | | | +--- org.slf4j:slf4j-log4j12:1.7.25 () | | | | +--- org.apache.logging.log4j:log4j-api:2.11.0 | | | | --- org.apache.logging.log4j:log4j-core:2.11.0 () | | | +--- de.alpharogroup:jobject-core:1.11 () | | | +--- org.projectlombok:lombok:1.16.20 | | | +--- org.slf4j:slf4j-api:1.7.25 | | | +--- org.slf4j:slf4j-log4j12:1.7.25 () | | | +--- org.apache.logging.log4j:log4j-api:2.11.0 | | | --- org.apache.logging.log4j:log4j-core:2.11.0 () | | +--- de.alpharogroup:jobject-core:1.11 () | | +--- de.alpharogroup:jobject-diff:1.11 | | | +--- commons-beanutils:commons-beanutils:1.9.3 () | | | +--- de.alpharogroup:jobject-compare:1.11 () | | | +--- de.alpharogroup:jobject-core:1.11 () | | | +--- org.projectlombok:lombok:1.16.20 | | | +--- org.slf4j:slf4j-api:1.7.25 | | | +--- org.slf4j:slf4j-log4j12:1.7.25 () | | | +--- org.apache.logging.log4j:log4j-api:2.11.0 | | | --- org.apache.logging.log4j:log4j-core:2.11.0 () | | +--- org.projectlombok:lombok:1.16.20 | | +--- org.slf4j:slf4j-api:1.7.25 | | +--- org.slf4j:slf4j-log4j12:1.7.25 () | | +--- org.apache.logging.log4j:log4j-api:2.11.0 | | --- org.apache.logging.log4j:log4j-core:2.11.0 () | +--- org.projectlombok:lombok:1.16.20 | +--- org.slf4j:slf4j-api:1.7.25 | +--- org.slf4j:slf4j-log4j12:1.7.25 () | +--- org.apache.logging.log4j:log4j-api:2.11.0 | --- org.apache.logging.log4j:log4j-core:2.11.0 ()

    opened by codeskraps 7
  • Enhancement: Implement ScalarFunction to include in Phoenix/HBase for spatial functions

    Enhancement: Implement ScalarFunction to include in Phoenix/HBase for spatial functions

    Add an example implementation that would allow using jgeohash for spatial indexes in Phoenix/Hbase.
    https://phoenix.apache.org/udf.html#How_to_write_custom_UDF

    opened by threedliteguy 6
  • range queries or adjacent areas with bitwise accuracy

    range queries or adjacent areas with bitwise accuracy

    I want to do a range query with bitwise accuracy rather than 5 bit accuracy (by truncating the string to however many characters I like).

    The get adjacent areas is fantastic. It deals with the prime meridian and equator issues that would come up if I just did a range query by truncating to a specific number of bits.

    A simpler option would be to add methods that would convert the geohash to and from a long value. Then I could truncate to an arbitrary number of bits then pass that value to a getAllAdjacentAreasList method which had an additional parameter indicating how many bits the geohash was using.

    A more complex option would be to have a method like this: public static String[] getRange(String geohash, int numUnits, UnitType units) Normally that method would return 2 values that identify a range. If the range crossed over the equator and/or prime meridian then it would return as many ranges as necessary to cover the area.

    If it helps, my specific use case is as follows:

    • I want to query a Cassandra DB for all objects within X meters of a point.
    • The partition key would be the geohash truncated to 6 characters. That means a single partition could include an area up to 0.22 miles by 1.1 miles. All points would be duplicated into all 9 adjacent partitions so only a single query is required to retrieve all points within that area (just in case the point in question is right on the edge of the area).
    • However, I do not want to actually transfer every point in that area back from Cassandra to the querying server. I want to do a range query that uses the clustering key to exclude as many points as possible. Ideally this means that I'd have 2 geohash values that would bound the range I'm looking for. If it crosses the prime meridian or equator then I guess 2 queries would be necessary.

    I suppose that instead of this I could simply create a different table for every different resolution that I want to query for, but that would still require bitwise accuracy. In that case I'd still need the ability to get adjacent areas given a specific number of bits.

    If I'm off the mark and there's a simple alternative then I'd love to hear about it.

    opened by EclecticEngineer 5
  • Improve GRADLE build Performance

    Improve GRADLE build Performance

    Parallel builds. This project contains multiple modules. Parallel builds can improve the build speed by executing tasks in parallel. We can enable this feature by setting org.gradle.parallel=true.

    File system watching. Since Gradle 6.5, File system watching was introduced which can help to avoid unnecessary I/O. This feature is the default since 7.0. For an older version, we can enable this feature by setting org.gradle.vfs.watch=true.

    Configuration on demand. Configuration on demand tells Gradle to configure modules that only are relevant to the requested tasks instead of configuring all of them. We can enable this feature by setting org.gradle.configureondemand=true.

    gradle caching. Shared caches can reduce the number of tasks you need to execute by reusing outputs already generated elsewhere. This can significantly decrease build times. We can enable this feature by setting org.gradle.caching=true.

    ===================== If there are any inappropriate modifications in this PR, please give me a reply and I will change them.

    opened by shisheng-1 4
  • GeoHashUtils can not find class

    GeoHashUtils can not find class

    I‘m usring your jgeohash,and the version is 2.3.0 first,thanks to you and i write my program like your example

    GeoHashUtils.encode(53.5526394, 10.0067103);

    but it just cann't resolve class GeoHashUtils i doubt whether the version problem

    opened by LuoYuWuSheng 1
Owner
Asterios Raptis
"Knowing how to think empowers you far beyond those who know only what to think." - Niel deGrasse Tyson
Asterios Raptis
Geohash utitlies in java

geo Java utility methods for geohashing. Status: production, available on Maven Central Maven site reports are here including javadoc. Add this to you

Dave Moten 386 Jan 1, 2023
Open source routing engine for OpenStreetMap. Use it as Java library or server.

GraphHopper Routing Engine GraphHopper is a fast and memory efficient Java routing engine, released under Apache License 2.0. By default it uses OpenS

GraphHopper 4k Jan 3, 2023
Vector map library and writer - running on Android and Desktop.

Mapsforge See the integration guide and changelog. And read through how to contribute guidelines. If you have any questions or problems, don't hesitat

mapsforge 1k Dec 30, 2022
LocationTech Spatial4j: A Geospatial Library for Java

Spatial4j (note: Spatial4j's official home page is at LocationTech: https://projects.eclipse.org/projects/locationtech.spatial4j but this README has r

LocationTech 880 Dec 23, 2022
The JTS Topology Suite is a Java library for creating and manipulating vector geometry.

JTS Topology Suite The JTS Topology Suite is a Java library for creating and manipulating vector geometry. It also provides a comprehensive set of geo

LocationTech 1.5k Jan 6, 2023
Vector map library and writer - running on Android and Desktop.

Mapsforge See the integration guide and changelog. And read through how to contribute guidelines. If you have any questions or problems, don't hesitat

mapsforge 1k Jan 7, 2023
LocationTech Spatial4j: A Geospatial Library for Java

Spatial4j (note: Spatial4j's official home page is at LocationTech: https://projects.eclipse.org/projects/locationtech.spatial4j but this README has r

LocationTech 880 Dec 23, 2022
Reference implementation for MINAS (MultI-class learNing Algorithm for data Streams), an algorithm to address novelty detection in data streams multi-class problems.

Reference implementation for MINAS (MultI-class learNing Algorithm for data Streams), an algorithm to address novelty detection in data streams multi-class problems.

Douglas M. Cavalcanti 4 Sep 7, 2022
Presti 5 Nov 19, 2022
🐀 Simple, Fast and easy to implement ORM for most popular databases

RatORM Simple, Fast and easy to implement ORM for most popular databases Status: Branch Tests Code Quality master Usefull links Helpful links: GitHub

Szczurowsky 3 Dec 25, 2022
Geohash utitlies in java

geo Java utility methods for geohashing. Status: production, available on Maven Central Maven site reports are here including javadoc. Add this to you

Dave Moten 385 Dec 27, 2022
Geohash utitlies in java

geo Java utility methods for geohashing. Status: production, available on Maven Central Maven site reports are here including javadoc. Add this to you

Dave Moten 386 Jan 1, 2023
Geohash utitlies in java

geo Java utility methods for geohashing. Status: production, available on Maven Central Maven site reports are here including javadoc. Add this to you

Dave Moten 386 Jan 1, 2023
With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any other file server

React Native In-App update With react-native-update-in-app library you can easily implement in-app updates in your React Native app using CDN or any o

Nepein Andrey 7 Dec 21, 2022
Easy-es - easy use for elastich search

Born To Simplify Development What is Easy-Es? Easy-Es is a powerfully enhanced toolkit of RestHighLevelClient for simplify development. This toolkit p

null 777 Jan 6, 2023
shiro only provide the support of ehcache and concurrentHashMap. Here is an implement of redis cache can be used by shiro. Hope it will help you!

shiro only provide the support of ehcache and concurrentHashMap. Here is an implement of redis cache can be used by shiro. Hope it will help you!

alex 1.1k Dec 18, 2022
HUAWEI 3D Modeling Kit project contains a sample app. Guided by this demo, you will be able to implement full 3D Modeling Kit capabilities, including 3D object reconstruction and material generation.

HUAWEI 3D Modeling Kit Sample English | 中文 Introduction This project includes apps developed based on HUAWEI 3D Modeling Kit. The project directory is

HMS 59 Jan 1, 2023
Forge example mod showing how to implement native hwid.

auth-client What is this? A forge mod showing how to use this How to use? Copy into your mod or use the base and make your own. You have to compile th

Jake Priddle 6 Jul 1, 2021
Understand Server-Sent Events (SSE), analyze its principle, and implement custom SSE.

custom-sse Email:[email protected] Github:https://github.com/JorringHsiao QQ:3129600569 ?? 关键词:SSE, 服务端推送, 实时推送, 进度条 ?? 本项目的目的 以进度条的功能需求为例,引出

JorringHsiao 17 Oct 18, 2021
How To Implement Fault Tolerance In Microservices Using Resilience4j

springboot-resilience4j-demo How To Implement Fault Tolerance In Microservices Using Resilience4j? Things todo list: Clone this repository: git clone

Hendi Santika 4 Mar 30, 2022