Skip to content

Commit

Permalink
Shorten api methods' name - add timeZone getter - switch for geoType …
Browse files Browse the repository at this point in the history
…from enum to case objects
  • Loading branch information
xavierguihot committed Jan 27, 2018
1 parent 6352102 commit 78abb25
Show file tree
Hide file tree
Showing 32 changed files with 2,820 additions and 1,473 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: scala
scala:
- 2.10.4
- 2.11.8
- 2.11.12
install: ./update_data.sh
script: "sbt clean coverage test"
after_success: "sbt coverageReport coveralls"
Expand Down
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Overview


Version: 1.1.3
Version: 1.2.0

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

Expand Down Expand Up @@ -39,20 +39,27 @@ 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)

Here is a non-exhaustive list of examples:
Here is a non-exhaustive list of available methods:

```scala
import com.geobase.GeoBase

val geoBase = new GeoBase()

assert(geoBase.getCityFor("CDG") == Success("PAR"))
assert(geoBase.getCountryFor("CDG") == Success("FR"))
assert(geoBase.getCountryForAirline("AF") == Success("FR"))
assert(geoBase.getCurrencyFor("NYC") == Success("USD"))
assert(geoBase.getDistanceBetween("PAR", "NCE") == Success(686))
assert(geoBase.getTripDurationFromLocalDates("20160606_1627", "CDG", "20160606_1757", "JFK") == Success(7.5d))
assert(geoBase.getNearbyAirports("CDG", 50) == Success(List("LBG", "ORY", "VIY", "POX")))
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")))
```

Getters all have a return type embedded within the Try monade. Throwing
Expand All @@ -70,7 +77,7 @@ With sbt, add these lines to your build.sbt:
```scala
resolvers += "jitpack" at "https://jitpack.io"

libraryDependencies += "com.github.xavierguihot" % "geobase" % "v1.1.3"
libraryDependencies += "com.github.xavierguihot" % "geobase" % "v1.2.0"
```

With maven, add these lines to your pom.xml:
Expand All @@ -86,7 +93,7 @@ With maven, add these lines to your pom.xml:
<dependency>
<groupId>com.github.xavierguihot</groupId>
<artifactId>geobase</artifactId>
<version>v1.1.3</version>
<version>v1.2.0</version>
</dependency>
```

Expand All @@ -100,7 +107,7 @@ allprojects {
}
dependencies {
compile 'com.github.xavierguihot:geobase:v1.1.3'
compile 'com.github.xavierguihot:geobase:v1.2.0'
}
```

Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name := "geobase"

version := "1.1.3"
version := "1.2.0"

scalaVersion := "2.11.8"
scalaVersion := "2.11.12"

