Git Product home page Git Product logo

jgeohash's Introduction

Overview

build status Java CI build and test Coverage 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

This project is kept as an open source product and relies on contributions to remain being developed. If you like this library, please consider a donation

over paypal:

PayPal this

or over bitcoin(BTC) with this address:

bc1ql2y99q7e8psndhcc3gferk03esw3qqf677rhjy

Donation Bitcoin Wallet

or over FIO with this address:

FIO7tFMUVAA9cHiPPqKMfMXiSxHrbpiFyRYqTketNuM67aULuwjop

Donation FIO Wallet

or over Ethereum(ETH) with:

0xc057D159D3C8f3311E73568b334FF6fE82EB2b7D

Donation Ethereum Wallet

or over Ethereum Classic(ETC) with:

0xF708cA86D86C246B69c3F4BAe431eBbe0c2bfddD

Donation Ethereum Classic Wallet

or over Dogecoin(DOGE) with:

D5yi4Um8cpakd6yPRm2hGWuQ5nrVzhSSW1

Donation Dogecoin Wallet

or over Monero(XMR) with:

49bqeRQ7Bf49oJFVC72pqpe5hFbb62pfXDYPdLsadGGF81KZW2ZfrPZ8PbAVu5X2v1TYAspeczMya3cYQysNS4usRRPQHVw

Donation Monero Wallet

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

javadoc

jgeohash-core Javadocs

jgeohash-geoip Javadocs

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

jgeohash's People

Contributors

astrapi69 avatar bitdeli-chef avatar carldea avatar jimmymaci avatar marie-christin avatar shisheng-1 avatar tatjana19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jgeohash's Issues

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

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 (
)

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.