| | 1126 | return true; |
|---|
| | 1127 | } |
|---|
| | 1128 | |
|---|
| | 1129 | void DataSet::computeDestinationGraphFromSources(unsigned int numLevels) |
|---|
| | 1130 | { |
|---|
| | 1131 | if (!prepareForDestinationGraphCreation()) return; |
|---|
| | 1132 | |
|---|
| | 1133 | #if 0 |
|---|
| | 1134 | if (!_sourceGraph) return; |
|---|
| | 1135 | |
|---|
| | 1136 | // ensure we have a valid coordinate system |
|---|
| | 1137 | if (_destinationCoordinateSystemString.empty()&& !getConvertFromGeographicToGeocentric()) |
|---|
| | 1138 | { |
|---|
| | 1139 | for(CompositeSource::source_iterator itr(_sourceGraph.get());itr.valid();++itr) |
|---|
| | 1140 | { |
|---|
| | 1141 | SourceData* sd = (*itr)->getSourceData(); |
|---|
| | 1142 | if (sd) |
|---|
| | 1143 | { |
|---|
| | 1144 | if (sd->_cs.valid()) |
|---|
| | 1145 | { |
|---|
| | 1146 | _destinationCoordinateSystem = sd->_cs; |
|---|
| | 1147 | log(osg::INFO,"Setting coordinate system to %s",_destinationCoordinateSystem->getCoordinateSystem().c_str()); |
|---|
| | 1148 | break; |
|---|
| | 1149 | } |
|---|
| | 1150 | } |
|---|
| | 1151 | } |
|---|
| | 1152 | } |
|---|
| | 1153 | |
|---|
| | 1154 | |
|---|
| | 1155 | assignIntermediateCoordinateSystem(); |
|---|
| | 1156 | |
|---|
| | 1157 | CoordinateSystemType destinateCoordSytemType = getCoordinateSystemType(_destinationCoordinateSystem.get()); |
|---|
| | 1158 | if (destinateCoordSytemType==GEOGRAPHIC && !getConvertFromGeographicToGeocentric()) |
|---|
| | 1159 | { |
|---|
| | 1160 | // convert elevation into degrees. |
|---|
| | 1161 | setVerticalScale(1.0f/111319.0f); |
|---|
| | 1162 | } |
|---|
| | 1163 | |
|---|
| | 1164 | // get the extents of the sources and |
|---|
| | 1165 | _destinationExtents = _extents; |
|---|
| | 1166 | _destinationExtents._isGeographic = destinateCoordSytemType==GEOGRAPHIC; |
|---|
| | 1167 | |
|---|
| | 1168 | // sort the sources so that the lowest res tiles are drawn first. |
|---|
| | 1169 | { |
|---|
| | 1170 | |
|---|
| | 1171 | #if 0 |
|---|
| | 1172 | for(CompositeSource::source_iterator itr(_sourceGraph.get());itr.valid();++itr) |
|---|
| | 1173 | { |
|---|
| | 1174 | Source* source = itr->get(); |
|---|
| | 1175 | if (source) |
|---|
| | 1176 | { |
|---|
| | 1177 | source->setSortValueFromSourceDataResolution(_intermediateCoordinateSystem.get()); |
|---|
| | 1178 | log(osg::INFO, "sort %s value %f",source->getFileName().c_str(),source->getSortValue()); |
|---|
| | 1179 | } |
|---|
| | 1180 | |
|---|
| | 1181 | } |
|---|
| | 1182 | |
|---|
| | 1183 | // sort them so highest sortValue is first. |
|---|
| | 1184 | #endif |
|---|
| | 1185 | _sourceGraph->setSortValueFromSourceDataResolution(_intermediateCoordinateSystem.get()); |
|---|
| | 1186 | _sourceGraph->sort(); |
|---|
| | 1187 | } |
|---|
| | 1188 | |
|---|
| | 1189 | if (!_destinationExtents.valid()) |
|---|
| | 1190 | { |
|---|
| | 1191 | for(CompositeSource::source_iterator itr(_sourceGraph.get());itr.valid();++itr) |
|---|
| | 1192 | { |
|---|
| | 1193 | SourceData* sd = (*itr)->getSourceData(); |
|---|
| | 1194 | if (sd) |
|---|
| | 1195 | { |
|---|
| | 1196 | GeospatialExtents local_extents(sd->getExtents(_intermediateCoordinateSystem.get())); |
|---|
| | 1197 | log(osg::INFO, "local_extents = xMin() %f %f",local_extents.xMin(),local_extents.xMax()); |
|---|
| | 1198 | log(osg::INFO, " yMin() %f %f",local_extents.yMin(),local_extents.yMax()); |
|---|
| | 1199 | |
|---|
| | 1200 | if (destinateCoordSytemType==GEOGRAPHIC) |
|---|
| | 1201 | { |
|---|
| | 1202 | // need to clamp within -180 and 180 range. |
|---|
| | 1203 | if (local_extents.xMin()>180.0) |
|---|
| | 1204 | { |
|---|
| | 1205 | // shift back to -180 to 180 range |
|---|
| | 1206 | local_extents.xMin() -= 360.0; |
|---|
| | 1207 | local_extents.xMax() -= 360.0; |
|---|
| | 1208 | } |
|---|
| | 1209 | else if (local_extents.xMin()<-180.0) |
|---|
| | 1210 | { |
|---|
| | 1211 | // shift back to -180 to 180 range |
|---|
| | 1212 | local_extents.xMin() += 360.0; |
|---|
| | 1213 | local_extents.xMax() += 360.0; |
|---|
| | 1214 | } |
|---|
| | 1215 | } |
|---|
| | 1216 | |
|---|
| | 1217 | _destinationExtents.expandBy(local_extents); |
|---|
| | 1218 | } |
|---|
| | 1219 | } |
|---|
| | 1220 | } |
|---|
| | 1221 | |
|---|
| | 1222 | |
|---|
| | 1223 | if (destinateCoordSytemType==GEOGRAPHIC) |
|---|
| | 1224 | { |
|---|
| | 1225 | double xRange = _destinationExtents.xMax() - _destinationExtents.xMin(); |
|---|
| | 1226 | if (xRange>360.0) |
|---|
| | 1227 | { |
|---|
| | 1228 | // clamp to proper 360 range. |
|---|
| | 1229 | _destinationExtents.xMin() = -180.0; |
|---|
| | 1230 | _destinationExtents.xMax() = 180.0; |
|---|
| | 1231 | } |
|---|
| | 1232 | } |
|---|
| | 1233 | |
|---|
| | 1234 | |
|---|
| | 1235 | // compute the number of texture layers required. |
|---|
| | 1236 | unsigned int maxTextureUnit = 0; |
|---|
| | 1237 | for(CompositeSource::source_iterator sitr(_sourceGraph.get());sitr.valid();++sitr) |
|---|
| | 1238 | { |
|---|
| | 1239 | Source* source = sitr->get(); |
|---|
| | 1240 | if (source) |
|---|
| | 1241 | { |
|---|
| | 1242 | if (maxTextureUnit<source->getLayer()) maxTextureUnit = source->getLayer(); |
|---|
| | 1243 | } |
|---|
| | 1244 | } |
|---|
| | 1245 | _numTextureLevels = maxTextureUnit+1; |
|---|
| | 1246 | |
|---|
| | 1247 | |
|---|
| | 1248 | log(osg::INFO, "extents = xMin() %f %f",_destinationExtents.xMin(),_destinationExtents.xMax()); |
|---|
| | 1249 | log(osg::INFO, " yMin() %f %f",_destinationExtents.yMin(),_destinationExtents.yMax()); |
|---|
| | 1250 | |
|---|
| | 1251 | #endif |
|---|
| | 2401 | if (getBuildOptionsString().find("tm")!=std::string::npos) |
|---|
| | 2402 | { |
|---|
| | 2403 | return generateTasks_new(taskManager); |
|---|
| | 2404 | } |
|---|
| | 2405 | else |
|---|
| | 2406 | { |
|---|
| | 2407 | return generateTasks_old(taskManager); |
|---|
| | 2408 | } |
|---|
| | 2409 | } |
|---|
| | 2410 | |
|---|
| | 2411 | bool DataSet::generateTasks_new(TaskManager* taskManager) |
|---|
| | 2412 | { |
|---|
| | 2413 | log(osg::NOTICE,"DataSet::generateTasks_new"); |
|---|
| | 2414 | if (!getLogFileName().empty()) |
|---|
| | 2415 | { |
|---|
| | 2416 | if (!getBuildLog()) setBuildLog(new BuildLog()); |
|---|
| | 2417 | |
|---|
| | 2418 | getBuildLog()->openLogFile(getLogFileName()); |
|---|
| | 2419 | } |
|---|
| | 2420 | |
|---|
| | 2421 | if (getBuildLog()) |
|---|
| | 2422 | { |
|---|
| | 2423 | pushOperationLog(getBuildLog()); |
|---|
| | 2424 | } |
|---|
| | 2425 | |
|---|
| | 2426 | loadSources(); |
|---|
| | 2427 | |
|---|
| | 2428 | if (!prepareForDestinationGraphCreation()) return false; |
|---|
| | 2429 | |
|---|
| | 2430 | computeOptimumTileSystemDimensions(_C1,_R1); |
|---|
| | 2431 | log(osg::NOTICE," C1=%i R1=%i",_C1,_R1); |
|---|
| | 2432 | |
|---|
| | 2433 | |
|---|
| | 2434 | |
|---|
| | 2435 | log(osg::NOTICE,"OK, OK I now need something to do..."); |
|---|
| | 2436 | |
|---|
| | 2437 | log(osg::NOTICE,"First compute the maximum level required"); |
|---|
| | 2438 | log(osg::NOTICE,"Then compute the appropriate split levels"); |
|---|
| | 2439 | log(osg::NOTICE,"Then generate the root task"); |
|---|
| | 2440 | log(osg::NOTICE,"Then generate the intermediate tasks if any"); |
|---|
| | 2441 | log(osg::NOTICE,"Then generate the leaf tasks if any"); |
|---|
| | 2442 | |
|---|
| | 2443 | if (getBuildLog()) |
|---|
| | 2444 | { |
|---|
| | 2445 | popOperationLog(); |
|---|
| | 2446 | } |
|---|
| | 2447 | |
|---|
| | 2448 | return false; |
|---|
| | 2449 | } |
|---|
| | 2450 | |
|---|
| | 2451 | bool DataSet::generateTasks_old(TaskManager* taskManager) |
|---|
| | 2452 | { |
|---|