Esempio n. 1
0
def MergeArea(x, y, zoom, mapIds, tileGroups):
	lat, lon = tiles.num2deg(x, y, zoom)
	x2, y2 = tiles.deg2num(lat, lon, dataTileZoom)

	lat2, lon2 = tiles.num2deg(x+1, y+1, zoom)
	x3, y3 = tiles.deg2num(lat2, lon2, dataTileZoom)

	fiList = []
	for cx in range(x2, x3):
		for cy in range(y2, y3):
			fina = "../12/{0}/{1}.osm.bz2".format(cx, cy)
			if not os.path.isfile(fina):
				continue
			fiList.append(fina)

	if len(fiList) == 0:
		return
	#out = bz2.BZ2File("merge.osm.bz2","w")
	#print "Found {0} data tiles".format(len(fiList))

	tileGroups.append(fiList)
	mapId = 63240000+len(mapIds)
	mapIds.append(mapId)

	if 0:
		countNodes, countWays, countRelations = mergeTiles.MergeFiles(fiList, out, 0)

		if countNodes + countWays + countRelations == 0:
			#Everything is empty
			return

		cmd = "java -jar ../splitter-r412/splitter.jar --mapid={0} merge.osm.bz2".format(mapId)
		
		os.system(cmd)
Esempio n. 2
0
def CalcFileSize(x, y, zoom, dataTileZoom):
	lat, lon = tiles.num2deg(x, y, zoom)
	x2, y2 = tiles.deg2num(lat, lon, dataTileZoom)

	lat2, lon2 = tiles.num2deg(x+1, y+1, zoom)
	x3, y3 = tiles.deg2num(lat2, lon2, dataTileZoom)

	#print (x2, x3), (y2, y3)
	totalSize = 0
	for cx in range(x2, x3):
		for cy in range(y2, y3):
			fina = "../12/{0}/{1}.osm.bz2".format(cx, cy)
			if not os.path.isfile(fina):
				continue
			s = os.path.getsize(fina)
			totalSize += s
	return totalSize
Esempio n. 3
0
def CalcFileSize(x, y, zoom, dataTileZoom):
    lat, lon = tiles.num2deg(x, y, zoom)
    x2, y2 = tiles.deg2num(lat, lon, dataTileZoom)

    lat2, lon2 = tiles.num2deg(x + 1, y + 1, zoom)
    x3, y3 = tiles.deg2num(lat2, lon2, dataTileZoom)

    #print (x2, x3), (y2, y3)
    totalSize = 0
    for cx in range(x2, x3):
        for cy in range(y2, y3):
            fina = "../12/{0}/{1}.osm.bz2".format(cx, cy)
            if not os.path.isfile(fina):
                continue
            s = os.path.getsize(fina)
            totalSize += s
    return totalSize
Esempio n. 4
0
def ProcessAreaNextZoom(x, y, zoom, dataTileZoom, mapIds, tileGroups):

	lat, lon = tiles.num2deg(x, y, zoom)
	x2, y2 = tiles.deg2num(lat, lon, zoom+1)

	lat2, lon2 = tiles.num2deg(x+1, y+1, zoom)
	x3, y3 = tiles.deg2num(lat2, lon2, zoom+1)

	for cx in range(x2, x3):
		for cy in range(y2, y3):
			totalFileSize = CalcFileSize(cx, cy, zoom+1, dataTileZoom)
			if totalFileSize <= maxAllowedFileSize or zoom >= dataTileZoom:

				if zoom >= dataTileZoom:
					ProcessSingleDataTile(cx, cy, zoom+1, mapIds, tileGroups)
				else:
					#Merge at this zoom
					#print "Merge tiles", cx, cy, zoom+1, totalFileSize
					MergeArea(cx, cy, zoom+1, mapIds, tileGroups)
			else:
				#Recusively consder higher zoom level
				ProcessAreaNextZoom(cx, cy, zoom+1, dataTileZoom, mapIds, tileGroups)
Esempio n. 5
0
def ProcessAreaNextZoom(x, y, zoom, dataTileZoom, mapIds, tileGroups):

    lat, lon = tiles.num2deg(x, y, zoom)
    x2, y2 = tiles.deg2num(lat, lon, zoom + 1)

    lat2, lon2 = tiles.num2deg(x + 1, y + 1, zoom)
    x3, y3 = tiles.deg2num(lat2, lon2, zoom + 1)

    for cx in range(x2, x3):
        for cy in range(y2, y3):
            totalFileSize = CalcFileSize(cx, cy, zoom + 1, dataTileZoom)
            if totalFileSize <= maxAllowedFileSize or zoom >= dataTileZoom:

                if zoom >= dataTileZoom:
                    ProcessSingleDataTile(cx, cy, zoom + 1, mapIds, tileGroups)
                else:
                    #Merge at this zoom
                    #print "Merge tiles", cx, cy, zoom+1, totalFileSize
                    MergeArea(cx, cy, zoom + 1, mapIds, tileGroups)
            else:
                #Recusively consder higher zoom level
                ProcessAreaNextZoom(cx, cy, zoom + 1, dataTileZoom, mapIds,
                                    tileGroups)
Esempio n. 6
0
def MergeArea(x, y, zoom, mapIds, tileGroups):
    lat, lon = tiles.num2deg(x, y, zoom)
    x2, y2 = tiles.deg2num(lat, lon, dataTileZoom)

    lat2, lon2 = tiles.num2deg(x + 1, y + 1, zoom)
    x3, y3 = tiles.deg2num(lat2, lon2, dataTileZoom)

    fiList = []
    for cx in range(x2, x3):
        for cy in range(y2, y3):
            fina = "../12/{0}/{1}.osm.bz2".format(cx, cy)
            if not os.path.isfile(fina):
                continue
            fiList.append(fina)

    if len(fiList) == 0:
        return
    #out = bz2.BZ2File("merge.osm.bz2","w")
    #print "Found {0} data tiles".format(len(fiList))

    tileGroups.append(fiList)
    mapId = 63240000 + len(mapIds)
    mapIds.append(mapId)

    if 0:
        countNodes, countWays, countRelations = mergeTiles.MergeFiles(
            fiList, out, 0)

        if countNodes + countWays + countRelations == 0:
            #Everything is empty
            return

        cmd = "java -jar ../splitter-r412/splitter.jar --mapid={0} merge.osm.bz2".format(
            mapId)

        os.system(cmd)
Esempio n. 7
0
	#tileBL = tiles.deg2num(27.673799, 32.1679688, 12) #Sinai
	#tileTR = tiles.deg2num(31.297328, 35.0024414, 12) #Sinai

	#tileBL = tiles.deg2num(51.00434, -4.02825, 12) #Exmoor
	#tileTR = tiles.deg2num(51.26630, -3.26607, 12) #Exmoor

	#tileBL = tiles.deg2num(49.0018439, -0.6632996, 12) #Caen
	#tileTR = tiles.deg2num(49.3644891, 0.0054932, 12) #Caen

	#tileBL = tiles.deg2num(49.6676278, -14.765625, 12) #UK and Eire
	#tileTR = tiles.deg2num(61.1856247, 2.2851563, 12) #UK and Eire

	#tileBL = tiles.deg2num(-47.279229, 107.7539063, 12) #Aus
	#tileTR = tiles.deg2num(-9.2756222, 162.5976563, 12) #Aus

	tileBL = tiles.deg2num(50.6599084, -1.3046265, 12) #Around portsmouth, uk
	tileTR = tiles.deg2num(50.9618867, -0.8061218, 12)

	print tileBL, tileTR
	count = 0
	#exit(0)
	for x in range(tileBL[0], tileTR[0] + 1):
		for y in range(tileTR[1], tileBL[1] + 1):
			print count, (tileBL[0] - tileTR[0] + 1) * (tileTR[1] - tileBL[1] + 1), x, y
			count += 1

			if not os.path.isdir("12"):
				os.mkdir("12")
			if not os.path.isdir("12/{0}".format(x)):
				os.mkdir("12/{0}".format(x))
Esempio n. 8
0
	#tileBL = tiles.deg2num(51.7882364, -3.4765251, 12) #Hampshire?
	#tileTR = tiles.deg2num(52.3707994, -2.2782056, 12) #Hampshire?

	#tileBL = tiles.deg2num(27.673799, 32.1679688, 12) #Sinai
	#tileTR = tiles.deg2num(31.297328, 35.0024414, 12) #Sinai

	#tileBL = tiles.deg2num(51.00434, -4.02825, 12) #Exmoor
	#tileTR = tiles.deg2num(51.26630, -3.26607, 12) #Exmoor

	#tileBL = tiles.deg2num(49.0018439, -0.6632996, 12) #Caen
	#tileTR = tiles.deg2num(49.3644891, 0.0054932, 12) #Caen

	#tileBL = tiles.deg2num(49.6676278, -14.765625, 12) #UK and Eire
	#tileTR = tiles.deg2num(61.1856247, 2.2851563, 12) #UK and Eire

	tileBL = tiles.deg2num(-47.279229, 107.7539063, 12) #Aus
	tileTR = tiles.deg2num(-9.2756222, 162.5976563, 12) #Aus

	print tileBL, tileTR
	count = 0
	outFolder = "australia"
	if not os.path.exists(outFolder):
		os.mkdir(outFolder)

	#exit(0)
	for x in range(tileBL[0], tileTR[0] + 1):
		for y in range(tileTR[1], tileBL[1] + 1):
			print count, (tileBL[0] - tileTR[0] + 1) * (tileTR[1] - tileBL[1] + 1), x, y
			count += 1

			inFina = "12/{0}/{1}.osm.bz2".format(x, y)
Esempio n. 9
0
	lats = (-47.279229, -9.2756222) #Aus
	lons = (107.7539063, 162.5976563) #Aus
	minZoom = 6

	count = 0
	os.chdir("tmp")
	dataTileZoom = 12
	mapIds = []
	tileGroups = []
	maxAllowedFileSize = 10000000

	#Plan work
	print "Lat range", min(lats), max(lats)
	print "Lon range", min(lons), max(lons)
	tileBL = tiles.deg2num(min(lats), min(lons), minZoom)
	tileTR = tiles.deg2num(max(lats), max(lons), minZoom)
	print "Tile coordinates", minZoom, tileBL, tileTR
	for x in range(tileBL[0], tileTR[0] + 1):
		for y in range(tileTR[1], tileBL[1] + 1):
			totalFileSize = CalcFileSize(x, y, minZoom, dataTileZoom)
			if totalFileSize <= maxAllowedFileSize or minZoom >= dataTileZoom:

				if minZoom >= dataTileZoom:
					ProcessSingleDataTile(x, y, minZoom, mapIds, tileGroups)
				else:
					#Merge at this zoom
					#print "Merge tiles", x, y, minZoom, totalFileSize
					MergeArea(x, y, minZoom, mapIds, tileGroups)
			else:
				#Recusively consider higher zoom level
Esempio n. 10
0
    lats = (-47.279229, -9.2756222)  #Aus
    lons = (107.7539063, 162.5976563)  #Aus
    minZoom = 6

    count = 0
    os.chdir("tmp")
    dataTileZoom = 12
    mapIds = []
    tileGroups = []
    maxAllowedFileSize = 10000000

    #Plan work
    print "Lat range", min(lats), max(lats)
    print "Lon range", min(lons), max(lons)
    tileBL = tiles.deg2num(min(lats), min(lons), minZoom)
    tileTR = tiles.deg2num(max(lats), max(lons), minZoom)
    print "Tile coordinates", minZoom, tileBL, tileTR
    for x in range(tileBL[0], tileTR[0] + 1):
        for y in range(tileTR[1], tileBL[1] + 1):
            totalFileSize = CalcFileSize(x, y, minZoom, dataTileZoom)
            if totalFileSize <= maxAllowedFileSize or minZoom >= dataTileZoom:

                if minZoom >= dataTileZoom:
                    ProcessSingleDataTile(x, y, minZoom, mapIds, tileGroups)
                else:
                    #Merge at this zoom
                    #print "Merge tiles", x, y, minZoom, totalFileSize
                    MergeArea(x, y, minZoom, mapIds, tileGroups)
            else:
                #Recusively consider higher zoom level