コード例 #1
0
ファイル: getarea.py プロジェクト: TimSC/mapbin
def MultiTileSave(getArea, queryArea, zoom):

	tl = slippy.deg2num(queryArea[3], queryArea[0], 11)
	br = slippy.deg2num(queryArea[1], queryArea[2], 11)

	for tilex in range(tl[0], br[0]+2):
		if not os.path.exists(str(tilex)):
			os.mkdir(str(tilex))
		for tiley in range(tl[1], br[1]+2):
			fina = "{0}/{1}.osm.bz2".format(tilex, tiley)
			try:
				getArea.GetTile(tilex, tiley, zoom, bz2.BZ2File(fina, "w"), False)
			except RuntimeError as err:
				print err
				os.unlink(fina)
コード例 #2
0
ファイル: layer.py プロジェクト: TimSC/kivmap
	def GetViewBounds(self):
		tilex, tiley = slippy.deg2num(self.viewPos[0], self.viewPos[1], self.viewZoom)
		#print tilex, tiley

		left = tilex - 0.5 * self.size[0] / self.tileSize
		right = tilex + 0.5 * self.size[0] / self.tileSize
		top = tiley - 0.5 * self.size[1] / self.tileSize
		bottom = tiley + 0.5 * self.size[1] / self.tileSize

		return left, right, top, bottom
コード例 #3
0
ファイル: indexspatial.py プロジェクト: TimSC/mapbin
	def RecusiveZoomAdd(self, currentZoom, lat, lon, objId, version):
		
		tilex, tiley = slippy.deg2num(lat, lon, currentZoom)
		#print lat, lon, tilex, tiley

		#fullFile = "/{0}/{1}/{2}.full".format(currentZoom, tilex, tiley)
		#if self.outFileSystem.exists(fullFile) and currentZoom < self.maxZoom:
		#	self.RecusiveZoomAdd(currentZoom + 1, lat, lon, objId, version)
		#	return

		fi = self.Open(currentZoom, tilex, tiley)
		objIdInt = int(objId)
		if objIdInt == 0:
			print "Warning: adding a zero objId"
		fi.write(self.entry.pack(objIdInt, version))
		numEntries = len(fi) / self.entry.size
コード例 #4
0
ファイル: layer.py プロジェクト: TimSC/kivmap
	def on_touch_move(self, touch):
		#Calculate distance dragged
		relativeMove = (touch.pos[0] - self.lastTouch[0], touch.pos[1] - self.lastTouch[1])
		self.lastTouch = touch.pos
		fractRelativeMove = (relativeMove[0] / self.size[0], relativeMove[1] / self.size[1])

		#Update view
		left, right, top, bottom = self.GetViewBounds() 
		dx = (right - left) * fractRelativeMove[0]
		dy = (bottom - top) * fractRelativeMove[1]
		tilex, tiley = slippy.deg2num(self.viewPos[0], self.viewPos[1], self.viewZoom)
		tilex -= dx
		tiley += dy
		self.viewPos = slippy.num2deg(tilex, tiley, self.viewZoom)

		self.UpdateExistingTilePositions()
		self.AddNewTilesAsRequired()
		self.RemoveUnneededTiles()