2,733
edits
Red Leader (talk | contribs) (→PositionedSearch: some more, but still WIP) |
Red Leader (talk | contribs) (→PositionedSearch: Should be finished now) |
||
Line 280: | Line 280: | ||
|mode = class | |mode = class | ||
|version = 3.0 | |version = 3.0 | ||
|text = This class can be used to show differences between | |text = This class can be used to show differences between FGPositioned (namespace: <code>positioned</code>) search queries. Although it is only used for [[MapStructure]] and the [[Nasal Browser]] as of 09/2016, it can also be used for other applications. | ||
}} | }} | ||
==== new() ==== | ==== new() ==== | ||
Line 295: | Line 295: | ||
|param4text = Optional <code>'''me'''</code> reference. This will be used as the <code>'''me'''</code> reference in each of the above fucntions. | |param4text = Optional <code>'''me'''</code> reference. This will be used as the <code>'''me'''</code> reference in each of the above fucntions. | ||
|example1 = var searchCmd = func(){ | |example1 = var searchCmd = func(){ | ||
return positioned.findAirportsWithinRange( | return positioned.findAirportsWithinRange(10); | ||
}; | }; | ||
var added = func(apt){ | var added = func(apt){ | ||
Line 305: | Line 305: | ||
var searcher = geo.PositionedSearch.new(searchCmd, added, removed); | var searcher = geo.PositionedSearch.new(searchCmd, added, removed); | ||
searcher.update(); | |||
}} | }} | ||
==== test() ==== | ==== test() ==== | ||
Line 324: | Line 325: | ||
|param1text = Optional search function to use instead of the one given in <code>[[#new()_2|PositionedSearch.new()]]</code>. | |param1text = Optional search function to use instead of the one given in <code>[[#new()_2|PositionedSearch.new()]]</code>. | ||
|example1 = var searchCmd = func(){ | |example1 = var searchCmd = func(){ | ||
return positioned.findAirportsWithinRange( | return positioned.findAirportsWithinRange(10); | ||
}; | }; | ||
var added = func(apt){ | var added = func(apt){ | ||
Line 339: | Line 340: | ||
{{Nasal doc | {{Nasal doc | ||
|syntax = geo.PositionedSearch._equals; | |syntax = geo.PositionedSearch._equals; | ||
|text = | |text = Function that checks if two objects are equal. You must redefine this function to use <code>geo.PositionedSearch</code> for other uses. | ||
|example1 = var searchCmd = func(){ | |example1 = var searchCmd = func(){ | ||
var vec = []; | |||
var max = rand() * 10; | |||
for(var i = 1; i <= max; i += 1){ | |||
append(vec, i); | |||
} | |||
return vec; | |||
}; | }; | ||
var added = func( | var added = func(num){ | ||
print( | print(num, " added"); | ||
} | } | ||
var removed = func( | var removed = func(num){ | ||
print( | print(num, " removed"); | ||
} | } | ||
var searcher = geo.PositionedSearch.new(searchCmd, added, removed); | var searcher = geo.PositionedSearch.new(searchCmd, added, removed); | ||
searcher._equals = func(a, b){ return a == b; } | |||
searcher.update(); | searcher.update(); | ||
print("===="); | |||
searcher.update(); # run again to see differences | |||
}} | }} | ||