本文整理汇总了C++中Projection::WorldX方法的典型用法代码示例。如果您正苦于以下问题:C++ Projection::WorldX方法的具体用法?C++ Projection::WorldX怎么用?C++ Projection::WorldX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projection
的用法示例。
在下文中一共展示了Projection::WorldX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartProcess
/**
* Mosaic Processing method, returns false if the cube is not inside the mosaic
*/
bool ProcessMapMosaic::StartProcess(QString inputFile) {
if (InputCubes.size() != 0) {
QString msg = "Input cubes already exist; do not call SetInputCube when using ";
msg += "ProcessMosaic::StartProcess(QString)";
throw IException(IException::Programmer, msg, _FILEINFO_);
}
if (OutputCubes.size() == 0) {
QString msg = "An output cube must be set before calling StartProcess";
throw IException(IException::Programmer, msg, _FILEINFO_);
}
CubeAttributeInput inAtt(inputFile);
Cube *inCube = ProcessMosaic::SetInputCube(inputFile, inAtt);
Cube *mosaicCube = OutputCubes[0];
Projection *iproj = inCube->projection();
Projection *oproj = mosaicCube->projection();
int nsMosaic = mosaicCube->sampleCount();
int nlMosaic = mosaicCube->lineCount();
if (*iproj != *oproj) {
QString msg = "Mapping groups do not match between cube [" + inputFile + "] and mosaic";
throw IException(IException::User, msg, _FILEINFO_);
}
int outSample, outSampleEnd, outLine, outLineEnd;
outSample = (int)(oproj->ToWorldX(iproj->ToProjectionX(1.0)) + 0.5);
outLine = (int)(oproj->ToWorldY(iproj->ToProjectionY(1.0)) + 0.5);
int ins = InputCubes[0]->sampleCount();
int inl = InputCubes[0]->lineCount();
outSampleEnd = outSample + ins;
outLineEnd = outLine + inl;
bool wrapPossible = iproj->IsEquatorialCylindrical();
int worldSize = 0;
if (wrapPossible) {
// Figure out how many samples 360 degrees is
wrapPossible = wrapPossible && oproj->SetUniversalGround(0, 0);
int worldStart = (int)(oproj->WorldX() + 0.5);
wrapPossible = wrapPossible && oproj->SetUniversalGround(0, 180);
int worldEnd = (int)(oproj->WorldX() + 0.5);
worldSize = abs(worldEnd - worldStart) * 2;
wrapPossible = wrapPossible && (worldSize > 0);
// This is EquatorialCylindrical, so shift to the left all the way
if (wrapPossible) {
// While some data would still be put in the mosaic, move left
// >1 for end because 0 still means no data, whereas 1 means 1 line of data
while (outSampleEnd - worldSize > 1) {
outSample -= worldSize;
outSampleEnd -= worldSize;
}
// Now we have the sample range to the furthest left
}
}
// Check overlaps of input image along the mosaic edges before
// calling ProcessMosaic::StartProcess
// Left edge
if (outSample < 1) {
ins = ins + outSample - 1;
}
// Top edge
if (outLine < 1) {
inl = inl + outLine - 1;
}
// Right edge
if ((outSample + ins - 1) > nsMosaic) {
ins = nsMosaic - outSample + 1;
}
// Bottom edge
if ((outLine + inl - 1) > nlMosaic) {
inl = nlMosaic - outLine + 1;
}
if (outSampleEnd < 1 || outLineEnd < 1 || outSample > nsMosaic || outLine > nlMosaic || ins < 1 || inl < 1) {
// Add a PvlKeyword naming which files are not included in output mosaic
ClearInputCubes();
return false;
}
else {
// Place the input in the mosaic
Progress()->SetText("Mosaicking " + FileName(inputFile).name());
try {
do {
int outBand = 1;
ProcessMosaic::StartProcess(outSample, outLine, outBand);
// Increment for projections where occurrances may happen multiple times
//.........这里部分代码省略.........
示例2: main
int main(int argc, char *argv[]) {
Preference::Preferences(true);
void doit(Pvl & lab);
void doit2(Pvl & lab);
try {
cout << "Unit test for ProjectionFactory" << endl;
Pvl lab;
lab.addGroup(PvlGroup("Mapping"));
PvlGroup &mapGroup = lab.findGroup("Mapping");
mapGroup += PvlKeyword("EquatorialRadius", toString(3396190.0));
mapGroup += PvlKeyword("PolarRadius", toString(3376200.0));
mapGroup += PvlKeyword("LatitudeType", "Planetographic");
mapGroup += PvlKeyword("LongitudeDirection", "PositiveEast");
mapGroup += PvlKeyword("LongitudeDomain", toString(360));
mapGroup += PvlKeyword("ProjectionName", "SimpleCylindrical");
mapGroup += PvlKeyword("CenterLongitude", toString(220.0));
cout << "Test for missing pixel resolution ... " << endl;
doit(lab);
doit2(lab);
mapGroup += PvlKeyword("PixelResolution", toString(2000.0));
cout << "Test for missing upper left X ... " << endl;
doit(lab);
mapGroup += PvlKeyword("UpperLeftCornerX", toString(-18000.0));
cout << "Test for missing upper left Y ... " << endl;
doit(lab);
mapGroup += PvlKeyword("UpperLeftCornerY", toString(2062000.0));
cout << "Testing conversion from image to ground ... " << endl;
Projection *proj = ProjectionFactory::CreateFromCube(lab);
proj->SetWorld(245.0, 355.0);
cout << setprecision(14);
cout << "Latitude: " << proj->Latitude() << endl;
cout << "Longitude: " << proj->Longitude() << endl;
cout << endl;
cout << "Testing conversion from ground to image ... " << endl;
proj->SetGround(22.84279897788801, 227.9291842833142);
cout << "Sample: " << proj->WorldX() << endl;
cout << "Line: " << proj->WorldY() << endl;
cout << endl;
cout << "Testing missing ground range on create method ... " << endl;
doit2(lab);
mapGroup += PvlKeyword("MinimumLatitude", toString(10.8920539924144));
mapGroup += PvlKeyword("MaximumLatitude", toString(34.7603960060206));
mapGroup += PvlKeyword("MinimumLongitude", toString(219.72432466275));
mapGroup += PvlKeyword("MaximumLongitude", toString(236.186050244411));
mapGroup.deleteKeyword("UpperLeftCornerX");
mapGroup.deleteKeyword("UpperLeftCornerY");
cout << "Testing create method ... " << endl;
int lines, samples;
proj = ProjectionFactory::CreateForCube(lab, samples, lines);
cout << "Lines: " << lines << endl;
cout << "Samples: " << samples << endl;
cout << "UpperLeftX: " << (double) mapGroup["UpperLeftCornerX"] << endl;
cout << "UpperLeftY: " << (double) mapGroup["UpperLeftCornerY"] << endl;
cout << endl;
cout << "Testing create method with existing cube labels" << endl;
mapGroup.addKeyword(PvlKeyword("UpperLeftCornerX", toString(-16000.0)), Pvl::Replace);
mapGroup.addKeyword(PvlKeyword("UpperLeftCornerY", toString(2060000.0)), Pvl::Replace);
Pvl lab2;
PvlObject icube("IsisCube");
PvlObject core("Core");
PvlGroup dims("Dimensions");
dims += PvlKeyword("Lines", toString(400));
dims += PvlKeyword("Samples", toString(600));
core.addGroup(dims);
icube.addObject(core);
icube.addGroup(mapGroup);
lab2.addObject(icube);
proj = ProjectionFactory::CreateForCube(lab2, samples, lines);
cout << "Lines: " << lines << endl;
cout << "Samples: " << samples << endl;
mapGroup = lab2.findGroup("Mapping", Pvl::Traverse);
cout << "UpperLeftX: " << (double) mapGroup["UpperLeftCornerX"] << endl;
cout << "UpperLeftY: " << (double) mapGroup["UpperLeftCornerY"] << endl;
cout << endl;
cout << "Label results" << endl;
cout << lab2 << endl;
}
catch(IException &e) {
e.print();
}
}