Skip to content

Instantly share code, notes, and snippets.

@kristopolous
Last active September 2, 2019 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristopolous/7f607acf218db8339b2910a48a5e3bf9 to your computer and use it in GitHub Desktop.
Save kristopolous/7f607acf218db8339b2910a48a5e3bf9 to your computer and use it in GitHub Desktop.
import sys, math
width=14400
height=10800
image = [ [ 0 for y in range ( width ) ] for x in range( height ) ]
maxval = 7
delta_lng = .9
delta_lat = delta_lng * 28/40
lng_low = -118.8
lng_high = lng_low + delta_lng
lat_low = 33.70
lat_high = lat_low + delta_lat
mult_lng = 360 / delta_lng * .999
mult_lat = 180 / delta_lat * .999
for line in sys.stdin:
lat,lng=line.split(',')
lat=float(lat)
lng=float(lng)
if(lng > lng_low and lng < lng_high and lat > lat_low and lat < lat_high):
x = round( (mult_lng * width/360.0) * (lng - lng_low) )
y = round( (mult_lat * height/180.0) * (lat - lat_low) )
if image[y][x] < maxval:
image[y][x] += 1
print("P2")
print("{} {}".format(width, height))
print(maxval)
for row in reversed(image):
print(" ".join([str(x) for x in row]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment