Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adrianulbona/cloc
Self-contained Java Library for Country Localization of GeoHashes
https://github.com/adrianulbona/cloc
apache-spark borders country geohash gis gps java scala
Last synced: 2 months ago
JSON representation
Self-contained Java Library for Country Localization of GeoHashes
- Host: GitHub
- URL: https://github.com/adrianulbona/cloc
- Owner: adrianulbona
- License: apache-2.0
- Created: 2016-09-05T15:47:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-28T10:55:08.000Z (over 6 years ago)
- Last Synced: 2023-07-03T23:41:06.576Z (over 1 year ago)
- Topics: apache-spark, borders, country, geohash, gis, gps, java, scala
- Language: Java
- Homepage:
- Size: 6.79 MB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cloc
[![Build Status](https://travis-ci.org/adrianulbona/cloc.svg?branch=master)](https://travis-ci.org/adrianulbona/cloc)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.adrianulbona/cloc/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.adrianulbona/cloc)This is a self-contained Java library able to do country localization based on [geohashes](https://en.wikipedia.org/wiki/Geohash).
The project puts together [discretized borders](http://adrianulbona.github.io/2017/01/25/borders.html) in a [trie](https://en.wikipedia.org/wiki/Trie) data structure.
## Gradle
```groovy
compile 'io.github.adrianulbona:cloc:0.3.2'
```## Maven
```xmlio.github.adrianulbona
cloc
0.3.2```
## Code sample - Java
```java
final CountryLocator countryLocator = CountryLocator.create();
final List countries = countryLocator.locate("u10hb1"); // ["United Kingdom"]
```## Code sample - Scala - Spark
```scala
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)).toDFpointsDF.withColumn("countries", locate($"geohash"))
.show()
// +-------+-----+-----+----------------+
// |geohash| lat| lon| countries|
// +-------+-----+-----+----------------+
// | u10hb1|51.47| 0.0|[United Kingdom]|
// | u33ff3|52.52|13.81| [Germany]|
// +-------+-----+-----+----------------+
```