User:Klaus/KingOfTheGraticules

From Geohashing
< User:Klaus
Revision as of 22:11, 28 August 2023 by Klaus (talk | contribs) (stupid idea of Klaus)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is just a stupid idea which I had. I'll dump it here for now, until I improve it.

What is the idea?

The idea is to create a world map where the whole world cube is claimed by geohashers. You can claim the area surrounding a geohash by visiting the geohash.

A geohasher is the king of a area if he/she either has

  • the closest geohash to that region and nobody else has "a lot" of hashes nearby
  • a lot of hashes which weren't the closest ones but he/she has reached much more hashes than the person who did the closest

Someone in Siberia might claim a huge amount of land by just doing one geohash while others might not claim any land at all if they live close to someone with 100+ hashes.

We might only count "recent" hashes, too.

Things I need to decide

  • Should geohashes fade out linearly over time, i.e. after 10 years, a geohash does not count anymore?
  • What kind of weight function to use? Something exponential like "exp(-dist/C)" or something quadratic like "1/(1+dist)^2"? I'll probably decide as soon as I have some maps.
  • Count only reached hashes? I think so...
  • How fine? 100 pixels per Graticule or more?

Script for now

# !/usr/bin/python

import json
from math import radians, cos, sin, asin, sqrt, exp
from copy import deepcopy

# ugly parsing of https://fippe.de/alldata.js
data=open("alldata.js","r").read()
HEADER = "var expeditions = "
FOOTER = ",\n];\n"
assert(data.startswith(HEADER))
assert(data.endswith(FOOTER))
data=data[len(HEADER):]
data=data[:-len(FOOTER)]
data=data+"]"
data = json.loads(data)

# now we have a list of geohashes like
# ["2023-08-16_52_7",52.05395,7.73412,["Fippe"],true,1,["Bicycle_geohash_achievement", "Land_geohash_achievement"]],
# ["2010-01-12_global",33.67653,-81.27146,["NWoodruff","LuxMundi"],true,12,["Globalhash_achievement"]],

# filter only reached hashes
data = [i for i in data if i[4] == True]

# get set of users
users = set()
for i in data:
    users |= set(i[3])
print(users)

# https://stackoverflow.com/questions/4913349/haversine-formula-in-python-bearing-and-distance-between-two-gps-points/4913653#4913653
def haversine(lon1, lat1, lon2, lat2):
    """
    Calculate the great circle distance between two points 
    on the earth (specified in decimal degrees)
    """
    # convert decimal degrees to radians 
    lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])

    # haversine formula 
    dlon = lon2 - lon1 
    dlat = lat2 - lat1 
    a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
    c = 2 * asin(sqrt(a)) 
    r = 6371 # Radius of earth in kilometers. Use 3956 for miles
    return c * r


LONRANGE = [i for i in range(-90,91)]
LATRANGE = [i for i in range(-180,181)]
LONRANGE = [i+0.5 for i in range(47,55+1)]
LATRANGE = [i+0.5 for i in range(5,15+1)]


king = [ [ "" for lat in LATRANGE ] for lon in LONRANGE] 
print("init density done")


def weight(dist):
    assert(dist >= 0)
    return exp(-dist/111.1111)

for lonindex, lon in enumerate(LONRANGE):
    for latindex, lat in enumerate(LATRANGE):
        tmp = deepcopy(dict.fromkeys(users, 0.))
        for geohash in data:
            geolon, geolat = geohash[1], geohash[2]
            for geouser in geohash[3]:
                tmp[geouser] += weight(haversine(lon,lat,geolon,geolat))
        max_user  = max(tmp, key=tmp.get)
        #print(tmp)
        print(f"maximum for {lon},{lat} is {max_user} with weight {tmp[max_user]}")
        king[lonindex][latindex] = (max_user, tmp[max_user])

example output for Germany

