Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.Vineeth-Mohan:OfflineReverseGeocode:1.0'
}
dependencies {
implementation("com.github.Vineeth-Mohan:OfflineReverseGeocode:1.0")
}
<dependency>
<groupId>com.github.Vineeth-Mohan</groupId>
<artifactId>OfflineReverseGeocode</artifactId>
<version>1.0</version>
</dependency>
libraryDependencies += "com.github.Vineeth-Mohan" % "OfflineReverseGeocode" % "1.0"
:dependencies [[com.github.Vineeth-Mohan/OfflineReverseGeocode "1.0"]]
An Offline Reverse Geocoding Java library
Uses KD-Trees for extremely fast placename lookups
Licensed under The MIT License
A C# port by Necrolis is available at https://github.com/Necrolis/GeoSharp
Usage:
First download a placenames file from http://download.geonames.org/export/dump/
Allcountries.zip from that site is comprehensive however if you're on mobile try the cities1000.zip file. It's 1/80th of the size.
Then simply
ReverseGeoCode reverseGeoCode = new ReverseGeoCode(new FileInputStream("c:\\AU.txt"), true);
System.out.println("Nearest to -23.456, 123.456 is " + geocode.nearestPlace(-23.456, 123.456));