Addis Ababa/Yahoo/raster.py

From OpenStreetMap Wiki
Jump to navigation Jump to search
##########################################################
# OSM-WikiMatrix.py                                      #
# v0.1 - 16. Aug 2009                                    #
#                                                        #
# Released under CC-BY-SA 3.0                            #
# Attribution: Alexander Menk <alex at addismap dot com> #
##########################################################

# Only working on southern hemisphere

#### configuration

# upper right coordinates of the city

lat_topright = 9.10489
lon_topright = 38.67059

rows = "ABCDEFGHI"
rowcount = len(rows)
colcount = 9

# number of steps in plus/minus direction to cover the needed area
#lat_steps =
#lon_steps =

# usually fixed
lat_step = 0.00544
lon_step = 0.00824
zoom = 17


lat = lat_topright
lon = lon_topright


# format strings for URLs
f_edit = "[http://www.openstreetmap.org/edit?lat=%f&lon=%f&zoom=17 P]"
f_josm = "[http://localhost:8111/load_and_zoom?left=%f&right=%f&top=%f&bottom=%f J]"
#f_static = "[http://dev.openstreetmap.org/~ojw/StaticMap/?lat=%f&lon=%f&z=%d&mode=Draw&mlat0=%f&mlon0=%f&mlat1=%f&mlon1=%f&show=1 M]"
f_static = "[http://dev.openstreetmap.org/~ojw/StaticMap/?lat=%f&lon=%f&z=%d&mode=Draw&d0p0lat=%f&d0p0lon=%f&d0p1lat=%f&d0p1lon=%f&d0p2lat=%f&d0p2lon=%f&d0p3lat=%f&d0p3lon=%f&d0p4lat=%f&d0p4lon=%f&dp_num=5&show=1 M]"





# static strings
s_begin = '{| style="vertical-align:middle;text-align:center;background-color:darkgray"'
s_newrow = '|- style="height:35px;"'
s_colbegin = '| style="background-color:white;width:35px" | '
s_end = '|}'

print f_static % (lat , lon, 10, lat - lat_step/2, lon - lon_step/2, lat - lat_step/2 , lon + lon_step*colcount + lon_step/2, lat + lat_step*rowcount + lat_step/2 , lon + lon_step*colcount + lon_step/2 , lat + lat_step*rowcount + lat_step/2  , lon - lon_step/2, lat - lat_step/2, lon - lon_step/2)


#print f_static % (lat , lon, 
print s_begin
for row in rows:
	print s_newrow
	for col in range(1,colcount+1):
		print s_colbegin , "%s%s" % (row, col)
#		link1 = f_static % (lat + (lat_step/2) , lon + (lon_step/2), 16, lat, lon, lat + lat_step, lon + lon_step)
		link1 = f_static % (lat , lon, 16, lat - lat_step/2, lon - lon_step/2, lat - lat_step/2 , lon + lon_step/2, lat + lat_step/2 , lon + lon_step/2 , lat + lat_step/2 , lon - lon_step/2, lat - lat_step/2, lon - lon_step/2)
		link2 = f_josm % ( lon , lon + lon_step , lat , lat + lat_step )
# unfortunately potlatch needs the center, not the upper left corner and it does not support marking the rectangle we mean
		link3 = f_edit % ( lat  , lon  )
		print "%s%s%s" % (link1, link2, link3)
		lon += lon_step
	lat -= lat_step

print s_end