Compare commits
No commits in common. "c945bec0ff2a46e7d0cda5d603f0edfcbed70bd8" and "b70c72fcfe7be28baff722719031c76f4e55153a" have entirely different histories.
c945bec0ff
...
b70c72fcfe
51
README
51
README
@ -79,6 +79,9 @@ 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
|
||||||
|
|
||||||
@ -107,30 +110,40 @@ 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,47 +119,11 @@ label.readout {
|
|||||||
|
|
||||||
(local cq (cqueues.new))
|
(local cq (cqueues.new))
|
||||||
|
|
||||||
(fn cairo-roads-path [g lines bounds]
|
(var map-surface nil)
|
||||||
(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]
|
||||||
@ -175,31 +139,23 @@ 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 0.7 0.8 0.8)
|
(g:set_source_rgb 1 1 1)
|
||||||
(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 0 0)
|
(g:set_source_rgb 0.2 0.2 0.6)
|
||||||
(g:set_line_width road-width)
|
(g:set_line_width 2)
|
||||||
(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.name
|
(case line
|
||||||
n (let [(x y angle) (label-coords line bounds)]
|
[[sx sy] & more]
|
||||||
(when (and x y)
|
(do
|
||||||
(g:save)
|
(g:move_to (* tile-size (- sx bounds.min.x))
|
||||||
(g:move_to x y)
|
(* tile-size (- sy bounds.min.y)))
|
||||||
(g:rotate angle)
|
(each [_ [x y] (ipairs more)]
|
||||||
(g:rel_move_to 0 3)
|
(let [x1 (* tile-size (- x bounds.min.x))
|
||||||
(g:text_path n)
|
y1 (* tile-size (- y bounds.min.y))]
|
||||||
(g:fill)
|
(g:line_to x1 y1))))))
|
||||||
(g:restore)))))
|
(g:stroke)
|
||||||
|
|
||||||
map-surface)))
|
map-surface)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
]
|
]
|
||||||
(table.concat "\n"))))
|
(table.concat "\n"))))
|
||||||
|
|
||||||
(fn canvas [elements zoom]
|
(fn canvas [elements]
|
||||||
(let [nodes {}
|
(let [nodes {}
|
||||||
lines {}]
|
lines {}]
|
||||||
(each [_ e (ipairs elements)]
|
(each [_ e (ipairs elements)]
|
||||||
@ -70,15 +70,11 @@
|
|||||||
(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 zoom)]
|
(tx ty) (latlon->tile node.lat node.lon 17)]
|
||||||
;;(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))
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +112,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) zoom)))
|
(canvas (. (json.decode data) :elements))))
|
||||||
(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