| 143 | {} |
| 144 | |
| 145 | void Importer::validate() |
| 146 | { |
| 147 | auto const& georef = map->getGeoreferencing(); |
| 148 | if (georef.getState() == Georeferencing::Geospatial) |
| 149 | { |
| 150 | auto const expected = georef.getProjectedRefPoint(); |
| 151 | auto const actual = georef.toProjectedCoords(georef.getGeographicRefPoint()); |
| 152 | auto const offset = QLineF(actual, expected).length(); |
| 153 | if (offset > 0.9) |
| 154 | { |
| 155 | addWarning(::OpenOrienteering::Importer::tr("Georeferencing mismatch:") + QChar::Space + |
| 156 | ::OpenOrienteering::Importer::tr("Data may appear shifted by %1 m.").arg(qCeil(offset)) + QChar::Space + |
| 157 | ::OpenOrienteering::Importer::tr("Check the reference point coordinates in the georeferencing dialog.")); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // Object post processing: |
| 162 | // - make sure that there is no object without symbol |
| 163 | // - make sure that all area-only path objects are closed |
| 164 | // - make sure that there are no special points in wrong places (e.g. curve starts inside curves) |
| 165 | for (int p = 0; p < map->getNumParts(); ++p) |
| 166 | { |
| 167 | MapPart* part = map->getPart(p); |
| 168 | for (int o = 0; o < part->getNumObjects(); ++o) |
| 169 | { |
| 170 | Object* object = part->getObject(o); |
| 171 | if (object->getSymbol() == nullptr) |
| 172 | { |
| 173 | addWarning(::OpenOrienteering::Importer::tr("Found an object without symbol.")); |
| 174 | if (object->getType() == Object::Point) |
| 175 | object->setSymbol(map->getUndefinedPoint(), true); |
| 176 | else if (object->getType() == Object::Path) |
| 177 | object->setSymbol(map->getUndefinedLine(), true); |
| 178 | else |
| 179 | { |
| 180 | // There is no undefined symbol for this type of object, delete the object |
| 181 | part->deleteObject(o); |
| 182 | --o; |
| 183 | continue; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if (object->getType() == Object::Path) |
| 188 | { |
| 189 | PathObject* path = object->asPath(); |
| 190 | auto contained_types = path->getSymbol()->getContainedTypes(); |
| 191 | if (contained_types & Symbol::Area && !(contained_types & Symbol::Line)) |
| 192 | path->closeAllParts(); |
| 193 | |
| 194 | path->normalize(); |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | if (auto deleted = map->deleteIrregularObjects()) |
| 200 | { |
| 201 | addWarning(tr("Dropped %n irregular object(s).", nullptr, int(deleted))); |
| 202 | } |
nothing calls this directly
no test coverage detected