|
@@ -8,19 +8,19 @@
|
8
|
8
|
void Country::limits(){
|
9
|
9
|
QMap<QString,City*>::iterator it = Cities.begin();
|
10
|
10
|
|
11
|
|
- minX = maxX = Cities.begin().value()->geometry->at(0).x;
|
12
|
|
- minY = maxY = Cities.begin().value()->geometry->at(0).y;
|
|
11
|
+ minX = maxX = Cities.begin().value()->geometry->at(0).x();
|
|
12
|
+ minY = maxY = Cities.begin().value()->geometry->at(0).y();
|
13
|
13
|
|
14
|
14
|
for (it = Cities.begin() + 1; it != Cities.end(); ++it) {
|
15
|
15
|
|
16
|
16
|
City *c = it.value();
|
17
|
17
|
|
18
|
18
|
for (int i = 0; i < c->getSize(); i++) {
|
19
|
|
- if (c->geometry->at(i).x != 0.0) {
|
20
|
|
- if (c->geometry->at(i).x > maxX ) maxX = c->geometry->at(i).x;
|
21
|
|
- if (c->geometry->at(i).y > maxY ) maxY = c->geometry->at(i).y;
|
22
|
|
- if (c->geometry->at(i).x < minX ) minX = c->geometry->at(i).x;
|
23
|
|
- if (c->geometry->at(i).y < minY ) minY = c->geometry->at(i).y;
|
|
19
|
+ if (c->geometry->at(i).x() != 0.0) {
|
|
20
|
+ if (c->geometry->at(i).x() > maxX ) maxX = c->geometry->at(i).x();
|
|
21
|
+ if (c->geometry->at(i).y() > maxY ) maxY = c->geometry->at(i).y();
|
|
22
|
+ if (c->geometry->at(i).x() < minX ) minX = c->geometry->at(i).x();
|
|
23
|
+ if (c->geometry->at(i).y() < minY ) minY = c->geometry->at(i).y();
|
24
|
24
|
}
|
25
|
25
|
}
|
26
|
26
|
}
|
|
@@ -43,12 +43,12 @@ bool Country::readInfoFromJSON(const QString &fileName) {
|
43
|
43
|
|
44
|
44
|
int ctr = 1;
|
45
|
45
|
foreach(QJsonValue obj, topLevelArray) {
|
46
|
|
- QVector<DoublePoint> *points = new QVector<DoublePoint>;
|
|
46
|
+ QVector<QPointF> *points = new QVector<QPointF>;
|
47
|
47
|
QJsonArray geometryArray = obj.toObject()["geometry"].toObject()["coordinates"].toArray();
|
48
|
48
|
QString polyType = obj.toObject()["geometry"].toObject()["type"].toString();
|
49
|
49
|
if (polyType == "Polygon") {
|
50
|
50
|
for (int i = 0; i < geometryArray[0].toArray().size(); i++) {
|
51
|
|
- points->push_back(DoublePoint(
|
|
51
|
+ points->push_back(QPointF(
|
52
|
52
|
geometryArray[0].toArray()[i].toArray()[0].toDouble(),
|
53
|
53
|
geometryArray[0].toArray()[i].toArray()[1].toDouble()));
|
54
|
54
|
}
|
|
@@ -58,13 +58,13 @@ bool Country::readInfoFromJSON(const QString &fileName) {
|
58
|
58
|
for (int i = 0; i <geometryArray.size() ; i++) {
|
59
|
59
|
// for every point in the city's polygon
|
60
|
60
|
for (int j = 0; j < geometryArray[i].toArray()[0].toArray().size(); j++) {
|
61
|
|
- points->push_back(DoublePoint(
|
|
61
|
+ points->push_back(QPointF(
|
62
|
62
|
geometryArray[i].toArray()[0].toArray()[j].toArray()[0].toDouble(),
|
63
|
63
|
geometryArray[i].toArray()[0].toArray()[j].toArray()[1].toDouble()));
|
64
|
64
|
|
65
|
65
|
}
|
66
|
66
|
// I will push a 0,0 between each polygon of a multipolygon to distinguish
|
67
|
|
- points->push_back(DoublePoint(0,0));
|
|
67
|
+ points->push_back(QPointF(0,0));
|
68
|
68
|
}
|
69
|
69
|
}
|
70
|
70
|
|