scalacOptions ++= Seq(
"-unchecked",
Expand Down
510 changes: 266 additions & 244 deletions docs/com/geobase/GeoBase.html

Large diffs are not rendered by default.

803 changes: 0 additions & 803 deletions docs/com/geobase/GeoType$.html

This file was deleted.

458 changes: 458 additions & 0 deletions docs/com/geobase/model/CONTINENTAL$.html

Large diffs are not rendered by default.

458 changes: 458 additions & 0 deletions docs/com/geobase/model/DOMESTIC$.html

Large diffs are not rendered by default.

485 changes: 485 additions & 0 deletions docs/com/geobase/model/GeoType.html

Large diffs are not rendered by default.

458 changes: 458 additions & 0 deletions docs/com/geobase/model/INTER_CONTINENTAL$.html

Large diffs are not rendered by default.

172 changes: 172 additions & 0 deletions docs/com/geobase/model/package.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<!DOCTYPE html >
<html>
<head>
<title>model - com.geobase.model</title>
<meta name="description" content="model - com.geobase.model" />
<meta name="keywords" content="model com.geobase.model" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<link href="../../../lib/template.css" media="screen" type="text/css" rel="stylesheet" />
<link href="../../../lib/diagrams.css" media="screen" type="text/css" rel="stylesheet" id="diagrams-css" />
<script type="text/javascript" src="../../../lib/jquery.js" id="jquery-js"></script>
<script type="text/javascript" src="../../../lib/jquery-ui.js"></script>
<script type="text/javascript" src="../../../lib/template.js"></script>
<script type="text/javascript" src="../../../lib/tools.tooltip.js"></script>

<script type="text/javascript">
if(top === self) {
var url = '../../../index.html';
var hash = 'com.geobase.model.package';
var anchor = window.location.hash;
var anchor_opt = '';
if (anchor.length >= 1)
anchor_opt = '@' + anchor.substring(1);
window.location.href = url + '#' + hash + anchor_opt;
}
</script>

</head>
<body class="value">
<div id="definition">
<img alt="Package" src="../../../lib/package_big.png" />
<p id="owner"><a href="../../package.html" class="extype" name="com">com</a>.<a href="../package.html" class="extype" name="com.geobase">geobase</a></p>
<h1>model</h1><span class="permalink">
<a href="../../../index.html#com.geobase.model.package" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" alt="Permalink" />
</a>
</span>
</div>

<h4 id="signature" class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">package</span>
</span>
<span class="symbol">
<span class="name">model</span>
</span>
</h4>

<div id="comment" class="fullcommenttop"></div>


<div id="mbrsel">
<div id="textfilter"><span class="pre"></span><span class="input"><input id="mbrsel-input" type="text" accesskey="/" /></span><span class="post"></span></div>


<div id="visbl">
<span class="filtertype">Visibility</span>
<ol><li class="public in"><span>Public</span></li><li class="all out"><span>All</span></li></ol>
</div>
</div>

<div id="template">
<div id="allMembers">


<div id="types" class="types members">
<h3>Type Members</h3>
<ol><li name="com.geobase.model.GeoType" visbl="pub" data-isabs="true" fullComment="no" group="Ungrouped">
<a id="GeoTypeextendsAnyRef"></a>
<a id="GeoType:GeoType"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">sealed </span>
<span class="kind">trait</span>
</span>
<span class="symbol">
<a href="GeoType.html"><span class="name">GeoType</span></a><span class="result"> extends <span class="extype" name="scala.AnyRef">AnyRef</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#com.geobase.model.package@GeoTypeextendsAnyRef" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" alt="Permalink" />
</a>
</span>
<p class="shortcomment cmt">An enumeration which represents the geograpic types of a trip</p>
</li></ol>
</div>



<div id="values" class="values members">
<h3>Value Members</h3>
<ol><li name="com.geobase.model.CONTINENTAL" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="CONTINENTAL"></a>
<a id="CONTINENTAL:CONTINENTAL"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<a href="CONTINENTAL$.html"><span class="name">CONTINENTAL</span></a><span class="result"> extends <a href="GeoType.html" class="extype" name="com.geobase.model.GeoType">GeoType</a> with <span class="extype" name="scala.Product">Product</span> with <span class="extype" name="scala.Serializable">Serializable</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#com.geobase.model.package@CONTINENTAL" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" alt="Permalink" />
</a>
</span>

</li><li name="com.geobase.model.DOMESTIC" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="DOMESTIC"></a>
<a id="DOMESTIC:DOMESTIC"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<a href="DOMESTIC$.html"><span class="name">DOMESTIC</span></a><span class="result"> extends <a href="GeoType.html" class="extype" name="com.geobase.model.GeoType">GeoType</a> with <span class="extype" name="scala.Product">Product</span> with <span class="extype" name="scala.Serializable">Serializable</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#com.geobase.model.package@DOMESTIC" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" alt="Permalink" />
</a>
</span>

</li><li name="com.geobase.model.INTER_CONTINENTAL" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="INTER_CONTINENTAL"></a>
<a id="INTER_CONTINENTAL:INTER_CONTINENTAL"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<a href="INTER_CONTINENTAL$.html"><span class="name">INTER_CONTINENTAL</span></a><span class="result"> extends <a href="GeoType.html" class="extype" name="com.geobase.model.GeoType">GeoType</a> with <span class="extype" name="scala.Product">Product</span> with <span class="extype" name="scala.Serializable">Serializable</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#com.geobase.model.package@INTER_CONTINENTAL" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" alt="Permalink" />
</a>
</span>

</li></ol>
</div>




</div>

<div id="inheritedMembers">


</div>

<div id="groupedMembers">
<div class="group" name="Ungrouped">
<h3>Ungrouped</h3>

</div>
</div>

</div>

<div id="tooltip"></div>

<div id="footer"> </div>


</body>
</html>
40 changes: 20 additions & 20 deletions docs/com/geobase/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ <h4 class="signature">

<span class="kw">val</span> geoBase = <span class="kw">new</span> GeoBase()

assert(geoBase.getCityFor(<span class="lit">"CDG"</span>) == Success(<span class="lit">"PAR"</span>))
assert(geoBase.getCountry(<span class="lit">"CDG"</span>) == Success(<span class="lit">"FR"</span>))
assert(geoBase.getCurrencyFor(<span class="lit">"NYC"</span>) == Success(<span class="lit">"USD"</span>))
assert(geoBase.getCountryForAirline(<span class="lit">"AF"</span>) == Success(<span class="lit">"FR"</span>))
assert(geoBase.getDistanceBetween(<span class="lit">"PAR"</span>, <span class="lit">"NCE"</span>) == Success(<span class="num">686</span>))
assert(geoBase.getTripDurationFromLocalDates(<span class="lit">"20160606_1627"</span>, <span class="lit">"CDG"</span>, <span class="lit">"20160606_1757"</span>, <span class="lit">"JFK"</span>) == Success(<span class="num">7.5</span>d))
assert(geoBase.getNearbyAirports(<span class="lit">"CDG"</span>, <span class="num">50</span>) == Success(<span class="std">List</span>(<span class="lit">"LBG"</span>, <span class="lit">"ORY"</span>, <span class="lit">"VIY"</span>, <span class="lit">"POX"</span>)))</pre><p>The GeoBase object can be used within Spark jobs (in this case, don't forget
assert(geoBase.city(<span class="lit">"CDG"</span>) == Success(<span class="lit">"PAR"</span>))
assert(geoBase.country(<span class="lit">"CDG"</span>) == Success(<span class="lit">"FR"</span>))
assert(geoBase.currency(<span class="lit">"NYC"</span>) == Success(<span class="lit">"USD"</span>))
assert(geoBase.countryForAirline(<span class="lit">"AF"</span>) == Success(<span class="lit">"FR"</span>))
assert(geoBase.distanceBetween(<span class="lit">"PAR"</span>, <span class="lit">"NCE"</span>) == Success(<span class="num">686</span>))
assert(geoBase.tripDurationFromLocalDates(<span class="lit">"20160606_1627"</span>, <span class="lit">"CDG"</span>, <span class="lit">"20160606_1757"</span>, <span class="lit">"JFK"</span>) == Success(<span class="num">7.5</span>d))
assert(geoBase.nearbyAirports(<span class="lit">"CDG"</span>, <span class="num">50</span>) == Success(<span class="std">List</span>(<span class="lit">"LBG"</span>, <span class="lit">"ORY"</span>, <span class="lit">"VIY"</span>, <span class="lit">"POX"</span>)))</pre><p>The GeoBase object can be used within Spark jobs (in this case, don't forget
the possibility to <b>broadcast GeoBase</b>).</p><p>Opentraveldata is an accurate and maintained source of various travel
mappings. This scala wrapper around opentraveldata mostly uses this
file: <a href="https://github.com/opentraveldata/opentraveldata/tree/master/opentraveldata/optd_por_public.csv">
Expand All @@ -106,44 +106,44 @@ <h4 class="signature">
monad doesn't give the user the possibility to understand what went wrong.
Thus the usage of the Try monade.</p><p>Source <a href="https://github.com/xavierguihot/geobase/blob/master/src/main/scala/com/geobase/GeoBase.scala">
GeoBase</a>
</p></div><dl class="attributes block"> <dt>Since</dt><dd><p>2016-05</p></dd></dl></div>
</p></div><dl class="attributes block"> <dt>Since</dt><dd><p>2016-05</p></dd><dt>To do</dt><dd><span class="cmt"><p>modify handling of geo type enum</p></span></dd></dl></div>
</li></ol>
</div>



<div id="values" class="values members">
<h3>Value Members</h3>
<ol><li name="com.geobase.GeoType" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="GeoType"></a>
<a id="GeoType:GeoType"></a>
<ol><li name="com.geobase.error" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="error"></a>
<a id="error:error"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
<span class="kind">package</span>
</span>
<span class="symbol">
<a href="GeoType$.html"><span class="name">GeoType</span></a><span class="result"> extends <span class="extype" name="scala.Enumeration">Enumeration</span></span>
<a href="error/package.html"><span class="name">error</span></a>
</span>
</h4><span class="permalink">
<a href="../../index.html#com.geobase.package@GeoType" title="Permalink" target="_top">
<a href="../../index.html#com.geobase.package@error" title="Permalink" target="_top">
<img src="../../lib/permalink.png" alt="Permalink" />
</a>
</span>
<p class="shortcomment cmt">An enumeration which represents the possible geograpic types of a trip</p>
</li><li name="com.geobase.error" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="error"></a>
<a id="error:error"></a>

</li><li name="com.geobase.model" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="model"></a>
<a id="model:model"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">package</span>
</span>
<span class="symbol">
<a href="error/package.html"><span class="name">error</span></a>
<a href="model/package.html"><span class="name">model</span></a>
</span>
</h4><span class="permalink">
<a href="../../index.html#com.geobase.package@error" title="Permalink" target="_top">
<a href="../../index.html#com.geobase.package@model" title="Permalink" target="_top">
<img src="../../lib/permalink.png" alt="Permalink" />
</a>
</span>
Expand Down
Loading

0 comments on commit 78abb25

Please sign in to comment.