File: main.cpp

package info (click to toggle)
stellarium 24.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 911,396 kB
  • sloc: ansic: 317,377; cpp: 204,602; xml: 48,590; javascript: 26,348; python: 1,254; perl: 1,108; sh: 207; makefile: 190; pascal: 169
file content (38 lines) | stat: -rw-r--r-- 1,053 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <QtCore/QCoreApplication>
#include "StelToast.hpp"
#include "StelJsonParser.hpp"

int main(int argc, char *argv[])
{
	Q_ASSERT(argc==3);
	QByteArray ar = argv[1];
	bool ok;
	int level = ar.toInt(&ok);
	if (!ok)
	{
		qFatal("Argument 1 must be a valid level number");
	}
	int length = sqrt(pow(4, level));
	SphericalRegionP reg = SphericalRegionP::loadFromQVariant(StelJsonParser::parse(argv[2]).toList());
	//SphericalRegionP reg = SphericalRegionP::loadFromQVariant(StelJsonParser::parse("[[21.286982057125858, 82.117482778097937], [341.20801035028205, 82.141350178494122], [308.54824444399429, 86.661406614892087], [54.398199236987082, 86.613098160666411]]").toList());
	ToastGrid grid(level);
	QVariantList l;
	for (int i=0;i<length;++i)
	{
		for (int j=0;j<length;++j)
		{
			SphericalConvexPolygon poly(grid.getPolygon(level,i,j));
			if (reg->intersects(poly))
			{
				QVariantMap m;
				m["i"]=i;
				m["j"]=j;
				m["tile"]= poly.toQVariant();
				l << m;
			}
		}
	}
	printf("%s", StelJsonParser::write(l).constData());

	return 0;
}