water runway support
This commit is contained in:
parent
d1aece0be3
commit
dfd63f3fd8
3 changed files with 92 additions and 33 deletions
|
@ -236,12 +236,16 @@ static void build_runway( const TGRunway& rwy_info,
|
|||
material = "grass_rwy";
|
||||
} else if ( surface_code == 4 /* Dirt */
|
||||
|| surface_code == 5 /* Gravel */
|
||||
|| surface_code == 12 /* Dry lakebed */ ) {
|
||||
|| surface_code == 12 /* Dry lakebed */
|
||||
|| surface_code == 13 /* Water */
|
||||
|| surface_code == 14 /* Snow/Ice */
|
||||
|| surface_code == 15 /* Transparent */) {
|
||||
material = "dirt_rwy";
|
||||
} else {
|
||||
SG_LOG(SG_GENERAL, SG_WARN, "surface_code = " << surface_code);
|
||||
throw sg_exception("unknown runway type!");
|
||||
}
|
||||
|
||||
if ( rwy_info.type == 102 ){
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Generating Helipad" );
|
||||
gen_heli( rwy_info, alt_m, material,
|
||||
|
@ -303,6 +307,7 @@ if ( rwy_info.type == 100 ){
|
|||
// build 3d airport
|
||||
void build_airport( string airport_id, float alt_m,
|
||||
string_list& runways_raw,
|
||||
string_list& water_raw,
|
||||
string_list& beacons_raw,
|
||||
string_list& towers_raw,
|
||||
string_list& windsocks_raw,
|
||||
|
@ -459,6 +464,38 @@ void build_airport( string airport_id, float alt_m,
|
|||
SGBucket b( apt_lon / (double)rwy_count, apt_lat / (double)rwy_count );
|
||||
SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str());
|
||||
|
||||
point_list water_rw; water_rw.clear();
|
||||
for ( i = 0; i < (int)water_raw.size(); ++i ) {
|
||||
string water_str = water_raw[i];
|
||||
vector<string> token = simgear::strutils::split( water_str );
|
||||
|
||||
//first runway end coordinates
|
||||
double lat_1 = atof( token[4].c_str() );
|
||||
double lon_1 = atof( token[5].c_str() );
|
||||
SGGeod pos_1(SGGeod::fromDegFt(lon_1, lat_1, 0.0));
|
||||
|
||||
//opposite end coordinates
|
||||
double lat_2 = atof( token[7].c_str() );
|
||||
double lon_2 = atof( token[8].c_str() );
|
||||
SGGeod pos_2(SGGeod::fromDegFt(lon_2, lat_2, 0.0));
|
||||
|
||||
//runway centerpoint
|
||||
Point3D rw_center = Point3D( (lon_1 + lon_2) / 2 , (lat_1 + lat_2) / 2, 0);
|
||||
|
||||
double heading = (SGGeodesy::courseDeg(pos_1, pos_2));
|
||||
|
||||
double length = (SGGeodesy::distanceM(pos_1, pos_2));
|
||||
double width = atoi( token[1].c_str() );
|
||||
|
||||
TGPolygon rw_outline = gen_wgs84_area(rw_center, length, 0, 0, width,
|
||||
heading, 0, false);
|
||||
|
||||
for ( i = 0; i < rw_outline.contour_size( 0 ); ++i ) {
|
||||
water_rw.push_back( rw_outline.get_pt( 0, i ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
point_list beacons; beacons.clear();
|
||||
for ( i = 0; i < (int)beacons_raw.size(); ++i ) {
|
||||
string beacon_str = beacons_raw[i];
|
||||
|
@ -1050,6 +1087,8 @@ void build_airport( string airport_id, float alt_m,
|
|||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Done with base calc_elevations()");
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Computing beacon node elevations");
|
||||
point_list water_buoys_nodes = calc_elevations( apt_surf, water_rw, 0.0 );
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Computing beacon node elevations");
|
||||
point_list beacon_nodes = calc_elevations( apt_surf, beacons, 0.0 );
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Computing tower node elevations");
|
||||
|
@ -1338,6 +1377,13 @@ void build_airport( string airport_id, float alt_m,
|
|||
// write out airport object reference
|
||||
write_index( objpath, b, name );
|
||||
|
||||
// write out water runway buoys references
|
||||
for ( i = 0; i < (int)water_buoys_nodes.size(); ++i ) {
|
||||
write_index_shared( objpath, b, water_buoys_nodes[i],
|
||||
"Models/Airport/water_rw_buoy.ac",
|
||||
0.0 );
|
||||
}
|
||||
|
||||
// write out beacon references
|
||||
for ( i = 0; i < (int)beacon_nodes.size(); ++i ) {
|
||||
write_index_shared( objpath, b, beacon_nodes[i],
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
// build 3d airport
|
||||
void build_airport( string airport_id, float alt_m,
|
||||
string_list& runways_raw,
|
||||
string_list& water_raw,
|
||||
string_list& beacons_raw,
|
||||
string_list& towers_raw,
|
||||
string_list& windsocks_raw,
|
||||
|
|
|
@ -248,6 +248,7 @@ int main( int argc, char **argv ) {
|
|||
}
|
||||
|
||||
string_list runways_list;
|
||||
string_list water_rw_list;
|
||||
string_list beacon_list;
|
||||
string_list tower_list;
|
||||
string_list windsock_list;
|
||||
|
@ -302,9 +303,11 @@ int main( int argc, char **argv ) {
|
|||
if ( runways_list.size() ) {
|
||||
vector<string> rwy_token
|
||||
= simgear::strutils::split( runways_list[0] );
|
||||
if ( token[0] == "100" ){
|
||||
rwy = token[8];
|
||||
lat = atof( token[9].c_str() );
|
||||
lon = atof( token[10].c_str() );
|
||||
}
|
||||
|
||||
if ( airport_id.length() && airport_id == last_apt_id ) {
|
||||
ready_to_go = true;
|
||||
|
@ -331,6 +334,7 @@ int main( int argc, char **argv ) {
|
|||
build_airport( last_apt_id,
|
||||
elev * SG_FEET_TO_METER,
|
||||
runways_list,
|
||||
water_rw_list,
|
||||
beacon_list,
|
||||
tower_list,
|
||||
windsock_list,
|
||||
|
@ -364,13 +368,18 @@ int main( int argc, char **argv ) {
|
|||
|
||||
// clear runway list for start of next airport
|
||||
runways_list.clear();
|
||||
water_rw_list.clear();
|
||||
beacon_list.clear();
|
||||
tower_list.clear();
|
||||
windsock_list.clear();
|
||||
light_list.clear();
|
||||
} else if ( token[0] == "100" || token[0] == "102") {
|
||||
// runway entry
|
||||
// runway entry (Land or heli)
|
||||
runways_list.push_back(line);
|
||||
} else if ( token[0] == "101" ) {
|
||||
// Water runway. Here we don't have to create any textures.
|
||||
// Only place some buoys
|
||||
water_rw_list.push_back(line);
|
||||
} else if ( token[0] == "18" ) {
|
||||
// beacon entry
|
||||
beacon_list.push_back(line);
|
||||
|
@ -395,7 +404,9 @@ int main( int argc, char **argv ) {
|
|||
} else if ( token[0] == "00" ) {
|
||||
// ??
|
||||
} else if ( token[0] >= "110" ) {
|
||||
//ignore lines for now
|
||||
//ignore taxiways for now
|
||||
} else if ( token[0] == "10" ) {
|
||||
//ignore old taxiways for now
|
||||
} else {
|
||||
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||
"Unknown line in file: " << line );
|
||||
|
@ -438,6 +449,7 @@ int main( int argc, char **argv ) {
|
|||
if( is_in_range( runways_list, min_lat, max_lat, min_lon, max_lon ) ) {
|
||||
build_airport( last_apt_id, elev * SG_FEET_TO_METER,
|
||||
runways_list,
|
||||
water_rw_list,
|
||||
beacon_list,
|
||||
tower_list,
|
||||
windsock_list,
|
||||
|
|
Loading…
Reference in a new issue