bool test_29() { bool state = true; IP_Address ip0("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); OS::get_singleton()->print("ip0 is %ls\n", String(ip0).c_str()); IP_Address ip(0x0123, 0x4567, 0x89ab, 0xcdef, true); OS::get_singleton()->print("ip6 is %ls\n", String(ip).c_str()); IP_Address ip2("fe80::52e5:49ff:fe93:1baf"); OS::get_singleton()->print("ip6 is %ls\n", String(ip2).c_str()); IP_Address ip3("::ffff:192.168.0.1"); OS::get_singleton()->print("ip6 is %ls\n", String(ip3).c_str()); String ip4 = "192.168.0.1"; bool success = ip4.is_valid_ip_address(); OS::get_singleton()->print("Is valid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL"); state = state && success; ip4 = "192.368.0.1"; success = (!ip4.is_valid_ip_address()); OS::get_singleton()->print("Is invalid ipv4: %ls, %s\n", ip4.c_str(), success ? "OK" : "FAIL"); state = state && success; String ip6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334"; success = ip6.is_valid_ip_address(); OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); state = state && success; ip6 = "2001:0db8:85j3:0000:0000:8a2e:0370:7334"; success = (!ip6.is_valid_ip_address()); OS::get_singleton()->print("Is invalid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); state = state && success; ip6 = "2001:0db8:85f345:0000:0000:8a2e:0370:7334"; success = (!ip6.is_valid_ip_address()); OS::get_singleton()->print("Is invalid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); state = state && success; ip6 = "2001:0db8::0:8a2e:370:7334"; success = (ip6.is_valid_ip_address()); OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); state = state && success; ip6 = "::ffff:192.168.0.1"; success = (ip6.is_valid_ip_address()); OS::get_singleton()->print("Is valid ipv6: %ls, %s\n", ip6.c_str(), success ? "OK" : "FAIL"); state = state && success; return state; };
bool rspfNitfRpcModel::parseImageHeader(const rspfNitfImageHeader* ih) { if (getRpcData(ih) == false) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::parseFile DEBUG:" << "\nError parsing rpc tags. Aborting with error." << std::endl; } setErrorStatus(); return false; } rspfString os = ih->getImageMagnification(); if ( os.contains("/") ) { os = os.after("/"); rspf_float64 d = os.toFloat64(); if (d) { theDecimation = 1.0 / d; } } theImageID = ih->getImageId(); rspfIrect imageRect = ih->getImageRect(); theImageSize.line = static_cast<rspf_int32>(imageRect.height() / theDecimation); theImageSize.samp = static_cast<rspf_int32>(imageRect.width() / theDecimation); getSensorID(ih); theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; theImageClipRect = rspfDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); rspfGpt v0, v1, v2, v3; rspfDpt ip0 (0.0, 0.0); rspfRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0); rspfDpt ip1 (theImageSize.samp-1.0, 0.0); rspfRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1); rspfDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); rspfRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2); rspfDpt ip3 (0.0, theImageSize.line-1.0); rspfRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3); theBoundGndPolygon = rspfPolygon (rspfDpt(v0), rspfDpt(v1), rspfDpt(v2), rspfDpt(v3)); updateModel(); rspfRpcModel::lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt); if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() ) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::rspfNitfRpcModel DEBUG:" << "\nGround Reference Point not valid." << " Aborting with error..." << std::endl; } setErrorStatus(); return false; } try { computeGsd(); } catch (const rspfException& e) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::rspfNitfRpcModel DEBUG:\n" << e.what() << std::endl; } } if (traceExec()) { rspfNotify(rspfNotifyLevel_DEBUG) << "DEBUG rspfNitfRpcModel::parseFile: returning..." << std::endl; } return true; }
bool ossimNitfRsmModel::parseImageHeader(const ossimNitfImageHeader* ih) { static const char MODULE[] = "ossimNitfRsmModel::getRsmData"; if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entering..." << std::endl; } bool status = false; if ( getRsmData(ih) ) { theImageID = m_iid.trim(); ossimIrect imageRect = ih->getImageRect(); // Fetch Image Size: theImageSize.line = static_cast<ossim_int32>(imageRect.height()); theImageSize.samp = static_cast<ossim_int32>(imageRect.width()); // Assign other data members: theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; // Assign the bounding image space rectangle: theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); lineSampleHeightToWorld(ip0, m_znrmo, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); lineSampleHeightToWorld(ip1, m_znrmo, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip2, m_znrmo, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip3, m_znrmo, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); updateModel(); // Set the ground reference point. lineSampleHeightToWorld(theRefImgPt, m_znrmo, theRefGndPt); // Height could have nan if elevation is not set so check lat, lon individually. if ( ( theRefGndPt.isLatNan() == false ) && ( theRefGndPt.isLonNan() == false ) ) { //--- // This will set theGSD and theMeanGSD. This model doesn't need these but // others do. //--- try { computeGsd(); // Set return status. status = true; } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n" << e.what() << std::endl; } setErrorStatus(); } } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:" << "\nGround Reference Point not valid(has nans)." << " Aborting with error..." << std::endl; } setErrorStatus(); } } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::parseFile DEBUG:" << "\nError parsing rsm tags. Aborting with error." << std::endl; } setErrorStatus(); } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status: " << ( status ? "true" : "false" ) << "\n"; } return status; } // End: ossimNitfRsmModel::parseImageHeader(const ossimNitfImageHeader* ih)
bool ossimNitfRpcModel::parseImageHeader(const ossimNitfImageHeader* ih) { // Do this first so we don't waste time if not rpc image. if (getRpcData(ih) == false) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::parseFile DEBUG:" << "\nError parsing rpc tags. Aborting with error." << std::endl; } setErrorStatus(); return false; } //--- // Get the decimation if any from the header "IMAG" field. // // Look for string like: // "/2" = 1/2 // "/4 = 1/4 // ... // "/16 = 1/16 // If it is full resolution it should be "1.0" //--- ossimString os = ih->getImageMagnification(); if ( os.contains("/") ) { os = os.after("/"); ossim_float64 d = os.toFloat64(); if (d) { theDecimation = 1.0 / d; } } //*** // Fetch Image ID: //*** theImageID = ih->getImageId(); ossimIrect imageRect = ih->getImageRect(); //--- // Fetch Image Size: //--- theImageSize.line = static_cast<ossim_int32>(imageRect.height() / theDecimation); theImageSize.samp = static_cast<ossim_int32>(imageRect.width() / theDecimation); // Search for the STDID Tag to fetch mission (satellite) name: getSensorID(ih); //*** // Assign other data members: //*** theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; //*** // Assign the bounding image space rectangle: //*** theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); //--- // Assign the bounding ground polygon: // // NOTE: We will use the base ossimRpcModel for transformation since all // of our calls are in full image space (not decimated). //--- ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); ossimRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); ossimRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); ossimRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); ossimRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); updateModel(); // Set the ground reference point. ossimRpcModel::lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt); if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:" << "\nGround Reference Point not valid." << " Aborting with error..." << std::endl; } setErrorStatus(); return false; } //--- // This will set theGSD and theMeanGSD. This model doesn't need these but // others do. //--- try { computeGsd(); } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n" << e.what() << std::endl; } } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimNitfRpcModel::parseFile: returning..." << std::endl; } return true; }
//***************************************************************************** // METHOD: ossimIkonosRpcModel::finishConstruction() // //***************************************************************************** void ossimIkonosRpcModel::finishConstruction() { if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel finishConstruction(): entering..." << std::endl; } //*** // Assign other data members: //*** thePolyType = B; // This may not be true for early RPC imagery theRefImgPt.line = theLineOffset; theRefImgPt.samp = theSampOffset; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; //*** // Assign the bounding image space rectangle: //*** theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); //--- // NOTE: We must call "updateModel()" to set parameter used by base // ossimRpcModel prior to calling lineSampleHeightToWorld or all // the world points will be same. //--- updateModel(); //*** // Assign the bounding ground polygon: //*** ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); lineSampleHeightToWorld(ip0, 0.0, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); lineSampleHeightToWorld(ip1, 0.0, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip2, 0.0, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip3, 0.0, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); //--- // Call compute gsd: // // This will set theGSD and theMeanGSD using lineSampleHeightToWorld on // three image points. Previously this was pulled from metadata. Some of // which was in US Survey feet and not converted to meters. This method // is more accurate as it uses the sensor model to compute. //--- try { // Method throws ossimException. computeGsd(); } catch (const ossimException& e) { ossimNotify(ossimNotifyLevel_WARN) << "ossimIkonosRpcModel finishConstruction Caught Exception:\n" << e.what() << std::endl; } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel finishConstruction(): returning..." << std::endl; } }