Add support for legacy taxiway '10'
This commit is contained in:
parent
5a80fe638b
commit
7c70cb8da7
9 changed files with 337 additions and 7 deletions
|
@ -17,6 +17,7 @@ add_executable(genapts850
|
|||
runway.cxx runway.hxx
|
||||
rwy_simple.cxx
|
||||
rwy_gen.cxx
|
||||
taxiway.cxx taxiway.hxx
|
||||
)
|
||||
|
||||
target_link_libraries(genapts850
|
||||
|
|
|
@ -149,9 +149,10 @@ Airport::~Airport()
|
|||
}
|
||||
}
|
||||
|
||||
void Airport::SetDebugPolys( int rwy, int pvmt, int feat, int base )
|
||||
void Airport::SetDebugPolys( int rwy, int taxi, int pvmt, int feat, int base )
|
||||
{
|
||||
dbg_rwy_poly = rwy;
|
||||
dbg_taxi_poly = taxi;
|
||||
dbg_pvmt_poly = pvmt;
|
||||
dbg_feat_poly = feat;
|
||||
dbg_base_poly = base;
|
||||
|
@ -730,6 +731,42 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
|
|||
log_time = time(0);
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Finished building Pavements for " << icao << " at " << ctime(&log_time) );
|
||||
|
||||
// Build the legacy taxiways
|
||||
if (taxiways.size())
|
||||
{
|
||||
for ( unsigned int i=0; i<taxiways.size(); i++ )
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Build Taxiway " << i + 1 << " of " << taxiways.size());
|
||||
slivers.clear();
|
||||
|
||||
if ( (dbg_taxi_poly > 0) && (i == (unsigned int)dbg_taxi_poly-1) ) {
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Problem taxi poly (" << i << ")");
|
||||
|
||||
make_shapefiles = true;
|
||||
} else {
|
||||
make_shapefiles = false;
|
||||
}
|
||||
|
||||
if (boundary)
|
||||
{
|
||||
taxiways[i]->BuildBtg( &pvmt_polys, &pvmt_tps, &rwy_lights, &accum, slivers, NULL, NULL, make_shapefiles );
|
||||
}
|
||||
else
|
||||
{
|
||||
taxiways[i]->BuildBtg( &pvmt_polys, &pvmt_tps, &rwy_lights, &accum, slivers, &apt_base, &apt_clearing, make_shapefiles );
|
||||
}
|
||||
|
||||
// Now try to merge any slivers we found
|
||||
merge_slivers( rwy_polys, slivers );
|
||||
merge_slivers( pvmt_polys, slivers );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "no taxiways");
|
||||
}
|
||||
|
||||
|
||||
// Build runway shoulders here
|
||||
for ( unsigned int i=0; i<runways.size(); i++ )
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "runway.hxx"
|
||||
#include "object.hxx"
|
||||
#include "helipad.hxx"
|
||||
#include "taxiway.hxx"
|
||||
#include "closedpoly.hxx"
|
||||
#include "linearfeature.hxx"
|
||||
#include "linked_objects.hxx"
|
||||
|
@ -41,6 +42,11 @@ public:
|
|||
helipads.push_back( helipad );
|
||||
}
|
||||
|
||||
void AddTaxiway( Taxiway* taxiway )
|
||||
{
|
||||
taxiways.push_back( taxiway );
|
||||
}
|
||||
|
||||
void AddPavement( ClosedPoly* pavement )
|
||||
{
|
||||
pavements.push_back( pavement );
|
||||
|
@ -107,7 +113,7 @@ public:
|
|||
void merge_slivers( superpoly_list& polys, poly_list& slivers );
|
||||
void BuildBtg( const string& root, const string_list& elev_src );
|
||||
|
||||
void SetDebugPolys( int rwy, int pvmt, int feat, int base );
|
||||
void SetDebugPolys( int rwy, int taxi, int pvmt, int feat, int base );
|
||||
|
||||
private:
|
||||
int code; // airport, heliport or sea port
|
||||
|
@ -119,6 +125,7 @@ private:
|
|||
FeatureList features;
|
||||
RunwayList runways;
|
||||
WaterRunwayList waterrunways;
|
||||
TaxiwayList taxiways;
|
||||
LightingObjList lightobjects;
|
||||
WindsockList windsocks;
|
||||
BeaconList beacons;
|
||||
|
@ -133,6 +140,7 @@ private:
|
|||
|
||||
// debug
|
||||
int dbg_rwy_poly;
|
||||
int dbg_taxi_poly;
|
||||
int dbg_pvmt_poly;
|
||||
int dbg_feat_poly;
|
||||
int dbg_base_poly;
|
||||
|
|
|
@ -141,6 +141,7 @@ int main(int argc, char **argv)
|
|||
string airport_id = "";
|
||||
string last_apt_file = "./last_apt.txt";
|
||||
int dump_rwy_poly = -1;
|
||||
int dump_taxi_poly = -1;
|
||||
int dump_pvmt_poly = -1;
|
||||
int dump_feat_poly = -1;
|
||||
int dump_base_poly = -1;
|
||||
|
@ -237,6 +238,10 @@ int main(int argc, char **argv)
|
|||
else if ( arg.find("--dump-rwy=") == 0 )
|
||||
{
|
||||
dump_rwy_poly = atoi( arg.substr(11).c_str() );
|
||||
}
|
||||
else if ( arg.find("--dump-taxi=") == 0 )
|
||||
{
|
||||
dump_taxi_poly = atoi( arg.substr(12).c_str() );
|
||||
}
|
||||
else if ( arg.find("--dump-pvmt=") == 0 )
|
||||
{
|
||||
|
@ -322,7 +327,7 @@ int main(int argc, char **argv)
|
|||
Parser* parser = new Parser(input_file, work_dir, elev_src);
|
||||
|
||||
// Add any debug
|
||||
parser->SetDebugPolys( dump_rwy_poly, dump_pvmt_poly, dump_feat_poly, dump_base_poly );
|
||||
parser->SetDebugPolys( dump_rwy_poly, dump_taxi_poly, dump_pvmt_poly, dump_feat_poly, dump_base_poly );
|
||||
|
||||
// just one airport
|
||||
if ( airport_id != "" )
|
||||
|
|
|
@ -279,6 +279,7 @@ void Parser::AddAirports( long start_pos, float min_lat, float min_lon, float ma
|
|||
}
|
||||
break;
|
||||
|
||||
case TAXIWAY_CODE:
|
||||
case PAVEMENT_CODE:
|
||||
case LINEAR_FEATURE_CODE:
|
||||
case BOUNDRY_CODE:
|
||||
|
@ -318,9 +319,10 @@ void Parser::RemoveAirport( string icao )
|
|||
}
|
||||
}
|
||||
|
||||
void Parser::SetDebugPolys( int rwy, int pvmt, int feat, int base )
|
||||
void Parser::SetDebugPolys( int rwy, int taxi, int pvmt, int feat, int base )
|
||||
{
|
||||
rwy_poly = rwy;
|
||||
taxi_poly = taxi;
|
||||
pvmt_poly = pvmt;
|
||||
feat_poly = feat;
|
||||
base_poly = base;
|
||||
|
@ -657,7 +659,7 @@ int Parser::ParseLine(char* line)
|
|||
SetState( STATE_PARSE_SIMPLE );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Parsing land airport: " << line);
|
||||
cur_airport = new Airport( code, line );
|
||||
cur_airport->SetDebugPolys( rwy_poly, pvmt_poly, feat_poly, base_poly );
|
||||
cur_airport->SetDebugPolys( rwy_poly, taxi_poly, pvmt_poly, feat_poly, base_poly );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -670,7 +672,7 @@ int Parser::ParseLine(char* line)
|
|||
SetState( STATE_PARSE_SIMPLE );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Parsing heliport: " << line);
|
||||
cur_airport = new Airport( code, line );
|
||||
cur_airport->SetDebugPolys( rwy_poly, pvmt_poly, feat_poly, base_poly );
|
||||
cur_airport->SetDebugPolys( rwy_poly, taxi_poly, pvmt_poly, feat_poly, base_poly );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -707,6 +709,16 @@ int Parser::ParseLine(char* line)
|
|||
}
|
||||
break;
|
||||
|
||||
case TAXIWAY_CODE:
|
||||
SetState( STATE_PARSE_SIMPLE );
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Parsing taxiway: " << line);
|
||||
cur_taxiway = new Taxiway(line);
|
||||
if (cur_airport)
|
||||
{
|
||||
cur_airport->AddTaxiway( cur_taxiway );
|
||||
}
|
||||
break;
|
||||
|
||||
case PAVEMENT_CODE:
|
||||
SetState( STATE_PARSE_PAVEMENT );
|
||||
cur_pavement = ParsePavement( line );
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define MAXLINE (256)
|
||||
|
||||
#define LAND_AIRPORT_CODE (1)
|
||||
#define TAXIWAY_CODE (10)
|
||||
#define SEA_AIRPORT_CODE (16)
|
||||
#define HELIPORT_CODE (17)
|
||||
|
||||
|
@ -74,6 +75,7 @@ public:
|
|||
cur_runway = NULL;
|
||||
cur_waterrunway = NULL;
|
||||
cur_helipad = NULL;
|
||||
cur_taxiway = NULL;
|
||||
cur_pavement = NULL;
|
||||
cur_boundary = NULL;
|
||||
cur_feat = NULL;
|
||||
|
@ -91,7 +93,7 @@ public:
|
|||
base_poly = -1;
|
||||
}
|
||||
|
||||
void SetDebugPolys( int rwy, int pvmt, int feat, int base );
|
||||
void SetDebugPolys( int rwy, int taxi, int pvmt, int feat, int base );
|
||||
long FindAirport( string icao );
|
||||
void AddAirport( string icao );
|
||||
void AddAirports( long start_pos, float min_lat, float min_lon, float max_lat, float max_lon );
|
||||
|
@ -119,6 +121,7 @@ private:
|
|||
// a polygon conists of an array of contours
|
||||
// (first is outside boundry, remaining are holes)
|
||||
Airport* cur_airport;
|
||||
Taxiway* cur_taxiway;
|
||||
Runway* cur_runway;
|
||||
WaterRunway* cur_waterrunway;
|
||||
Helipad* cur_helipad;
|
||||
|
@ -136,6 +139,7 @@ private:
|
|||
|
||||
// debug
|
||||
int rwy_poly;
|
||||
int taxi_poly;
|
||||
int pvmt_poly;
|
||||
int feat_poly;
|
||||
int base_poly;
|
||||
|
|
|
@ -49,6 +49,7 @@ Runway::Runway(char* definition)
|
|||
geo_inverse_wgs_84( rwy.lat[0], rwy.lon[0], rwy.lat[1], rwy.lon[1], &rwy.heading, &az2, &rwy.length );
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Read runway: (" << rwy.lon[0] << "," << rwy.lat[0] << ") to (" << rwy.lon[1] << "," << rwy.lat[1] << ") heading: " << rwy.heading << " length: " << rwy.length << " width: " << rwy.width );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
219
src/Airports/GenAirports850/taxiway.cxx
Normal file
219
src/Airports/GenAirports850/taxiway.cxx
Normal file
|
@ -0,0 +1,219 @@
|
|||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/bucket/newbucket.hxx>
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
|
||||
#include <Geometry/poly_support.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
#include "global.hxx"
|
||||
#include "apt_math.hxx"
|
||||
#include "beznode.hxx"
|
||||
#include "taxiway.hxx"
|
||||
|
||||
extern int nudge;
|
||||
|
||||
Taxiway::Taxiway(char* definition)
|
||||
{
|
||||
// variables for sdjusting 810 rwy format to 850 rwy format
|
||||
double pt_x, pt_y;
|
||||
double az2;
|
||||
|
||||
// variables to store unused parameters
|
||||
char designation[16];
|
||||
double threshold;
|
||||
double overrun;
|
||||
int shoulder;
|
||||
int markings;
|
||||
double smoothness;
|
||||
int signs;
|
||||
|
||||
// format:
|
||||
// taxiway lat lon designation heading length threshold overrun
|
||||
// 10 44.38085600 -074.20606200 xxx 79.29 3384 0.0 0.0
|
||||
//
|
||||
// width lighting surface shoulder markings smoothness dist remain
|
||||
// 60 161161 1 0 0 0.35 0
|
||||
|
||||
// Parse the line
|
||||
// 44.38085600 -074.20606200 xxx 79.29 3384 0.0 0.0 60 161161 1 0 0 0.35 0
|
||||
|
||||
// int fscanf(FILE *stream, const char *format, ...);
|
||||
sscanf(definition, "%lf %lf %s %lf %lf %lf %lf %lf %s %d %d %d %lf %d",
|
||||
&lat, &lon, designation, &heading, &length, &threshold, &overrun,
|
||||
&width, lighting, &surface, &shoulder, &markings, &smoothness, &signs);
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Read taxiway: (" << lon << "," << lat << ") heading: " << heading << " length: " << length << " width: " << width );
|
||||
|
||||
// adjust length and width from feet to meters
|
||||
length *= SG_FEET_TO_METER;
|
||||
width *= SG_FEET_TO_METER;
|
||||
|
||||
// adjust lat / lon to the start of the taxiway, not the middle
|
||||
geo_direct_wgs_84( lat, lon, heading, -length/2, &pt_y, &pt_x, &az2 );
|
||||
|
||||
lat = pt_y;
|
||||
lon = pt_x;
|
||||
}
|
||||
|
||||
int Taxiway::BuildBtg( superpoly_list* rwy_polys, texparams_list* texparams, superpoly_list* rwy_lights, ClipPolyType* accum, poly_list& slivers, TGPolygon* apt_base, TGPolygon* apt_clearing, bool make_shapefiles )
|
||||
{
|
||||
TGPolygon taxi;
|
||||
TGPolygon base, safe_base;
|
||||
TGPolygon pre_accum;
|
||||
std::string material;
|
||||
void* ds_id = NULL; // If we are going to build shapefiles
|
||||
void* l_id = NULL; // datasource and layer IDs
|
||||
|
||||
if ( make_shapefiles ) {
|
||||
char ds_name[128];
|
||||
sprintf(ds_name, "./taxi_debug");
|
||||
ds_id = tgShapefileOpenDatasource( ds_name );
|
||||
}
|
||||
|
||||
if ( surface == 1 /* Asphalt */ )
|
||||
{
|
||||
if ( (width <= 50) && (lighting[1] == '6') ) {
|
||||
material = "pa_taxiway";
|
||||
} else {
|
||||
material = "pa_tiedown";
|
||||
}
|
||||
}
|
||||
else if ( surface == 2 /* Concrete */ )
|
||||
{
|
||||
if ( (width <= 50) && (lighting[1] == '6') ) {
|
||||
material = "pc_taxiway";
|
||||
} else {
|
||||
material = "pc_tiedown";
|
||||
}
|
||||
}
|
||||
else if ( surface == 3 /* Turf/Grass */ )
|
||||
{
|
||||
material = "grass_rwy";
|
||||
}
|
||||
else if ( surface == 4 /* Dirt */ || surface == 5 /* Gravel */ )
|
||||
{
|
||||
material = "dirt_rwy";
|
||||
}
|
||||
else if ( surface == 12 /* Dry Lakebed */ )
|
||||
{
|
||||
material = "dirt_rwy";
|
||||
}
|
||||
else if ( surface == 13 /* Water runway (buoy's?) */ )
|
||||
{
|
||||
// water
|
||||
}
|
||||
else if ( surface == 14 /* Snow / Ice */ )
|
||||
{
|
||||
// Ice
|
||||
}
|
||||
else if ( surface == 15 /* Transparent */ )
|
||||
{
|
||||
//Transparent texture
|
||||
}
|
||||
else
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_WARN, "surface_code = " << surface);
|
||||
throw sg_exception("unknown runway type!");
|
||||
}
|
||||
|
||||
// generate a poly for this segment
|
||||
taxi = gen_wgs84_rect( lat, lon, heading, length, width );
|
||||
|
||||
TGSuperPoly sp;
|
||||
TGTexParams tp;
|
||||
|
||||
if ( make_shapefiles ) {
|
||||
char layer_name[128];
|
||||
char feature_name[128];
|
||||
|
||||
sprintf( layer_name, "original" );
|
||||
l_id = tgShapefileOpenLayer( ds_id, layer_name );
|
||||
sprintf( feature_name, "original" );
|
||||
tgShapefileCreateFeature( ds_id, l_id, taxi, feature_name );
|
||||
|
||||
pre_accum = *accum;
|
||||
}
|
||||
|
||||
TGPolygon clipped = tgPolygonDiffClipper( taxi, *accum );
|
||||
tgPolygonFindSlivers( clipped, slivers );
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "clipped = " << clipped.contours());
|
||||
|
||||
sp.erase();
|
||||
sp.set_poly( clipped );
|
||||
sp.set_material( material );
|
||||
sp.set_flag("taxi");
|
||||
|
||||
rwy_polys->push_back( sp );
|
||||
|
||||
*accum = tgPolygonUnionClipper( taxi, *accum );
|
||||
|
||||
/* If debugging this poly, write the poly, and clipped poly and the accum buffer into their own layers */
|
||||
if ( make_shapefiles ) {
|
||||
char layer_name[128];
|
||||
char feature_name[128];
|
||||
|
||||
sprintf( layer_name, "clipped" );
|
||||
l_id = tgShapefileOpenLayer( ds_id, layer_name );
|
||||
sprintf( feature_name, "clipped" );
|
||||
tgShapefileCreateFeature( ds_id, l_id, clipped, feature_name );
|
||||
|
||||
sprintf( layer_name, "pre_accum" );
|
||||
l_id = tgShapefileOpenLayer( ds_id, layer_name );
|
||||
sprintf( feature_name, "pre_accum" );
|
||||
tgShapefileCreateFeature( ds_id, l_id, pre_accum, feature_name );
|
||||
|
||||
sprintf( layer_name, "post_accum" );
|
||||
l_id = tgShapefileOpenLayer( ds_id, layer_name );
|
||||
sprintf( feature_name, "post_accum" );
|
||||
tgShapefileCreateFeature( ds_id, l_id, *accum, feature_name );
|
||||
}
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "tp construct");
|
||||
|
||||
tp = TGTexParams( taxi.get_pt(0,0), width, 250*SG_FEET_TO_METER, heading );
|
||||
texparams->push_back( tp );
|
||||
|
||||
if ( apt_base )
|
||||
{
|
||||
base = tgPolygonExpand( taxi, 20.0);
|
||||
if ( make_shapefiles ) {
|
||||
char layer_name[128];
|
||||
char feature_name[128];
|
||||
|
||||
sprintf( layer_name, "exp_base" );
|
||||
l_id = tgShapefileOpenLayer( ds_id, layer_name );
|
||||
sprintf( feature_name, "exp_base" );
|
||||
tgShapefileCreateFeature( ds_id, l_id, base, feature_name );
|
||||
}
|
||||
|
||||
safe_base = tgPolygonExpand( taxi, 50.0);
|
||||
if ( make_shapefiles ) {
|
||||
char layer_name[128];
|
||||
char feature_name[128];
|
||||
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "expanded safe poly: " << safe_base);
|
||||
|
||||
sprintf( layer_name, "exp_safe_base" );
|
||||
l_id = tgShapefileOpenLayer( ds_id, layer_name );
|
||||
sprintf( feature_name, "exp_safe_base" );
|
||||
tgShapefileCreateFeature( ds_id, l_id, safe_base, feature_name );
|
||||
}
|
||||
|
||||
// add this to the airport clearing
|
||||
*apt_clearing = tgPolygonUnionClipper( safe_base, *apt_clearing);
|
||||
|
||||
// and add the clearing to the base
|
||||
*apt_base = tgPolygonUnionClipper( base, *apt_base );
|
||||
}
|
||||
|
||||
if ( make_shapefiles )
|
||||
{
|
||||
tgShapefileCloseDatasource( ds_id );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
43
src/Airports/GenAirports850/taxiway.hxx
Normal file
43
src/Airports/GenAirports850/taxiway.hxx
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef _TAXIWAY_H_
|
||||
#define _TAXIWAY_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/superpoly.hxx>
|
||||
#include <Polygon/texparams.hxx>
|
||||
#include <Geometry/point3d.hxx>
|
||||
|
||||
#include "apt_math.hxx"
|
||||
|
||||
using std::string;
|
||||
|
||||
class Taxiway
|
||||
{
|
||||
public:
|
||||
|
||||
Taxiway(char* def);
|
||||
|
||||
int BuildBtg( superpoly_list* taxi_polys,
|
||||
texparams_list* texparams,
|
||||
superpoly_list* taxi_lights,
|
||||
ClipPolyType* accum,
|
||||
poly_list& slivers,
|
||||
TGPolygon* apt_base,
|
||||
TGPolygon* apt_clearing,
|
||||
bool make_shapefiles );
|
||||
|
||||
private:
|
||||
double lat;
|
||||
double lon;
|
||||
double heading;
|
||||
double length;
|
||||
double width;
|
||||
int surface;
|
||||
char lighting[8];
|
||||
};
|
||||
|
||||
typedef std::vector <Taxiway *> TaxiwayList;
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue