MCPcopy Create free account
hub / github.com/DOI-USGS/ISIS3 / write

Method write

isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.cpp:1657–1736  ·  view source on GitHub ↗

* This will write a control net file object to disk. * * @param netFile The output filename that will be written to * */

Source from the content-addressed store, hash-verified

1655 *
1656 */
1657 void ControlNetVersioner::write(FileName netFile) {
1658 try {
1659
1660 const int labelBytes = 65536;
1661 fstream output(netFile.expanded().toLatin1().data(), ios::out | ios::trunc | ios::binary);
1662 char *blankLabel = new char[labelBytes];
1663 memset(blankLabel, 0, labelBytes);
1664 output.write(blankLabel, labelBytes);
1665 delete [] blankLabel;
1666
1667 int numMeasures = 0;
1668 int numPoints = m_points.size();
1669 foreach (ControlPoint *point, m_points) {
1670 numMeasures += point->GetNumMeasures();
1671 }
1672
1673 streampos startCoreHeaderPos = output.tellp();
1674
1675 writeHeader(&output);
1676
1677 BigInt pointByteTotal = 0;
1678 while ( !m_points.isEmpty() ) {
1679 pointByteTotal += writeFirstPoint(&output);
1680 }
1681
1682 // Insert header at the beginning of the file once writing is done.
1683 ControlNetFileHeaderV0005 protobufHeader;
1684
1685 protobufHeader.set_networkid(m_header.networkID.toLatin1().data());
1686 protobufHeader.set_targetname(m_header.targetName.toLatin1().data());
1687 protobufHeader.set_created(m_header.created.toLatin1().data());
1688 protobufHeader.set_lastmodified(m_header.lastModified.toLatin1().data());
1689 protobufHeader.set_description(m_header.description.toLatin1().data());
1690 protobufHeader.set_username(m_header.userName.toLatin1().data());
1691
1692 streampos coreHeaderSize = protobufHeader.ByteSizeLong();
1693
1694 Pvl p;
1695
1696 PvlObject protoObj("ProtoBuffer");
1697
1698 PvlObject protoCore("Core");
1699 protoCore.addKeyword(PvlKeyword("HeaderStartByte",
1700 toString((BigInt) startCoreHeaderPos)));
1701 protoCore.addKeyword(PvlKeyword("HeaderBytes", toString((BigInt) coreHeaderSize)));
1702
1703 BigInt pointsStartByte = (BigInt) (startCoreHeaderPos + coreHeaderSize);
1704
1705 protoCore.addKeyword(PvlKeyword("PointsStartByte", toString(pointsStartByte)));
1706
1707 protoCore.addKeyword(PvlKeyword("PointsBytes",
1708 toString(pointByteTotal)));
1709 protoObj.addObject(protoCore);
1710
1711 PvlGroup netInfo("ControlNetworkInfo");
1712 netInfo.addComment("This group is for informational purposes only");
1713 netInfo += PvlKeyword("NetworkId", protobufHeader.networkid().c_str());
1714 netInfo += PvlKeyword("TargetName", protobufHeader.targetname().c_str());

Callers 5

mainFunction · 0.45
TestNetworkFunction · 0.45
writeFirstPointMethod · 0.45
WriteMethod · 0.45

Calls 14

dataMethod · 0.80
addKeywordMethod · 0.80
addObjectMethod · 0.80
createdMethod · 0.80
PvlKeywordClass · 0.50
toStringFunction · 0.50
IExceptionClass · 0.50
expandedMethod · 0.45
sizeMethod · 0.45
isEmptyMethod · 0.45
addCommentMethod · 0.45
descriptionMethod · 0.45

Tested by 2

mainFunction · 0.36
TestNetworkFunction · 0.36