1
0
Fork 0

rename genapts850 -> genapts

This commit is contained in:
scttgs0 2023-05-12 22:13:01 -05:00
parent a7d1a331ad
commit 777ea6ab92
41 changed files with 82 additions and 170 deletions

View file

@ -129,9 +129,9 @@ endif (CGAL_FOUND)
# check required dependencies
find_package(Boost COMPONENTS system thread REQUIRED)
find_package(ZLIB 1.2.9 REQUIRED)
find_package(ZLIB 1.2.11 REQUIRED)
find_package(Threads REQUIRED)
find_package(SimGear 2020.1.0 REQUIRED)
find_package(SimGear 2020.3.0 REQUIRED)
find_package(GDAL 2.0.0 REQUIRED)
find_package(TIFF REQUIRED) # needed for SRTM

View file

@ -1 +1 @@
add_subdirectory(GenAirports850)
add_subdirectory(GenAirports)

View file

@ -2,7 +2,7 @@ include_directories(${GDAL_INCLUDE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/src/Lib)
include_directories(${PROJECT_SOURCE_DIR}/src/Lib/terragear)
add_executable(genapts850
add_executable(genapts
airport.hxx airport.cxx
apt_math.hxx apt_math.cxx
beznode.hxx
@ -26,7 +26,7 @@ add_executable(genapts850
trafficFlow.cxx trafficFlow.hxx
)
target_link_libraries(genapts850
target_link_libraries(genapts
terragear
Array
${GDAL_LIBRARY}
@ -36,4 +36,4 @@ target_link_libraries(genapts850
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
${Boost_LIBRARIES})
install(TARGETS genapts850 RUNTIME DESTINATION bin)
install(TARGETS genapts RUNTIME DESTINATION bin)

View file

@ -214,16 +214,18 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
// Find the average of all the runway and heliport long / lats
int num_samples = 0;
for (unsigned int i = 0; i < runways.size(); i++) {
apt_lon += runways[i]->GetMidpoint().getLongitudeDeg();
apt_lat += runways[i]->GetMidpoint().getLatitudeDeg();
for (auto& runway : runways) {
apt_lon += runway->GetMidpoint().getLongitudeDeg();
apt_lat += runway->GetMidpoint().getLatitudeDeg();
num_samples++;
}
for (unsigned int i = 0; i < helipads.size(); i++) {
apt_lon += helipads[i]->GetLoc().getLongitudeDeg();
apt_lat += helipads[i]->GetLoc().getLatitudeDeg();
for (auto& helipad : helipads) {
apt_lon += helipad->GetLoc().getLongitudeDeg();
apt_lat += helipad->GetLoc().getLatitudeDeg();
num_samples++;
}
apt_lon = apt_lon / (double)num_samples;
apt_lat = apt_lat / (double)num_samples;
@ -232,8 +234,8 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
// If we are cutting in the linear features, add them first
if (pavements.size()) {
for (unsigned int i = 0; i < pavements.size(); i++) {
AddFeatures(pavements[i]->GetFeatures());
for (auto& pavement : pavements) {
AddFeatures(pavement->GetFeatures());
}
}
@ -247,15 +249,14 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
tgAccumulator lf_accum(icao);
TG_LOG(SG_GENERAL, SG_INFO, "Build " << features.size() << " Linear Feature Polys");
for (unsigned int i = 0; i < features.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Feature Poly " << i + 1 << " of " << features.size() << " : " << features[i]->GetDescription());
unsigned i = 0;
for (auto& feature : features) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Feature Poly " << ++i << " of " << features.size() << " : " << feature->GetDescription());
bool make_shapefiles = false;
features[i]->BuildBtg(line_polys, rwy_lights, lf_accum, make_shapefiles);
feature->BuildBtg(line_polys, rwy_lights, lf_accum, make_shapefiles);
}
// lf_accum.ToShapefiles( "./lf_accum", "test", false );
log_time = time(0);
TG_LOG(SG_GENERAL, SG_ALERT, "Finished building Linear Features for " << icao << " at " << DebugTimeToString(log_time));
}
@ -266,25 +267,21 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
// Build runways next
if (runways.size()) {
TG_LOG(SG_GENERAL, SG_INFO, "Build " << runways.size() << " Runway Polys");
for (unsigned int i = 0; i < runways.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Runway " << i + 1 << " of " << runways.size());
//slivers.clear();
unsigned i = 0;
for (auto& runway : runways) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Runway " << i+1 << " of " << runways.size());
if (isDebugRunway(i)) {
if (isDebugRunway(i))
sprintf(shapefile_name, "runway_%u", i);
} else {
else
strcpy(shapefile_name, "");
}
shapefile = shapefile_name;
if (boundary.size()) {
runways[i]->BuildBtg(rwy_polys, rwy_lights, slivers, pvmt_accum, shapefile);
} else {
runways[i]->BuildBtg(rwy_polys, rwy_lights, slivers, apt_base_polys, apt_clearing_polys, pvmt_accum, shapefile);
}
// Now try to merge any slivers we found
// tgPolygon::MergeSlivers( rwy_polys, slivers );
if (boundary.size())
runway->BuildBtg(rwy_polys, rwy_lights, slivers, pvmt_accum, shapefile);
else
runway->BuildBtg(rwy_polys, rwy_lights, slivers, apt_base_polys, apt_clearing_polys, pvmt_accum, shapefile);
++i;
}
log_time = time(0);
@ -293,53 +290,45 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
if (lightobjects.size()) {
TG_LOG(SG_GENERAL, SG_INFO, "Build " << lightobjects.size() << " Light Objects ");
for (unsigned int i = 0; i < lightobjects.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build runway light " << i + 1 << " of " << lightobjects.size());
lightobjects[i]->BuildBtg(rwy_lights);
unsigned i = 0;
for (auto& light : lightobjects) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build runway light " << ++i << " of " << lightobjects.size());
light->BuildBtg(rwy_lights);
}
}
// Build helipads (use runway poly- and texture list for this)
if (helipads.size()) {
TG_LOG(SG_GENERAL, SG_INFO, "Build " << helipads.size() << " Helipad Polys ");
for (unsigned int i = 0; i < helipads.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build helipad " << i + 1 << " of " << helipads.size());
//slivers.clear();
unsigned i = 0;
for (auto& helipad : helipads) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build helipad " << ++i << " of " << helipads.size());
if (boundary.size()) {
helipads[i]->BuildBtg(rwy_polys, rwy_lights, slivers, pvmt_accum);
} else {
helipads[i]->BuildBtg(rwy_polys, rwy_lights, slivers, apt_base_polys, apt_clearing_polys, pvmt_accum);
}
// Now try to merge any slivers we found
//tgPolygon::MergeSlivers( rwy_polys, slivers );
if (boundary.size())
helipad->BuildBtg(rwy_polys, rwy_lights, slivers, pvmt_accum);
else
helipad->BuildBtg(rwy_polys, rwy_lights, slivers, apt_base_polys, apt_clearing_polys, pvmt_accum);
}
}
// Build the pavements
if (pavements.size()) {
TG_LOG(SG_GENERAL, SG_INFO, "Build " << pavements.size() << " Pavement Polys ");
for (unsigned int i = 0; i < pavements.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Pavement " << i + 1 << " of " << pavements.size() << " : " << pavements[i]->GetDescription());
//slivers.clear();
unsigned i = 0;
for (auto& pavement : pavements) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Pavement " << i+1 << " of " << pavements.size() << " : " << pavement->GetDescription());
if (isDebugPavement(i)) {
if (isDebugPavement(i))
sprintf(shapefile_name, "pvmnt_%u", i);
} else {
else
strcpy(shapefile_name, "");
}
shapefile = shapefile_name;
if (boundary.size()) {
pavements[i]->BuildBtg(pvmt_polys, slivers, pvmt_accum, shapefile);
} else {
pavements[i]->BuildBtg(pvmt_polys, slivers, apt_base_polys, apt_clearing_polys, pvmt_accum, shapefile);
}
// Now try to merge any slivers we found
//tgPolygon::MergeSlivers( rwy_polys, slivers );
//tgPolygon::MergeSlivers( pvmt_polys, slivers );
if (boundary.size())
pavement->BuildBtg(pvmt_polys, slivers, pvmt_accum, shapefile);
else
pavement->BuildBtg(pvmt_polys, slivers, apt_base_polys, apt_clearing_polys, pvmt_accum, shapefile);
++i;
}
log_time = time(0);
@ -349,60 +338,48 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
// Build the legacy taxiways
if (taxiways.size()) {
TG_LOG(SG_GENERAL, SG_INFO, "Build " << taxiways.size() << " Taxiway Polys ");
for (unsigned int i = 0; i < taxiways.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Taxiway " << i + 1 << " of " << taxiways.size());
//slivers.clear();
if (isDebugTaxiway(i)) {
unsigned i = 0;
for (auto& taxiway : taxiways) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Taxiway " << i+1 << " of " << taxiways.size());
if (isDebugTaxiway(i))
sprintf(shapefile_name, "taxiway_%u", i);
} else {
else
strcpy(shapefile_name, "");
}
shapefile = shapefile_name;
if (boundary.size()) {
taxiways[i]->BuildBtg(pvmt_polys, rwy_lights, slivers, pvmt_accum, shapefile);
} else {
taxiways[i]->BuildBtg(pvmt_polys, rwy_lights, slivers, apt_base_polys, apt_clearing_polys, pvmt_accum, shapefile);
}
// Now try to merge any slivers we found
//tgPolygon::MergeSlivers( rwy_polys, slivers );
//tgPolygon::MergeSlivers( pvmt_polys, slivers );
if (boundary.size())
taxiway->BuildBtg(pvmt_polys, rwy_lights, slivers, pvmt_accum, shapefile);
else
taxiway->BuildBtg(pvmt_polys, rwy_lights, slivers, apt_base_polys, apt_clearing_polys, pvmt_accum, shapefile);
++i;
}
}
// Build runway shoulders here
if (runways.size()) {
TG_LOG(SG_GENERAL, SG_INFO, "Build " << runways.size() << " Runway Shoulder Polys ");
for (unsigned int i = 0; i < runways.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Runway shoulder " << i + 1 << " of " << runways.size());
if (runways[i]->GetsShoulder()) {
//slivers.clear();
runways[i]->BuildShoulder(rwy_polys, slivers, pvmt_accum);
unsigned i = 0;
for (auto& runway : runways) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Runway shoulder " << ++i << " of " << runways.size());
// Now try to merge any slivers we found
//tgPolygon::MergeSlivers( rwy_polys, slivers );
//tgPolygon::MergeSlivers( pvmt_polys, slivers );
}
if (runway->GetsShoulder())
runway->BuildShoulder(rwy_polys, slivers, pvmt_accum);
}
}
// Build helipad shoulders here
if (helipads.size()) {
TG_LOG(SG_GENERAL, SG_INFO, "Build " << runways.size() << " Helipad Shoulder Polys ");
for (unsigned int i = 0; i < helipads.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Helipad shoulder " << i + 1 << " of " << helipads.size());
if (helipads[i]->GetsShoulder()) {
//slivers.clear();
helipads[i]->BuildShoulder(rwy_polys, slivers, pvmt_accum);
unsigned i = 0;
for (auto& helipad : helipads) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build Helipad shoulder " << ++i << " of " << helipads.size());
// Now try to merge any slivers we found
//tgPolygon::MergeSlivers( rwy_polys, slivers );
//tgPolygon::MergeSlivers( pvmt_polys, slivers );
}
if (helipad->GetsShoulder())
helipad->BuildShoulder(rwy_polys, slivers, pvmt_accum);
}
}
@ -410,11 +387,14 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
tgPolygon apt_base, apt_clearing;
if (boundary.size()) {
TG_LOG(SG_GENERAL, SG_INFO, "Build " << boundary.size() << " Boundary Polys ");
shapefile = "";
for (unsigned int i = 0; i < boundary.size(); i++) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build user-defined boundary " << i + 1 << " of " << boundary.size());
boundary[i]->BuildBtg(apt_base, apt_clearing, shapefile);
unsigned i = 0;
for (auto& b : boundary) {
TG_LOG(SG_GENERAL, SG_DEBUG, "Build user-defined boundary " << ++i << " of " << boundary.size());
b->BuildBtg(apt_base, apt_clearing, shapefile);
}
} else {
apt_base = tgPolygon::Union(apt_base_polys);
@ -523,13 +503,6 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
poly = tgPolygon::RemoveCycles(poly);
poly = tgPolygon::RemoveDups(poly);
poly = tgPolygon::RemoveBadContours(poly);
// poly = tgPolygon::Simplify( poly );
// poly = tgPolygon::RemoveTinyContours( poly );
// poly = tgPolygon::RemoveSpikes( poly );
// poly = tgPolygon::RemoveDups( poly );
// poly = tgPolygon::RemoveBadContours( poly );
// poly = tgPolygon::RemoveTinyContours( poly );
#endif
line_polys[k] = poly;
@ -539,33 +512,6 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
TG_LOG(SG_GENERAL, SG_ALERT, "Finished cleaning polys for " << icao << " at " << DebugTimeToString(log_time));
base_poly = tgPolygon::AddColinearNodes(base_poly, tmp_pvmt_nodes);
// base_poly = tgPolygon::Snap( base_poly, gSnap );
// Finally find slivers in base
//slivers.clear();
//tgPolygon::RemoveSlivers( base_poly, slivers );
//tgPolygon::MergeSlivers( rwy_polys, slivers );
//tgPolygon::MergeSlivers( pvmt_polys, slivers );
#if 0
// Then snap rwy and pavement to grid (was done right after adding intermediate nodes...)
for ( unsigned int k = 0; k < rwy_polys.size(); ++k )
{
tgPolygon poly = rwy_polys[k];
poly = tgPolygon::Snap(poly, gSnap);
poly = tgPolygon::RemoveDups( poly );
poly = tgPolygon::RemoveBadContours( poly );
rwy_polys[k] = poly;
}
for ( unsigned int k = 0; k < pvmt_polys.size(); ++k )
{
tgPolygon poly = pvmt_polys[k];
poly = tgPolygon::Snap(poly, gSnap);
poly = tgPolygon::RemoveDups( poly );
poly = tgPolygon::RemoveBadContours( poly );
pvmt_polys[k] = poly;
}
#endif
cleanup_end.stamp();
cleanup_time = cleanup_end - cleanup_start;
@ -585,13 +531,6 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
TG_LOG(SG_GENERAL, SG_DEBUG, "contours before " << rwy_polys[i].Contours() << " total points before = " << rwy_polys[i].TotalNodes());
rwy_polys[i].Tesselate();
#if 0
// dump the triangles for each poly
char desc[128];
sprintf( desc, "poly_%06d", i );
tgShapefile::FromTriangles( rwy_polys[i], debug_root, "rwy_polys", desc );
#endif
TG_LOG(SG_GENERAL, SG_DEBUG, "triangles after = " << rwy_polys[i].Triangles());
rwy_polys[i].Texture();
}
@ -606,12 +545,6 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
TG_LOG(SG_GENERAL, SG_DEBUG, "contours before " << pvmt_polys[i].Contours() << " total points before = " << pvmt_polys[i].TotalNodes());
pvmt_polys[i].Tesselate();
#if 0
char desc[128];
sprintf( desc, "poly_%06d", i );
tgShapefile::FromTriangles( pvmt_polys[i], debug_root, "pvmt_polys", desc );
#endif
TG_LOG(SG_GENERAL, SG_DEBUG, "triangles after = " << pvmt_polys[i].Triangles());
pvmt_polys[i].Texture();
}
@ -626,12 +559,6 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
TG_LOG(SG_GENERAL, SG_DEBUG, "contours before " << line_polys[i].Contours() << " total points before = " << line_polys[i].TotalNodes());
line_polys[i].Tesselate();
#if 0
char desc[128];
sprintf( desc, "poly_%06d", i );
tgShapefile::FromTriangles( line_polys[i], debug_root, "line_polys", desc );
#endif
TG_LOG(SG_GENERAL, SG_DEBUG, "triangles after = " << line_polys[i].Triangles());
line_polys[i].Texture();
}
@ -640,12 +567,6 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
TG_LOG(SG_GENERAL, SG_INFO, "Tesselating base poly : " << base_poly.Contours() << " contours ");
base_poly.Tesselate();
#if 0
char desc[128];
sprintf( desc, "poly" );
tgShapefile::FromTriangles( base_poly, debug_root, "base_poly", desc );
#endif
TG_LOG(SG_GENERAL, SG_INFO, "Tesselating base poly - done : Triangles = " << base_poly.Triangles());
// should we texture base here?
base_poly.SetTexMethod(TG_TEX_BY_GEODE, b.get_center_lat());
@ -661,15 +582,6 @@ void Airport::BuildBtg(const std::string& root, const string_list& elev_src)
triangulation_time = triangulation_end - triangulation_start;
#if 0
// CheckZFighting( "post triangulation", debug_root, base_poly, rwy_polys, pvmt_polys );
if ( CheckZFightingTriangles( "post triangulation tris", debug_root, base_poly, rwy_polys, pvmt_polys ) ) {
char cmd[128];
snprintf(cmd, 128, "echo %s >> zfight.txt\n", icao.c_str());
system (cmd);
}
#endif
//
// We should now have the runway polygons all generated with their
// corresponding triangles and texture coordinates, and the

View file

@ -33,7 +33,7 @@ APTDAT=${HOME}/live/airfield/v10+/apt.dat
DEM="--dem-path=SRTM2-VFP-3-NE --dem-path=SRTM2-VFP-3-NW \
--dem-path=SRTM2-VFP-3-SE --dem-path=SRTM2-VFP-3-SW"
GENAPTS=${HOME}/terragear/bin/genapts850
GENAPTS=${HOME}/terragear/bin/genapts
#${GENAPTS} --threads --input=${APTDAT} --work=${WORKBASE} ${DEM} ${NUDGE} ${SPAT}
${GENAPTS} --input=${APTDAT} --work=${WORKBASE} ${DEM} ${NUDGE} ${SPAT}

View file

@ -18,6 +18,7 @@
#include <memory>
#include "runway.hxx"
#include <terragear/tg_polygon.hxx>
#include <terragear/tg_accumulator.hxx>
#include <terragear/tg_light.hxx>

View file

@ -147,7 +147,7 @@ int main(int argc, char** argv)
// parse arguments
std::string work_dir = "";
std::string input_file = "";
std::string summary_file = "./genapt850.csv";
std::string summary_file = "./genapt.csv";
std::string start_id = "";
std::string airport_id = "";
int num_threads = 1;
@ -212,7 +212,7 @@ int main(int argc, char** argv)
std::string airportareadir = work_dir + "/AirportArea";
// this is the main program -
TG_LOG(SG_GENERAL, SG_INFO, "Genapts850 version " << getTGVersion() << " running with " << num_threads << " threads");
TG_LOG(SG_GENERAL, SG_INFO, "Genapts version " << getTGVersion() << " running with " << num_threads << " threads");
TG_LOG(SG_GENERAL, SG_INFO, "Launch command was " << argv[0]);
TG_LOG(SG_GENERAL, SG_INFO, "Input file = " << input_file);
TG_LOG(SG_GENERAL, SG_INFO, "Work directory = " << work_dir);

View file

@ -1 +0,0 @@
genapts850