void ossimPiecewiseRemapper::ossimBandRemap::saveState( ossimKeywordlist& kwl, const std::string& prefix, ossimPiecewiseRemapper::PiecewiseRemapType remapType, ossim_uint32 band ) const { //--- // Remap set: // Remap set: "band0.remap0": // band0.remap0:((0, 127, 0, 127), (128, 255, 128, 382)) // band0.remap1:((0, 382, 0, 255)) //--- ossim_uint32 remapIndex = 0; std::vector<ossimRemapSet>::const_iterator i = m_remap.begin(); while ( i != m_remap.end() ) { std::string key = "band"; key += ossimString::toString(band).string(); key += "."; key += REMAP_KW; key += ossimString::toString(remapIndex).string(); std::string value; getRemapSetString( remapType, (*i), value ); kwl.addPair( prefix, key, value ); ++i; ++remapIndex; } } // End: ossimPiecewiseRemapper::ossimBandRemap::saveState
bool ossimPngReader::saveState(ossimKeywordlist& kwl, const char* prefix) const { std::string p = ( prefix ? prefix : "" ); std::string v = ossimString::toString(m_useAlphaChannelFlag).string(); kwl.addPair( p, USE_ALPHA_KW, v, true ); return ossimImageHandler::saveState(kwl, prefix); }
bool ossimH5GridModel::saveState(ossimKeywordlist& kwl, const char* prefix) const { // Base save state. This will save the "type" key to "ossimH5GridModel". bool status = ossimCoarseGridModel::saveState( kwl, prefix ); if ( status ) { std::string myPrefix = ( prefix ? prefix: "" ); std::string value; // m_crossesDateline: value = ossimString::toString(m_crossesDateline).string(); kwl.addPair( myPrefix,CROSSES_DATELINE_KW, value, true ); // Computed wkt footprint: if ( getWktFootprint( value ) ) { kwl.addPair( myPrefix, WKT_FOOTPRINT_KW, value, true ); } // m_boundGndPolygon: if ( m_boundGndPolygon.getNumberOfVertices() ) { std::string polyPrefix = myPrefix; polyPrefix += GROUND_POLYGON_KW; polyPrefix += "."; m_boundGndPolygon.saveState( kwl, polyPrefix.c_str() ); } //--- // theSeedFunction: This is in the base class ossimSensorModel but is not // in the ossimSensorModel::saveState so do it here. //--- if ( theSeedFunction.valid() ) { ossimString seedPrefix = myPrefix; seedPrefix += "seed_projection."; status = theSeedFunction->saveState(kwl, seedPrefix.c_str()); } } return status; }
bool ossimWkt::parseName( std::istringstream& is, const std::string& prefix, const std::string& object, ossimKeywordlist& kwl ) { bool result = false; char c; std::string name; // Find the first quote: while ( is.good() ) { is.get(c); if ( is.good() ) { if ( c == '"' ) { break; } } } // Get the name: while ( is.good() ) { is.get(c); if ( is.good() ) { if ( c != '"' ) { name.push_back(c); } else { break; // End quote: } } } if ( name.size() ) { // Add to keyword list. std::string key; if ( prefix.size() ) { key += prefix; } key += object; key += ".name"; kwl.addPair( key, name ); result = true; } return result; }
bool ossimHdfGridModel::saveState(ossimKeywordlist& kwl, const char* prefix) const { bool status = ossimCoarseGridModel::saveState( kwl, prefix ); if ( status ) { std::string myPrefix = ( prefix ? prefix: "" ); // Add the is hdf4 flag: std::string key = "is_hdf4"; std::string value = ossimString::toString( m_isHdf4 ).string(); kwl.addPair( myPrefix, key, value, true ); if ( getWktFootprint( value ) ) { std::string key = "wkt_footprint"; kwl.addPair( myPrefix, key, value, true ); } } return status; }
void ossimGpkgTileMatrixSetRecord::saveState( ossimKeywordlist& kwl, const std::string& prefix ) const { std::string myPref = prefix.size() ? prefix : std::string("gpkg_tile_matrix_set."); std::string value; std::string key = "table_name"; kwl.addPair(myPref, key, m_table_name, true); key = "srs_id"; value = ossimString::toString(m_srs_id).string(); kwl.addPair(myPref, key, value, true); key = "min_x"; value = ossimString::toString(m_min_x, 15).string(); kwl.addPair(myPref, key, value, true); key = "min_y"; value = ossimString::toString(m_min_y, 15).string(); kwl.addPair(myPref, key, value, true); key = "max_x"; value = ossimString::toString(m_max_x, 15).string(); kwl.addPair(myPref, key, value, true); key = "max_y"; value = ossimString::toString(m_max_y, 15).string(); kwl.addPair(myPref, key, value, true); }
void ossimKeywordlist::extractKeysThatMatch(ossimKeywordlist& kwl, const ossimString ®ularExpression)const { KeywordMap::const_iterator i; std::vector<ossimString> result; ossimRegExp regExp; regExp.compile(regularExpression.c_str()); for(i = m_map.begin(); i != m_map.end(); ++i) { if(regExp.find( (*i).first.c_str())) { kwl.addPair((*i).first, (*i).second); } } }
void ossimGpkgTileMatrixRecord::saveState( ossimKeywordlist& kwl, const std::string& prefix ) const { std::string myPref = prefix.size() ? prefix : std::string("gpkg_tile_matrix."); std::string value; std::string key = "table_name"; kwl.addPair(myPref, key, m_table_name, true); key = "zoom_level"; value = ossimString::toString(m_zoom_level).string(); kwl.addPair(myPref, key, value, true); key = "matrix_width"; value = ossimString::toString(m_matrix_width).string(); kwl.addPair(myPref, key, value, true); key = "matrix_height"; value = ossimString::toString(m_matrix_height).string(); kwl.addPair(myPref, key, value, true); key = "tile_width"; value = ossimString::toString(m_tile_width).string(); kwl.addPair(myPref, key, value, true); key = "tile_height"; value = ossimString::toString(m_tile_height).string(); kwl.addPair(myPref, key, value, true); key = "pixel_x_size"; value = ossimString::toString(m_pixel_x_size, 15).string(); kwl.addPair(myPref, key, value, true); key = "pixel_y_size"; value = ossimString::toString(m_pixel_y_size, 15).string(); kwl.addPair(myPref, key, value, true); }
bool ossimWkt::parseParam( std::istringstream& is, const std::string& prefix, const std::string& object, ossim_uint32& objectIndex, ossim_uint32& paramIndex, ossimKeywordlist& kwl ) { bool result = false; char c; std::string name; // Get the name: while ( is.good() ) { int i = is.peek(); // Don't gobble the trailing comma or bracket. if ( (i == ',') || (i == ']') || (i == ')') ) { // End of param. if ( name.size() ) { // Add to keyword list. std::string key; if ( prefix.size() ) { key += prefix; } key += object; key += ".param"; key += ossimString::toString(paramIndex).string(); kwl.addPair( key, name ); name = ""; ++paramIndex; result = true; } break; // Next param or at end of object. } is.get(c); if ( is.good() ) { // Look nexted object. if ( (c == '[') || (c == '(') ) { std::string myPrefix; if ( prefix.size() ) { myPrefix += prefix; } myPrefix += object; myPrefix += "."; //--- // Special hack for duplicated keyword "PARAMETER" //--- if ( name == "PARAMETER" ) { name += ossimString::toString(objectIndex).string(); ++objectIndex; } result = parseObject( is, myPrefix, name, kwl ); name = ""; } else { name.push_back(c); } } } return result; }
bool ossimQuickbirdMetaData::getMapProjectionKwl( const ossimFilename& imd_file, ossimKeywordlist& kwl ) { static const char MODULE[] = "ossimQuickbirdMetaData::getMapProjectionKwl"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; } bool result = false; if( imd_file.exists() ) { FILE* fptr = fopen (imd_file.c_str(), "r"); if (fptr) { char* strptr(NULL); //--- // Read the file into a buffer: //--- ossim_int32 fileSize = static_cast<ossim_int32>(imd_file.fileSize()); char* filebuf = new char[fileSize]; fread(filebuf, 1, fileSize, fptr); strptr = filebuf; fclose(fptr); ossimString imd_key; ossimString tempStr; std::string key; std::string value; // Loop until we find all our keys or bust out with error. while ( 1 ) { // Verify map projected. imd_key = "BEGIN_GROUP = MAP_PROJECTED_PRODUCT"; if ( strstr( filebuf, imd_key.c_str() ) == NULL ) { break; // Not a map projected product. } // Get datum: if( getEndOfLine( strptr, ossimString("\n\tdatumName = "), "%13c %s", tempStr) ) { if ( tempStr.contains("WE") ) { key = "dataum"; value = "WGE"; kwl.addPair(key, value); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "Unhandled datum: " << tempStr << "\n"; } } } // Get projection: if( getEndOfLine( strptr, ossimString("\n\tmapProjName = "), "%15c %s", tempStr) ) { if ( tempStr.contains("UTM") ) { key = "type"; value = "ossimUtmProjection"; kwl.addPair(key, value); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "Unhandled projection name: " << tempStr << "\n"; } } } // Get projection: if( getEndOfLine( strptr, ossimString("\n\tmapProjName = "), "%15c %s", tempStr) ) { if ( tempStr.contains("UTM") ) { key = "type"; value = "ossimUtmProjection"; kwl.addPair(key, value); // Get UTM zone: if( getEndOfLine( strptr, ossimString("\n\tmapZone = "), "%11c %s", tempStr) ) { key = "zone"; value = tempStr.trim(";").string(); kwl.addPair(key, value); } else { break; } // Get UTM hemisphere: if( getEndOfLine( strptr, ossimString("\n\tmapHemi = "), "%11c %s", tempStr) ) { key = "hemisphere"; tempStr = tempStr.trim(";"); tempStr = tempStr.trim("\""); value = tempStr.string(); kwl.addPair(key, value); } else { break; } } // End UTM: } // Get projection units: std::string units; if( getEndOfLine( strptr, ossimString("\n\tproductUnits = "), "%16c %s", tempStr) ) { if ( tempStr == "\"M\";" ) { key = "units"; units = "meters"; kwl.addPair(key, units); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "Unhandled units: " << tempStr << "\n"; } } } // Get projection tie point: ossimDpt dpt; dpt.makeNan(); if( getEndOfLine( strptr, ossimString("\n\toriginX = "), "%11c %s", tempStr) ) { tempStr = tempStr.trim(";"); dpt.x = tempStr.toFloat64(); } else { break; } if( getEndOfLine( strptr, ossimString("\n\toriginY = "), "%11c %s", tempStr) ) { tempStr = tempStr.trim(";"); dpt.y = tempStr.toFloat64(); } else { break; } if ( dpt.hasNans() == false ) { key = "tie_point_units"; kwl.addPair(key, units); key = "tie_point_xy"; value = dpt.toString().string(); kwl.addPair( key, value ); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "tie point has nans!"; } break; } // Get projection scale: dpt.makeNan(); if( getEndOfLine( strptr, ossimString("\n\tcolSpacing = "), "%14c %s", tempStr) ) { tempStr = tempStr.trim(";"); dpt.x = tempStr.toFloat64(); } else { break; } if( getEndOfLine( strptr, ossimString("\n\trowSpacing = "), "%14c %s", tempStr) ) { tempStr = tempStr.trim(";"); dpt.y = tempStr.toFloat64(); } else { break; } if ( dpt.hasNans() == false ) { key = "pixel_scale_units"; kwl.addPair(key, units); key = "pixel_scale_xy"; value = dpt.toString().string(); kwl.addPair( key, value ); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "scale has nans!"; } break; } //--- // End of key look up. If we get here set the status to true and // bust out of loop. //--- result = true; break; } if ( result == false ) { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ERROR: Missing or unhandled key in metadat: " << imd_key << "\n"; } } delete [] filebuf; filebuf = 0; } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimQuickbirdRpcModel::parseMetaData(imd_file) DEBUG:" << "\nCould not open Meta data file: " << imd_file << "\nreturning with error...\n"; } } } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false") << "\n"; } return result; }