MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / validate

Method validate

src/fileformats/file_import_export.cpp:145–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143{}
144
145void 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 }

Callers

nothing calls this directly

Calls 15

FileFormatExceptionClass · 0.85
getStateMethod · 0.80
getProjectedRefPointMethod · 0.80
toProjectedCoordsMethod · 0.80
getGeographicRefPointMethod · 0.80
getObjectMethod · 0.80
getUndefinedPointMethod · 0.80
getUndefinedLineMethod · 0.80
asPathMethod · 0.80
closeAllPartsMethod · 0.80
getNumSymbolsMethod · 0.80

Tested by

no test coverage detected