GeodeticDatum *GeodeticDatum::clone() const { GeodeticDatum *datum = new GeodeticDatum(); datum->name(name()) ; datum->code(code()); datum->setDescription(description()); datum->_area = _area; datum->_authority = _authority; datum->_datumParams = _datumParams; datum->_mode = _mode; datum->_isValid = _isValid; datum->_wkt = _wkt; return datum; }
GeodeticDatum *CoordinateSystemConnector::getDatum(QString& ellipsoid) { QString datum =_odf->value("CoordSystem","Datum"); if ( datum == sUNDEF) return 0; // not an error; simply no datum with this csy QString area = _odf->value("CoordSystem","Datum Area"); if ( area != sUNDEF && area != "" ) datum = datum + "." + area; QString code = name2Code(datum,"datum"); if ( code == "?"){ kernel()->issues()->log(TR("No datum code for this alias %1").arg(datum)); return 0; } QSqlQuery stmt(kernel()->database()); QString query = QString("Select * from datum where code='%1'").arg(code); if (stmt.exec(query)) { if ( stmt.next()) { GeodeticDatum *gdata = new GeodeticDatum(); QString area = stmt.value(stmt.record().indexOf("area")).toString(); QString code = stmt.value(stmt.record().indexOf("code")).toString(); double dx = stmt.value(stmt.record().indexOf("dx")).toDouble(); double dy = stmt.value(stmt.record().indexOf("dy")).toDouble(); double dz = stmt.value(stmt.record().indexOf("dz")).toDouble(); gdata->setArea(area); gdata->code(code); gdata->set3TransformationParameters(dx, dy, dz); ellipsoid = stmt.value(stmt.record().indexOf("ellipsoid")).toString(); return gdata; } else { kernel()->issues()->log(TR("No datum for this code %1").arg(code)); } } else { kernel()->issues()->logSql(stmt.lastError()); } return 0; }
GeodeticDatum *InternalIlwisObjectFactory::createDatum(const Resource& resource, const IOOptions &options) const { QString query; if ( resource.code() != sUNDEF) { QString code = resource.code(); if ( code != "") { query = QString("Select * from datum where code = '%1'").arg(code); } } if ( resource["area"] != sUNDEF) { QString name = resource.name(); QString area = resource["area"].toString(); query = QString("Select * from datum where name='%1' and area='%1'").arg(name, area); } if ( query == "") return 0; InternalDatabaseConnection db; if (db.exec(query) && db.next()) { GeodeticDatum *datum = new GeodeticDatum(); QSqlRecord rec = db.record(); datum->name(rec.field("name").value().toString()); datum->setDescription(rec.field("description").value().toString()); datum->setAuthority(rec.field("authority").value().toString()); datum->setArea(rec.field("area").value().toString()); datum->code(rec.field("code").value().toString()); QString ellips = rec.field("code").value().toString(); IEllipsoid ell; QString ellres = QString("code=ellipsoid:%1").arg(ellips); ell.prepare(ellres); datum->set3TransformationParameters(rec.field("dx").value().toDouble(), rec.field("dy").value().toDouble(), rec.field("dz").value().toDouble(), ell); return datum; } return 0; }