From ccfde6914a5c8d76fcf81d2cdd79fd6ef8336338 Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Fri, 14 Sep 2012 12:41:16 +0200 Subject: [PATCH] Linear features: Yellow hold lights are unidirectional to the right of the line direction. Implement this by creating a directional normal for these types. --- src/Airports/GenAirports850/linearfeature.cxx | 27 ++++++++++++++++--- src/Airports/GenAirports850/linearfeature.hxx | 5 ++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/Airports/GenAirports850/linearfeature.cxx b/src/Airports/GenAirports850/linearfeature.cxx index 174a0cd6..4d548810 100644 --- a/src/Airports/GenAirports850/linearfeature.cxx +++ b/src/Airports/GenAirports850/linearfeature.cxx @@ -759,6 +759,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx ) { prev_outer = Point3D(0.0f, 0.0f, 0.0f); cur_light_dist = 0.0f; + bool directional_light = lights[i]->IsDirectional(); // which material for this light switch( lights[i]->type ) @@ -839,10 +840,28 @@ int LinearFeature::Finish( bool closed, unsigned int idx ) poly.add_node(0, tmp); - // calculate the normal - Point3D vec = sgGeodToCart( tmp * SG_DEGREES_TO_RADIANS ); - double length = vec.distance3D( Point3D(0.0) ); - vec = vec / length; + double length; + Point3D vec; + + if ( !directional_light ) + { + // calculate the omnidirectional normal + vec = sgGeodToCart( tmp * SG_DEGREES_TO_RADIANS ); + length = vec.distance3D( Point3D(0.0) ); + vec = vec / length; + } else + { + // calculate the directional normal + double heading_vec = heading + 90.0; + if (heading_vec > 360.0) { heading_vec -= 360.0; } + geo_direct_wgs_84( tmp.y(), tmp.x(), heading_vec, 10, &pt_y, &pt_x, &az2 ); + Point3D cart1 = sgGeodToCart( tmp * SG_DEGREES_TO_RADIANS ); + Point3D cart2 = sgGeodToCart( Point3D(pt_x, pt_y, 0.0) * SG_DEGREES_TO_RADIANS ); + + vec = cart2 - cart1; + length = vec.distance3D( Point3D(0.0) ); + vec = vec / length; + } normals_poly.add_node(0, vec ); diff --git a/src/Airports/GenAirports850/linearfeature.hxx b/src/Airports/GenAirports850/linearfeature.hxx index f122b1c2..8799280c 100644 --- a/src/Airports/GenAirports850/linearfeature.hxx +++ b/src/Airports/GenAirports850/linearfeature.hxx @@ -57,6 +57,11 @@ public: unsigned int type; unsigned int start_idx; unsigned int end_idx; + + bool IsDirectional() + { + return (type == 103 || type == 104) ? true : false; + } }; typedef std::vector LightingList;