orthographic/functions.py

68 lines
1.7 KiB
Python
Raw Normal View History

# -------------------------------------------------------------------
# ORTHOGRAPHIC
# Your personal aerial satellite. Always on. At any altitude.*
# Developed by MarStrMind
# License: Open Software License 3.0
# Up to date version always on marstr.online
# -------------------------------------------------------------------
# functions.py
# A number of utility functions that don't belong in any class
# -------------------------------------------------------------------
import os
import json
from defines import *
# Find out if we have a tiledata.json file at all
def doesTileDataExist(lat, lng):
e = False
if os.path.isfile(mstr_datafolder + "Tiles\\" + str(lat) + "_" + str(lng) + "\\data.db"):
e = True
return e
# Find adjacent tiles to check against existing chosen imagery
#
# The provided tile is the center, and it will provide a list of
# all adjacent tiles, like so:
#
# #
# #X#
# #
#
# If we are in a corner, those will be omitted.
def findAdjacentTilesTo(v, h):
adj = []
adj.append( (v+1, h) ) # Top
adj.append( (v, h+1) ) # Right
adj.append( (v-1, h) ) # Bottom
adj.append( (v, h-1) ) # Left
return adj
# Find the tiles we need in order to construct zoom level 16 photos,
# based on the tile provided. This is usually called at the very end
# of the ortho generation process.
def findZL16tiles(v, h):
# Contains the tiles, in forward order (order of processing)
tiles = []
for y in range(0, 4):
tr = []
for x in range(0, 4):
tl = (v+y, h+x)
tr.append(tl)
tiles.append(tr)
return tiles
# Testing
def in_circle(center_x, center_y, radius, x, y):
square_dist = (center_x - x) ** 2 + (center_y - y) ** 2
return square_dist <= radius ** 2