Skip to content

Commit

Permalink
zipzap and localbitcoins location added
Browse files Browse the repository at this point in the history
  • Loading branch information
darekw committed Oct 13, 2013
1 parent bb78890 commit 7d1552f
Show file tree
Hide file tree
Showing 8 changed files with 430 additions and 36 deletions.
3 changes: 2 additions & 1 deletion coinmap-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,5 @@ var icon_transport_tram_stop = L.icon({iconUrl: 'icons/transport_tram_stop.n.24.
var icon_transport_turning_circle = L.icon({iconUrl: 'icons/transport_turning_circle.n.24.png', iconSize: [24, 24] });
var icon_transport_weir = L.icon({iconUrl: 'icons/transport_weir.n.24.png', iconSize: [24, 24] });
var icon_transport_zebracrossing = L.icon({iconUrl: 'icons/transport_zebracrossing.n.24.png', iconSize: [24, 24] });
var icon_local_bitcoins = L.icon({iconUrl:'icons/local_bitcoins.n.24.png', iconSize:[24,24]});
var icon_local_bitcoins = L.icon({iconUrl:'icons/local_bitcoins.n.24.png', iconSize:[24,24]});
var icon_zipzap = L.icon({iconUrl:'icons/zipzap.n.24.png', iconSize:[24, 24]});
Binary file added icons/zipzap.n.24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
251 changes: 251 additions & 0 deletions lb/country_names_and_code_elements.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
Country Name;ISO 3166-1-alpha-2 code
AFGHANISTAN;AF
ÅLAND ISLANDS;AX
ALBANIA;AL
ALGERIA;DZ
AMERICAN SAMOA;AS
ANDORRA;AD
ANGOLA;AO
ANGUILLA;AI
ANTARCTICA;AQ
ANTIGUA AND BARBUDA;AG
ARGENTINA;AR
ARMENIA;AM
ARUBA;AW
AUSTRALIA;AU
AUSTRIA;AT
AZERBAIJAN;AZ
BAHAMAS;BS
BAHRAIN;BH
BANGLADESH;BD
BARBADOS;BB
BELARUS;BY
BELGIUM;BE
BELIZE;BZ
BENIN;BJ
BERMUDA;BM
BHUTAN;BT
BOLIVIA;BO
BONAIRE;BQ
BOSNIA AND HERZEGOVINA;BA
BOTSWANA;BW
BOUVET ISLAND;BV
BRAZIL;BR
BRITISH INDIAN OCEAN TERRITORY;IO
BRUNEI DARUSSALAM;BN
BULGARIA;BG
BURKINA FASO;BF
BURUNDI;BI
CAMBODIA;KH
CAMEROON;CM
CANADA;CA
CAPE VERDE;CV
CAYMAN ISLANDS;KY
CENTRAL AFRICAN REPUBLIC;CF
CHAD;TD
CHILE;CL
CHINA;CN
CHRISTMAS ISLAND;CX
COCOS (KEELING) ISLANDS;CC
COLOMBIA;CO
COMOROS;KM
CONGO;CG
CONGO;CD
COOK ISLANDS;CK
COSTA RICA;CR
CÔTE D'IVOIRE;CI
CROATIA;HR
CUBA;CU
CURAÇAO;CW
CYPRUS;CY
CZECH REPUBLIC;CZ
DENMARK;DK
DJIBOUTI;DJ
DOMINICA;DM
DOMINICAN REPUBLIC;DO
ECUADOR;EC
EGYPT;EG
EL SALVADOR;SV
EQUATORIAL GUINEA;GQ
ERITREA;ER
ESTONIA;EE
ETHIOPIA;ET
FALKLAND ISLANDS (MALVINAS);FK
FAROE ISLANDS;FO
FIJI;FJ
FINLAND;FI
FRANCE;FR
FRENCH GUIANA;GF
FRENCH POLYNESIA;PF
FRENCH SOUTHERN TERRITORIES;TF
GABON;GA
GAMBIA;GM
GEORGIA;GE
GERMANY;DE
GHANA;GH
GIBRALTAR;GI
GREECE;GR
GREENLAND;GL
GRENADA;GD
GUADELOUPE;GP
GUAM;GU
GUATEMALA;GT
GUERNSEY;GG
GUINEA;GN
GUINEA-BISSAU;GW
GUYANA;GY
HAITI;HT
HEARD ISLAND AND MCDONALD ISLANDS;HM
HOLY SEE (VATICAN CITY STATE);VA
HONDURAS;HN
HONG KONG;HK
HUNGARY;HU
ICELAND;IS
INDIA;IN
INDONESIA;ID
IRAN;IR
IRAQ;IQ
IRELAND;IE
ISLE OF MAN;IM
ISRAEL;IL
ITALY;IT
JAMAICA;JM
JAPAN;JP
JERSEY;JE
JORDAN;JO
KAZAKHSTAN;KZ
KENYA;KE
KIRIBATI;KI
KOREA;KP
KOREA;KR
KUWAIT;KW
KYRGYZSTAN;KG
LAO;LA
LATVIA;LV
LEBANON;LB
LESOTHO;LS
LIBERIA;LR
LIBYA;LY
LIECHTENSTEIN;LI
LITHUANIA;LT
LUXEMBOURG;LU
MACAO;MO
MACEDONIA;MK
MADAGASCAR;MG
MALAWI;MW
MALAYSIA;MY
MALDIVES;MV
MALI;ML
MALTA;MT
MARSHALL ISLANDS;MH
MARTINIQUE;MQ
MAURITANIA;MR
MAURITIUS;MU
MAYOTTE;YT
MEXICO;MX
MICRONESIA;FM
MOLDOVA;MD
MONACO;MC
MONGOLIA;MN
MONTENEGRO;ME
MONTSERRAT;MS
MOROCCO;MA
MOZAMBIQUE;MZ
MYANMAR;MM
NAMIBIA;NA
NAURU;NR
NEPAL;NP
NETHERLANDS;NL
NEW CALEDONIA;NC
NEW ZEALAND;NZ
NICARAGUA;NI
NIGER;NE
NIGERIA;NG
NIUE;NU
NORFOLK ISLAND;NF
NORTHERN MARIANA ISLANDS;MP
NORWAY;NO
OMAN;OM
PAKISTAN;PK
PALAU;PW
PALESTINE;PS
PANAMA;PA
PAPUA NEW GUINEA;PG
PARAGUAY;PY
PERU;PE
PHILIPPINES;PH
PITCAIRN;PN
POLAND;PL
PORTUGAL;PT
PUERTO RICO;PR
QATAR;QA
RÉUNION;RE
ROMANIA;RO
RUSSIAN FEDERATION;RU
RWANDA;RW
SAINT BARTHÉLEMY;BL
SAINT HELENA;SH
SAINT KITTS AND NEVIS;KN
SAINT LUCIA;LC
SAINT MARTIN;MF
SAINT PIERRE AND MIQUELON;PM
SAINT VINCENT AND THE GRENADINES;VC
SAMOA;WS
SAN MARINO;SM
SAO TOME AND PRINCIPE;ST
SAUDI ARABIA;SA
SENEGAL;SN
SERBIA;RS
SEYCHELLES;SC
SIERRA LEONE;SL
SINGAPORE;SG
SINT MAARTEN;SX
SLOVAKIA;SK
SLOVENIA;SI
SOLOMON ISLANDS;SB
SOMALIA;SO
SOUTH AFRICA;ZA
SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS;GS
SOUTH SUDAN;SS
SPAIN;ES
SRI LANKA;LK
SUDAN;SD
SURINAME;SR
SVALBARD AND JAN MAYEN;SJ
SWAZILAND;SZ
SWEDEN;SE
SWITZERLAND;CH
SYRIAN ARAB REPUBLIC;SY
TAIWAN;TW
TAJIKISTAN;TJ
TANZANIA;TZ
THAILAND;TH
TIMOR-LESTE;TL
TOGO;TG
TOKELAU;TK
TONGA;TO
TRINIDAD AND TOBAGO;TT
TUNISIA;TN
TURKEY;TR
TURKMENISTAN;TM
TURKS AND CAICOS ISLANDS;TC
TUVALU;TV
UGANDA;UG
UKRAINE;UA
UNITED ARAB EMIRATES;AE
UNITED KINGDOM;GB
UNITED STATES;US
UNITED STATES MINOR OUTLYING ISLANDS;UM
URUGUAY;UY
UZBEKISTAN;UZ
VANUATU;VU
VENEZUELA;VE
VIET NAM;VN
VIRGIN ISLANDS;VG
VIRGIN ISLANDS;VI
WALLIS AND FUTUNA;WF
WESTERN SAHARA;EH
YEMEN;YE
ZAMBIA;ZM
ZIMBABWE;ZW

61 changes: 61 additions & 0 deletions lb/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import public as local_bitcoins

country_codes_filename = 'lb/country_names_and_code_elements.csv'


def get_country_codes():
import csv
code_to_name = {}
with open(country_codes_filename, 'rb') as codes_file:
reader = csv.reader(codes_file, delimiter=';')
for row in reader:
if len(row) == 2:
code = row[1]
name = row[0]
code_to_name[code] = name
return code_to_name


def get_lb_country_codes():
return local_bitcoins.countrycodes()


def convert_lb_to_cm_element(data):
e = data['data']
j = {
'id': e.get('profile', {}).get('id', '-1'),
'lat': e.get('lat', None),
'lon': e.get('lon', None),
'type': 'node',
'tags': {
'payment:bitcoin': 'yes',
'local_bitcoins': 'local_bitcoins',
'addr:city': e.get('city', ''),
'add:country': e.get('countrycode', ''),
'contact:website': 'https://localbitcoins.com/accounts/profile/'
+ e.get('profile', {}).get('username', '')
},
'website': 'http://localbitcoins.com'
}
return j


def get_lb_points():
lb_countrycodes = get_lb_country_codes()

if not lb_countrycodes:
return []

code_to_name = get_country_codes()

result = {}
for code in lb_countrycodes:
country = code_to_name[code]

query = '%s,%s' % (country.decode('utf-8'), code)
bl_data = local_bitcoins.get_local_sell_ads(query)
for entry in bl_data:
j = convert_lb_to_cm_element(entry)
if j['id'] not in result:
result[j['id']] = j
return result.values()
47 changes: 12 additions & 35 deletions refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import urllib2
import simplejson
import os
from lb import public as locals
from lb import parser as local_bitcoins_parser
from zipzap import parser as zipzap_parser

icon_mapping = {
'aeroway:aerodrome': 'transport_airport',
Expand Down Expand Up @@ -155,6 +156,7 @@
'tourism:zoo': 'tourist_zoo',
'traffic_calming:yes': 'transport_speedbump',
'local_bitcoins:local_bitcoins': 'local_bitcoins',
'zipzap:zipzap': 'zipzap'
}

def determine_icon(tags):
Expand Down Expand Up @@ -239,40 +241,15 @@ def write_elements(f, e):

with open(scriptdir + '/coinmap-data.js', 'w') as f:
f.write('function coinmap_populate(markers) {\n')
# overpass
for e in json['elements']:
place = write_elements(f, e)
if place:
cnt += 1

# Bitcoin Locals
elements = []

country_codes = locals.countrycodes()
for country in country_codes:
bl_data = locals.get_local_sell_ads(country)
for entry in bl_data[:2]:
e = entry['data']
j = {
'id': e.get('profile', {}).get('id', '-1'),
'lat': e.get('lat', None),
'lon': e.get('lon', None),
'type': 'node',
'tags': {
'payment:bitcoin': 'yes',
'local_bitcoins': 'local_bitcoins',
'addr:city': e.get('city', ''),
'add:country': e.get('countrycode', ''),
'contact:website': 'https://localbitcoins.com/accounts/profile/'
+ e.get('profile', {}).get('username', '')
},
'website': 'http://localbitcoins.com'
}
elements.append(j)

for e in elements:
place = write_elements(f, e)
if place:
data_sources = [
json['elements'],
local_bitcoins_parser.get_lb_points(),
zipzap_parser.get_zipzap_points()
]
for source in data_sources:
for d in source:
place = write_elements(f, d)
if place:
cnt += 1

f.write(' document.getElementById("count").innerHTML = "<b>%d</b>";\n' % cnt);
Expand Down
1 change: 1 addition & 0 deletions zipzap/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'dwa'
Loading

0 comments on commit 7d1552f

Please sign in to comment.