From 667e8f7a29e7f8a5d8a60059f119ca783b33bf75 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 25 Oct 2016 14:13:55 -0700 Subject: [PATCH] Use the same discovered gamma across all tiles of a zoom level --- tests/muni/out/-Z11_-z13_-k10000_-aG.json | 120 ----------- tile.cpp | 237 +++++++++++++--------- 2 files changed, 136 insertions(+), 221 deletions(-) diff --git a/tests/muni/out/-Z11_-z13_-k10000_-aG.json b/tests/muni/out/-Z11_-z13_-k10000_-aG.json index b82bd39..014c68a 100644 --- a/tests/muni/out/-Z11_-z13_-k10000_-aG.json +++ b/tests/muni/out/-Z11_-z13_-k10000_-aG.json @@ -44,8 +44,6 @@ , { "type": "Feature", "properties": { "name": "SAN JOSE AVE & GENEVA AVE" }, "geometry": { "type": "Point", "coordinates": [ -122.446618, 37.720627 ] } } , -{ "type": "Feature", "properties": { "name": "SAN JOSE AVE & GENEVA AVE" }, "geometry": { "type": "Point", "coordinates": [ -122.446704, 37.720491 ] } } -, { "type": "Feature", "properties": { "name": "Persia Ave & Athens St" }, "geometry": { "type": "Point", "coordinates": [ -122.429538, 37.720152 ] } } , { "type": "Feature", "properties": { "name": "Brazil Ave & Prague St" }, "geometry": { "type": "Point", "coordinates": [ -122.426190, 37.720525 ] } } @@ -168,8 +166,6 @@ , { "type": "Feature", "properties": { "name": "Arleta Ave & Bay Shore Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.402630, 37.712242 ] } } , -{ "type": "Feature", "properties": { "name": "Bay Shore Blvd/Arleta/Blanken" }, "geometry": { "type": "Point", "coordinates": [ -122.402372, 37.712242 ] } } -, { "type": "Feature", "properties": { "name": "Bay Shore Blvd & Hester Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.400098, 37.713566 ] } } , { "type": "Feature", "properties": { "name": "Blanken Ave & Peninsula Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.398982, 37.711631 ] } } @@ -1547,8 +1543,6 @@ { "type": "FeatureCollection", "properties": { "zoom": 11, "x": 954, "y": 791 }, "features": [ { "type": "FeatureCollection", "properties": { "layer": "muni", "version": 2, "extent": 4096 }, "features": [ { "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -12.240014, 37.820023 ] } } -, -{ "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -12.240014, 37.820023 ] } } ] } ] } , @@ -1632,8 +1626,6 @@ , { "type": "Feature", "properties": { "name": "Chumasero Dr & Font Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.473140, 37.715009 ] } } , -{ "type": "Feature", "properties": { "name": "Chumasero Dr & Font Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.473075, 37.714822 ] } } -, { "type": "Feature", "properties": { "name": "19th Ave & Junipero Serra Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.472281, 37.716893 ] } } , { "type": "Feature", "properties": { "name": "Junipero Serra Blvd & Font Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.471917, 37.714635 ] } } @@ -1702,8 +1694,6 @@ , { "type": "Feature", "properties": { "name": "San Jose Ave & Lakeview Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.450395, 37.716299 ] } } , -{ "type": "Feature", "properties": { "name": "San Jose Ave & Lakeview Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.450373, 37.716061 ] } } -, { "type": "Feature", "properties": { "name": "San Jose Ave & Broad St" }, "geometry": { "type": "Point", "coordinates": [ -122.453163, 37.713311 ] } } , { "type": "Feature", "properties": { "name": "San Jose Ave & Farallones St" }, "geometry": { "type": "Point", "coordinates": [ -122.452154, 37.714160 ] } } @@ -3338,8 +3328,6 @@ , { "type": "Feature", "properties": { "name": "Fillmore St & Chestnut St" }, "geometry": { "type": "Point", "coordinates": [ -122.436233, 37.801104 ] } } , -{ "type": "Feature", "properties": { "name": "Chestnut St & Fillmore St" }, "geometry": { "type": "Point", "coordinates": [ -122.436383, 37.800748 ] } } -, { "type": "Feature", "properties": { "name": "Fillmore St & Lombard St" }, "geometry": { "type": "Point", "coordinates": [ -122.435954, 37.799713 ] } } , { "type": "Feature", "properties": { "name": "Chestnut St & Fillmore St" }, "geometry": { "type": "Point", "coordinates": [ -122.435632, 37.800849 ] } } @@ -3394,8 +3382,6 @@ , { "type": "Feature", "properties": { "name": "Presidio Ave & California St" }, "geometry": { "type": "Point", "coordinates": [ -122.446897, 37.787369 ] } } , -{ "type": "Feature", "properties": { "name": "California St & Presidio Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.447004, 37.787200 ] } } -, { "type": "Feature", "properties": { "name": "California St & Baker St" }, "geometry": { "type": "Point", "coordinates": [ -122.443399, 37.787624 ] } } , { "type": "Feature", "properties": { "name": "California St & Divisadero St" }, "geometry": { "type": "Point", "coordinates": [ -122.440739, 37.787963 ] } } @@ -3426,8 +3412,6 @@ , { "type": "Feature", "properties": { "name": "DUBLIN ST & BRAZIL AVE" }, "geometry": { "type": "Point", "coordinates": [ -122.425783, 37.719371 ] } } , -{ "type": "Feature", "properties": { "name": "DUBLIN ST & BRAZIL AVE" }, "geometry": { "type": "Point", "coordinates": [ -122.425804, 37.719320 ] } } -, { "type": "Feature", "properties": { "name": "Mansell St & University St" }, "geometry": { "type": "Point", "coordinates": [ -122.411277, 37.718964 ] } } , { "type": "Feature", "properties": { "name": "Mansell St & Dartmouth St" }, "geometry": { "type": "Point", "coordinates": [ -122.409067, 37.719388 ] } } @@ -3476,12 +3460,8 @@ , { "type": "Feature", "properties": { "name": "Santos St & Brookdale Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.418895, 37.711716 ] } } , -{ "type": "Feature", "properties": { "name": "Santos St & Brookdale Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.418852, 37.711716 ] } } -, { "type": "Feature", "properties": { "name": "Visitacion Ave & Hahn St" }, "geometry": { "type": "Point", "coordinates": [ -122.415183, 37.713532 ] } } , -{ "type": "Feature", "properties": { "name": "Hahn St & Visitacion Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.415226, 37.713413 ] } } -, { "type": "Feature", "properties": { "name": "Sunnydale Ave & Sawyer St" }, "geometry": { "type": "Point", "coordinates": [ -122.415226, 37.711631 ] } } , { "type": "Feature", "properties": { "name": "Mansell St & John F Shelley Dr" }, "geometry": { "type": "Point", "coordinates": [ -122.414260, 37.718047 ] } } @@ -3552,12 +3532,8 @@ , { "type": "Feature", "properties": { "name": "SAN BRUNO AVE & BAYSHORE BLVD" }, "geometry": { "type": "Point", "coordinates": [ -122.402587, 37.712361 ] } } , -{ "type": "Feature", "properties": { "name": "Arleta Ave & Bay Shore Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.402608, 37.712225 ] } } -, { "type": "Feature", "properties": { "name": "Bay Shore Blvd & Arleta Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.402308, 37.712463 ] } } , -{ "type": "Feature", "properties": { "name": "Bay Shore Blvd/Arleta/Blanken" }, "geometry": { "type": "Point", "coordinates": [ -122.402351, 37.712242 ] } } -, { "type": "Feature", "properties": { "name": "Bay Shore Blvd & Blanken Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.402179, 37.712242 ] } } , { "type": "Feature", "properties": { "name": "Leland Ave@Bay Shore Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.403810, 37.711139 ] } } @@ -3572,8 +3548,6 @@ , { "type": "Feature", "properties": { "name": "Sunnydale Ave & Bay Shore Blvd" }, "geometry": { "type": "Point", "coordinates": [ -122.405205, 37.708949 ] } } , -{ "type": "Feature", "properties": { "name": "BAY SHORE BLVD & SUNNYDALE AVE" }, "geometry": { "type": "Point", "coordinates": [ -122.405076, 37.708847 ] } } -, { "type": "Feature", "properties": { "name": "SUNNYDALE AVE & BAYSHORE BLVD" }, "geometry": { "type": "Point", "coordinates": [ -122.405269, 37.708813 ] } } , { "type": "Feature", "properties": { "name": "Blanken Ave & Nueva Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.397480, 37.711206 ] } } @@ -3832,8 +3806,6 @@ , { "type": "Feature", "properties": { "name": "11th St & Howard St" }, "geometry": { "type": "Point", "coordinates": [ -122.415397, 37.772835 ] } } , -{ "type": "Feature", "properties": { "name": "8th St & Market St" }, "geometry": { "type": "Point", "coordinates": [ -122.414603, 37.778500 ] } } -, { "type": "Feature", "properties": { "name": "8th St & Mission St" }, "geometry": { "type": "Point", "coordinates": [ -122.413037, 37.777245 ] } } , { "type": "Feature", "properties": { "name": "Mission St & 9th St" }, "geometry": { "type": "Point", "coordinates": [ -122.414324, 37.776464 ] } } @@ -3874,8 +3846,6 @@ , { "type": "Feature", "properties": { "name": "Church St & 16th St" }, "geometry": { "type": "Point", "coordinates": [ -122.428615, 37.764388 ] } } , -{ "type": "Feature", "properties": { "name": "16th St & Church St" }, "geometry": { "type": "Point", "coordinates": [ -122.428529, 37.764591 ] } } -, { "type": "Feature", "properties": { "name": "Church St & 18th St" }, "geometry": { "type": "Point", "coordinates": [ -122.428508, 37.762810 ] } } , { "type": "Feature", "properties": { "name": "Market St & Guerrero St" }, "geometry": { "type": "Point", "coordinates": [ -122.424989, 37.770579 ] } } @@ -3894,8 +3864,6 @@ , { "type": "Feature", "properties": { "name": "18th St & Church St" }, "geometry": { "type": "Point", "coordinates": [ -122.428207, 37.761385 ] } } , -{ "type": "Feature", "properties": { "name": "Right Of Way/18th St" }, "geometry": { "type": "Point", "coordinates": [ -122.428186, 37.761199 ] } } -, { "type": "Feature", "properties": { "name": "Right Of Way/20th St" }, "geometry": { "type": "Point", "coordinates": [ -122.427928, 37.758281 ] } } , { "type": "Feature", "properties": { "name": "Church St & Liberty St" }, "geometry": { "type": "Point", "coordinates": [ -122.428079, 37.757382 ] } } @@ -3926,8 +3894,6 @@ , { "type": "Feature", "properties": { "name": "Mission St & 16th St" }, "geometry": { "type": "Point", "coordinates": [ -122.419689, 37.765134 ] } } , -{ "type": "Feature", "properties": { "name": "Mission St & 16th St" }, "geometry": { "type": "Point", "coordinates": [ -122.419732, 37.765015 ] } } -, { "type": "Feature", "properties": { "name": "Mission St & 16th St" }, "geometry": { "type": "Point", "coordinates": [ -122.419603, 37.764948 ] } } , { "type": "Feature", "properties": { "name": "Mission St & 18th St" }, "geometry": { "type": "Point", "coordinates": [ -122.419367, 37.762641 ] } } @@ -3970,8 +3936,6 @@ , { "type": "Feature", "properties": { "name": "Folsom St & 20th St" }, "geometry": { "type": "Point", "coordinates": [ -122.414796, 37.759010 ] } } , -{ "type": "Feature", "properties": { "name": "Folsom St & 20th St" }, "geometry": { "type": "Point", "coordinates": [ -122.414625, 37.758824 ] } } -, { "type": "Feature", "properties": { "name": "Bryant St & 18th St" }, "geometry": { "type": "Point", "coordinates": [ -122.410054, 37.761674 ] } } , { "type": "Feature", "properties": { "name": "Bryant St & 19th St" }, "geometry": { "type": "Point", "coordinates": [ -122.409925, 37.760384 ] } } @@ -3992,16 +3956,10 @@ , { "type": "Feature", "properties": { "name": "POWELL STREET TURNABLE OUT OB" }, "geometry": { "type": "Point", "coordinates": [ -122.407823, 37.784775 ] } } , -{ "type": "Feature", "properties": { "name": "POWELL & MARKET TURNTABLE" }, "geometry": { "type": "Point", "coordinates": [ -122.407694, 37.784808 ] } } -, -{ "type": "Feature", "properties": { "name": "POWELL STREET TURNABLE IN IB" }, "geometry": { "type": "Point", "coordinates": [ -122.407629, 37.784792 ] } } -, { "type": "Feature", "properties": { "name": "Powell/Market" }, "geometry": { "type": "Point", "coordinates": [ -122.407651, 37.784469 ] } } , { "type": "Feature", "properties": { "name": "Market St & 5th St" }, "geometry": { "type": "Point", "coordinates": [ -122.407994, 37.784096 ] } } , -{ "type": "Feature", "properties": { "name": "Cyril Magnin St & Market St" }, "geometry": { "type": "Point", "coordinates": [ -122.408080, 37.783994 ] } } -, { "type": "Feature", "properties": { "name": "Market St & Powell St" }, "geometry": { "type": "Point", "coordinates": [ -122.407329, 37.784690 ] } } , { "type": "Feature", "properties": { "name": "O'Farrell St & Grant Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.405634, 37.786657 ] } } @@ -4026,12 +3984,8 @@ , { "type": "Feature", "properties": { "name": "Market St & Kearny St" }, "geometry": { "type": "Point", "coordinates": [ -122.403381, 37.787742 ] } } , -{ "type": "Feature", "properties": { "name": "Market St & Kearny St" }, "geometry": { "type": "Point", "coordinates": [ -122.403424, 37.787640 ] } } -, { "type": "Feature", "properties": { "name": "Mission St & 3rd St" }, "geometry": { "type": "Point", "coordinates": [ -122.401578, 37.786521 ] } } , -{ "type": "Feature", "properties": { "name": "3rd St & Mission St" }, "geometry": { "type": "Point", "coordinates": [ -122.402093, 37.786352 ] } } -, { "type": "Feature", "properties": { "name": "4th St & Mission St" }, "geometry": { "type": "Point", "coordinates": [ -122.404132, 37.784266 ] } } , { "type": "Feature", "properties": { "name": "Mission St & 2nd St" }, "geometry": { "type": "Point", "coordinates": [ -122.399862, 37.787878 ] } } @@ -4076,8 +4030,6 @@ , { "type": "Feature", "properties": { "name": "Folsom St & 2nd St" }, "geometry": { "type": "Point", "coordinates": [ -122.396536, 37.785758 ] } } , -{ "type": "Feature", "properties": { "name": "2nd St & Folsom St" }, "geometry": { "type": "Point", "coordinates": [ -122.396536, 37.785504 ] } } -, { "type": "Feature", "properties": { "name": "Folsom St & 1st St" }, "geometry": { "type": "Point", "coordinates": [ -122.394197, 37.787437 ] } } , { "type": "Feature", "properties": { "name": "Harrison St & 2nd St" }, "geometry": { "type": "Point", "coordinates": [ -122.395463, 37.784198 ] } } @@ -4114,12 +4066,8 @@ , { "type": "Feature", "properties": { "name": "4TH ST & TOWNSEND ST" }, "geometry": { "type": "Point", "coordinates": [ -122.394884, 37.777075 ] } } , -{ "type": "Feature", "properties": { "name": "4TH ST & TOWNSEND ST" }, "geometry": { "type": "Point", "coordinates": [ -122.394905, 37.776905 ] } } -, { "type": "Feature", "properties": { "name": "4TH ST & BERRY ST" }, "geometry": { "type": "Point", "coordinates": [ -122.393961, 37.776380 ] } } , -{ "type": "Feature", "properties": { "name": "4th St & King St" }, "geometry": { "type": "Point", "coordinates": [ -122.394047, 37.776261 ] } } -, { "type": "Feature", "properties": { "name": "King St & 4th St" }, "geometry": { "type": "Point", "coordinates": [ -122.394369, 37.776074 ] } } , { "type": "Feature", "properties": { "name": "King St & 6th St" }, "geometry": { "type": "Point", "coordinates": [ -122.397845, 37.773174 ] } } @@ -4166,8 +4114,6 @@ , { "type": "Feature", "properties": { "name": "17th St & De Haro St" }, "geometry": { "type": "Point", "coordinates": [ -122.401729, 37.764778 ] } } , -{ "type": "Feature", "properties": { "name": "17th St & De Haro St" }, "geometry": { "type": "Point", "coordinates": [ -122.401471, 37.764914 ] } } -, { "type": "Feature", "properties": { "name": "Rhode Island St & Mariposa St" }, "geometry": { "type": "Point", "coordinates": [ -122.402544, 37.763268 ] } } , { "type": "Feature", "properties": { "name": "16th St & Wisconsin St" }, "geometry": { "type": "Point", "coordinates": [ -122.399690, 37.766237 ] } } @@ -4210,8 +4156,6 @@ , { "type": "Feature", "properties": { "name": "23RD ST & KANSAS ST" }, "geometry": { "type": "Point", "coordinates": [ -122.402673, 37.754464 ] } } , -{ "type": "Feature", "properties": { "name": "KANSAS ST & 23RD ST" }, "geometry": { "type": "Point", "coordinates": [ -122.402480, 37.754447 ] } } -, { "type": "Feature", "properties": { "name": "Rhode Island St & 24th St" }, "geometry": { "type": "Point", "coordinates": [ -122.401578, 37.753395 ] } } , { "type": "Feature", "properties": { "name": "Carolina St & 22nd St" }, "geometry": { "type": "Point", "coordinates": [ -122.399991, 37.757348 ] } } @@ -4278,8 +4222,6 @@ , { "type": "Feature", "properties": { "name": "3rd St & 20th St" }, "geometry": { "type": "Point", "coordinates": [ -122.388468, 37.760792 ] } } , -{ "type": "Feature", "properties": { "name": "3RD ST & 20TH ST" }, "geometry": { "type": "Point", "coordinates": [ -122.388639, 37.760588 ] } } -, { "type": "Feature", "properties": { "name": "Third Street & 20th St" }, "geometry": { "type": "Point", "coordinates": [ -122.388575, 37.760384 ] } } , { "type": "Feature", "properties": { "name": "22nd St & Minnesota St" }, "geometry": { "type": "Point", "coordinates": [ -122.390013, 37.757806 ] } } @@ -4320,8 +4262,6 @@ , { "type": "Feature", "properties": { "name": "30th St & Church St" }, "geometry": { "type": "Point", "coordinates": [ -122.426770, 37.742044 ] } } , -{ "type": "Feature", "properties": { "name": "30th St & Church St" }, "geometry": { "type": "Point", "coordinates": [ -122.426512, 37.742112 ] } } -, { "type": "Feature", "properties": { "name": "30th St & Church St" }, "geometry": { "type": "Point", "coordinates": [ -122.426383, 37.742163 ] } } , { "type": "Feature", "properties": { "name": "Bemis St & Addison St" }, "geometry": { "type": "Point", "coordinates": [ -122.429538, 37.737734 ] } } @@ -4346,8 +4286,6 @@ , { "type": "Feature", "properties": { "name": "San Jose Ave & Randolph St" }, "geometry": { "type": "Point", "coordinates": [ -122.424431, 37.739567 ] } } , -{ "type": "Feature", "properties": { "name": "San Jose Ave & Randall St" }, "geometry": { "type": "Point", "coordinates": [ -122.424324, 37.739397 ] } } -, { "type": "Feature", "properties": { "name": "Mission St & Appleton Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.424045, 37.739007 ] } } , { "type": "Feature", "properties": { "name": "Mission St & Highland Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.424216, 37.737072 ] } } @@ -4490,8 +4428,6 @@ , { "type": "Feature", "properties": { "name": "DUBLIN ST & BRAZIL AVE" }, "geometry": { "type": "Point", "coordinates": [ -122.425783, 37.719371 ] } } , -{ "type": "Feature", "properties": { "name": "DUBLIN ST & BRAZIL AVE" }, "geometry": { "type": "Point", "coordinates": [ -122.425804, 37.719320 ] } } -, { "type": "Feature", "properties": { "name": "Crescent Ave & Murray St" }, "geometry": { "type": "Point", "coordinates": [ -122.420139, 37.735138 ] } } , { "type": "Feature", "properties": { "name": "Crescent Ave & Roscoe St" }, "geometry": { "type": "Point", "coordinates": [ -122.418637, 37.735070 ] } } @@ -4626,8 +4562,6 @@ , { "type": "Feature", "properties": { "name": "3RD ST & EVANS AVE" }, "geometry": { "type": "Point", "coordinates": [ -122.387931, 37.742723 ] } } , -{ "type": "Feature", "properties": { "name": "Evans Ave & 3rd St" }, "geometry": { "type": "Point", "coordinates": [ -122.387867, 37.742638 ] } } -, { "type": "Feature", "properties": { "name": "3rd St & Galvez Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.388704, 37.740890 ] } } , { "type": "Feature", "properties": { "name": "Phelps St & Jerrold Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.391279, 37.739770 ] } } @@ -4642,12 +4576,8 @@ , { "type": "Feature", "properties": { "name": "Third Street/Hudson/Innes" }, "geometry": { "type": "Point", "coordinates": [ -122.388897, 37.739923 ] } } , -{ "type": "Feature", "properties": { "name": "3rd St & Hudson Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.388704, 37.740127 ] } } -, { "type": "Feature", "properties": { "name": "3rd St & La Salle Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.389820, 37.737225 ] } } , -{ "type": "Feature", "properties": { "name": "3rd St & Kirkwood Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.389627, 37.737938 ] } } -, { "type": "Feature", "properties": { "name": "Third Street/Kirkwood/La Salle" }, "geometry": { "type": "Point", "coordinates": [ -122.389691, 37.737649 ] } } , { "type": "Feature", "properties": { "name": "Bay Shore Blvd & Augusta St" }, "geometry": { "type": "Point", "coordinates": [ -122.405591, 37.734255 ] } } @@ -4710,8 +4640,6 @@ , { "type": "Feature", "properties": { "name": "San Bruno Ave & Mansell St" }, "geometry": { "type": "Point", "coordinates": [ -122.401235, 37.721612 ] } } , -{ "type": "Feature", "properties": { "name": "Mansell St & San Bruno Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.401171, 37.721459 ] } } -, { "type": "Feature", "properties": { "name": "San Bruno Ave & Ward St" }, "geometry": { "type": "Point", "coordinates": [ -122.400441, 37.719388 ] } } , { "type": "Feature", "properties": { "name": "Topeka Ave & Bridge View Dr" }, "geometry": { "type": "Point", "coordinates": [ -122.397630, 37.733305 ] } } @@ -4730,12 +4658,8 @@ , { "type": "Feature", "properties": { "name": "Third Street/Oakdale/Palou" }, "geometry": { "type": "Point", "coordinates": [ -122.390850, 37.734374 ] } } , -{ "type": "Feature", "properties": { "name": "3rd St & Oakdale Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.390742, 37.734798 ] } } -, { "type": "Feature", "properties": { "name": "Palou Ave & 3rd St" }, "geometry": { "type": "Point", "coordinates": [ -122.390828, 37.734035 ] } } , -{ "type": "Feature", "properties": { "name": "Palou Ave & 3rd St" }, "geometry": { "type": "Point", "coordinates": [ -122.390871, 37.733865 ] } } -, { "type": "Feature", "properties": { "name": "Third Street/Revere/Shafter" }, "geometry": { "type": "Point", "coordinates": [ -122.391515, 37.732270 ] } } , { "type": "Feature", "properties": { "name": "Revere Ave & 3rd St" }, "geometry": { "type": "Point", "coordinates": [ -122.391365, 37.732422 ] } } @@ -4752,8 +4676,6 @@ , { "type": "Feature", "properties": { "name": "3RD ST & WILLIAMS ST" }, "geometry": { "type": "Point", "coordinates": [ -122.392759, 37.729232 ] } } , -{ "type": "Feature", "properties": { "name": "3rd St & Van Dyke Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.392609, 37.729249 ] } } -, { "type": "Feature", "properties": { "name": "Van Dyke Ave & Lane St" }, "geometry": { "type": "Point", "coordinates": [ -122.392244, 37.729215 ] } } , { "type": "Feature", "properties": { "name": "Van Dyke Ave & Keith St" }, "geometry": { "type": "Point", "coordinates": [ -122.390270, 37.727891 ] } } @@ -4778,8 +4700,6 @@ , { "type": "Feature", "properties": { "name": "Gilman Ave & 3rd St" }, "geometry": { "type": "Point", "coordinates": [ -122.395420, 37.722460 ] } } , -{ "type": "Feature", "properties": { "name": "Gilman St & 3rd St" }, "geometry": { "type": "Point", "coordinates": [ -122.395613, 37.722341 ] } } -, { "type": "Feature", "properties": { "name": "Gilman Ave & Jennings St" }, "geometry": { "type": "Point", "coordinates": [ -122.393596, 37.721425 ] } } , { "type": "Feature", "properties": { "name": "Van Dyke Ave & Jennings St" }, "geometry": { "type": "Point", "coordinates": [ -122.388554, 37.727043 ] } } @@ -4788,10 +4708,6 @@ , { "type": "Feature", "properties": { "name": "Not a public stop" }, "geometry": { "type": "Point", "coordinates": [ -122.386901, 37.755397 ] } } , -{ "type": "Feature", "properties": { "name": "Not a public stop" }, "geometry": { "type": "Point", "coordinates": [ -122.386837, 37.755397 ] } } -, -{ "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -122.386730, 37.755397 ] } } -, { "type": "Feature", "properties": { "name": "Muni Metro East/Not a public stop" }, "geometry": { "type": "Point", "coordinates": [ -122.386837, 37.752818 ] } } , { "type": "Feature", "properties": { "name": "Third St & Marin St" }, "geometry": { "type": "Point", "coordinates": [ -122.387588, 37.749102 ] } } @@ -4898,10 +4814,6 @@ { "type": "FeatureCollection", "properties": { "layer": "subway", "version": 2, "extent": 4096 }, "features": [ { "type": "Feature", "properties": { "name": "Metro Montgomery Station/Downtown" }, "geometry": { "type": "Point", "coordinates": [ -122.401943, 37.788709 ] } } , -{ "type": "Feature", "properties": { "name": "Metro Van Ness Station" }, "geometry": { "type": "Point", "coordinates": [ -122.419195, 37.775074 ] } } -, -{ "type": "Feature", "properties": { "name": "Metro Van Ness Station/Downtown" }, "geometry": { "type": "Point", "coordinates": [ -122.419260, 37.775040 ] } } -, { "type": "Feature", "properties": { "name": "Metro Civic Center Station/Outbd" }, "geometry": { "type": "Point", "coordinates": [ -122.415011, 37.778686 ] } } , { "type": "Feature", "properties": { "name": "Metro Civic Center Station/Downtn" }, "geometry": { "type": "Point", "coordinates": [ -122.414818, 37.778551 ] } } @@ -4932,8 +4844,6 @@ , { "type": "Feature", "properties": { "name": "HYDE STREET TURNABLE OUT OB" }, "geometry": { "type": "Point", "coordinates": [ -122.420504, 37.805800 ] } } , -{ "type": "Feature", "properties": { "name": "HYDE STREET TURNABLE IN IB" }, "geometry": { "type": "Point", "coordinates": [ -122.420504, 37.805800 ] } } -, { "type": "Feature", "properties": { "name": "North Point St & Hyde St" }, "geometry": { "type": "Point", "coordinates": [ -122.420247, 37.805817 ] } } , { "type": "Feature", "properties": { "name": "Jefferson St & Taylor St" }, "geometry": { "type": "Point", "coordinates": [ -122.415526, 37.808326 ] } } @@ -4980,8 +4890,6 @@ , { "type": "Feature", "properties": { "name": "Chestnut St & Van Ness Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.424881, 37.802341 ] } } , -{ "type": "Feature", "properties": { "name": "Chestnut St & Van Ness Ave" }, "geometry": { "type": "Point", "coordinates": [ -122.424903, 37.802206 ] } } -, { "type": "Feature", "properties": { "name": "Polk St & Francisco St" }, "geometry": { "type": "Point", "coordinates": [ -122.423251, 37.803664 ] } } , { "type": "Feature", "properties": { "name": "Polk St & Lombard St" }, "geometry": { "type": "Point", "coordinates": [ -122.423015, 37.801629 ] } } @@ -5058,8 +4966,6 @@ , { "type": "Feature", "properties": { "name": "Union St & Hyde St" }, "geometry": { "type": "Point", "coordinates": [ -122.418959, 37.799273 ] } } , -{ "type": "Feature", "properties": { "name": "Union St & Hyde St" }, "geometry": { "type": "Point", "coordinates": [ -122.419152, 37.799137 ] } } -, { "type": "Feature", "properties": { "name": "Hyde St & Green St" }, "geometry": { "type": "Point", "coordinates": [ -122.418787, 37.798323 ] } } , { "type": "Feature", "properties": { "name": "Union St & Leavenworth St" }, "geometry": { "type": "Point", "coordinates": [ -122.417564, 37.799459 ] } } @@ -5252,8 +5158,6 @@ , { "type": "Feature", "properties": { "name": "Powell St & California St" }, "geometry": { "type": "Point", "coordinates": [ -122.409303, 37.792219 ] } } , -{ "type": "Feature", "properties": { "name": "CALIFORNIA ST & POWELL ST" }, "geometry": { "type": "Point", "coordinates": [ -122.409303, 37.792032 ] } } -, { "type": "Feature", "properties": { "name": "POWELL ST & CALIFORNIA ST" }, "geometry": { "type": "Point", "coordinates": [ -122.409089, 37.792134 ] } } , { "type": "Feature", "properties": { "name": "Powell St & Pine St" }, "geometry": { "type": "Point", "coordinates": [ -122.408917, 37.791100 ] } } @@ -5328,8 +5232,6 @@ , { "type": "Feature", "properties": { "name": "Market St & Main St" }, "geometry": { "type": "Point", "coordinates": [ -122.396643, 37.792999 ] } } , -{ "type": "Feature", "properties": { "name": "Market St & Drumm St" }, "geometry": { "type": "Point", "coordinates": [ -122.396128, 37.793508 ] } } -, { "type": "Feature", "properties": { "name": "The Embarcadero & Washington St" }, "geometry": { "type": "Point", "coordinates": [ -122.395184, 37.796356 ] } } , { "type": "Feature", "properties": { "name": "The Embarcadero & Folsom St" }, "geometry": { "type": "Point", "coordinates": [ -122.393575, 37.795034 ] } } @@ -5340,10 +5242,6 @@ , { "type": "Feature", "properties": { "name": "Market St & Steuart St" }, "geometry": { "type": "Point", "coordinates": [ -122.394927, 37.794271 ] } } , -{ "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -122.394626, 37.794542 ] } } -, -{ "type": "Feature", "properties": { "name": "EMBARCADERO & ST" }, "geometry": { "type": "Point", "coordinates": [ -122.394626, 37.794542 ] } } -, { "type": "Feature", "properties": { "name": "Steuart St & Market St" }, "geometry": { "type": "Point", "coordinates": [ -122.394562, 37.794440 ] } } , { "type": "Feature", "properties": { "name": "MUNI METRO TNL & DRUMM ST" }, "geometry": { "type": "Point", "coordinates": [ -122.393746, 37.794237 ] } } @@ -5354,8 +5252,6 @@ , { "type": "Feature", "properties": { "name": "Steuart St & Mission St" }, "geometry": { "type": "Point", "coordinates": [ -122.393510, 37.793372 ] } } , -{ "type": "Feature", "properties": { "name": "Steuart St & Mission St" }, "geometry": { "type": "Point", "coordinates": [ -122.393274, 37.793372 ] } } -, { "type": "Feature", "properties": { "name": "Front & Market St" }, "geometry": { "type": "Point", "coordinates": [ -122.398424, 37.791897 ] } } , { "type": "Feature", "properties": { "name": "Fremont St & Market St" }, "geometry": { "type": "Point", "coordinates": [ -122.398167, 37.791659 ] } } @@ -5374,14 +5270,10 @@ , { "type": "Feature", "properties": { "name": "Main St & Howard St" }, "geometry": { "type": "Point", "coordinates": [ -122.393339, 37.790608 ] } } , -{ "type": "Feature", "properties": { "name": "Main St. & Howard St." }, "geometry": { "type": "Point", "coordinates": [ -122.393317, 37.790557 ] } } -, { "type": "Feature", "properties": { "name": "Fremont St & Mission St" }, "geometry": { "type": "Point", "coordinates": [ -122.395892, 37.789879 ] } } , { "type": "Feature", "properties": { "name": "Beale St & Howard St" }, "geometry": { "type": "Point", "coordinates": [ -122.394476, 37.789947 ] } } , -{ "type": "Feature", "properties": { "name": "Beale St. & Howard St." }, "geometry": { "type": "Point", "coordinates": [ -122.394261, 37.789828 ] } } -, { "type": "Feature", "properties": { "name": "Fremont St & Folsom St" }, "geometry": { "type": "Point", "coordinates": [ -122.393768, 37.788217 ] } } , { "type": "Feature", "properties": { "name": "Steuart St&Mission St" }, "geometry": { "type": "Point", "coordinates": [ -122.393188, 37.793101 ] } } @@ -5462,8 +5354,6 @@ , { "type": "Feature", "properties": { "name": "Market St & Kearny St" }, "geometry": { "type": "Point", "coordinates": [ -122.403381, 37.787742 ] } } , -{ "type": "Feature", "properties": { "name": "Market St & Kearny St" }, "geometry": { "type": "Point", "coordinates": [ -122.403424, 37.787640 ] } } -, { "type": "Feature", "properties": { "name": "Mission St & 2nd St" }, "geometry": { "type": "Point", "coordinates": [ -122.399862, 37.787878 ] } } , { "type": "Feature", "properties": { "name": "Folsom St & 1st St" }, "geometry": { "type": "Point", "coordinates": [ -122.394197, 37.787437 ] } } @@ -5475,22 +5365,12 @@ { "type": "Feature", "properties": { "name": "Metro Montgomery Station/Downtown" }, "geometry": { "type": "Point", "coordinates": [ -122.401943, 37.788709 ] } } , { "type": "Feature", "properties": { "name": "Metro Embarcadero Station/Downtown" }, "geometry": { "type": "Point", "coordinates": [ -122.396557, 37.793016 ] } } -, -{ "type": "Feature", "properties": { "name": "Metro Embarcadero Station" }, "geometry": { "type": "Point", "coordinates": [ -122.396450, 37.793168 ] } } ] } ] } , { "type": "FeatureCollection", "properties": { "zoom": 12, "x": 1908, "y": 1582 }, "features": [ { "type": "FeatureCollection", "properties": { "layer": "muni", "version": 2, "extent": 4096 }, "features": [ { "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -12.240014, 37.820006 ] } } -, -{ "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -12.240014, 37.820006 ] } } -, -{ "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -12.240014, 37.820006 ] } } -, -{ "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -12.240014, 37.820006 ] } } -, -{ "type": "Feature", "properties": { "name": "REFERENCE & REFERENCE" }, "geometry": { "type": "Point", "coordinates": [ -12.240014, 37.820006 ] } } ] } ] } , diff --git a/tile.cpp b/tile.cpp index 633dd2d..9d6945a 100644 --- a/tile.cpp +++ b/tile.cpp @@ -932,7 +932,7 @@ bool find_common_edges(std::vector &partials, int z, int line_detail, d // If necessary, merge some adjacent polygons into some other polygons struct merge_order { - size_t edge; + ssize_t edge; unsigned long long gap; size_t p1; size_t p2; @@ -943,7 +943,7 @@ bool find_common_edges(std::vector &partials, int z, int line_detail, d }; std::vector order; - for (ssize_t i = 0; i < simplified_arcs.size(); i++) { + for (ssize_t i = 0; i < (ssize_t) simplified_arcs.size(); i++) { auto r1 = merge_candidates.equal_range(i); for (auto r1i = r1.first; r1i != r1.second; ++r1i) { auto r2 = merge_candidates.equal_range(-i); @@ -1141,7 +1141,43 @@ bool find_common_edges(std::vector &partials, int z, int line_detail, d } } -long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *stringpool, int z, unsigned tx, unsigned ty, int detail, int min_detail, int basezoom, sqlite3 *outdb, double droprate, int buffer, const char *fname, FILE **geomfile, int minzoom, int maxzoom, double todo, volatile long long *along, long long alongminus, double gamma, int child_shards, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, volatile int *running, double simplification, std::vector> *layermaps, std::vector> *layer_unmaps) { +struct write_tile_args { + struct task *tasks; + char *metabase; + char *stringpool; + int min_detail; + int basezoom; + sqlite3 *outdb; + double droprate; + int buffer; + const char *fname; + FILE **geomfile; + double todo; + volatile long long *along; + double gamma; + int child_shards; + int *geomfd; + off_t *geom_size; + volatile unsigned *midx; + volatile unsigned *midy; + int maxzoom; + int minzoom; + int full_detail; + int low_detail; + double simplification; + volatile long long *most; + long long *meta_off; + long long *pool_off; + unsigned *initial_x; + unsigned *initial_y; + volatile int *running; + int err; + std::vector> *layermaps; + std::vector> *layer_unmaps; + size_t pass; +}; + +long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *stringpool, int z, unsigned tx, unsigned ty, int detail, int min_detail, int basezoom, sqlite3 *outdb, double droprate, int buffer, const char *fname, FILE **geomfile, int minzoom, int maxzoom, double todo, volatile long long *along, long long alongminus, double gamma, int child_shards, long long *meta_off, long long *pool_off, unsigned *initial_x, unsigned *initial_y, volatile int *running, double simplification, std::vector> *layermaps, std::vector> *layer_unmaps, size_t pass, write_tile_args *arg) { int line_detail; double fraction = 1; double merge_fraction = 1; @@ -1358,7 +1394,7 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s unclipped_features++; } - if (first_time) { /* only write out the next zoom once, even if we retry */ + if (first_time && pass == 1) { /* only write out the next zoom once, even if we retry */ rewrite(geom, z, nextzoom, maxzoom, bbox, tx, ty, buffer, line_detail, within, geompos, geomfile, fname, t, layer, metastart, feature_minzoom, child_shards, max_zoom_increment, original_seq, tippecanoe_minzoom, tippecanoe_maxzoom, segment, initial_x, initial_y, m, metakeys, metavals, has_id, id); } @@ -1677,6 +1713,8 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s gamma = gamma * 1.25; } + arg->gamma = gamma; + if (!quiet) { fprintf(stderr, "Going to try gamma of %0.3f to make it fit\n", gamma); } @@ -1711,6 +1749,8 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s gamma = gamma * 1.25; } + arg->gamma = gamma; + if (!quiet) { fprintf(stderr, "Going to try gamma of %0.3f to make it fit\n", gamma); } @@ -1723,16 +1763,18 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s line_detail++; // to keep it the same when the loop decrements it } } else { - if (pthread_mutex_lock(&db_lock) != 0) { - perror("pthread_mutex_lock"); - exit(EXIT_FAILURE); - } + if (pass == 1) { + if (pthread_mutex_lock(&db_lock) != 0) { + perror("pthread_mutex_lock"); + exit(EXIT_FAILURE); + } - mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size()); + mbtiles_write_tile(outdb, z, tx, ty, compressed.data(), compressed.size()); - if (pthread_mutex_unlock(&db_lock) != 0) { - perror("pthread_mutex_unlock"); - exit(EXIT_FAILURE); + if (pthread_mutex_unlock(&db_lock) != 0) { + perror("pthread_mutex_unlock"); + exit(EXIT_FAILURE); + } } return count; @@ -1751,41 +1793,6 @@ struct task { struct task *next; }; -struct write_tile_args { - struct task *tasks; - char *metabase; - char *stringpool; - int min_detail; - int basezoom; - sqlite3 *outdb; - double droprate; - int buffer; - const char *fname; - FILE **geomfile; - double todo; - volatile long long *along; - double gamma; - int child_shards; - int *geomfd; - off_t *geom_size; - volatile unsigned *midx; - volatile unsigned *midy; - int maxzoom; - int minzoom; - int full_detail; - int low_detail; - double simplification; - volatile long long *most; - long long *meta_off; - long long *pool_off; - unsigned *initial_x; - unsigned *initial_y; - volatile int *running; - int err; - std::vector> *layermaps; - std::vector> *layer_unmaps; -}; - void *run_thread(void *vargs) { write_tile_args *arg = (write_tile_args *) vargs; struct task *task; @@ -1824,7 +1831,7 @@ void *run_thread(void *vargs) { // fprintf(stderr, "%d/%u/%u\n", z, x, y); - long long len = write_tile(geom, &geompos, arg->metabase, arg->stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->basezoom, arg->outdb, arg->droprate, arg->buffer, arg->fname, arg->geomfile, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->child_shards, arg->meta_off, arg->pool_off, arg->initial_x, arg->initial_y, arg->running, arg->simplification, arg->layermaps, arg->layer_unmaps); + long long len = write_tile(geom, &geompos, arg->metabase, arg->stringpool, z, x, y, z == arg->maxzoom ? arg->full_detail : arg->low_detail, arg->min_detail, arg->basezoom, arg->outdb, arg->droprate, arg->buffer, arg->fname, arg->geomfile, arg->minzoom, arg->maxzoom, arg->todo, arg->along, geompos, arg->gamma, arg->child_shards, arg->meta_off, arg->pool_off, arg->initial_x, arg->initial_y, arg->running, arg->simplification, arg->layermaps, arg->layer_unmaps, arg->pass, arg); if (len < 0) { int *err = &arg->err; @@ -1863,12 +1870,26 @@ void *run_thread(void *vargs) { } } + if (arg->pass == 1) { + // Since the fclose() has closed the underlying file descriptor + arg->geomfd[j] = -1; + } else { + int newfd = dup(arg->geomfd[j]); + if (newfd < 0) { + perror("dup geometry"); + exit(EXIT_FAILURE); + } + if (lseek(newfd, 0, SEEK_SET) < 0) { + perror("lseek geometry"); + exit(EXIT_FAILURE); + } + arg->geomfd[j] = newfd; + } + if (fclose(geom) != 0) { perror("close geom"); exit(EXIT_FAILURE); } - // Since the fclose() has closed the underlying file descriptor - arg->geomfd[j] = -1; } arg->running--; @@ -1987,62 +2008,76 @@ int traverse_zooms(int *geomfd, off_t *geom_size, char *metabase, char *stringpo *d = here; } - pthread_t pthreads[threads]; - write_tile_args args[threads]; - int running = threads; - - for (size_t thread = 0; thread < threads; thread++) { - args[thread].metabase = metabase; - args[thread].stringpool = stringpool; - args[thread].min_detail = min_detail; - args[thread].basezoom = basezoom; - args[thread].outdb = outdb; // locked with db_lock - args[thread].droprate = droprate; - args[thread].buffer = buffer; - args[thread].fname = fname; - args[thread].geomfile = sub + thread * (TEMP_FILES / threads); - args[thread].todo = todo; - args[thread].along = &along; // locked with var_lock - args[thread].gamma = gamma; - args[thread].child_shards = TEMP_FILES / threads; - args[thread].simplification = simplification; - - args[thread].geomfd = geomfd; - args[thread].geom_size = geom_size; - args[thread].midx = midx; // locked with var_lock - args[thread].midy = midy; // locked with var_lock - args[thread].maxzoom = maxzoom; - args[thread].minzoom = minzoom; - args[thread].full_detail = full_detail; - args[thread].low_detail = low_detail; - args[thread].most = &most; // locked with var_lock - args[thread].meta_off = meta_off; - args[thread].pool_off = pool_off; - args[thread].initial_x = initial_x; - args[thread].initial_y = initial_y; - args[thread].layermaps = &layermaps; - args[thread].layer_unmaps = &layer_unmaps; - - args[thread].tasks = dispatches[thread].tasks; - args[thread].running = &running; - - if (pthread_create(&pthreads[thread], NULL, run_thread, &args[thread]) != 0) { - perror("pthread_create"); - exit(EXIT_FAILURE); - } - } - int err = INT_MAX; - for (size_t thread = 0; thread < threads; thread++) { - void *retval; + size_t start = 1; + if (additional[A_INCREASE_GAMMA_AS_NEEDED]) { + start = 0; + } - if (pthread_join(pthreads[thread], &retval) != 0) { - perror("pthread_join"); + double zoom_gamma = gamma; + + for (size_t pass = start; pass < 2; pass++) { + pthread_t pthreads[threads]; + write_tile_args args[threads]; + int running = threads; + + for (size_t thread = 0; thread < threads; thread++) { + args[thread].metabase = metabase; + args[thread].stringpool = stringpool; + args[thread].min_detail = min_detail; + args[thread].basezoom = basezoom; + args[thread].outdb = outdb; // locked with db_lock + args[thread].droprate = droprate; + args[thread].buffer = buffer; + args[thread].fname = fname; + args[thread].geomfile = sub + thread * (TEMP_FILES / threads); + args[thread].todo = todo; + args[thread].along = &along; // locked with var_lock + args[thread].gamma = zoom_gamma; + args[thread].child_shards = TEMP_FILES / threads; + args[thread].simplification = simplification; + + args[thread].geomfd = geomfd; + args[thread].geom_size = geom_size; + args[thread].midx = midx; // locked with var_lock + args[thread].midy = midy; // locked with var_lock + args[thread].maxzoom = maxzoom; + args[thread].minzoom = minzoom; + args[thread].full_detail = full_detail; + args[thread].low_detail = low_detail; + args[thread].most = &most; // locked with var_lock + args[thread].meta_off = meta_off; + args[thread].pool_off = pool_off; + args[thread].initial_x = initial_x; + args[thread].initial_y = initial_y; + args[thread].layermaps = &layermaps; + args[thread].layer_unmaps = &layer_unmaps; + + args[thread].tasks = dispatches[thread].tasks; + args[thread].running = &running; + args[thread].pass = pass; + + if (pthread_create(&pthreads[thread], NULL, run_thread, &args[thread]) != 0) { + perror("pthread_create"); + exit(EXIT_FAILURE); + } } - if (retval != NULL) { - err = *((int *) retval); + for (size_t thread = 0; thread < threads; thread++) { + void *retval; + + if (pthread_join(pthreads[thread], &retval) != 0) { + perror("pthread_join"); + } + + if (retval != NULL) { + err = *((int *) retval); + } + + if (args[thread].gamma > zoom_gamma) { + zoom_gamma = args[thread].gamma; + } } }