bool rspfGeoPolyCutter::loadState(const rspfKeywordlist& kwl, const char* prefix) { rspfString copyPrefix(prefix); rspfString polygons = rspfString("^(") + copyPrefix + "geo_polygon[0-9]+.)"; vector<rspfString> keys = kwl.getSubstringKeyList( polygons ); int offset = (int)(copyPrefix+"geo_polygon").size(); std::vector<int> numberList(keys.size()); for(int idx = 0; idx < (int)numberList.size();++idx) { rspfString numberStr(keys[idx].begin() + offset, keys[idx].end()); numberList[idx] = numberStr.toInt(); } std::sort(numberList.begin(), numberList.end()); rspfString newPrefix; thePolygonList.clear(); for(int i = 0; i < (int)numberList.size();++i) { theGeoPolygonList.push_back(rspfGeoPolygon()); newPrefix = copyPrefix+"geo_polygon"+rspfString::toString(numberList[i])+"."; theGeoPolygonList[i].loadState(kwl, newPrefix.c_str()); } const char* lookup = kwl.find(prefix, "cut_type"); if(lookup) { theCutType = RSPF_POLY_NULL_INSIDE; rspfString test = lookup; if(test == "null_outside") { theCutType = RSPF_POLY_NULL_OUTSIDE; } } else { theCutType = RSPF_POLY_NULL_OUTSIDE; } rspfString viewPrefix = prefix; viewPrefix += "view."; theViewProjection = new rspfImageGeometry(); if(theViewProjection->loadState(kwl, viewPrefix)) { transformVertices(); } return rspfImageSourceFilter::loadState(kwl, prefix); }
/** * Method to the load (recreate) the state of an object from a keyword * list. Return true if ok or false on error. */ bool ossimElevManager::loadState(const ossimKeywordlist& kwl, const char* prefix) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState: Entered..." << std::endl; } if(!ossimElevSource::loadState(kwl, prefix)) { return false; } ossimString copyPrefix(prefix); ossimString elevationOffset = kwl.find(copyPrefix, "elevation_offset"); ossimString defaultHeightAboveEllipsoid = kwl.find(copyPrefix, "default_height_above_ellipsoid"); ossimString useGeoidIfNull = kwl.find(copyPrefix, "use_geoid_if_null"); ossimString elevRndRbnSize = kwl.find(copyPrefix, "threads"); if(!elevationOffset.empty()) { m_elevationOffset = elevationOffset.toDouble(); } if(!defaultHeightAboveEllipsoid.empty()) { m_defaultHeightAboveEllipsoid = defaultHeightAboveEllipsoid.toDouble(); } if(!useGeoidIfNull.empty()) { m_useGeoidIfNullFlag = useGeoidIfNull.toBool(); } ossim_uint32 numThreads = 1; if(!elevRndRbnSize.empty()) { if (elevRndRbnSize.contains("yes") || elevRndRbnSize.contains("true")) numThreads = ossim::getNumberOfThreads(); else if (elevRndRbnSize.contains("no") || elevRndRbnSize.contains("false")) numThreads = 1; else { numThreads = elevRndRbnSize.toUInt32(); numThreads = numThreads > 0 ? numThreads : 1; } } setRoundRobinMaxSize(numThreads); ossimString regExpression = ossimString("^(") + copyPrefix + "elevation_source[0-9]+.)"; vector<ossimString> keys = kwl.getSubstringKeyList( regExpression ); long numberOfSources = (long)keys.size(); ossim_uint32 offset = (ossim_uint32)(copyPrefix+"elevation_source").size(); ossim_uint32 idx = 0; std::vector<int> theNumberList(numberOfSources); 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()); for(idx=0;idx < theNumberList.size();++idx) { ossimString newPrefix = copyPrefix; newPrefix += ossimString("elevation_source"); newPrefix += ossimString::toString(theNumberList[idx]); if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState:" << "\nLooking for key: " << newPrefix << std::endl; } //--- // Check for enabled key first. Default, if not found is true for // legacy compatibility. //--- bool enabled = true; std::string key = newPrefix.string(); key += "."; key += ossimKeywordNames::ENABLED_KW; std::string value = kwl.findKey( key ); if ( value.size() ) { enabled = ossimString(value).toBool(); } if ( enabled ) { // first check if new way is supported ossimRefPtr<ossimElevationDatabase> database = ossimElevationDatabaseRegistry::instance()->createDatabase(kwl, newPrefix+"."); if(database.valid()) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState:" << "\nadding elevation database: " << database->getClassName() << ": " << database->getConnectionString() << std::endl; } addDatabase(database.get()); } else { // if not new elevation load verify the old way by // looking at the filename // ossimString fileKey = newPrefix; fileKey += "."; fileKey += ossimKeywordNames::FILENAME_KW; ossimString lookup = kwl.find(prefix, fileKey.c_str()); if (!lookup.empty()) { loadElevationPath(ossimFilename(lookup)); } // end if lookup } } } // end for loop return true; }
void generate(struct data *data){ register int i; char **string; struct ngram *prefix; char *sufix; char *out; out = strdup( get_name( "out" ) ); numberOfWords = get_number( "w" ); numberOfParagraphs = get_number( "p" ); wordsInParagraph = numberOfWords / numberOfParagraphs; lefOvers = numberOfWords - numberOfParagraphs * wordsInParagraph; FILE *output; output = fopen( out, "w" ); srand(time(NULL)); string = malloc(n * sizeof *string ); n = get_number("m"); while( numberOfParagraphs-- ) { if(numberOfParagraphs == 0){ wordsInParagraph += lefOvers; } fprintf(output, "\t"); while( wrote < wordsInParagraph ){ //jeżeli nie ma jescze żadnych wypisanych wyrazów to wylosuj pierwszy if (wrote == 0) { prefix = randPrefix(data); copyPrefix(prefix, string); string[0][0] = (char) toupper(string[0][0]); //Zmien pierwsza litere na wielka for (i = 0; i < n - 1; i++) { fprintf(output, "%s ", string[i]); //Wypisz prefix if( ++wrote >= wordsInParagraph ) break; if (wrote % 8 == 0) { //Wypisuj tylko 8 wyrazów w wierszu fprintf(output, "\n"); } } } else { //Jeżeli wypisano już jakieś słowa to znajdź kolejny ngram prefix = nextNgram(string, data); if (prefix == NULL) { prefix = randPrefix(data); copyPrefix(prefix, string); for (i = 0; i < n - 1; i++) { fprintf(output, "%s ", string[i]); //Wypisz prefix if( ++wrote >= wordsInParagraph ) break; if (wrote % 8 == 0) { //Wypisuj tylko 8 wyrazów w wierszu fprintf(output, "\n"); } } } } sufix = randSufix(prefix); //znajdz odpowiadajacy sufix string[n - 1] = strdup(sufix); fprintf(output, "%s ", string[n - 1]); //wypisz sufix if( ++wrote >= wordsInParagraph ) break; if (wrote % 8 == 0) { //Wypisuj tylko 8 wyrazów w wierszu fprintf(output, "\n"); } for (i = 1; i < n; i++) { string[i - 1] = strdup(string[i]); } } if( string[n-1][strlen(string[n-1]) - 1] != '.' ) fprintf(output, "." ); if( numberOfParagraphs > 0) fprintf(output, "\n"); wrote = 0; } fclose(output); }
/** * Method to the load (recreate) the state of an object from a keyword * list. Return true if ok or false on error. */ bool ossimElevManager::loadState(const ossimKeywordlist& kwl, const char* prefix) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState: Entered..." << std::endl; } if(!ossimElevSource::loadState(kwl, prefix)) { return false; } ossimString copyPrefix(prefix); ossimString elevationOffset = kwl.find(copyPrefix, "elevation_offset"); ossimString defaultHeightAboveEllipsoid = kwl.find(copyPrefix, "default_height_above_ellipsoid"); ossimString useGeoidIfNull = kwl.find(copyPrefix, "use_geoid_if_null"); if(!elevationOffset.empty()) { m_elevationOffset = elevationOffset.toDouble(); } if(!defaultHeightAboveEllipsoid.empty()) { m_defaultHeightAboveEllipsoid = defaultHeightAboveEllipsoid.toDouble(); } if(!useGeoidIfNull.empty()) { m_useGeoidIfNullFlag = useGeoidIfNull.toBool(); } ossimString regExpression = ossimString("^(") + copyPrefix + "elevation_source[0-9]+.)"; vector<ossimString> keys = kwl.getSubstringKeyList( regExpression ); long numberOfSources = (long)keys.size(); ossim_uint32 offset = (ossim_uint32)(copyPrefix+"elevation_source").size(); ossim_uint32 idx = 0; std::vector<int> theNumberList(numberOfSources); 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()); for(idx=0;idx < theNumberList.size();++idx) { ossimString newPrefix = copyPrefix; newPrefix += ossimString("elevation_source"); newPrefix += ossimString::toString(theNumberList[idx]); if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState:" << "\nLooking for key: " << newPrefix << std::endl; } // first check if new way is supported // ossimRefPtr<ossimElevationDatabase> database = ossimElevationDatabaseRegistry::instance()->createDatabase(kwl, newPrefix+"."); if(database.valid()) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState:" << "\nadding elevation database: " << database->getClassName() << ": " << database->getConnectionString() << std::endl; } addDatabase(database.get()); } else { // if not new elevation load verify the old way by // looking at the filename // ossimString fileKey = newPrefix; fileKey += "."; fileKey += ossimKeywordNames::FILENAME_KW; ossimString lookup = kwl.find(prefix, fileKey.c_str()); if (!lookup.empty()) { loadElevationPath(ossimFilename(lookup)); } // end if lookup } } // end for loop return true; }