Skip to content

Commit

Permalink
Merge pull request #2 from xavierguihot/dev/2.0.0
Browse files Browse the repository at this point in the history
Dev/2.0.0
  • Loading branch information
xavierguihot authored Jun 16, 2018
2 parents fc48696 + 32539d8 commit 15773c8
Show file tree
Hide file tree
Showing 20 changed files with 1,224 additions and 445 deletions.
77 changes: 46 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
## Overview


Version: 1.2.3

API Scaladoc: [GeoBase](http://xavierguihot.com/geobase/#com.geobase.GeoBase)
API Scaladoc: [GeoBase](http://xavierguihot.com/geobase/#com.geobase.GeoBase$)

Scala wrapper around opentraveldata (geo/travel data).

Expand Down Expand Up @@ -37,51 +35,65 @@ Inspired by [neobase](https://github.com/alexprengere/neobase) for python users.


The full list of methods is available at
[GeoBase doc](http://xavierguihot.com/geobase/#com.geobase.GeoBase)
[GeoBase doc](http://xavierguihot.com/geobase/#com.geobase.GeoBase$)

Here is a non-exhaustive list of available methods:

```scala
import com.geobase.GeoBase

val geoBase = new GeoBase()

assert(geoBase.city("CDG") == Success("PAR"))
assert(geoBase.country("CDG") == Success("FR"))
assert(geoBase.continent("JFK") == Success("NA"))
assert(geoBase.iataZone("LON") == Success("21"))
assert(geoBase.currency("NYC") == Success("USD"))
assert(geoBase.countryForAirline("AF") == Success("FR"))
assert(geoBase.timeZone("PAR") == Success("Europe/Paris"))
assert(geoBase.distanceBetween("PAR", "NCE") == Success(686))
assert(geoBase.localDateToGMT("20160606_2227", "NYC") == Success("20160607_0227"))
assert(geoBase.gmtDateToLocal("20160607_0227", "NYC") == Success("20160606_2227"))
assert(geoBase.offsetForLocalDate("20171224", "NYC") == Success(-300))
assert(geoBase.tripDurationFromLocalDates("20160606_1627", "CDG", "20160606_1757", "JFK") == Success(7.5d))
assert(geoBase.geoType(List("CDG", "TLS", "DUB", "FRA")) == Success(CONTINENTAL))
assert(geoBase.nearbyAirports("CDG", 50) == Success(List("LBG", "ORY", "VIY", "POX")))
assert(geoBase.nameOfAirline("AF") == Success("Air France"))
GeoBase.city("CDG") // Success("PAR")
GeoBase.country("CDG") // Success("FR")
GeoBase.continent("JFK") // Success("NA")
GeoBase.iataZone("LON") // Success("21")
GeoBase.currency("NYC") // Success("USD")
GeoBase.countryForAirline("AF") // Success("FR")
GeoBase.timeZone("PAR") // Success("Europe/Paris")
GeoBase.distanceBetween("PAR", "NCE") // Success(686)
GeoBase.localDateToGMT("20160606_2227", "NYC") // Success("20160607_0227")
GeoBase.gmtDateToLocal("20160607_0227", "NYC") // Success("20160606_2227")
GeoBase.offsetForLocalDate("20171224", "NYC") // Success(-300)
GeoBase.tripDurationFromLocalDates("20160606_1627", "CDG", "20160606_1757", "JFK") // Success(7.5d)
GeoBase.geoType(List("CDG", "TLS", "DUB", "FRA")) // Success(CONTINENTAL)
GeoBase.nearbyAirports("CDG", 50) // Success(List("LBG", "ORY", "VIY", "POX"))
GeoBase.nameOfAirline("AF") // Success("Air France")
```

These functions can also be called as attachments to Strings:

```scala
import com.geobase.GeoBase.StringExtensions

"CDG".city // Success("PAR")
"PAR".country // Success("FR")
"CDG".continent // Success("EU")
"CDG".iataZone // Success("21")
"JFK".currency // Success("USD")
"AF".name // Success("Air France")
"CDG".timeZone // Success("Europe/Paris")
"LON".distanceWith("NYC") // Success(5568)
"CDG".nearbyAirports(50) // Success(List("LBG", "ORY", "VIY", "POX"))
```

Getters all have a return type embedded within the Try monade. Throwing
Getters all have a return type embedded within the Try monad. Throwing
exceptions when one might request mappings for non existing locations, isn't
realy the idiomatic scala way, and simply embedding the result in the Option
monade doesn't give the user the possibility to understand what went wrong.
Thus the usage of the Try monade.
really the idiomatic scala way, and simply embedding the result in the Option
monad doesn't give the user the possibility to understand what went wrong.
Thus the usage of the Try monad.


## Including geobase to your dependencies:


With sbt, add these lines to your build.sbt:
With sbt:

```scala
resolvers += "jitpack" at "https://jitpack.io"

libraryDependencies += "com.github.xavierguihot" % "geobase" % "v1.2.3"
libraryDependencies += "com.github.xavierguihot" % "geobase" % "2.0.0"
```

With maven, add these lines to your pom.xml:
With maven:

```xml
<repositories>
Expand All @@ -94,11 +106,11 @@ With maven, add these lines to your pom.xml:
<dependency>
<groupId>com.github.xavierguihot</groupId>
<artifactId>geobase</artifactId>
<version>v1.2.3</version>
<version>2.0.0</version>
</dependency>
```

With gradle, add these lines to your build.gradle:
With gradle:

```groovy
allprojects {
Expand All @@ -108,10 +120,13 @@ allprojects {
}
dependencies {
compile 'com.github.xavierguihot:geobase:v1.2.3'
compile 'com.github.xavierguihot:geobase:2.0.0'
}
```

For versions anterior to `2.0.0`, use prefix `v` in the version tag; for
instance `v1.0.0`


## Building the project:

Expand Down
10 changes: 7 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "geobase"

version := "1.2.3"
version := "2.0.0"

scalaVersion := "2.11.12"

Expand Down Expand Up @@ -31,8 +31,12 @@ scalafmtOnCompile := true

val catsVersion = "1.0.1"
val scalatestVersion = "3.0.4"
val sparkVersion = "2.1.0"
val sparkTestVersion = "2.1.0_0.8.0"

libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsVersion,
"org.scalatest" %% "scalatest" % scalatestVersion % "test"
"org.typelevel" %% "cats-core" % catsVersion,
"org.scalatest" %% "scalatest" % scalatestVersion % "test",
"org.apache.spark" %% "spark-core" % sparkVersion % "test",
"com.holdenkarau" %% "spark-testing-base" % sparkTestVersion % "test"
)
Loading

0 comments on commit 15773c8

Please sign in to comment.