- _scaler.scale();
- // Calculate scale factor to fit within box
- _scaleFactor = 1.0;
- if (_scaler.getMaximumHoriz() > 0.0 || _scaler.getMaximumVert() > 0.0)
- {
- if (_scaler.getMaximumHoriz() > _scaler.getMaximumVert())
- {
- // scale limited by longitude
- _scaleFactor = _modelSize / _scaler.getMaximumHoriz();
- }
- else
- {
- // scale limited by latitude
- _scaleFactor = _modelSize / _scaler.getMaximumVert();
- }
- }
- // calculate altitude scale factor
- _altFactor = 1.0;
- if (_scaler.getMaximumAlt() >= 0)
+ _scaler.addTerrain(_terrainTrack);
+ _scaler.scale(); // Add 10% border
+
+ // cap altitude scale factor if it's too big
+ double maxAlt = _scaler.getAltitudeRange() * _altFactor;
+ if (maxAlt > 0.5)