maximum for 47.5,5.5 is Baarde with weight 14.898538450051866
maximum for 47.5,6.5 is Baarde with weight 29.29607425612856
maximum for 47.5,7.5 is Baarde with weight 45.61624163332782
maximum for 47.5,8.5 is Ekorren with weight 58.28426546324664
maximum for 47.5,9.5 is Ekorren with weight 58.57831454867424
maximum for 47.5,10.5 is Ekorren with weight 32.22948678757896
maximum for 47.5,11.5 is Clearlucid9 with weight 27.22259177300158
maximum for 47.5,12.5 is dawidi with weight 18.93138350798357
maximum for 47.5,13.5 is dawidi with weight 11.767977367673756
maximum for 47.5,14.5 is B2c with weight 10.525521991031578
maximum for 47.5,15.5 is B2c with weight 17.574995214642634
maximum for 48.5,5.5 is Baarde with weight 14.130466746469853
maximum for 48.5,6.5 is Baarde with weight 33.45800180958267
maximum for 48.5,7.5 is Baarde with weight 63.079397288083584
maximum for 48.5,8.5 is Ekorren with weight 104.06968663621687
maximum for 48.5,9.5 is Ekorren with weight 108.40806628771308
maximum for 48.5,10.5 is Ekorren with weight 44.38171360825119
maximum for 48.5,11.5 is dawidi with weight 37.970593329872315
maximum for 48.5,12.5 is dawidi with weight 42.97704795205722
maximum for 48.5,13.5 is dawidi with weight 20.629557586688378
maximum for 48.5,14.5 is B2c with weight 11.386942347075962
maximum for 48.5,15.5 is B2c with weight 21.233596635515774
maximum for 49.5,5.5 is GeorgDerReisende with weight 12.460492009097289
maximum for 49.5,6.5 is DODO with weight 30.441175219592328
maximum for 49.5,7.5 is DODO with weight 76.09050491328843
maximum for 49.5,8.5 is DODO with weight 143.76562536413397
maximum for 49.5,9.5 is GeorgDerReisende with weight 94.74638761218867
maximum for 49.5,10.5 is Danatar with weight 80.40993484414254
maximum for 49.5,11.5 is Reinhard with weight 58.08147404406503
maximum for 49.5,12.5 is dawidi with weight 45.377958217226855
maximum for 49.5,13.5 is Danatar with weight 24.942275126518897
maximum for 49.5,14.5 is Danatar with weight 17.48206834498561
maximum for 49.5,15.5 is B2c with weight 12.730094849833108
maximum for 50.5,5.5 is GeorgDerReisende with weight 17.842861832248353
maximum for 50.5,6.5 is GeorgDerReisende with weight 42.98954530726278
maximum for 50.5,7.5 is GeorgDerReisende with weight 89.66566487351831
maximum for 50.5,8.5 is GeorgDerReisende with weight 164.69000177445264
maximum for 50.5,9.5 is GeorgDerReisende with weight 199.15642286952632
maximum for 50.5,10.5 is GeorgDerReisende with weight 136.3824260237695
maximum for 50.5,11.5 is Reinhard with weight 126.87026750572352
maximum for 50.5,12.5 is Reinhard with weight 72.5180923125278
maximum for 50.5,13.5 is Danatar with weight 48.29850058765375
maximum for 50.5,14.5 is Danatar with weight 33.81167110299955
maximum for 50.5,15.5 is Danatar with weight 15.14990311420647
maximum for 51.5,5.5 is FelixTheCat with weight 29.56187773637542
maximum for 51.5,6.5 is GeorgDerReisende with weight 50.069515663170996
maximum for 51.5,7.5 is GeorgDerReisende with weight 107.46513071360482
maximum for 51.5,8.5 is GeorgDerReisende with weight 194.70913984586983
maximum for 51.5,9.5 is GeorgDerReisende with weight 310.0886041251239
maximum for 51.5,10.5 is GeorgDerReisende with weight 194.15761195776
maximum for 51.5,11.5 is Reinhard with weight 104.89620802555953
maximum for 51.5,12.5 is Reinhard with weight 71.31902796934932
maximum for 51.5,13.5 is Danatar with weight 51.03361169520544
maximum for 51.5,14.5 is Danatar with weight 36.00541300143595
maximum for 51.5,15.5 is Danatar with weight 15.914365180089959
maximum for 52.5,5.5 is FelixTheCat with weight 32.369676118635475
maximum for 52.5,6.5 is GeorgDerReisende with weight 36.909465505701085
maximum for 52.5,7.5 is Fippe with weight 76.53303542997364
maximum for 52.5,8.5 is GeorgDerReisende with weight 136.99060863918805
maximum for 52.5,9.5 is GeorgDerReisende with weight 202.46738424914352
maximum for 52.5,10.5 is GeorgDerReisende with weight 150.72061016230901
maximum for 52.5,11.5 is GeorgDerReisende with weight 71.48571210177522
maximum for 52.5,12.5 is Reinhard with weight 34.75320615664992
maximum for 52.5,13.5 is relet with weight 44.64104582337929
maximum for 52.5,14.5 is relet with weight 21.94044192474408
maximum for 52.5,15.5 is Danatar with weight 10.24227849353604
maximum for 53.5,5.5 is FelixTheCat with weight 16.671078451678795
maximum for 53.5,6.5 is Fippe with weight 27.063639876795783
maximum for 53.5,7.5 is Fippe with weight 55.52927171983086
maximum for 53.5,8.5 is Fippe with weight 83.73468252633798
maximum for 53.5,9.5 is Fippe with weight 100.15459562958549
maximum for 53.5,10.5 is π_π_π with weight 91.21761778612391
maximum for 53.5,11.5 is Fippe with weight 44.26091632062462
maximum for 53.5,12.5 is Fippe with weight 22.57492519437279
maximum for 53.5,13.5 is relet with weight 25.49497486147569
maximum for 53.5,14.5 is relet with weight 15.445324928368441
maximum for 53.5,15.5 is relet with weight 6.903072213931649
maximum for 54.5,5.5 is Fippe with weight 7.285386176339357
maximum for 54.5,6.5 is Fippe with weight 15.507475778552834
maximum for 54.5,7.5 is Fippe with weight 27.930655791832088
maximum for 54.5,8.5 is Fippe with weight 39.5041953957787
maximum for 54.5,9.5 is π_π_π with weight 70.09611329697292
maximum for 54.5,10.5 is π_π_π with weight 67.29692468309526
maximum for 54.5,11.5 is π_π_π with weight 31.93010582625227
maximum for 54.5,12.5 is Llavids with weight 18.85963753961714
maximum for 54.5,13.5 is Llavids with weight 25.528072820304075
maximum for 54.5,14.5 is Llavids with weight 18.73229134567415
maximum for 54.5,15.5 is Llavids with weight 9.395800125343479
maximum for 55.5,5.5 is Fippe with weight 3.9459228317426596
maximum for 55.5,6.5 is Fippe with weight 7.533300037061222
maximum for 55.5,7.5 is Fippe with weight 12.363483571042664
maximum for 55.5,8.5 is π_π_π with weight 18.49677320315892
maximum for 55.5,9.5 is π_π_π with weight 29.162967221180317
maximum for 55.5,10.5 is π_π_π with weight 28.54185799113508
maximum for 55.5,11.5 is π_π_π with weight 18.10077376180053
maximum for 55.5,12.5 is Llavids with weight 35.07239830784898
maximum for 55.5,13.5 is Llavids with weight 62.977527094573375
maximum for 55.5,14.5 is Llavids with weight 34.93915985832775
maximum for 55.5,15.5 is Llavids with weight 14.189348594242926