Commits
4449 4449 | String *sa = new String[maxn]; |
4450 4450 | String sep = " "; |
4451 4451 | int n = split(s, sa, maxn, sep); |
4452 4452 | if (n==1) { |
4453 4453 | rec->define("qstring", s); // quantum string such as '4kHz' |
4454 4454 | } else { |
4455 4455 | Vector<String> sarr(n); |
4456 4456 | for (int i=0; i < n; i++) sarr[i]=sa[i]; |
4457 4457 | RecordDesc rd; |
4458 4458 | rd.addField("string", TpArrayString, IPosition(1,n)); |
4459 - | rec = new Record(rd); |
4459 + | rec->restructure(rd); |
4460 4460 | rec->define("string", sarr); |
4461 4461 | } |
4462 4462 | delete [] sa; |
4463 4463 | } else { |
4464 4464 | // Convert to numeric e.g. "1 20" -> [1,20] |
4465 4465 | //tovector(value, 'double'); NEEDS WORK HERE!!! |
4466 4466 | //rec->define(RecordFieldId("numeric"),value); |
4467 4467 | } |
4468 4468 | return rec; |
4469 4469 | } |
4470 4470 | if (value.type() == ::casac::variant::STRINGVEC) { |
4471 4471 | Vector<String> sarr = toVectorString(value.toStringVec()); |
4472 4472 | int n = sarr.size(); |
4473 4473 | RecordDesc rd; |
4474 4474 | rd.addField("string", TpArrayString, IPosition(1,n)); |
4475 - | rec = new Record(rd); |
4475 + | rec->restructure(rd); |
4476 4476 | rec->define("string", sarr); |
4477 4477 | return rec; |
4478 4478 | } |
4479 4479 | // variant doesn't support quantity yet |
4480 4480 | //if (value.type() == ::casac::variant::QUANTITY) { |
4481 4481 | // if (!isWorld) { |
4482 4482 | // *_log << LogIO::SEVERE |
4483 4483 | // << "Pixel coordinate must be numeric" << LogIO::POST; |
4484 4484 | // return rec; |
4485 4485 | // } |
4486 4486 | // rec->define(RecordFieldId("quantity"), |
4487 4487 | // defaultcoordsyssupport.valuetovectorquantum(value, singlevector=T)); |
4488 4488 | // if (is_fail(rec.quantity)) fail; |
4489 4489 | // return rec; |
4490 4490 | //} |
4491 4491 | if (value.type() == ::casac::variant::RECORD) { |
4492 4492 | // Catch r := cs.toworld (value, 'nqms') style where r is a record |
4493 4493 | // with fields including 'measure' |
4494 4494 | Bool none = true; |
4495 + | delete rec; |
4495 4496 | rec = toRecord(tmpv.asRecord()); |
4496 4497 | if (rec->isDefined("numeric")) { |
4497 4498 | if (first) return rec; |
4498 4499 | none = false; |
4499 4500 | } |
4500 4501 | if (rec->isDefined("measure")) { |
4501 4502 | if (first) return rec; |
4502 4503 | if (!isWorld) { |
4503 4504 | *_log << LogIO::SEVERE |
4504 4505 | << "Pixel coordinate must be numeric not a measure" |
4535 4536 | if (!isWorld) { |
4536 4537 | *_log << LogIO::WARN |
4537 4538 | << "Pixel coordinate must be numeric not a measure" |
4538 4539 | << LogIO::POST; |
4539 4540 | delete rec; |
4540 4541 | rec = 0; |
4541 4542 | return rec; |
4542 4543 | } |
4543 4544 | RecordDesc rd; |
4544 4545 | rd.addField("measure", TpRecord); |
4545 - | rec = new Record(rd); |
4546 + | rec->restructure(rd); |
4546 4547 | rec->defineRecord("measure", *toRecord(tmpv.asRecord())); |
4547 4548 | } |
4548 4549 | return rec; |
4549 4550 | |
4550 4551 | /* |
4551 4552 | // Assumes the record is a quantity |
4552 4553 | Record tmpR = *toRecord(tmpv.asRecord()); |
4553 4554 | if (none) { |
4554 4555 | if (!isWorld) { |
4555 4556 | *_log << LogIO::SEVERE |