(use doodle) (define cities (with-input-from-file "staedte.sexpr" read)) (define coord second) (define get-x first) (define get-y second) (define-constant +width+ 680) (define-constant +height+ 460) (define blue (list 0 0 1 1)) (new-doodle background: solid-white) (define +pi+ 3.14159265358979323846) (define (->radians x) (* x (/ +pi+ 180))) (define mercator-x ->radians) (define (mercator-y y) (let ((tany (tan (->radians y)))) (log (+ tany (sqrt (+ (* tany tany) 1)))))) (define min-x (mercator-x (fold (lambda (c s) (min s (get-x (coord c)))) most-positive-fixnum cities))) (define max-x (mercator-x (fold (lambda (c s) (max s (get-x (coord c)))) 0 cities))) (define min-y (mercator-y (fold (lambda (c s) (min s (get-y (coord c)))) most-positive-fixnum cities))) (define max-y (mercator-y (fold (lambda (c s) (max s (get-y (coord c)))) 0 cities))) (define (scale val min max mapped-min mapped-max) (* (+ mapped-min (- mapped-max mapped-min)) (/ (- val min) (- max min)))) (print "min-x: " min-x ", max-x: " max-x ", min-y: " min-y ", max-y: " max-y) (for-each (lambda (c) (let* ((xy (coord c)) (x (get-x xy)) (y (get-y xy)) (scaled-x (scale (mercator-x x) min-x max-x +width+ +height+)) (scaled-y (scale (mercator-y y) min-y max-y +width+ +height+))) (circle scaled-x (- +height+ scaled-y) 1 blue))) cities) (show!) (save-screenshot "germany.png")