Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "mapscanner.h"
- #include "scanner.h"
- #include <QtCore/QtMath>
- #include <QEventLoop>
- //Для z=17 4820 326.97
- //Для z=18 2415 161.09
- //https://static-maps.yandex.ru/1.x/?ll=30.3607,59.9280982&size=256,256&z=17&l=sat&pt=37.620070,55.753630,~30.3607,59.9280982,pmblm99,~30.3607,59.9280692,pmorm99
- //https://maps.googleapis.com/maps/api/staticmap?center=59.9280982,30.3661&zoom=17&maptype=satellite&size=256x256&markers=color:red%7C59.9280982,30.3661&scale=2key=
- //http://dev.virtualearth.net/REST/V1/Imagery/Map/Aerial/59.9280982%2C30.3661/17?mapSize=256,256&imagerySet=AerialWithLabels&format=png&pushpin=59.9280982,30.3661;60;&key=Ah12kIOAYzmW3ONiCcYEImWIp2xL8pwMXEvlOjhzjLRhjBBOCgBygJe4PHOY_aKU
- #define _CRT_SECURE_NO_WARNINGS
- double eps = sqrt(pow(6378, 2) - pow(6356, 2)) / (6378);
- double Delta = 0.002746368;
- int check = 0;
- bool bag = true;
- int CountWidth = -1;
- int CountHeight = 0;
- int n, m;
- int j = 0, i = 0;
- MapScanner::MapScanner(QWidget *parent)
- : QDialog(parent), m_renderPixmap(2048, 2048)
- {
- ui.setupUi(this);
- double w = ui.EarthWidth->text().toDouble();
- double w2 = ui.EarthWidth2->text().toDouble();
- n = CountI(w, w2);
- double k = ui.EarthHeight->text().toDouble();
- double k2 = ui.EarthHeight2->text().toDouble();
- double kRad = k / 180 * M_PI;
- double kdelta = Delta*(0.5*cos(kRad)*(pow(eps, 2)* (cos(2 * kRad) - 1) + 2)) / (1);
- m = CountJ(k, k2, kdelta);
- ui.lineEdit->setText(QString::number(n) + QString::number(m));
- QPixmap pix(2048, 2048);
- pix.save(ui.SavePath->text() + "newfile.png");
- m_View = new QWebEngineView();
- m_View->setGeometry(1000, 500, ui.SizeX->text().toFloat(), ui.SizeY->text().toFloat());
- m_Timer = new QTimer();
- connect(ui.MyButton, &QPushButton::clicked, [&]()
- {
- m_Timer->start(1);
- });
- m_Timer->setSingleShot(true);
- connect(m_Timer, &QTimer::timeout, [&]()
- {
- SaveImages();
- DownloadMap();
- Work();
- });
- }
- MapScanner::~MapScanner()
- {
- }
- void MapScanner::Work()
- {
- double w = ui.EarthWidth->text().toDouble();
- double w2 = ui.EarthWidth2->text().toDouble();
- double k = ui.EarthHeight->text().toDouble();
- double k2 = ui.EarthHeight2->text().toDouble();
- double kRad = k / 180 * M_PI;
- double kdelta = Delta*(0.5*cos(kRad)*(pow(eps, 2)* (cos(2 * kRad) - 1) + 2)) / (1);
- if (i < m)
- {
- if (j < n)
- {
- if (i % 2 == 0)
- {
- w = RightStep(w, w2);
- j++;
- bag = true;
- }
- else
- {
- w = LeftStep(w, w2);
- j++;
- bag = false;
- }
- }
- else
- {
- k = DownStep(k, k2, kdelta);
- i++;
- if (bag) CountWidth += 2;//это не баг - это фича
- else CountWidth -= 2;
- j = 0;
- }
- m_Timer->start(2500);
- }
- else
- m_Timer->stop();
- }
- double MapScanner::RightStep(double a, double b)
- {
- a += Delta;
- ui.EarthWidth->setText(QString::number(a));
- check++;
- CountWidth++;
- return a;
- }
- double MapScanner::DownStep(double a, double b,double delta)
- {
- a -= delta;
- ui.EarthHeight->setText(QString::number(a));
- check++;
- CountHeight++;
- //m_Timer->start(2500);
- return a;
- }
- double MapScanner::LeftStep(double a, double b)
- {
- a -= Delta;
- ui.EarthWidth->setText(QString::number(a));
- check++;
- CountWidth--;
- //m_Timer->start(2500);
- return a;
- }
- int MapScanner::CountI(double a, double b)
- {
- int l = ((abs(a - b)) + 2 * Delta*(ui.LineSize->text().toDouble()) / 326.97) / Delta;
- return l;
- }
- int MapScanner::CountJ(double a, double b,double delta)
- {
- int l = (abs(a - b) + 2 * delta*(ui.LineSize->text().toDouble()) / 326.97) / Delta;
- return l;
- }
- void MapScanner::DownloadMap()
- {
- QUrl UrlYandex("https://static-maps.yandex.ru/1.x/?ll=" + ui.EarthWidth->text() + ',' + ui.EarthHeight->text() + "&size=" + ui.SizeX->text() + ',' + ui.SizeY->text() + "&z=17&l=sat&pt=37.620070,55.753630,pmwtm1~37.64,55.76363,pmwtm99");
- QUrl UrlGoodle("https://maps.googleapis.com/maps/api/staticmap?center=" + ui.EarthHeight->text() + ',' + ui.EarthWidth->text() + "&zoom=17&maptype=satellite&size=" + ui.SizeX->text() + 'x' + ui.SizeY->text() + "&scale=2key=");
- QUrl UrlBing("http://dev.virtualearth.net/REST/V1/Imagery/Map/Aerial/" + ui.EarthHeight->text() + "%2C" + ui.EarthWidth->text() + "/17?mapSize=" + ui.SizeX->text() + ',' + ui.SizeY->text() + "&imagerySet=AerialWithLabels&format=png&key=Ah12kIOAYzmW3ONiCcYEImWIp2xL8pwMXEvlOjhzjLRhjBBOCgBygJe4PHOY_aKU");
- if (ui.GoogleUrl->isChecked())
- m_View->load(QUrl(UrlGoodle));
- if (ui.YandexUrl->isChecked())
- m_View->load(QUrl(UrlYandex));
- if (ui.BingUrl->isChecked())
- m_View->load(QUrl(UrlBing));
- }
- void MapScanner::SaveImages()
- {
- QPixmap pic(m_View->size());
- m_View->show();
- m_View->render(&pic);
- pic.save(ui.SavePath->text() + "img" + QString::number(check) + ".png");
- m_renderPixmap.load(ui.SavePath->text() + "newfile.png"); // создаём картинку
- QPainter p(&m_renderPixmap); // создаём рисовалку и нацеливаем её на картинку
- p.drawPixmap(256 * CountWidth, 256 * CountHeight, QPixmap(ui.SavePath->text() + "img" + QString::number(check) + ".png")); // накладываем изображение из файла на эту картинку в координаты 0,0
- p.end(); // завершаем работу рисовалки
- m_renderPixmap.save(ui.SavePath->text() + "newfile.png", "PNG"); // сохраняем файл
- }
- void MapScanner::LoadMaps()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement