From 1a56fd692cfc69f73fe0945a67f1e5e8270c29d7 Mon Sep 17 00:00:00 2001 From: Phil! Gold Date: Tue, 9 Oct 2012 10:22:07 -0400 Subject: [PATCH] Highway turning circle rendering. The generate_turning_circles.py script creates the circles based on its parameters, which, currently, are to make circle 2.5 time the width of the roads they're on. generate_turning_circles.py must be run before rendering, naturally. --- .gitignore | 3 ++ README.md | 5 +++ generate_turning_circles.py | 30 ++++++++++++++ include/highway.inc.templ | 76 ++++++++++++++++++++++++++++++++++++ templates/features.xml.templ | 34 ++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100755 generate_turning_circles.py diff --git a/.gitignore b/.gitignore index 175ea0f..3215c12 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ landcoverrelief.xml ocean.xml include/*.inc +# These are generated by programs +custom-symbols/turning_circle* + *.pyc errors.log geodata diff --git a/README.md b/README.md index 1f7c9f5..c4d5274 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,11 @@ Generate hillshade and colormaps: ``` $ ./prep_toposm_data ``` +Generate turning circle images: +``` +$ ./generate_turning_circles.py +``` + Add a shortcut for your area(s) of interest to areas.py. diff --git a/generate_turning_circles.py b/generate_turning_circles.py new file mode 100755 index 0000000..8ad5cb1 --- /dev/null +++ b/generate_turning_circles.py @@ -0,0 +1,30 @@ +#!/usr/bin/python + +import subprocess + +# Fill is 2.5 times the width of the corresponding road fills. +metrics = { 'tertiary': { 15: { 'fill': 8.75, 'border': 1.0 }, + 16: { 'fill': 20.00, 'border': 1.0 } }, + 'minor': { 15: { 'fill': 5.0, 'border': 1.0 }, + 16: { 'fill': 12.5, 'border': 1.0 } }, + 'service': { 15: { 'fill': 3.25, 'border': 0.6 }, + 16: { 'fill': 5.00, 'border': 1.0 } } } +colors = { 'border': 'black', 'fill': 'white' } + +def save_circle(diameter, color, file_name): + img_size = int(diameter + 4) # Two pixels on either side of the circle. + circle_center = img_size / 2.0 + circle_edge = (img_size - diameter) / 2 + file_path = 'custom-symbols/' + file_name + subprocess.call(['convert', + '-size', '{0}x{0}'.format(img_size), 'xc:none', + '-fill', color, + '-draw', 'circle {0},{0} {0},{1}'.format(circle_center, circle_edge), + file_path]) + +for classification, zooms in metrics.items(): + for zoom, dimensions in zooms.items(): + save_circle(dimensions['fill'], colors['fill'], + 'turning_circle-{0}-z{1}-fill.png'.format(classification, zoom)) + save_circle(dimensions['fill'] + dimensions['border'] * 2, colors['border'], + 'turning_circle-{0}-z{1}-casing.png'.format(classification, zoom)) diff --git a/include/highway.inc.templ b/include/highway.inc.templ index e6adc39..fd272e7 100644 --- a/include/highway.inc.templ +++ b/include/highway.inc.templ @@ -466,10 +466,86 @@ + + + +