columbus3 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +126 -33
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/columbus3.gemspec +7 -7
- data/doc/ChangeLog.org +47 -0
- data/doc/todo.org +24 -11
- data/lib/columbus3/cli/command_semantics.rb +71 -192
- data/lib/columbus3/cli/command_syntax.rb +214 -15
- data/lib/columbus3/metadata/sidecar.rb +6 -1
- data/lib/columbus3/renderer/flot_renderer.rb +12 -8
- data/lib/columbus3/renderer/leaflet_renderer.rb +12 -8
- data/lib/columbus3/version.rb +1 -1
- data/lib/html/flot.html.erb +1 -1
- data/lib/html/show.html.erb +1 -1
- data/lib/html/track.js.erb +3 -3
- metadata +18 -18
- data/doc/manual.txt +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7cc5864ef1e5f14f52939520fa0a1bc7e2506a45
|
4
|
+
data.tar.gz: b95abe7c54af522d1a747e25d1dd647585fa5e22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96aa4ef40cd7bd9cdf16764839cf9fc38c00494ae698bf7242aa0cb808983b25d2cbf05f1c903a56c2773d6e708f3256313d9750cc78348e20a727d925e6f1df
|
7
|
+
data.tar.gz: 54db9fe50f38f4e405b9fd94c1dbba2655d57509dd6d0422ae1be196753ad2a094f6a1ca496eac0e225d90ddfc03e566d4003a4505894891d42ad4c3144aa798
|
data/README.md
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
Columbus3
|
2
2
|
=========
|
3
3
|
|
4
|
-
A gem to
|
4
|
+
A ruby gem to show, organize, and search GPS tracks generated by the
|
5
|
+
Columbus V900 and V990 GPS trackers.
|
5
6
|
|
6
|
-
|
7
|
+
The gem works by allowing you to associate a "sidecar" file to each
|
8
|
+
Columbus track. The sidecar file, in YAML fromat, contains
|
9
|
+
information such as the start and end location, the maximum speed, the
|
10
|
+
maximum elevation of the track.
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
The information stored in the sidecar files can then be used to search
|
13
|
+
tracks. Them gem allows you, for instance, to perform complex queries
|
14
|
+
such as: "get the tracks whose max speed less than 10 kilometers per
|
15
|
+
hours and whose start location is in the USA".
|
16
|
+
|
17
|
+
Tracks can be shown on a map. The application is pipe "friendly", so
|
18
|
+
that, for instance, you can pipe the output of a search to the show
|
19
|
+
command to view all the tracks matching your search.
|
16
20
|
|
17
21
|
Installation
|
18
22
|
------------
|
@@ -32,16 +36,77 @@ Or install it yourself as:
|
|
32
36
|
|
33
37
|
Usage
|
34
38
|
-----
|
39
|
+
Generate the sidecar files for your tracks with the `process` command:
|
40
|
+
|
41
|
+
columbus3 process 11010101.CSV # generate the sidecar file for 11010101.CSV
|
42
|
+
|
43
|
+
notice that you can pass `*` as argument to process all your tracks at
|
44
|
+
once. The process command reverse geocodes the first and last point
|
45
|
+
of the track and stores other information about the track.
|
46
|
+
|
47
|
+
cat 11010101.CSV
|
48
|
+
---
|
49
|
+
:start_date: 2011-01-01 22:15:58.000000000 Z
|
50
|
+
:end_date: 2011-01-02 03:06:57.000000000 Z
|
51
|
+
:duration: 17459.0
|
52
|
+
:size: 17440
|
53
|
+
:start_location: University of California, Santa Barbara, Ocean Road, Isla Vista, CA 93117, USA
|
54
|
+
:end_location: 500-524 Matadero Avenue, Palo Alto, CA 94306, USA
|
55
|
+
:min_speed: 0
|
56
|
+
:max_speed: 138
|
57
|
+
:min_height: -9
|
58
|
+
:max_height: 432
|
59
|
+
:bearing: NW
|
60
|
+
:distance: 885.6399415490763
|
61
|
+
:distance_aerial: 392.2223148453187
|
62
|
+
:filename: 11010101.CSV
|
63
|
+
|
64
|
+
Once you have the sidecar files, you can search, show, and display
|
65
|
+
detailed information about your tracks.
|
66
|
+
|
67
|
+
For instance:
|
68
|
+
|
69
|
+
columbus3 search 'location ~ "USA"'
|
70
|
+
|
71
|
+
returns all tracks in the current directory, whose start or end location has "USA" in the address
|
72
|
+
field. Notice the usage of the single quote to protect the `~` from expansion.
|
35
73
|
|
36
|
-
|
74
|
+
The command:
|
37
75
|
|
38
|
-
columbus3
|
76
|
+
columbus3 show 11010101.CSV 11010201.CSV
|
77
|
+
|
78
|
+
shows tracks on a map (you need to open `_show.html` in a browser to view the map), while
|
79
|
+
|
80
|
+
columbus3 graph 11010101.CSV
|
81
|
+
|
82
|
+
shows info about a single track (you need to open `_graph.html` in a browser to view the info).
|
83
|
+
|
84
|
+
Piping also works. For instance:
|
85
|
+
|
86
|
+
columbus3 search 'location ~ "USA"' --fields path | colmumbus3 show
|
87
|
+
|
88
|
+
gets all tracks whose start or end location has "USA" in the address field and diplays them on a map.
|
89
|
+
|
90
|
+
GPX files can also be managed, although it is first necessary to
|
91
|
+
convert them to V900 tracks with the following command:
|
92
|
+
|
93
|
+
columbus3 convert file.gpx
|
39
94
|
|
40
|
-
|
95
|
+
makes `file.gpx` into a V900 CSV track.
|
41
96
|
|
42
|
-
|
97
|
+
If you do not want to type `columbus3` every time, you can invoke a console:
|
43
98
|
|
44
99
|
columbus3 console
|
100
|
+
columbus3:000> process 11010101.CSV
|
101
|
+
columbus3:001> show 11010101.CSV
|
102
|
+
columbus3:002>
|
103
|
+
|
104
|
+
More information with:
|
105
|
+
|
106
|
+
columbus3 help # get list of available commands
|
107
|
+
columbus3 help process # get help about the process command
|
108
|
+
columbus3 man
|
109
|
+
|
45
110
|
|
46
111
|
Development
|
47
112
|
-----------
|
@@ -60,11 +125,55 @@ Contributing
|
|
60
125
|
------------
|
61
126
|
|
62
127
|
Bug reports and pull requests are welcome on GitHub at
|
63
|
-
https://github.com
|
128
|
+
https://github.com/avillafiorita/columbus3.
|
129
|
+
|
130
|
+
License
|
131
|
+
-------
|
132
|
+
|
133
|
+
The original code of this gem is available as open source under the
|
134
|
+
terms of the [MIT License](http://opensource.org/licenses/MIT).
|
135
|
+
|
136
|
+
The gem ships wih the following Javascript libraries, which are
|
137
|
+
distributed according to their licenses:
|
138
|
+
|
139
|
+
- [Leaflet](http://leafletjs.com/)
|
140
|
+
([License](https://github.com/Leaflet/Leaflet/blob/master/LICENSE))
|
141
|
+
- [Flot](http://www.flotcharts.org/)
|
142
|
+
([License](https://github.com/flot/flot/blob/master/LICENSE.txt))
|
143
|
+
- [jQuery](http://jquery.com/)
|
144
|
+
([License](https://github.com/jquery/jquery/blob/master/LICENSE.txt))
|
145
|
+
|
146
|
+
See Also
|
147
|
+
--------
|
148
|
+
|
149
|
+
If you are looking for a full graphical client and work on MacOS, you
|
150
|
+
might want to download Columbus from http://www.minimalbit.com
|
64
151
|
|
65
152
|
Version History
|
66
153
|
---------------
|
67
154
|
|
155
|
+
**0.6.0**
|
156
|
+
- More informative output from commands
|
157
|
+
- The `help` command is now more informative
|
158
|
+
- The `path` field in the search command now returns the path of the
|
159
|
+
CSV file (and not that of the YAML sidecar file), simplifying piping
|
160
|
+
searches to the show command
|
161
|
+
- When searching, a new field `yaml` returns the name of the sidecar
|
162
|
+
file associated to a track
|
163
|
+
- New behaviour of `show` and `graph` commands: the `_show.html` and
|
164
|
+
`_graph.html` are always created, even if a file with the same name
|
165
|
+
already exists in the current directory (previous versions required
|
166
|
+
to specify the `--force` option to achieve the same behaviour); a
|
167
|
+
backup copy of the files which are overwritten is always created.
|
168
|
+
The `--force` option forces rewriting of the javascript files;
|
169
|
+
backup copies of existing files are created.
|
170
|
+
- The number of tile providers has been significantly reduced
|
171
|
+
- Some code has been refactored to improve readability
|
172
|
+
- Added `-h` and `--help` (in addition to the `help` command)
|
173
|
+
- Updates to the documentation
|
174
|
+
- Bumped version of gems used in production
|
175
|
+
- Bumped version of gems used for development
|
176
|
+
|
68
177
|
**0.5.0**
|
69
178
|
|
70
179
|
- Fixed a bug with searches on dates
|
@@ -73,14 +182,14 @@ Version History
|
|
73
182
|
- More informative messages when running commands
|
74
183
|
- Added a console: launch it with `columbus3 console`
|
75
184
|
- Fixed a bug with graph (call to sanitize failed)
|
76
|
-
- Added [Changelog File](doc/ChangeLog.org), which I am using to help
|
185
|
+
- Added [Changelog File](doc/ChangeLog.org), which I am using to help maintaning
|
77
186
|
this list of changes
|
78
187
|
|
79
188
|
**0.4.0**
|
80
189
|
|
81
190
|
- Improved syntax for search:
|
82
191
|
- new option -r searches in sub-directories
|
83
|
-
- new option --fields allows to specify the
|
192
|
+
- new option --fields allows to specify the to look for
|
84
193
|
|
85
194
|
**0.3.0**
|
86
195
|
|
@@ -104,19 +213,3 @@ Version History
|
|
104
213
|
|
105
214
|
- Initial release
|
106
215
|
|
107
|
-
License
|
108
|
-
-------
|
109
|
-
|
110
|
-
The original code of this gem is available as open source under the
|
111
|
-
terms of the [MIT License](http://opensource.org/licenses/MIT).
|
112
|
-
|
113
|
-
The gem ships wih the following javascript libraries, which are
|
114
|
-
distributed according to their licenses:
|
115
|
-
|
116
|
-
- [Leaflet](http://leafletjs.com/)
|
117
|
-
([License](https://github.com/Leaflet/Leaflet/blob/master/LICENSE))
|
118
|
-
- [Flot](http://www.flotcharts.org/)
|
119
|
-
([License](https://github.com/flot/flot/blob/master/LICENSE.txt))
|
120
|
-
- [jQuery](http://jquery.com/)
|
121
|
-
([License](https://github.com/jquery/jquery/blob/master/LICENSE.txt))
|
122
|
-
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/columbus3.gemspec
CHANGED
@@ -7,11 +7,11 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "columbus3"
|
8
8
|
spec.version = Columbus3::VERSION
|
9
9
|
spec.authors = ["Adolfo Villafiorita"]
|
10
|
-
spec.email = ["adolfo.villafiorita@
|
10
|
+
spec.email = ["adolfo.villafiorita@me.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Manage V900 and V990 GPS tracks from the command line.}
|
13
|
-
spec.description = %q{Some simple command line commands to manage tracks generated by the
|
14
|
-
spec.homepage = "
|
12
|
+
spec.summary = %q{Manage Columbus V900 and V990 GPS tracks from the command line.}
|
13
|
+
spec.description = %q{Some simple command line commands to manage tracks generated by the Columbus family of GPS loggers (CSV format).}
|
14
|
+
spec.homepage = "http://www.github.com/avillafiorita/columbus3"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "minitest"
|
25
25
|
|
26
|
-
spec.add_dependency "slop", "~> 4.
|
26
|
+
spec.add_dependency "slop", "~> 4.5.0"
|
27
27
|
spec.add_dependency "geocoder"
|
28
28
|
end
|
data/doc/ChangeLog.org
CHANGED
@@ -8,3 +8,50 @@ Archived entries from file /home/adolfo/Documents/Sources/ruby/columbus3/doc/tod
|
|
8
8
|
:ARCHIVE_CATEGORY: todo
|
9
9
|
:ARCHIVE_TODO: DONE
|
10
10
|
:END:
|
11
|
+
|
12
|
+
* REJECTED fix filename standards in a specific class (or one method per class)
|
13
|
+
:PROPERTIES:
|
14
|
+
:ARCHIVE_TIME: 2017-08-10 Thu 14:29
|
15
|
+
:ARCHIVE_FILE: ~/Documents/Sources/ruby/columbus3/doc/todo.org
|
16
|
+
:ARCHIVE_OLPATH: Rails: columbus3
|
17
|
+
:ARCHIVE_CATEGORY: todo
|
18
|
+
:ARCHIVE_TODO: REJECTED
|
19
|
+
:ARCHIVE_ITAGS: columbus3
|
20
|
+
:END:
|
21
|
+
.yaml extension
|
22
|
+
.js extension
|
23
|
+
_show.html
|
24
|
+
_graph.html
|
25
|
+
... there should be one place only where filename.csv is tranformed
|
26
|
+
appropriately
|
27
|
+
|
28
|
+
|
29
|
+
* DONE new policy for --force
|
30
|
+
:PROPERTIES:
|
31
|
+
:ARCHIVE_TIME: 2017-08-10 Thu 14:30
|
32
|
+
:ARCHIVE_FILE: ~/Documents/Sources/ruby/columbus3/doc/todo.org
|
33
|
+
:ARCHIVE_OLPATH: Rails: columbus3
|
34
|
+
:ARCHIVE_CATEGORY: todo
|
35
|
+
:ARCHIVE_TODO: DONE
|
36
|
+
:ARCHIVE_ITAGS: columbus3
|
37
|
+
:END:
|
38
|
+
backup are always created, if the files exist
|
39
|
+
--force rewrites yaml, js, or graph_js files (they shouldn't be changed
|
40
|
+
once generated)
|
41
|
+
|
42
|
+
_show.html, _graph.html are expendable and can be written and rewritten
|
43
|
+
every time
|
44
|
+
|
45
|
+
|
46
|
+
* DONE be more informative about what is going on
|
47
|
+
:PROPERTIES:
|
48
|
+
:ARCHIVE_TIME: 2017-08-10 Thu 15:21
|
49
|
+
:ARCHIVE_FILE: ~/Documents/Sources/ruby/columbus3/doc/todo.org
|
50
|
+
:ARCHIVE_OLPATH: Rails: columbus3
|
51
|
+
:ARCHIVE_CATEGORY: todo
|
52
|
+
:ARCHIVE_TODO: DONE
|
53
|
+
:ARCHIVE_ITAGS: columbus3
|
54
|
+
:END:
|
55
|
+
Many commands succeed silently. They could probably print some
|
56
|
+
informative messages
|
57
|
+
|
data/doc/todo.org
CHANGED
@@ -4,10 +4,27 @@
|
|
4
4
|
#+STARTUP: showall
|
5
5
|
|
6
6
|
* Rails: columbus3
|
7
|
-
**
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
** FEATURE Add a web interface with sinatra
|
8
|
+
The web interface does three things:
|
9
|
+
- show the list of tracks
|
10
|
+
- filter tracks using search
|
11
|
+
- show/graph tracks
|
12
|
+
|
13
|
+
** FEATURE support for tags
|
14
|
+
columbus3 tag -a TAG_NAME track1...trackN
|
15
|
+
columbus3 tag -d TAG_NAME track1...trackN
|
16
|
+
|
17
|
+
** FEATURE As a user I want to split a track at a given point
|
18
|
+
Pass the index as argument and generate two files out of the existing one
|
19
|
+
Give the option to delete the old file and to process the new files
|
20
|
+
|
21
|
+
** FEATURE As a user I want to merge to different tracks
|
22
|
+
Main motivation for this feature is that the CSV files have an index
|
23
|
+
column, which needs to be properly updated.
|
24
|
+
|
25
|
+
** FEATURE GPX export (for DarkTable and GoogleEarth)
|
26
|
+
This is covered by GPS Babel, but it is also very simple to implement
|
27
|
+
|
11
28
|
** FEATURE As a user I want to be able to view the individual points
|
12
29
|
Performance is an issue, here. Maybe activate the layer on a need-basis.
|
13
30
|
Also: it would be nice to produce a single GeoJSON set of data (e.g., the
|
@@ -47,17 +64,13 @@
|
|
47
64
|
|
48
65
|
** FEATURE As a user I want to identify the time/index of individual points
|
49
66
|
This is useful for track splitting
|
67
|
+
|
50
68
|
** FEATURE As a user I want to have an idea of the direction and other info such as speed and height
|
51
69
|
Some possible solutions include: color dots, put height and speed plot on the same page)
|
52
|
-
|
53
|
-
Pass the index as argument and generate two files out of the existing one
|
54
|
-
Give the option to delete the old file and to process the new files
|
55
|
-
** FEATURE GPX export for DarkTable and GoogleEarth
|
56
|
-
** FEATURE As a user I want to be able to add custom fields
|
57
|
-
Allow users to specify custom fields in the sidecar file
|
70
|
+
|
58
71
|
** FEATURE As a user I want to filter values with wrong precision
|
72
|
+
|
59
73
|
** FEATURE As a user I do not want to view data only in ZULU time
|
60
74
|
- get the local timezone (or let the user specify a timezone)
|
61
75
|
- use the timezone of the starting point
|
62
|
-
** FEATURE Make it into a sinatra app?
|
63
76
|
|
@@ -1,135 +1,12 @@
|
|
1
1
|
require 'columbus3/version'
|
2
2
|
require 'find'
|
3
3
|
require 'readline'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
module Columbus3
|
6
7
|
module CommandSemantics
|
7
8
|
APPNAME = 'columbus3'
|
8
9
|
VERSION = Columbus3::VERSION
|
9
|
-
MAN = <<EOS
|
10
|
-
NAME
|
11
|
-
#{APPNAME} -- manage Columbus V900 and V990 tracks from the command line
|
12
|
-
|
13
|
-
SYNOPSYS
|
14
|
-
#{APPNAME} [-h|-v]
|
15
|
-
#{APPNAME} command [options] [args]
|
16
|
-
|
17
|
-
DESCRIPTION
|
18
|
-
|
19
|
-
columbus3 manages Columbus V900 and V990 tracks from the command line,
|
20
|
-
allowing a user to associate a sidecar file with the main information
|
21
|
-
about a track, searching tracks (through sidecar files), displaying
|
22
|
-
tracks on a map.
|
23
|
-
|
24
|
-
EXAMPLES
|
25
|
-
|
26
|
-
#{APPNAME} -h # get syntax of each command
|
27
|
-
columbus3 process 11010101.CSV # generate a sidecar file
|
28
|
-
columbus3 search 'location ~ "USA"' # get tracks in the USA
|
29
|
-
columbus3 show 11010101.CSV 11010201.CSV # show tracks on a map (_show.html)
|
30
|
-
columbus3 graph 11010101.CSV # show info about a track (_graph.html)
|
31
|
-
|
32
|
-
if you do not want to type columbus3 each type, you can invoke a console:
|
33
|
-
|
34
|
-
columbus3 console
|
35
|
-
columbus3:000> process 11010101.CSV
|
36
|
-
columbus3:001> show 11010101.CSV
|
37
|
-
columbus3:002>
|
38
|
-
|
39
|
-
columbus3 also has a function to convert a GPX into a bunch of CSV
|
40
|
-
files (which you can then process with the other commands), with some
|
41
|
-
limitations (see below).
|
42
|
-
|
43
|
-
The command is useful if you are using different loggers for generating your
|
44
|
-
tracks:
|
45
|
-
|
46
|
-
columbus3 convert file.gpx
|
47
|
-
|
48
|
-
will generate
|
49
|
-
|
50
|
-
file-1.csv
|
51
|
-
file-2.csv
|
52
|
-
...
|
53
|
-
|
54
|
-
one per track in the GPX file.
|
55
|
-
|
56
|
-
**CSV export limitations** The Columbus V900 format has fields with fixed width,
|
57
|
-
and uses ^@ as a filler. The CSV file generated by the convert command generates fields
|
58
|
-
of variable width (standard CSV files, I dare say). The heading field is not computed
|
59
|
-
and the field is filled with -1.
|
60
|
-
|
61
|
-
Piping commands. You can pipe the output of a search command to show, using
|
62
|
-
the following syntax:
|
63
|
-
|
64
|
-
columbus3 search 'location ~ "USA"' --fields path | columbus3 show --sidecar
|
65
|
-
|
66
|
-
The option --fields shows only the pathname of the files found; the option
|
67
|
-
--sidecar removes the .yaml extension from the list of files found.
|
68
|
-
|
69
|
-
SEARCH SYNTAX
|
70
|
-
|
71
|
-
>>> DON'T FORGET TO EMBED YOUR QUERY IN SINGLE QUOTES <<<
|
72
|
-
|
73
|
-
Terms you can search for:
|
74
|
-
|
75
|
-
location, start_location, end_location
|
76
|
-
date, start_date, end_date
|
77
|
-
year
|
78
|
-
duration
|
79
|
-
max_speed
|
80
|
-
min_height
|
81
|
-
max_height
|
82
|
-
|
83
|
-
Numerical operators:
|
84
|
-
<, <=, ==, >=, >
|
85
|
-
|
86
|
-
String operators (locations):
|
87
|
-
~ (contains), == (is exactly)
|
88
|
-
|
89
|
-
Complex Terms:
|
90
|
-
Use "and" and "or" to build complex queries
|
91
|
-
|
92
|
-
Examples of simple searches
|
93
|
-
'location ~ "USA"' any track whose start or end location contains USA
|
94
|
-
'date > 2015-02-14' any track whose start or end date is after Feb 14, 2015
|
95
|
-
'year == 2015' any track whose start or end date is in 2015
|
96
|
-
'duration <= 01:02:03' any track with a duration of less than 1h, 2min, and 3secs
|
97
|
-
'max_speed > 120' any track with a max speed greater than 120 km/h
|
98
|
-
'min_height == 10' any track with a min height lower than 10 meters
|
99
|
-
|
100
|
-
Examples of complex searches
|
101
|
-
'location ~ "USA" and start_date >= 2015-01-01' tracks in the USA after or on Jan 1, 2015
|
102
|
-
'start_location ~ "Trenton" and end_location ~ "New York"' trips from Trenton to New York
|
103
|
-
|
104
|
-
List of supported fields in output
|
105
|
-
path -> relative path of the CSV file
|
106
|
-
filename -> basename of the CSV file
|
107
|
-
start_location -> start location
|
108
|
-
end_location -> end location
|
109
|
-
start_date -> start date (and time)
|
110
|
-
end_date -> end date (and time)
|
111
|
-
duration -> duration in seconds
|
112
|
-
min_speed -> minimum speed in km/h
|
113
|
-
max_speed -> maximum speed in km/h
|
114
|
-
min_height -> minimum height in meters
|
115
|
-
max_height -> maximum height in meters
|
116
|
-
|
117
|
-
VERSION
|
118
|
-
This is version #{VERSION}
|
119
|
-
|
120
|
-
LICENSE
|
121
|
-
MIT
|
122
|
-
|
123
|
-
Columbus3 uses leaflet, leafleft-providers, flot, and jquery. They
|
124
|
-
are distributed under a different license: see their websites for more
|
125
|
-
details (or have a look at the license file shipped with the Gem)
|
126
|
-
|
127
|
-
SEE ALSO
|
128
|
-
If you are looking for a full graphical client, you might want to
|
129
|
-
download Columbus from http://www.minimalbit.com
|
130
|
-
|
131
|
-
https://github.com/avillafiorita/columbus3
|
132
|
-
EOS
|
133
10
|
|
134
11
|
#
|
135
12
|
# Main App Starts Here!
|
@@ -139,14 +16,17 @@ EOS
|
|
139
16
|
end
|
140
17
|
|
141
18
|
def self.man opts = nil, argv = []
|
142
|
-
|
19
|
+
path = File.join(File.dirname(__FILE__), "/../../../README.md")
|
20
|
+
file = File.open(path, "r")
|
21
|
+
contents = file.read
|
22
|
+
puts contents
|
143
23
|
end
|
144
24
|
|
145
25
|
def self.help opts = nil, argv = []
|
146
26
|
all_commands = CommandSyntax.commands
|
147
27
|
|
148
28
|
if argv != []
|
149
|
-
argv.map { |x| puts all_commands[x.to_sym][
|
29
|
+
argv.map { |x| puts all_commands[x.to_sym][2] }
|
150
30
|
else
|
151
31
|
puts "#{APPNAME} command [options] [args]"
|
152
32
|
puts ""
|
@@ -187,6 +67,7 @@ EOS
|
|
187
67
|
if sidecar.exist? and not force
|
188
68
|
puts "Sidecar file for #{track.filename} already exists. Use --force if you want to overwrite it."
|
189
69
|
else
|
70
|
+
backup(sidecar.filename) if sidecar.exist?
|
190
71
|
printf "Processing %s ...", track.filename
|
191
72
|
sidecar.metadata = track.metadata
|
192
73
|
sidecar.save
|
@@ -199,7 +80,7 @@ EOS
|
|
199
80
|
debug = opts[:debug]
|
200
81
|
directory = opts[:dir] || "."
|
201
82
|
recurse = opts[:recurse]
|
202
|
-
|
83
|
+
output_fields = opts[:fields].any? ? opts[:fields].map { |x| x.to_sym } : [:path, :filename, :start_location, :end_location, :start_date, :end_date, :duration, :min_speed, :max_speed, :min_height, :max_height]
|
203
84
|
|
204
85
|
if recurse then
|
205
86
|
files = Find.find(directory).select { |e| File.extname(e) == ".yaml" }
|
@@ -212,84 +93,24 @@ EOS
|
|
212
93
|
puts "Searched files: #{files.join(",")}"
|
213
94
|
puts "Searched files count: #{files.size}"
|
214
95
|
puts "Processed query: #{query}"
|
215
|
-
puts "Fields: #{fields}"
|
96
|
+
puts "Output Fields: #{fields}"
|
216
97
|
else
|
217
98
|
sidecar_search = Columbus3::SidecarSearch.new
|
218
99
|
sidecar_search.load files
|
219
100
|
match = sidecar_search.search query
|
220
101
|
match.each do |m|
|
221
|
-
string =
|
102
|
+
string = output_fields.map { |x| "#{m[x]}" }.join("\t")
|
222
103
|
printf "%s\n", string
|
223
104
|
end
|
224
105
|
end
|
225
106
|
end
|
226
107
|
|
227
108
|
def self.show opts, args
|
228
|
-
|
229
|
-
force = opts[:force]
|
230
|
-
sidecar = opts[:sidecar]
|
231
|
-
|
232
|
-
# build the argument list, which are either provided from the command line
|
233
|
-
# or, if args, is empty, from the standard input
|
234
|
-
files = args == [] ? STDIN.read.split("\n") : args
|
235
|
-
|
236
|
-
# remove .yaml from files, if required to do so
|
237
|
-
pruned_args = sidecar ? files.map { |x| x.gsub(/\.(YAML|yaml)$/, '') } : files
|
238
|
-
|
239
|
-
pruned_args.each do |arg|
|
240
|
-
# generate the js file(s), if not already existing or forced to
|
241
|
-
# do so by the force directive
|
242
|
-
if force or not File.exist? arg
|
243
|
-
printf "Creating json file for #{arg} ..."
|
244
|
-
complete = true
|
245
|
-
else
|
246
|
-
puts "Json file for #{arg} already exists (--force to force updating)"
|
247
|
-
complete = false
|
248
|
-
end
|
249
|
-
Columbus3::LeafletRenderer::to_leaflet arg, force
|
250
|
-
puts "done!" if complete
|
251
|
-
end
|
252
|
-
if force or not File.exist? filename
|
253
|
-
printf "Creating #{filename} ..."
|
254
|
-
complete = true
|
255
|
-
else
|
256
|
-
puts "#{filename} already exists (--force to force updating)"
|
257
|
-
complete = false
|
258
|
-
end
|
259
|
-
Columbus3::LeafletRenderer::show(filename, pruned_args) if args
|
260
|
-
puts "done!" if complete
|
261
|
-
puts "You might now want to open #{filename}."
|
109
|
+
show_machinery opts, args, Columbus3::LeafletRenderer
|
262
110
|
end
|
263
111
|
|
264
112
|
def self.graph opts, args
|
265
|
-
|
266
|
-
force = opts[:force]
|
267
|
-
|
268
|
-
input_filename = args[0]
|
269
|
-
if input_filename
|
270
|
-
if force or not File.exist? input_filename
|
271
|
-
printf "Creating javascript graph data for #{input_filename} ..."
|
272
|
-
complete = true
|
273
|
-
else
|
274
|
-
puts "Javascript graph data for #{input_filename} already exists (--force to force updating)"
|
275
|
-
complete = false
|
276
|
-
end
|
277
|
-
Columbus3::FlotRenderer::to_graph_data input_filename, force
|
278
|
-
puts "done!" if complete
|
279
|
-
|
280
|
-
if force or not File.exist? arg
|
281
|
-
printf "Creating #{filename} ..."
|
282
|
-
complete = true
|
283
|
-
else
|
284
|
-
puts "#{filename} already exists (--force to force updating)"
|
285
|
-
complete = false
|
286
|
-
end
|
287
|
-
Columbus3::FlotRenderer::show filename, input_filename
|
288
|
-
puts "done!" if complete
|
289
|
-
puts "You might now want to open #{filename}."
|
290
|
-
else
|
291
|
-
puts "Error: please specify a track file"
|
292
|
-
end
|
113
|
+
show_machinery opts, args, Columbus3::FlotRenderer
|
293
114
|
end
|
294
115
|
|
295
116
|
def self.convert opts, args
|
@@ -320,7 +141,7 @@ EOS
|
|
320
141
|
|
321
142
|
# read-eval-print step
|
322
143
|
def self.reps all_commands, argv
|
323
|
-
if argv == []
|
144
|
+
if argv == [] or argv[0] == "--help" or argv[0] == "-h"
|
324
145
|
CommandSemantics.help
|
325
146
|
exit 0
|
326
147
|
else
|
@@ -348,5 +169,63 @@ EOS
|
|
348
169
|
end
|
349
170
|
end
|
350
171
|
end
|
172
|
+
|
173
|
+
private
|
174
|
+
|
175
|
+
def self.backup filename
|
176
|
+
FileUtils::cp filename, filename + "~"
|
177
|
+
puts "Backup copy #{filename} created in #{filename}~."
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.backup_and_write filename, content
|
181
|
+
backup(filename) if File.exist?(filename)
|
182
|
+
File.open(filename, "w") { |f| f.puts content }
|
183
|
+
end
|
184
|
+
|
185
|
+
# low level machinery for all renderers
|
186
|
+
# - opts list of options (filename and force)
|
187
|
+
# - args: CSV files to process
|
188
|
+
# - renderer, the renderer module to use, which has to expose the following
|
189
|
+
# calls: OUTPUT_FILENAME, to_javascript_filename, to_javascript_file,
|
190
|
+
def self.show_machinery opts, args, renderer
|
191
|
+
filename = opts[:filename] || renderer::OUTPUT_FILENAME
|
192
|
+
force = opts[:force]
|
193
|
+
|
194
|
+
# build the argument list, which is either provided from the
|
195
|
+
# command line or, if args is empty, from the standard input
|
196
|
+
files = (args == [] ? STDIN.read.split("\n") : args)
|
197
|
+
|
198
|
+
if files.empty?
|
199
|
+
puts "Error! Please pipe or pass as argument the list of files to show on the map."
|
200
|
+
exit 1
|
201
|
+
end
|
202
|
+
|
203
|
+
files.each do |file|
|
204
|
+
javascript_filename = renderer::to_javascript_filename file
|
205
|
+
|
206
|
+
# backup if the geojson file exists and we are forcing writing
|
207
|
+
backup(javascript_filename) if File.exist?(javascript_filename) and force
|
208
|
+
|
209
|
+
# print some messages
|
210
|
+
if force or not File.exist?(javascript_filename)
|
211
|
+
printf "Creating javascript file for #{file} ..."
|
212
|
+
print_done = true
|
213
|
+
else
|
214
|
+
puts "Javascript file for #{file} already exists (--force to force updating)"
|
215
|
+
print_done = false
|
216
|
+
end
|
217
|
+
# create the geojson file (if necessary or required to do so)
|
218
|
+
renderer::to_javascript_file file, force
|
219
|
+
# print some messages
|
220
|
+
puts "done!" if print_done
|
221
|
+
end
|
222
|
+
|
223
|
+
backup(filename) if File.exist? filename
|
224
|
+
printf "Writing #{filename}... "
|
225
|
+
renderer::show filename: filename, files: files
|
226
|
+
puts "done!"
|
227
|
+
puts "You might now want to open #{filename}."
|
228
|
+
end
|
229
|
+
|
351
230
|
end
|
352
231
|
end
|