<img src=“badge.fury.io/rb/rozi.svg” alt=“Gem Version” />
Rozi
Rozi is a Ruby gem for working with all Ozi Explorer file formats. Currently the implemented functionality is:
-
Creating Waypoint files.
-
Creating Track files.
-
Creating Name Search Text (.nst) files.
Files.
Text based file formats read by Ozi Explorer should be encoded as ISO-8859-1 and use CR LF line endings (\r\n). If you pass file paths to Rozi’s write functions (rather than file objects) Rozi will handle this for you. If that isn’t an alternative you either have to handle this yourself, or you can use Rozi.open_file_for_writing.
file = Rozi.open_file_for_writing("file_path.wpt")
file.write("Østre aker\n") # Writes "Østre aker\r\n" in ISO-8859-1.
# Does the same thing, but closes the file for you when you're done.
Rozi.open_file_for_writing("file_path.wpt") { |file|
file.write("Østre aker\n")
}
Colors.
Any time you set colors in Rozi, you can either use the three-byte integer representation that Ozi Explorer expects, or you can use a hex string like “RRGGBB” and Rozi will convert it for you. Example:
# Identical.
Rozi::Waypoint.new(bg_color: "ABCDEF")
Rozi::Waypoint.new(bg_color: 15715755)
# Identical.
Rozi::Waypoint.new(bg_color: "FF0000")
Rozi::Waypoint.new(bg_color: 255)
Creating Waypoint files.
Waypoint files are created in Rozi by creating an array of Rozi::Waypoint instances and writing them to a file using Rozi.write_waypoints:
Example:
waypoints = [
Rozi::Waypoint.new(latitude: -12.7, longitude: -58.0, name: "South America"),
Rozi::Waypoint.new(latitude: 43.7, longitude: -103.7, name: "North America"),
Rozi::Waypoint.new(latitude: 49.6, longitude: 20.9, name: "Europe")
]
Rozi.write_waypoints(waypoints, "file_path.wpt")
See Rozi::Waypoint for a list of attributes.
Creating Track files.
Track files are created in Rozi by creating a Rozi::Track instance with two or more Rozi::TrackPoint instances, then writing them to a file using Rozi.write_track.
Example:
track = Rozi::Track.new()
track << Rozi::TrackPoint.new(latitude: 39.8, longitude: -3.4)
track << Rozi::TrackPoint.new(latitude: 46.6, longitude: 3.1)
track << Rozi::TrackPoint.new(latitude: 50.79, longitude: 10.3)
track << Rozi::TrackPoint.new(latitude: 49.04, longitude: 31.5)
Rozi.write_track(track, "file_path.plt")
Creating NST files.
See Ozi Explorer: Name Search for information about Name Search. An NST file has to be converted into a Name Database using the “Name Search Creator” tool before they can be used by Ozi Explorer.
In Rozi, an NST file is represented by a Rozi::NameSearchText object. This object lets you control the coordinate system (lat/lng or UTM) of the name database, as well as the datum, UTM Zone and Hemisphere (if applicable). You can also add a comment to the top of the exported file using Rozi::NameSearchText#comment. By default, decimal lat/lng coordinates are used with the WGS 84 datum.
Rozi::Name objects are added to the Rozi::NameSearchText instance, which is then written to a file using Rozi.write_nst.
Example:
nst = Rozi::NameSearchText.new
nst.comment = "Generated #{Time.now}"
nst << Rozi::Name.new("Place name", "Feature code", nil, 12.3456, 23.4567)
Rozi.write_nst(nst, "file_path.nst")
Example using UTM with the “Norsk” datum:
nst = Rozi::NameSearchText.new
nst.comment = "Generated #{Time.now}"
nst.utm = true
nst.utm_zone = "33"
nst.datum = "Norsk"
nst.hemisphere = "N"
nst << Rozi::Name.new("Place name", "Feature code", nil, 67890.12, 56789.01)
# UTM Zone overridden.
nst << Rozi::Name.new("Place name", "Feature code", "32", 67890.12, 56789.01)
Rozi.write_nst(nst, "file_path.nst")