Nasal library/geo: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 9: Line 9:
{{Nasal doc
{{Nasal doc
|mode = class
|mode = class
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = The main class, used widely for storing and managing positional data. Coordinates may be stored in either {{wikipedia|ECEF|Earth-centered, Earth-fixed}} coordinates (x, y and z) or {{wikipedia|geodetic coordinates}} (latitude, longitude, and altitude). In addition, it will convert coordinates as necessary. However, note that for the conversion to work, set_latlon() and set_xyz() must be used.
|text = The main class, used widely for storing and managing positional data. Coordinates may be stored in either {{wikipedia|ECEF|Earth-centered, Earth-fixed}} coordinates (x, y and z) or {{wikipedia|geodetic coordinates}} (latitude, longitude, and altitude). In addition, it will convert coordinates as necessary. However, note that for the conversion to work, set_latlon() and set_xyz() must be used.
}}
}}
Line 15: Line 14:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.new([coord]);
|syntax = geo.Coord.new([coord]);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Constructor function. Returns a <code>geo.Coord</code> instance.
|text = Constructor function. Returns a <code>geo.Coord</code> instance.
|param1 = coord
|param1 = coord
Line 27: Line 25:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set(coord);
|syntax = geo.Coord.set(coord);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets the coordinates. Returns the <code>geo.Coord</code> instance.
|text = Sets the coordinates. Returns the <code>geo.Coord</code> instance.
|param1 = coord
|param1 = coord
Line 39: Line 36:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set_lat(lat);
|syntax = geo.Coord.set_lat(lat);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets the {{wikipedia|latitude}} coordinate. Returns the <code>geo.Coord</code> instance.
|text = Sets the {{wikipedia|latitude}} coordinate. Returns the <code>geo.Coord</code> instance.
|param1 = lat
|param1 = lat
Line 51: Line 47:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set_lon(lon);
|syntax = geo.Coord.set_lon(lon);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets the {{wikipedia|longitude}} coordinate. Returns the <code>geo.Coord</code> instance.
|text = Sets the {{wikipedia|longitude}} coordinate. Returns the <code>geo.Coord</code> instance.
|param1 = lon
|param1 = lon
Line 63: Line 58:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set_alt(alt);
|syntax = geo.Coord.set_alt(alt);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets the {{wikipedia|altitude}} coordinate. Returns the <code>geo.Coord</code> instance.
|text = Sets the {{wikipedia|altitude}} coordinate. Returns the <code>geo.Coord</code> instance.
|param1 = alt
|param1 = alt
Line 75: Line 69:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set_latlon(lat, lon[, alt]);
|syntax = geo.Coord.set_latlon(lat, lon[, alt]);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets the latitude and longitude coordinates, and optionally the altitude coordinate. Returns the <code>geo.Coord</code> instance.
|text = Sets the latitude and longitude coordinates, and optionally the altitude coordinate. Returns the <code>geo.Coord</code> instance.
|param1 = lat
|param1 = lat
Line 93: Line 86:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set_x(x);
|syntax = geo.Coord.set_x(x);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets the x-axis coordinate coordinate. Returns the <code>geo.Coord</code> instance.
|text = Sets the x-axis coordinate coordinate. Returns the <code>geo.Coord</code> instance.
|param1 = x
|param1 = x
Line 105: Line 97:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set_y(y);
|syntax = geo.Coord.set_y(y);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets the y-axis coordinate coordinate. Returns the <code>geo.Coord</code> instance.
|text = Sets the y-axis coordinate coordinate. Returns the <code>geo.Coord</code> instance.
|param1 = y
|param1 = y
Line 117: Line 108:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set_z(z);
|syntax = geo.Coord.set_z(z);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets the y-axis coordinate coordinate. Returns the <code>geo.Coord</code> instance.
|text = Sets the y-axis coordinate coordinate. Returns the <code>geo.Coord</code> instance.
|param1 = z
|param1 = z
Line 129: Line 119:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.set_xyz(x, y, z);
|syntax = geo.Coord.set_xyz(x, y, z);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Sets all three Cartesian coordinates. Returns the <code>geo.Coord</code> instance. All arguments are mandatory.
|text = Sets all three Cartesian coordinates. Returns the <code>geo.Coord</code> instance. All arguments are mandatory.
|param1 = x
|param1 = x
Line 144: Line 133:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.lat();
|syntax = geo.Coord.lat();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the latitude coordinate.
|text = Returns the latitude coordinate.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 153: Line 141:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.lon();
|syntax = geo.Coord.lon();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the longitude coordinate.
|text = Returns the longitude coordinate.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 162: Line 149:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.alt();
|syntax = geo.Coord.alt();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the altitude coordinate.
|text = Returns the altitude coordinate.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 171: Line 157:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.latlon();
|syntax = geo.Coord.latlon();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns a vector containing the latitude, longitude, and altitude, in that order.
|text = Returns a vector containing the latitude, longitude, and altitude, in that order.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 180: Line 165:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.x();
|syntax = geo.Coord.x();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the x-axis coordinate.
|text = Returns the x-axis coordinate.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 189: Line 173:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.y();
|syntax = geo.Coord.y();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the y-axis coordinate.
|text = Returns the y-axis coordinate.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 198: Line 181:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.z();
|syntax = geo.Coord.z();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the z-axis coordinate.
|text = Returns the z-axis coordinate.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 207: Line 189:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.xyz();
|syntax = geo.Coord.xyz();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns a vector containing the x, y, and z coordinates, in that order.
|text = Returns a vector containing the x, y, and z coordinates, in that order.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 216: Line 197:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.is_defined();
|syntax = geo.Coord.is_defined();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns 1 (true) if all three coordinates (either x/y/z or /lat/lon/alt) are defined. Note that set_latlon() or set_xyz() must be used for this function to work correctly.
|text = Returns 1 (true) if all three coordinates (either x/y/z or /lat/lon/alt) are defined. Note that set_latlon() or set_xyz() must be used for this function to work correctly.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 227: Line 207:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.dump();
|syntax = geo.Coord.dump();
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Dumps all six coordinates into the console. It requires all three coordinates (either x/y/z or /lat/lon/alt) to be defined. Note that set_latlon() or set_xyz() must be used for this function to work correctly.
|text = Dumps all six coordinates into the console. It requires all three coordinates (either x/y/z or /lat/lon/alt) to be defined. Note that set_latlon() or set_xyz() must be used for this function to work correctly.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
Line 239: Line 218:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.course_to(coord);
|syntax = geo.Coord.course_to(coord);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the initial bearing (see [http://www.movable-type.co.uk/scripts/latlong.html#bearing here]) to another <code>geo.Coord</code> instance. The bearing will be an {{wikipedia|absolute bearing}} (in the range 0–360).
|text = Returns the initial bearing (see [http://www.movable-type.co.uk/scripts/latlong.html#bearing here]) to another <code>geo.Coord</code> instance. The bearing will be an {{wikipedia|absolute bearing}} (in the range 0–360).
|param1 = coord
|param1 = coord
Line 253: Line 231:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.distance_to(coord);
|syntax = geo.Coord.distance_to(coord);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the great circle distance in metres to another <code>geo.Coord</code> instance. Note that this function ignores altitude.
|text = Returns the great circle distance in metres to another <code>geo.Coord</code> instance. Note that this function ignores altitude.
|param1 = coord
|param1 = coord
Line 266: Line 243:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.direct_distance_to(coord);
|syntax = geo.Coord.direct_distance_to(coord);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the direct distance (cutting through the earth) in metres to another <code>geo.Coord</code> instance.  
|text = Returns the direct distance (cutting through the earth) in metres to another <code>geo.Coord</code> instance.  
|param1 = coord
|param1 = coord
Line 280: Line 256:
{{Nasal doc
{{Nasal doc
|syntax = geo.Coord.apply_course_distance(course, dist);
|syntax = geo.Coord.apply_course_distance(course, dist);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Calculates a new coordinate from a given course and distancce, and then updates the coordinates to the new set. Returns the <code>geo.Coord</code> instance.
|text = Calculates a new coordinate from a given course and distancce, and then updates the coordinates to the new set. Returns the <code>geo.Coord</code> instance.
|param1 = course
|param1 = course
Line 302: Line 277:


=== PositionedSearch ===
=== PositionedSearch ===
{{Note|This is currently only used by the MapStructure code to run more efficient searches (i.e. the delta-search stuff for map-canvas.xml)}}
{{Nasal doc
|mode = class
|version = 3.0
|text = This class can be used to show differences between 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() ====
==== condense() ====
==== condense() ====
Line 368: Line 347:
{{Nasal doc
{{Nasal doc
|syntax = geo.normdeg180(angle);
|syntax = geo.normdeg180(angle);
|version = 2.12
|text = Normalizes an angle to be in the range -180–180.
|text = Normalizes an angle to be in the range -180–180.
|param1 = angle
|param1 = angle

Navigation menu