bool EllipsoidConnector::createEllipsoidFromCode(const QString& code, IlwisObject *data) { QString query = QString("Select * from ellipsoid where code = '%1'").arg(code); QSqlQuery db(kernel()->database()); if (db.exec(query)) { if ( db.next()) { Ellipsoid *ellipsoid = static_cast<Ellipsoid *>(data); ellipsoid->setName(db.record().field("name").value().toString()); ellipsoid->setDescription(db.record().field("description").value().toString()); double ma = db.record().field("majoraxis").value().toDouble(); double rf = db.record().field("invflattening").value().toDouble(); ellipsoid->setEllipsoid(ma,rf); ellipsoid->setAuthority(db.record().field("authority").value().toString()); ellipsoid->setConnector(this); // we are internal, no connector needed ellipsoid->setCode(code); return true; } }else kernel()->issues()->logSql(db.lastError()); return false; }
IEllipsoid CoordinateSystemConnector::getEllipsoid() { QString ell = _odf->value("CoordSystem","Ellipsoid"); if ( ell == "?") return IEllipsoid(); if ( ell == "User Defined") { double invf = _odf->value("Ellipsoid","1/f").toDouble(); double majoraxis = _odf->value("Ellipsoid","a").toDouble(); Ellipsoid *ellips = new Ellipsoid(); QString newName = ellips->setEllipsoid(majoraxis,invf);; ellips->name(newName); IEllipsoid ellipsoid(ellips); return ellipsoid; } IEllipsoid ellipsoid; QString code = name2Code(ell, "ellipsoid"); if ( code == sUNDEF) return IEllipsoid(); QString resource = QString("ilwis://tables/ellipsoid?code=%1").arg(code); ellipsoid.prepare(resource); return ellipsoid; }