1. 程式人生 > 實用技巧 >根據經緯度獲取高度

根據經緯度獲取高度

import matplotlib.pyplot as plt
import cv2 as cv
import numpy as np
import random
import glob
import os
import sys
import re
import datetime
import pymysql
import time
import csv
import datetime 
import requests

def connect_database(): 
    server = "localhost"
    user = "root"
    password = "000000"
    database 
= "lightning" db = pymysql.connect(server, user, password, database) return db def check(x,y): global cmcc url = 'https://www.advancedconverter.com/ajax/getElev9.php?lat='+str(y)+'&lng='+str(x)+'&cookieIDD='+cmcc headers = { 'authority':'www.advancedconverter.com', '
method':'GET', 'scheme':'https', 'accept':'application/json, text/javascript, */*; q=0.01', 'accept-encoding':'gzip, deflate, br', 'accept-language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6', 'referer':'https://www.advancedconverter.com/map-tools/find-altitude-by-coordinates', 'sec-fetch-dest
':'empty', 'sec-fetch-mode':'cors', 'sec-fetch-site':'same-origin', 'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 Edg/84.0.522.52', 'x-requested-with':'XMLHttpRequest' } data = {'lat': x, 'lng': y, 'cookieIDD': cmcc} print("use ",cmcc) r = requests.post(url, data=data, headers=headers) print(r.text) if(len(r.text))<10: r = requests.post("https://www.advancedconverter.com/map-tools/find-altitude-by-coordinates") datt=r.text list=re.findall('var cookieIDD=(.*?);',datt) cmcc=list[0][1:17] print(cmcc) return 1 else: with open("2.txt","a") as f: f.write(str(x)) f.write('\t') f.write(str(y)) f.write('\t') if(len(r.text))>10: f.write(r.text[55:66]) f.write('\n') f.close() return 0 def get_height(x,y): ree=check(x,y) if(ree==1): ree=check(x,y) if(ree==1): ree=check(x,y) if(ree==1): ree=check(x,y) # y = datetime.datetime(int(get_data[7][0:4]),int(get_data[7][4:6]),int(get_data[7][6:8]),int(get_data[8][0:2]),int(get_data[8][2:4]),int(get_data[8][4:6]),000000) # y += datetime.timedelta(seconds=2 * int(get_data[16]) - 2) #??????+120s # starttime = "'" + str(y.year) + "-" + str(y.month) + "-" + str(y.day) + " " + str(y.hour) + ":" + str(y.minute) + ":" + str(y.second) + "." + str(y.microsecond) + "'" # update_lightning(starttime,file_name) cmcc='LxB74mpUYJEr/A==' k=0 for ear_x in range(-180,181): for ear_y in range(-90,91): k+=1 if(k>603): get_height(ear_x,ear_y)