Compare commits
7 Commits
b70c72fcfe
...
c945bec0ff
Author | SHA1 | Date | |
---|---|---|---|
c945bec0ff | |||
48cfa81595 | |||
890cdb1c1d | |||
521bc409e5 | |||
11bbf10781 | |||
441120efd6 | |||
04f6665a91 |
51
README
51
README
@ -79,9 +79,6 @@ elapsed time: what should it actually show? moving time, I guess
|
|||||||
|
|
||||||
should we rename bearing as course in nmea?
|
should we rename bearing as course in nmea?
|
||||||
|
|
||||||
perhaps we need a server-side component for route planning
|
|
||||||
|
|
||||||
|
|
||||||
7) think about how to use nfc tags or something for profiles so that
|
7) think about how to use nfc tags or something for profiles so that
|
||||||
it can recognise when it's attached to bicycle or motorbike
|
it can recognise when it's attached to bicycle or motorbike
|
||||||
|
|
||||||
@ -110,40 +107,30 @@ cover more than 1/16th the length of the tile"
|
|||||||
|
|
||||||
d) render ways according to their type (road/cycleway/path/etc)
|
d) render ways according to their type (road/cycleway/path/etc)
|
||||||
|
|
||||||
e) label the ways
|
|
||||||
|
|
||||||
f) async tile fetching
|
|
||||||
|
|
||||||
we don't want everything to stop when it's time to fetch a new
|
|
||||||
row of tiles, what are our options? lua-http is built on cqueues
|
|
||||||
which is async enough to make my head hurt, but we also need
|
|
||||||
to make it coexist with the gtk event loop
|
|
||||||
|
|
||||||
assumptions:
|
|
||||||
1) gtk stuff has to happen in the main thread (whatever that is...)
|
|
||||||
so we can't control it from cqueues because that has its own
|
|
||||||
threading stuff
|
|
||||||
2) there will be lots of fds from lua-http, do we really want the
|
|
||||||
housekeeping of making GLib.io_add_watch for each of them? it looks
|
|
||||||
like adding a glib source from lgi is not currently practical
|
|
||||||
https://github.com/lgi-devs/lgi/issues/111
|
|
||||||
|
|
||||||
3) if we put http calls inside cq:wrap, that make them background
|
|
||||||
provided that we call (cq:step 0)
|
|
||||||
periodically. we could do that in a glib idle function, perhaps.
|
|
||||||
|
|
||||||
- The tile fetcher would need to know where to write the data when
|
|
||||||
eventually it comes back
|
|
||||||
- need some say to not fetch the same tile 18 times if there's more than
|
|
||||||
one request for it while a previous request is in progress
|
|
||||||
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
https://git.syndicate-lang.org/tonyg/squeak-phone/raw/commit/474960ddc665ed445a1f5afb0164fe39057720f9/devices/pine64-pinephone/modem-docs/80545ST10798A_LM940_QMI_Command_Reference_Guide_r3.pdf
|
https://git.syndicate-lang.org/tonyg/squeak-phone/raw/commit/474960ddc665ed445a1f5afb0164fe39057720f9/devices/pine64-pinephone/modem-docs/80545ST10798A_LM940_QMI_Command_Reference_Guide_r3.pdf
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
... sod, forgot to push latest changes from noetbook
|
||||||
|
|
||||||
|
we need to extend to multiple tiles'-worth of map
|
||||||
|
|
||||||
|
* get tile for curent lat/long and request overpass data for enough
|
||||||
|
surrounding tiles to fill the screen
|
||||||
|
|
||||||
|
* I think a way is served with all its nodes whether or not they're in
|
||||||
|
the bbox, so we can just store the ids of ways we've seen and skip
|
||||||
|
them if the come up again
|
||||||
|
|
||||||
|
* render all the polylines into the widget (some day also the labels etc)
|
||||||
|
|
||||||
|
* to get it centred on the cyclist, take the tile fractional part *
|
||||||
|
256, and translate the canvas up and left by that amount
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
and offset
|
||||||
|
by
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,11 +119,47 @@ label.readout {
|
|||||||
|
|
||||||
(local cq (cqueues.new))
|
(local cq (cqueues.new))
|
||||||
|
|
||||||
(var map-surface nil)
|
(fn cairo-roads-path [g lines bounds]
|
||||||
|
(each [_ line (pairs lines)]
|
||||||
|
(case line.points
|
||||||
|
[[sx sy] & more]
|
||||||
|
(do
|
||||||
|
(g:save)
|
||||||
|
(g:move_to (* tile-size (- sx bounds.min.x))
|
||||||
|
(* tile-size (- sy bounds.min.y)))
|
||||||
|
(each [_ [x y] (ipairs more)]
|
||||||
|
(let [x1 (* tile-size (- x bounds.min.x))
|
||||||
|
y1 (* tile-size (- y bounds.min.y))]
|
||||||
|
(g:line_to x1 y1)))
|
||||||
|
(g:stroke)
|
||||||
|
(g:restore)))))
|
||||||
|
|
||||||
|
(fn label-coords [{ : points } bounds]
|
||||||
|
(var biggest 0)
|
||||||
|
(var biggest-n 0)
|
||||||
|
|
||||||
|
(for [i 2 (# points)]
|
||||||
|
(let [[x1 y1] (. points (- i 1))
|
||||||
|
[x2 y2] (. points i)
|
||||||
|
dist
|
||||||
|
(+ (* (- x2 x1) (- x2 x1))
|
||||||
|
(* (- y2 y1) (- y2 y1)))]
|
||||||
|
(when (>= dist biggest)
|
||||||
|
(set biggest dist)
|
||||||
|
(set biggest-n (- i 1)))))
|
||||||
|
(let [[x y] (. points biggest-n)
|
||||||
|
[nx ny] (. points (+ 1 biggest-n))
|
||||||
|
angle (math.atan (- ny y) (- nx x))]
|
||||||
|
(values
|
||||||
|
(* tile-size (- x bounds.min.x))
|
||||||
|
(* tile-size (- y bounds.min.y))
|
||||||
|
angle)))
|
||||||
|
|
||||||
|
|
||||||
(fn cairo-the-map [window]
|
(fn cairo-the-map [window]
|
||||||
(let [{ : lat : lon : zoom } app-state
|
(let [{ : lat : lon : zoom } app-state
|
||||||
{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
|
{ : num-tiles-x : num-tiles-y &as bounds } (map-bounds lat lon zoom)
|
||||||
|
road-width 14
|
||||||
lines []]
|
lines []]
|
||||||
|
|
||||||
(for [x bounds.min.x bounds.max.x]
|
(for [x bounds.min.x bounds.max.x]
|
||||||
@ -139,23 +175,31 @@ label.readout {
|
|||||||
(* tile-size num-tiles-y))
|
(* tile-size num-tiles-y))
|
||||||
g (cairo.Context.create map-surface)]
|
g (cairo.Context.create map-surface)]
|
||||||
|
|
||||||
(g:set_source_rgb 1 1 1)
|
(g:set_source_rgb 0.7 0.8 0.8)
|
||||||
(g:rectangle 0 0 (* tile-size num-tiles-x) (* tile-size num-tiles-y))
|
(g:rectangle 0 0 (* tile-size num-tiles-x) (* tile-size num-tiles-y))
|
||||||
(g:fill)
|
(g:fill)
|
||||||
|
|
||||||
(g:set_source_rgb 0.2 0.2 0.6)
|
(g:set_source_rgb 0 0 0)
|
||||||
(g:set_line_width 2)
|
(g:set_line_width road-width)
|
||||||
|
(cairo-roads-path g lines bounds)
|
||||||
|
(g:set_source_rgb 1 1 1)
|
||||||
|
(g:set_line_width (- road-width 2))
|
||||||
|
(cairo-roads-path g lines bounds)
|
||||||
|
|
||||||
|
(g:set_source_rgb 0.2 0.2 0.2)
|
||||||
|
(g:set_font_size (- road-width 3))
|
||||||
(each [_ line (pairs lines)]
|
(each [_ line (pairs lines)]
|
||||||
(case line
|
(case line.name
|
||||||
[[sx sy] & more]
|
n (let [(x y angle) (label-coords line bounds)]
|
||||||
(do
|
(when (and x y)
|
||||||
(g:move_to (* tile-size (- sx bounds.min.x))
|
(g:save)
|
||||||
(* tile-size (- sy bounds.min.y)))
|
(g:move_to x y)
|
||||||
(each [_ [x y] (ipairs more)]
|
(g:rotate angle)
|
||||||
(let [x1 (* tile-size (- x bounds.min.x))
|
(g:rel_move_to 0 3)
|
||||||
y1 (* tile-size (- y bounds.min.y))]
|
(g:text_path n)
|
||||||
(g:line_to x1 y1))))))
|
(g:fill)
|
||||||
(g:stroke)
|
(g:restore)))))
|
||||||
|
|
||||||
map-surface)))
|
map-surface)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
]
|
]
|
||||||
(table.concat "\n"))))
|
(table.concat "\n"))))
|
||||||
|
|
||||||
(fn canvas [elements]
|
(fn canvas [elements zoom]
|
||||||
(let [nodes {}
|
(let [nodes {}
|
||||||
lines {}]
|
lines {}]
|
||||||
(each [_ e (ipairs elements)]
|
(each [_ e (ipairs elements)]
|
||||||
@ -70,11 +70,15 @@
|
|||||||
(tset
|
(tset
|
||||||
lines
|
lines
|
||||||
e.id
|
e.id
|
||||||
|
{
|
||||||
|
:name (?. e :tags :name)
|
||||||
|
:points
|
||||||
(icollect [_ nd (ipairs e.nodes)]
|
(icollect [_ nd (ipairs e.nodes)]
|
||||||
(let [node (. nodes nd)
|
(let [node (. nodes nd)
|
||||||
(tx ty) (latlon->tile node.lat node.lon 17)]
|
(tx ty) (latlon->tile node.lat node.lon zoom)]
|
||||||
;;(print e.tags.name e.id e.name node.lat node.lon)
|
;;(print e.tags.name e.id e.name node.lat node.lon)
|
||||||
[ tx ty ])))))
|
[ tx ty ]))
|
||||||
|
})))
|
||||||
lines))
|
lines))
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +116,7 @@
|
|||||||
(let [data (with-open [i (io.open pathname :r)] (i:read "*a"))]
|
(let [data (with-open [i (io.open pathname :r)] (i:read "*a"))]
|
||||||
(if (= data "")
|
(if (= data "")
|
||||||
[]
|
[]
|
||||||
(canvas (. (json.decode data) :elements))))
|
(canvas (. (json.decode data) :elements) zoom)))
|
||||||
(let [out (io.open pathname :w)]
|
(let [out (io.open pathname :w)]
|
||||||
(cq:wrap (fn []
|
(cq:wrap (fn []
|
||||||
(print "getting " k)
|
(print "getting " k)
|
||||||
|
Loading…
Reference in New Issue
Block a user