/usr/lib/gpsman/dos2gpsman.tcl is in gpsman 6.4.4.2-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | #!/bin/sh
# This is a Tcl/Tk script to be interpreted by tclsh \
exec tclsh "$0" "$@"
############################################################################
# #
# dos2gpsman --- Convert BGA Turnpoints gpsman "WayPoint" format #
# #
# BGA Turnpoints are available at #
# http://www.spsys.demon.co.uk/turningpoints.htm #
# The DOS format file is required by this program #
# #
# usage: dos2gpsman [-p feature] [-f findability] [-a air_activity] \ #
# [-i in_file] [-o out_file] [-h] [--help] #
# #
# With no arguments, converts all records from stdin to stdout #
# #
# Version 0.1 #
# #
# Bugs: #
# * "Air activity" is best specified by any single or double #
# character, e.g. "x" or "xx", rather than the "#" or "##". #
# This avoids the need to escape "#" from the shell. #
# #
# * There is no way to _exclude_ points by a criterion #
# #
# * Some information in the original file is discarded #
# #
# * This code will probably fail if the file format changes #
# e.g. if extra information is added to the TurnPoint file #
# #
# Copyright (c) Paul Scorer, Leeds Metropolitan University #
# p.scorer@leedsmet.ac.uk #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. #
# #
############################################################################
global fullname trigraph bganum findability exactpoint\
description distance direction feature\
OSMap Easting_Northing Lat_Long altitude \
degLat minLat NS degLong minLong decLong EW
################
# Read one complete waypoint record
################
proc getRecord {f} {
global fullname trigraph bganum findability exactpoint\
description distance direction feature\
OSMap Easting_Northing Lat_Long altitude\
degLat minLat NS degLong minLong decLong EW
if {[gets $f fullname] > 0 && \
[gets $f trigraph] > 0 && \
[gets $f bganum] > 0 && \
[gets $f findability] > 0 && \
[gets $f exactpoint] > 0 && \
[gets $f description] > 0 && \
[gets $f distance] > 0 && \
[gets $f direction] > 0 && \
[gets $f feature] > 0 && \
[gets $f OSMap] > 0 && \
[gets $f Easting_Northing] > 0 && \
[gets $f Lat_Long] > 0 && \
[gets $f altitude] > 0 && \
[gets $f trigraph1] > 0 && \
[gets $f junk] == 0} {
# Blank line - Record Separator
# Simple consistency check:
# Trigraph at last line should match that at second line
if {[string equal $trigraph $trigraph1] } {
scan $Lat_Long "%d%lf%s%d%d.%d%s" \
degLat minLat NS degLong minLong decLong EW
return 1;
} else {
puts stderr "Format Error";
return 0;
}
} else {
return 0
}
}
##################
# Check if current record is associated
# with "feature" specified on command line
#################
proc checkPlace {} {
global placeList feature
foreach place $placeList {
if { [string equal -nocase $feature $place] } {
return 1
}
}
return 0
}
################
# Check if "findability" (A B C D or G)
# matches that given on command line
################
proc checkFind {} {
global findList findability
foreach category $findList {
if { [string equal -nocase -length 1 $category $findability] } {
return 1
}
}
return 0
}
################
# Check if category of "Air Activity"
# matches that given on command line
################
proc checkActivity {} {
global activityList findability
foreach category $activityList {
set len [string length $category]
incr len
if { [string length $findability ] == $len } {
return 1
}
}
return 0
}
#################
# Set some initial values
#################
set fi stdin
# May be modified by "-i <in-file>"
set fo stdout
# May be modified by "-o <out-file>"
set usage "
usage: dos2gpsman \[-p feature\] \[-f findability\] \[-a air_activity\] \
\[-i in_file\] \[-o out_file\] \n\
\tfindability == \[A B C D G\]\n\
\tair_activity == \[x xx\] (any character)\n\
\tArguments may be repeated (e.g. to seach for more than one place)\n\
\tSee http://www.spsys.demon.co.uk/turningpoints.htm for the meaning of these terms\n
"
################
# Process args
################
foreach {option arg} $argv {
# Need help?
if { [string equal -nocase -length 6 "--help" $option]} {
puts stderr $usage
exit
} elseif { [string equal -nocase -length 2 "-h" $option]} {
puts stderr $usage
exit
# Select points associated with "Feature" (aka "Place")
} elseif { [string equal -nocase -length 2 "-p" $option]} {
lappend placeList $arg
# Select points with "Findability" A B C D or G
} elseif { [string equal -nocase -length 2 "-f" $option]} {
if { [lsearch -exact "A B C D G a b c d g" $arg] > 0 } {
lappend findList $arg
} else {
puts stderr $usage
exit
}
# Air Activity
} elseif { [string equal -nocase -length 2 "-a" $option]} {
if { [string length $arg] < 3 } {
lappend activityList $arg
} else {
puts stderr $usage
exit
}
# Change i/p file
} elseif { [string equal -nocase -length 2 "-i" $option]} {
set fi [open $arg r]
# Change o/p file
} elseif { [string equal -nocase -length 2 "-o" $option]} {
set fo [open $arg w]
} else {
puts stderr $usage
exit
}
}
###############
# Generate time stamp
# Not used, but useful to give date of conversion
###############
set timestring [clock format [clock seconds] -format "%d-%b-%Y %H%M"]
set doneHdr 0; # Flag to ensure header o/p once only
# Process each record
while { [getRecord $fi ] } {
# Matches "Findability"?
if { [info exists findList] } {
if { [checkFind] == 0} {
continue
}
}
# Matches "Feature"?
if { [info exists placeList] } {
if { [checkPlace] == 0} {
continue
}
}
# Matches "Air Activity"?
if { [info exists activityList] } {
if { [checkActivity] == 0} {
continue
}
}
# Do the Header if needed
if {$doneHdr == 0} {
puts $fo "!Format: DMM 0 WGS 84\n!Creation: no\n"
set doneHdr 1;
}
# Output the record (with altitude in metres)
puts $fo [format "!W:\n%s\t%s\t%s%d %.3f\t%s%d %d.%d\talt=%.0f" \
$trigraph \
$timestring \
$NS $degLat $minLat \
$EW $degLong $minLong $decLong \
[expr { $altitude * 12 * 25.4 / 1000 }]];
puts $fo "!NB:"
puts $fo $fullname
puts $fo $exactpoint
puts $fo $description
puts $fo $feature
puts $fo $findability
puts $fo ""
}
if {$doneHdr == 0} {
puts stderr "No matching waypoints found!\n"
}
|