Closed JayBrown closed 4 years ago
Thanks for sharing. Generally I prefer to use documented standards for output formats. Is there any documentation (ISO/IETF/etc.) where this is a preferred format?
Can't say. I just stumbled across sunwait today, and it seems to accept only this non-standard format.
It's easy to convert, though:
loc=$(CoreLocationCLI)
lat=$(echo "$loc" | awk '{print $1}')
long=$(echo "$loc" | awk '{print $2}')
[[ $lat == "-"* ]] && lat="$lat"S || lat="$lat"N
[[ $long == "-"* ]] && long="$long"W || long="$long"E
echo "$lat $long" | sed -e 's/-//g'
Thanks for reporting this. For now I believe non-standard GPS representations should be outside the scope of this project. But you do have a nice workaround.
And of course, awk can do all kinds of stuff, and even more golfing can be done on top of the below
echo '-45.356 -15' | awk '{print ($1>0) ? $1"N" : -$1"S"}'
echo '-45.356 -15' | awk '{print ($2>0) ? $2"E" : -$2"W"}'
I know this is a weird question, because decimal coordinates are just negative for S & W, but some programs like
sunwait
need input as decimal, but with N|S and E|W, i.e. in the format52.516667N 13.388889E
instead of52.516667 13.388889
for Berlin, and40.7127N 74.0059W
instead of40.7127 -74.0059
for NYC, et cetera. (Same for N vs. S.) I guess I can always parse CoreLocationCLI's output and change it myself, but maybe it isn't too complicated to add an option for an alternate output, e.g.CoreLocationCLI -orientation
orCoreLocationCLI -o
.