teralytics / geohex Goto Github PK
View Code? Open in Web Editor NEWThis project forked from chsh/geohex4j
Geographical area hashing algorithms GeoHex and TeraHex
This project forked from chsh/geohex4j
Geographical area hashing algorithms GeoHex and TeraHex
Example of incorrect behavior:
To make the algorithm simpler, consider iterating by columns from bottom to top like here:
https://github.com/teralytics/edge-treasure-chest/blob/master/app/src/util/hexes.js#L143
currently hardcoded to 1300
When measured in lat/lon degrees (or meters) the vertical and horizontal sizes of a hexagon are not the same because of the Mercator distortions. From the API documentation it is not clear what sizes size
and innerRadius
actually represent.
The API should clarify that and ideally provide means for obtaining sizes along the two axes. For example, the functions below give outer sizes for both axes (but don't account for wrapping at antimeridian and poles):
const zoneSize = (z, accessor) => {
let [ a, b ] = d3.extent(z.geometry, accessor)
return (b - a)
}
const zoneHeight = (z) => zoneSize(z, d => d.lat)
const zoneWidth = (z) => zoneSize(z, d => d.lon)
Also z.size seems to return half of the outer radius (zoneWidth) contrary to the documentation which states that it is the side length
let z = terahex.decode('130046352')
z.size * 2 // 2.469135802469136
z.geometry[0].lon - z.geometry[3].lon // 2.469135802469168
having new problems using this, and I think it's related to bintray being sunsetted.
[error] https://dl.bintray.com/teralytics/maven/net/teralytics/geohex_2.12/0.1.128/geohex_2.12-0.1.128.jar: download error:
Caught java.io.IOException: Server returned HTTP response code: 403 for URL:
https://dl.bintray.com/teralytics/maven/net/teralytics/geohex_2.12/0.1.128/geohex_2.12-0.1.128.jar (Server returned HTTP
response code: 403 for URL: https://dl.bintray.com/teralytics/maven/net/teralytics/geohex_2.12/0.1.128/geohex_2.12-
0.1.128.jar) while downloading https://dl.bintray.com/teralytics/maven/net/teralytics/geohex_2.12/0.1.128/geohex_2.12-
0.1.128.jar
is anybody maintaining this or interested in publishing to Sonatype OSSRH and then Maven Central?
NoSuchElementException due to the presence of Cell(2,-2) in an Hexagon but not in the dictionary
. The dictionary is defined as following:
val dictionary = IndexedSeq(
Cell.subS,
Cell.subSW,
Cell.subW,
Cell.subSE,
Cell.subCenter,
Cell.subNW,
Cell.subE,
Cell.subNE,
Cell.subN)
The following snippet reproduces the bug:
import net.teralytics.terahex.{Encoding, Grid, Lat, LatLon, Lon, Zone}
implicit val grid = Grid(0.00224579 * 19683)
val zones =
Zone.zonesWithin(LatLon(Lon(51.55d), Lat(26.55d)) -> LatLon(Lon(56.55d), Lat(22.55d)), 9)
val z = zones.head
implicit val encoding = Encoding.numeric
print(zones(1).code)
I end up with the following exception:
Exception in thread "main" java.util.NoSuchElementException: key not found: Cell(2,-2)
at scala.collection.MapLike$class.default(MapLike.scala:228)
at scala.collection.AbstractMap.default(Map.scala:58)
at scala.collection.MapLike$class.apply(MapLike.scala:141)
at scala.collection.AbstractMap.apply(Map.scala:58)
at net.teralytics.terahex.Encoding$$anon$1$$anonfun$encode$1.apply(Encoding.scala:42)
at net.teralytics.terahex.Encoding$$anon$1$$anonfun$encode$1.apply(Encoding.scala:42)
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
at scala.collection.immutable.List.foldLeft(List.scala:84)
at net.teralytics.terahex.Encoding$$anon$1.encode(Encoding.scala:42)
at net.teralytics.terahex.Encoding$$anon$1.encode(Encoding.scala:17)
at net.teralytics.terahex.package$ZoneOps$.code$extension(package.scala:14)
at ae.du.populationdensity.PopulationDensityApp$delayedInit$body.apply(PopulationDensityApp.scala:53)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at ae.du.populationdensity.PopulationDensityApp$.main(PopulationDensityApp.scala:17)
at ae.du.populationdensity.PopulationDensityApp.main(PopulationDensityApp.scala)
> t.zoneByLocation(-177.77777777777777, 82.77472507444895,5).code
java.util.NoSuchElementException: key not found: Cell(-2,0)
> t.zoneByLocation(-22.22222222222223, 88.55526595063087, 5).code
java.util.NoSuchElementException: key not found: Cell(-1,-1)
Just getting the zone works, but trying to access the code prop leads to exceptions. It would be more reasonable if exceptions were already thrown when calling zoneByLocation. This way it would be easier to track and remove unsupported hexagons.
> t.zoneByLocation(-22.22222222222223, 88.55526595063087, 5)
{ hb:
{ Eb: 300,
Rb: { rd: [Object], xd: [Object] },
Yb: { Eb: 300 },
zc: 5,
Ee: 1.234567901234568,
Xi: null,
ma: false },
zc: 5,
Ee: 1.234567901234568 }
> t.zoneByLocation(-22.22222222222223, 88.55526595063087, 5).code
java.util.NoSuchElementException: key not found: Cell(-1,-1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.