Skip to content

Self-contained Java Library for Country Localization of GeoHashes

License

Notifications You must be signed in to change notification settings

adrianulbona/cloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloc

Build Status Maven Central

This is a self-contained Java library able to do country localization based on geohashes.

The project puts together discretized borders in a trie data structure.

Gradle

compile 'io.github.adrianulbona:cloc:0.3.2'

Maven

<dependency>
    <groupId>io.github.adrianulbona</groupId>
    <artifactId>cloc</artifactId>
    <version>0.3.2</version>
</dependency>

Code sample - Java

final CountryLocator countryLocator = CountryLocator.create();
final List<String> countries = countryLocator.locate("u10hb1"); // ["United Kingdom"]

Code sample - Scala - Spark

val locator = spark.sparkContext.broadcast(CountryLocator.create())
val locate = udf { (geohash: String) => locator.value.locate(geohash).asScala }

val pointsDF: DataFrame = Seq(
  Point("u10hb1", 51.47, 0.00),
  Point("u33ff3", 52.52, 13.81)).toDF

pointsDF.withColumn("countries", locate($"geohash"))
  .show()
  
// +-------+-----+-----+----------------+
// |geohash|  lat|  lon|       countries|
// +-------+-----+-----+----------------+
// | u10hb1|51.47|  0.0|[United Kingdom]|
// | u33ff3|52.52|13.81|       [Germany]|
// +-------+-----+-----+----------------+

About

Self-contained Java Library for Country Localization of GeoHashes

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages