2024-09-12 22:51:39 +02:00
|
|
|
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
|
|
# Find the tiles to keep around an airport, using the defined tile
|
|
|
|
# radius amount in defines.py
|
|
|
|
def findAirportTiles(av, ah):
|
|
|
|
# The tiles
|
|
|
|
tiles=[]
|
|
|
|
|
|
|
|
# Starting points
|
|
|
|
sty = av - int(mstr_airport_radius/2)
|
|
|
|
stx = ah - int(mstr_airport_radius/2)
|
|
|
|
|
|
|
|
for y in range(mstr_airport_radius):
|
|
|
|
for x in range(mstr_airport_radius):
|
|
|
|
a = ( sty+y, stx+x )
|
|
|
|
tiles.append(a)
|
|
|
|
|
|
|
|
# Return the tiles
|
|
|
|
return tiles
|
|
|
|
|
|
|
|
|
|
|
|
# Testing
|
|
|
|
def in_circle(center_x, center_y, radius, x, y):
|
|
|
|
square_dist = (center_x - x) ** 2 + (center_y - y) ** 2
|
2024-08-29 22:46:49 +02:00
|
|
|
return square_dist <= radius ** 2
|