bool ossimAdjustmentInfo::saveState(ossimKeywordlist& kwl, const ossimString& prefix)const { kwl.add(prefix, ossimKeywordNames::DESCRIPTION_KW, getDescription(), true); kwl.add(prefix.c_str(), NUMBER_OF_PARAMS_KW, static_cast<ossim_uint32>(theParameterList.size()), true); kwl.add(prefix, DIRTY_FLAG_KW, (short)theDirtyFlag, true); ossimString value; for(ossim_uint32 idx = 0; idx < theParameterList.size();++idx) { ossimString newPrefix = ossimString(prefix) + (ossimString(PARAM_PREFIX) + ossimString::toString(idx)+"."); theParameterList[idx].saveState(kwl, newPrefix.c_str()); } return true; }
bool ossimAdjustmentInfo::loadState(const ossimKeywordlist& kwl, const ossimString& prefix) { setDescription(kwl.find(prefix, ossimKeywordNames::DESCRIPTION_KW)); setNumberOfAdjustableParameters(ossimString(kwl.find(prefix, NUMBER_OF_PARAMS_KW)).toUInt32()); const char *dirtyFlag = kwl.find(prefix, DIRTY_FLAG_KW); ossimString value; if(dirtyFlag) { theDirtyFlag = ossimString(dirtyFlag).toBool(); } else { theDirtyFlag = false; } for(ossim_uint32 idx = 0; idx < theParameterList.size();++idx) { ossimString newPrefix = ossimString(prefix) + (ossimString(PARAM_PREFIX) + ossimString::toString(idx)+"."); if(!theParameterList[idx].loadState(kwl, newPrefix.c_str())) { return false; } } return true; }
bool ossimImageToPlaneNormalFilter::saveState(ossimKeywordlist& kwl, const char* prefix)const { kwl.add(prefix, ossimKeywordNames::SCALE_PER_PIXEL_X_KW, theXScale, true); kwl.add(prefix, ossimKeywordNames::SCALE_PER_PIXEL_Y_KW, theXScale, true); kwl.add(prefix, "track_scale_flag", (ossim_uint32)theTrackScaleFlag, true); kwl.add(prefix, SMOOTHNESS_FACTOR_KW, theSmoothnessFactor, true); return ossimImageSourceFilter::saveState(kwl, prefix); }
bool ossimBlendMosaic::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool result = ossimImageMosaic::loadState(kwl, prefix); ossim_uint32 count = 0; theWeights.clear(); if(result) { ossimString copyPrefix = prefix; ossimString regExpression = ossimString("^(") + copyPrefix + "weight[0-9]+)"; ossim_uint32 result = kwl.getNumberOfSubstringKeys(regExpression); ossim_uint32 numberOfMatches = 0; while(numberOfMatches < result) { ossimString value = ossimString("weight") + ossimString::toString(count); const char* lookup = kwl.find(copyPrefix.c_str(), value.c_str()); if(lookup) { ++numberOfMatches; theWeights.push_back(ossimString(lookup).toDouble()); } ++count; } } return result; }
bool ossimMemoryImageSource::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool returnResult = ossimImageSource::loadState(kwl, prefix); m_geometry = 0; if(returnResult) { ossimString imagePrefix = ossimString(prefix) + "image."; ossimString geomPrefix = ossimString(prefix) + "geom."; ossimString type = kwl.find(imagePrefix, "type"); if(!type.empty()) { m_image = new ossimImageData(); returnResult = m_image->loadState(kwl, imagePrefix.c_str()); m_image->initialize(); m_boundingRect = m_image->getImageRectangle(); } if(returnResult) { type = kwl.find(geomPrefix, "type"); if(!type.empty()) { m_geometry = new ossimImageGeometry(); returnResult = m_geometry->loadState(kwl, geomPrefix.c_str()); } } } m_result = 0; return returnResult; }
bool ossimTilingPoly::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool result = ossimTilingRect::loadState(kwl, prefix); //Get the shp file if any m_shpFilename = kwl.find(prefix, "tile_source"); // Get the mask if any. if (!m_shpFilename.empty()) { if (theTileNameMask.contains("%r%_%c%")) { theTileNameMask = theTileNameMask.substitute("%r%_%c%", "%f%", true); } result = true; } const char* useMbr = kwl.find(prefix, "padding_use_mbr"); if (useMbr) { if (!ossimString(useMbr).toBool()) { m_useMbr = false; m_bufferDistance = thePaddingSizeInPixels.x; } } return result; }
/*************************************************************** * This method saves the filter state between property box edits ***************************************************************/ bool ossimCFARFilter::saveState(ossimKeywordlist& kwl, const char* prefix)const { kwl.add(prefix, "rows", 5, true); kwl.add(prefix, "cols", 5, true); for(ossim_int32 row = 0; row < 5; ++row) { for(ossim_int32 col =0; col < 5; ++col) { ossimString newPrefix = "m" + ossimString::toString(row+1) + "_" + ossimString::toString(col+1); kwl.add(prefix, newPrefix, theKernel[row][col], true); } } kwl.add(prefix, "threshold", theThreshold, true); return ossimImageSourceFilter::saveState(kwl, prefix); }
bool buildChains(const ossimKeywordlist& kwl, ossimConnectableObject::ConnectableObjectList& chains) { ossim_int32 index = 0; ossim_int32 result = kwl.getNumberOfSubstringKeys("file[0-9]+\\.filename"); const char* lookup = NULL; ossim_int32 numberOfMatches = 0; vector<ossimFilename> fileList; while(numberOfMatches < result) { ossimString searchValue = "file" + ossimString::toString(index); ossimString filename = searchValue + ".filename"; lookup = kwl.find(filename.c_str()); if(lookup) { fileList.push_back(ossimFilename(lookup)); ++numberOfMatches; } ++index; } return buildChains(fileList, chains); }
bool ossimCosmoSkymedModel::InitSRGR(const ossimKeywordlist &kwl, const char *prefix) { const char* rangeProjectionType_str = kwl.find(prefix,"rangeProjectionType"); std::string rangeProjectionType(rangeProjectionType_str); const char* pixel_spacing_str = kwl.find(prefix,"pixel_spacing"); _pixel_spacing= atof(pixel_spacing_str); _isProductGeoreferenced = (rangeProjectionType=="GROUNDRANGE") ; // Number of columns const char* nbCol_str = kwl.find(prefix,"nbCol"); _nbCol = atoi(nbCol_str); // SRGR polynomial reference const char* SrGr_R0_str = kwl.find(prefix,"SrGr_R0"); _SrGr_R0 = atof(SrGr_R0_str); // SRGR coefficients char name[64]; double coeff ; for(int i=0;i<6;i++) { sprintf(name,"SrToGr_coeffs_%i",i); const char* coeff_str = kwl.find(prefix,name); coeff = atof(coeff_str); _SrGr_coeffs.push_back(coeff); } return true; }
bool ImageNoise::saveState(ossimKeywordlist& kwl, const char* prefix) const { std::string pfx; std::string pfx2; if (prefix) { pfx = prefix; } pfx += PREFIX; kwl.add(pfx.c_str(), TIME_UTC, _timeUTC); pfx2 = pfx + NOISE_ESTIMATE; kwl.add(pfx2.c_str(), VALIDITY_RANGE_MIN, _validityRangeMin); kwl.add(pfx2.c_str(), VALIDITY_RANGE_MAX, _validityRangeMax); kwl.add(pfx2.c_str(), REFERENCE_POINT, _referencePoint); kwl.add(pfx2.c_str(), POLYNOMIAL_DEGREE, _polynomialDegree); for(unsigned int i=0 ; i<_polynomialCoefficients.size();i++) { ossimString iStr = ossimString::toString(i); ossimString kw = ossimString(COEFFICIENT) + "["+iStr+ "]"; kwl.add(pfx2.c_str(), kw.c_str(), _polynomialCoefficients[i]); } return true; }
bool ossimQtVceShape::loadState(const ossimKeywordlist& kwl, const char* prefix) { const char* id = kwl.find(prefix, ossimKeywordNames::ID_KW); const char* selectionSize = kwl.find(prefix, "selection_box_size"); const char* position = kwl.find(prefix, "position"); if(id) { theId = ossimString(id).toInt(); } if(selectionSize) { std::stringstream s(selectionSize); int w, h; s >> w >> h; theSelectionBoxSize = QSize(w, h); } if(position) { std::stringstream s(position); int x, y; s >> x >> y; setX(x); setY(y); } return true; }
bool ossimQtVceShape::saveState(ossimKeywordlist& kwl, const char* prefix)const { kwl.add(prefix, ossimKeywordNames::TYPE_KW, "ossimQtVceShape", true); kwl.add(prefix, ossimKeywordNames::ID_KW, theId, true); kwl.add(prefix, "selection_box_size", ossimString::toString(theSelectionBoxSize.width())+" "+ ossimString::toString(theSelectionBoxSize.height()), true); kwl.add(prefix, "position", ossimString::toString((int)x())+" "+ ossimString::toString((int)y()), true); QRect b = boundingVceShapeRect(); return true; }
bool ossimLambertConformalConicProjection::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool flag = ossimMapProjection::loadState(kwl, prefix); const char* type = kwl.find(prefix, ossimKeywordNames::TYPE_KW); const char* stdParallel1 = kwl.find(prefix, ossimKeywordNames::STD_PARALLEL_1_KW); const char* stdParallel2 = kwl.find(prefix, ossimKeywordNames::STD_PARALLEL_2_KW); setDefaults(); if(ossimString(type) == STATIC_TYPE_NAME(ossimLambertConformalConicProjection)) { Lambert_False_Easting = theFalseEastingNorthing.x; Lambert_False_Northing = theFalseEastingNorthing.y; if(stdParallel1) { Lambert_Std_Parallel_1 = ossimString(stdParallel1).toDouble()*RAD_PER_DEG; } if(stdParallel2) { Lambert_Std_Parallel_2 = ossimString(stdParallel2).toDouble()*RAD_PER_DEG; } } update(); return flag; }
bool RefPoint::saveState(ossimKeywordlist& kwl, const char* prefix) const { bool result = true; std::string pfx; if (prefix) { pfx = prefix; } pfx += PREFIX; if (_ephemeris) { result = _ephemeris->saveState(kwl, pfx.c_str()); } else { result = false; } kwl.add(pfx.c_str(), DISTANCE_KW, _distance); kwl.add(pfx.c_str(), LINE_KW, _pix_line); kwl.add(pfx.c_str(), COL_KW, _pix_col); return result; }
/*************************************************************** * This method loads the filter state between property box edits ***************************************************************/ bool ossimCFARFilter::loadState(const ossimKeywordlist& kwl, const char* prefix) { ossimString newPrefix = prefix; newPrefix += ossimString("m"); for(ossim_int32 r = 0; r < 5; r++) { for(ossim_int32 c = 0; c < 5; c++) { theKernel[r][c] = 0.0; ossimString value = ossimString::toString(r+1); value += "_"; value += ossimString::toString(c+1); const char* v = kwl.find(newPrefix.c_str(), value.c_str()); if(v) { theKernel[r][c] = ossimString(v).toDouble(); } } } const char* threshold = kwl.find(prefix, "threshold"); if(threshold) { theThreshold = ossimString(threshold).toDouble(); } return ossimImageSourceFilter::loadState(kwl, prefix); }
bool ossimQuadTreeWarpVertex::saveState(ossimKeywordlist& kwl, const char* prefix)const { kwl.add(prefix, "x", thePosition.x, true); kwl.add(prefix, "y", thePosition.y, true); kwl.add(prefix, "dx", theDelta.x, true); kwl.add(prefix, "dy", theDelta.y, true); kwl.add(prefix, "lock_flag", (int)theLockedFlag, true); return true; }
bool ossimPolygon::loadState(const ossimKeywordlist& kwl, const char* prefix) { ossimString order = kwl.find(prefix, VERTEX_ORDER_KW); const char* number_vertices = kwl.find(prefix, NUMBER_VERTICES_KW); ossimString x,y; if(order=="unknown") { theOrderingType = OSSIM_VERTEX_ORDER_UNKNOWN; } else if(order =="clockwise") { theOrderingType = OSSIM_CLOCKWISE_ORDER; } else if(order =="counter_clockwise") { theOrderingType = OSSIM_COUNTERCLOCKWISE_ORDER; } theVertexList.clear(); int vertexCount = ossimString(number_vertices).toLong(); int i = 0; for(i = 0; i < vertexCount; ++i) { ossimString v = kwl.find(prefix, (ossimString("v")+ossimString::toString(i)).c_str()); v = v.trim(); istringstream vStream(v); vStream >> x >> y; theVertexList.push_back(ossimDpt(x.toDouble(),y.toDouble())); } return true; }
bool ossimMultiResLevelHistogram::saveState(ossimKeywordlist& kwl, const char* prefix)const { bool result = true; if(theHistogramList.size() > 0) { ossimString s1 = prefix; kwl.add(prefix, ossimKeywordNames::TYPE_KW, "ossimMultiResLevelHistogram", true); kwl.add(prefix, NUMBER_OF_RES_LEVELS.key(), static_cast<ossim_uint32>(theHistogramList.size()), true); for(ossim_uint32 idx = 0; idx < theHistogramList.size(); ++idx) { ossimString rr_level = ossimString(prefix) + "rr_level"; rr_level += ossimString::toString(idx) + "."; if(theHistogramList[idx].valid()) { result = theHistogramList[idx]->saveState(kwl, rr_level.c_str()); if(!result) { return result; } } } } return result; }
bool ossimImageToPlaneNormalFilter::loadState(const ossimKeywordlist& kwl, const char* prefix) { ossimString scaleX = kwl.find(prefix, ossimKeywordNames::SCALE_PER_PIXEL_X_KW); ossimString scaleY = kwl.find(prefix, ossimKeywordNames::SCALE_PER_PIXEL_Y_KW); ossimString trackFlag = kwl.find(prefix, "track_scale_flag"); ossimString smoothness = kwl.find(prefix, SMOOTHNESS_FACTOR_KW); if(scaleX != "") { theXScale = scaleX.toDouble(); } if(scaleY != "") { theYScale = scaleY.toDouble(); } if(trackFlag != "") { theTrackScaleFlag = trackFlag.toBool(); } if(smoothness!="") { theSmoothnessFactor = smoothness.toDouble(); } return ossimImageSourceFilter::loadState(kwl, prefix); }
void ossimXmlNode::toKwl(ossimKeywordlist& kwl, const ossimString& prefix)const { ossimString name = getTag(); ossimString value = getText(); ossimString copyPrefix = prefix; if(name != "") { copyPrefix += (name+"."); } if(theChildNodes.size() < 1) { kwl.add(prefix+name, value, true); } ossimString attributePrefix = copyPrefix + "@"; ossim_uint32 attributeIdx = 0; for(attributeIdx = 0; attributeIdx < theAttributes.size(); ++attributeIdx) { kwl.add(attributePrefix+theAttributes[attributeIdx]->getName(), theAttributes[attributeIdx]->getValue(), true); } ossim_uint32 idx = 0; for(idx = 0; idx < theChildNodes.size();++idx) { theChildNodes[idx]->toKwl(kwl, copyPrefix); } }
bool ossimQuadTreeWarpVertex::loadState(const ossimKeywordlist& kwl, const char* prefix) { const char* x = kwl.find(prefix, "x"); const char* y = kwl.find(prefix, "y"); const char* dx = kwl.find(prefix, "dx"); const char* dy = kwl.find(prefix, "dy"); const char* lockedFlag = kwl.find(prefix, "lock_flag"); if(x&&y&&dx&&dy&&lockedFlag) { thePosition.x = ossimString(x).toDouble(); thePosition.y = ossimString(y).toDouble(); theDelta.x = ossimString(dx).toDouble(); theDelta.y = ossimString(dy).toDouble(); theLockedFlag = ossimString(lockedFlag).toBool(); return true; } return false; }
bool ossimRangeDomeTileSource::loadState(const ossimKeywordlist& kwl, const char* prefix) { static const char MODULE[] = "ossimRangeDomeTileSource::loadState()"; theDecimationFactors.clear(); ossimImageHandler::loadState(kwl, prefix); if (kwl.getErrorStatus() == ossimErrorCodes::OSSIM_ERROR) { ossimNotify(ossimNotifyLevel_WARN)<< MODULE << "WARNING: error detected in keyword list! State not load." << std::endl; return false; } ossimDpt gsd; ossimString value = kwl.find(prefix, ossimKeywordNames::METERS_PER_PIXEL_KW); if (!value.empty()) gsd.x = value.toDouble(); value = kwl.find(prefix, ossimKeywordNames::METERS_PER_PIXEL_Y_KW); if (!value.empty()) setGSD(value.toDouble()); // The rest of the state is established by opening the file: bool good_open = open(); return good_open; }
bool ossimHdfGridModel::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool result = false; std::string myPrefix = ( prefix ? prefix: "" ); // Look for type key: std::string typeKey = "type"; std::string value = kwl.findKey( myPrefix, typeKey ); if ( value == "ossimHdfGridModel" ) { // Look for "is_hdf4" key: std::string key = "is_hdf4"; value = kwl.findKey( myPrefix, key ); if ( value.size() ) { m_isHdf4 = ossimString(value).toBool(); } // Make a copy of kwl so we can change type. ossimKeywordlist myKwl = kwl; value = "ossimCoarseGridModel"; myKwl.addPair( myPrefix, typeKey, value, true ); // Load the state of base class. result = ossimCoarseGridModel::loadState( myKwl, prefix ); } return result; }
bool ossimBandSelector::loadState(const ossimKeywordlist& kwl, const char* prefix) { ossimImageSourceFilter::loadState(kwl, prefix); // call ossimSource method to delete the list of objects theOutputBandList.clear(); ossimString copyPrefix = prefix; ossimString regExpression = ossimString("^(") + copyPrefix + "band[0-9]+)"; vector<ossimString> keys = kwl.getSubstringKeyList( regExpression ); long numberOfBands = (long)keys.size(); ossim_uint32 offset = (ossim_uint32)(copyPrefix+"band").size(); std::vector<int>::size_type idx = 0; std::vector<int> numberList(numberOfBands); for(idx = 0; idx < keys.size();++idx) { ossimString numberStr(keys[idx].begin() + offset, keys[idx].end()); numberList[idx] = numberStr.toInt(); } std::sort(numberList.begin(), numberList.end()); for(idx=0;idx < numberList.size();++idx) { const char* bandValue = kwl.find(copyPrefix, ("band"+ossimString::toString(numberList[idx])).c_str()); theOutputBandList.push_back( ossimString(bandValue).toLong()-1); } initialize(); return true; }
//************************************************************************************************* //! Save all adjustments to the KWL file. //************************************************************************************************* bool ossimAdjustableParameterInterface::saveAdjustments(ossimKeywordlist& kwl, const ossimString& prefix)const { // Nothing to do if no adjustments defined (okramer 04Sep2005) if (theAdjustmentList.size() == 0) return true; // A problem: There may have been adjustments written to the KWL by another process that this // instance doesn't know about. So we need to load in all adjustments present in the KWL and // replace kwl.add(prefix, NUMBER_OF_ADJUSTMENTS_KW, (ossim_uint32) theAdjustmentList.size(), true); kwl.add(prefix, CURRENT_ADJUSTMENT_KW, (int)theCurrentAdjustment, true); for(ossim_uint32 adjIdx = 0; adjIdx < theAdjustmentList.size(); ++adjIdx) { ossimString adjPrefix = prefix + (ossimString(ADJUSTMENT_PREFIX) + ossimString::toString(adjIdx)+"."); theAdjustmentList[adjIdx].saveState(kwl, adjPrefix); } return true; }
bool ossimBandSelector::saveState(ossimKeywordlist& kwl, const char* prefix)const { ossimString temp; kwl.add(prefix, ossimKeywordNames::NUMBER_OUTPUT_BANDS_KW, static_cast<int>(theOutputBandList.size()), true); ossimString bandsString; ossim::toSimpleStringList(bandsString, theOutputBandList); kwl.add(prefix, ossimKeywordNames::BANDS_KW, bandsString, true); /* for(ossim_uint32 counter = 0; counter < theOutputBandList.size();counter++) { temp = ossimKeywordNames::BAND_KW; temp += ossimString::toString(counter+1); kwl.add(prefix, temp.c_str(), ossimString::toString(theOutputBandList[counter]+1).c_str()); } */ return ossimImageSourceFilter::saveState(kwl, prefix); }
void ossimImageChain::findInputConnectionIds(vector<ossimId>& result, const ossimKeywordlist& kwl, const char* prefix) { ossimString copyPrefix = prefix; ossim_uint32 idx = 0; ossimString regExpression = ossimString("^") + ossimString(prefix) + "input_connection[0-9]+"; vector<ossimString> keys = kwl.getSubstringKeyList( regExpression ); ossim_int32 offset = (ossim_int32)(copyPrefix+"input_connection").size(); ossim_uint32 numberOfKeys = (ossim_uint32)keys.size(); std::vector<int> theNumberList(numberOfKeys); for(idx = 0; idx < theNumberList.size();++idx) { ossimString numberStr(keys[idx].begin() + offset, keys[idx].end()); theNumberList[idx] = numberStr.toInt(); } std::sort(theNumberList.begin(), theNumberList.end()); copyPrefix += ossimString("input_connection"); for(idx=0;idx < theNumberList.size();++idx) { const char* lookup = kwl.find(copyPrefix,ossimString::toString(theNumberList[idx])); if(lookup) { long id = ossimString(lookup).toLong(); result.push_back(ossimId(id)); } } }
void ossimXmlNode::toKwl(ossimKeywordlist& kwl, const ossimString& prefix)const { ossimRefPtr<ossimXmlAttribute> nameAtt = findAttribute("name"); ossimRefPtr<ossimXmlAttribute> valueAtt = findAttribute("value"); ossimRefPtr<ossimXmlAttribute> typeAtt = findAttribute("type"); ossimString name; ossimString value; ossimString type; if(nameAtt.valid()) { name = nameAtt->getValue(); } if(valueAtt.valid()) { value = valueAtt->getValue(); } else { value = theText; } if(typeAtt.valid()) { type = typeAtt->getValue(); } ossimString copyPrefix = prefix; if(name != "") { copyPrefix += (name+"."); } if(type!= "") { kwl.add(copyPrefix, "type", typeAtt->getValue(), true); } if(theChildNodes.size() < 1) { kwl.add(prefix+name, value, true); } else { ossim_uint32 idx=0; for(idx = 0; idx < theChildNodes.size(); ++idx) { theChildNodes[idx]->toKwl(kwl, copyPrefix); } } }
bool ossimIndexToRgbLutFilter::saveState(ossimKeywordlist& kwl, const char* prefix)const { if (theMinValueOverride) kwl.add(prefix, MIN_VALUE_KW, theMinValue, true); if (theMaxValueOverride) kwl.add(prefix, MAX_VALUE_KW, theMaxValue, true); ossimString value; switch (theMode) { case LITERAL: value = "literal"; break; case VERTICES: value = "vertices"; break; default: value = "regular"; } kwl.add(prefix, MODE_KW, value.c_str(), true); bool rtn_stat = true; // Save the actual LUT: const ossimString entry_kw ("entry"); ossimString color_keyword, base_keyword; ossimRgbVector rgbVector; ossimString blank(" "); ossim_uint32 entry = 0; std::map<double, ossimRgbVector>::const_iterator iter = theLut.begin(); while (iter != theLut.end()) { base_keyword = entry_kw + ossimString::toString(entry); if ((theMode == LITERAL) || (theMode == VERTICES)) { // Index and color are sub-entries for these modes: kwl.add(prefix, (base_keyword+".index").chars(), iter->first); color_keyword = base_keyword + ".color"; } else { color_keyword = base_keyword; } rgbVector = iter->second; value = ossimString::toString((int)rgbVector.getR()) + blank + ossimString::toString((int)rgbVector.getG()) + blank + ossimString::toString((int)rgbVector.getB()); kwl.add(prefix, color_keyword.chars(), value.chars()); ++iter; ++entry; } rtn_stat &= ossimImageSourceFilter::saveState(kwl, prefix); return rtn_stat; }
bool ossimElevManager::saveState(ossimKeywordlist& kwl, const char* prefix) const { kwl.add(prefix, "elevation_offset", m_elevationOffset, true); kwl.add(prefix, "default_height_above_ellipsoid", m_defaultHeightAboveEllipsoid, true); kwl.add(prefix, "use_geoid_if_null", m_useGeoidIfNullFlag, true); kwl.add(prefix, "threads", ossimString::toString(m_maxRoundRobinSize), true); return ossimElevSource::saveState(kwl, prefix); }