akiatoji / geohex-scala

Scala porting of GeoHex library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GeoHex for Scala

# GeoHex for Scala DESCRIPTION
GeoHex V3 for Scala implemented by @pomu0325.
http://twitter.com/pomu0325

# GeoHex object
* GeoHex object can convert between latitude/longitude and GeoHex
  V3: ported from
    JavaScript implementation by @sa2da (http://geohex.net/hex_v3_core.js), and
    Java implementation by @chshii (https://github.com/chsh/geohex4j)

  Currently only #decode, #encode, #getZoneByLocation and #getZoneByCode methods are ready.
  Other methods will be provided after well tested.

# INSTALL
* copy GeoHex.scala and package.scala from ./src/main/scala/net/geohex directory into your app.

  or
  
* run 'sbt package' and copy created jar file into your project

# USAGE

  import net.geohex._

  val code: String = GeoHex.encode(35.780516755235475, 139.57031250000003, 9)
  // code -> "XM566370240"
  val zone1: Zone = GeoHex.getZoneByLocation(35.780516755235475, 139.57031250000003, 9)
  // zone1.code -> "XM566370240"

  val zone2: Zone = GeoHex.decode("XM566370240") // decode method is an alias of getZoneByCode.
  // zone2.lat -> 35.78044332128247
  // zone2.lon -> 139.57018747142203
  // zone2.level -> 9
  // zone2.hexSize -> 37.70410702222824
  val polygon: List[Loc] = z.hexCoords
  // [0]:{35.780516755235475,139.33593750000003}
  // [1]:{35.945011915675025,139.45312500000006}
  // [2]:{35.945011915675025,139.68750000000006}
  // [3]:{35.780516755235475,139.80468750000006}
  // [4]:{35.61568052680066,139.68750000000006}
  // [5]:{35.61568052680066,139.45312500000006}
 ...

# LICENSE
This library "geohex-scala" is a Scala porting of "GeoHex"
 originally licensed by @sa2da (http://geogames.net)
 under Creative Commons BY-SA 2.1 Japan License.

This library partly derives from "geohex4j" (https://github.com/chsh/geohex4j),
 licensed by CHIKURA Shinsaku
 under Creative Commons BY-SA 2.1 Japan License.

geohex-scala is licensed by Pomu TAKEUCHI
 under Creative Commons BY-SA 2.1 Japan License.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  

About

Scala porting of GeoHex library