Canvas MapStructure: Difference between revisions

Jump to navigation Jump to search
m
No edit summary
Line 738: Line 738:


For SingleSymbolLayers: this is responsible for the mandatory getModel() to provide a model object. This is called once and used for the lifetime of the layer, so the object should be dynamic (this works particularly well with a simple property node that supplies position/latitude-deg + position/longitude-deg or latitude-deg + longitude-deg -- this can of course be extended, see [https://gitorious.org/fg/fgdata/source/4732a3b620cd0df36ebffdba76a3872c43539bf8:Nasal/canvas/MapStructure.nas#L243-246]). If the returned object has an update() method, this is called before the position is retreived.
For SingleSymbolLayers: this is responsible for the mandatory getModel() to provide a model object. This is called once and used for the lifetime of the layer, so the object should be dynamic (this works particularly well with a simple property node that supplies position/latitude-deg + position/longitude-deg or latitude-deg + longitude-deg -- this can of course be extended, see [https://gitorious.org/fg/fgdata/source/4732a3b620cd0df36ebffdba76a3872c43539bf8:Nasal/canvas/MapStructure.nas#L243-246]). If the returned object has an update() method, this is called before the position is retreived.


{{Note|the _equals line adds a new function to the layer's searcher hash - we need to provide a way to check for "equality", i.e. for navaids that could be position and/or the ID (name). For custom/new layers, we need to provide a custom equality check function. What you are doing there is just adding a custom equality check function that always returns "false" (not equal). This is used by MapStructure to "smartly" identify and differentiate between old and new objects, i.e. to reduce workload and improve performance - imagine the "FIX" layer, which may have hundreds of fixes - while flying, a few dozen will be "new" ones, while most others will be "old" - we'll only remove the old ones, and only add new ones. If the custom definition is not provided, you should get an error suggesting that you add a corresponding method so that the underlying logic can check all objects for equality - see the bottom of the MapStructure article for details, or search for "_equals"}}
{{Note|the _equals line adds a new function to the layer's searcher hash - we need to provide a way to check for "equality", i.e. for navaids that could be position and/or the ID (name). For custom/new layers, we need to provide a custom equality check function. What you are doing there is just adding a custom equality check function that always returns "false" (not equal). This is used by MapStructure to "smartly" identify and differentiate between old and new objects, i.e. to reduce workload and improve performance - imagine the "FIX" layer, which may have hundreds of fixes - while flying, a few dozen will be "new" ones, while most others will be "old" - we'll only remove the old ones, and only add new ones. If the custom definition is not provided, you should get an error suggesting that you add a corresponding method so that the underlying logic can check all objects for equality - see the bottom of the MapStructure article for details, or search for "_equals"}}
Line 762: Line 761:
}}
}}


{{FGCquote
  |The main thing to keep in mind here is that many MapStructure layers deal with positioned objects, i.e. objects that have lat/lon/altitude - internally, the system uses a "diff" (delta) method to compare the current result set against the previous result set to tell how many new/removed items are there - so that things can be selectived updated (added/removed), i.e. to only partially redraw/update things for the sake of efficiency.
  |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=216407#p216407
    |title=<nowiki>Re: Live WXRadar MapStructure Layer Development</nowiki>
    |author=<nowiki>Hooray</nowiki>
    |date=<nowiki>Sun Aug 10</nowiki>
  }}
}}
<!--
<!--
TFC (TCAS) is a bit problematic to test. Assuming that the map's range is set to ~ 50 nm, we could simply use the .apply_course_distance() method in geo.nas to create 10 objects in a range of 20 nm with a 36 degree spacing using something along the lines of.
TFC (TCAS) is a bit problematic to test. Assuming that the map's range is set to ~ 50 nm, we could simply use the .apply_course_distance() method in geo.nas to create 10 objects in a range of 20 nm with a 36 degree spacing using something along the lines of.

Navigation menu