]> git.mxchange.org Git - flightgear.git/commitdiff
Canvas: Use seperate projection instance for each map
authorThomas Geymayer <tomgey@gmail.com>
Mon, 17 Sep 2012 22:29:54 +0000 (00:29 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Mon, 17 Sep 2012 22:33:36 +0000 (00:33 +0200)
src/Canvas/elements/map.cxx
src/Canvas/elements/map.hxx

index fd793b8d0e174f63e5445233dd2423b3affc6909..a06ebfe230a44776db583681e85e7bdea13d8fc3 100644 (file)
 namespace canvas
 {
 
-  // TODO make projection configurable
-  SansonFlamsteedProjection projection;
   const std::string GEO = "-geo";
 
   //----------------------------------------------------------------------------
   Map::Map(SGPropertyNode_ptr node, const Style& parent_style):
     Group(node, parent_style),
+    // TODO make projection configurable
+    _projection(new SansonFlamsteedProjection),
     _projection_dirty(true)
   {
 
@@ -80,7 +80,7 @@ namespace canvas
         continue;
 
       Projection::ScreenPosition pos =
-        projection.worldToScreen(lat.value, lon.value);
+        _projection->worldToScreen(lat.value, lon.value);
 
       geo_node->setScreenPos(pos.x, pos.y);
 
@@ -182,12 +182,12 @@ namespace canvas
 
     if(    child->getNameString() == "ref-lat"
         || child->getNameString() == "ref-lon" )
-      projection.setWorldPosition( _node->getDoubleValue("ref-lat"),
-                                   _node->getDoubleValue("ref-lon") );
+      _projection->setWorldPosition( _node->getDoubleValue("ref-lat"),
+                                     _node->getDoubleValue("ref-lon") );
     else if( child->getNameString() == "hdg" )
-      projection.setOrientation(child->getFloatValue());
+      _projection->setOrientation(child->getFloatValue());
     else if( child->getNameString() == "range" )
-      projection.setRange(child->getDoubleValue());
+      _projection->setRange(child->getDoubleValue());
     else
       return;
 
index a5ae1fb828d2aefa0dbd94e59005c5369b71648f..a48bde64b247522c752007868af4417d962aa4f9 100644 (file)
@@ -28,6 +28,7 @@
 namespace canvas
 {
   class GeoNodePair;
+  class HorizontalProjection;
   class Map:
     public Group
   {
@@ -51,6 +52,7 @@ namespace canvas
                                     boost::shared_ptr<GeoNodePair>
                                   > GeoNodes;
       GeoNodes _geo_nodes;
+      boost::shared_ptr<HorizontalProjection> _projection;
       bool _projection_dirty;
 
       struct GeoCoord