diff --git a/tests/join-population/windows.mbtiles.json b/tests/join-population/windows.mbtiles.json index 88fbe93..dfb95eb 100644 --- a/tests/join-population/windows.mbtiles.json +++ b/tests/join-population/windows.mbtiles.json @@ -7,7 +7,7 @@ "maxzoom": "10", "minzoom": "5", "name": "tests/join-population/macarthur.mbtiles", -"tilestats": "{\"layerCount\": 1,\"layers\": [{\"layer\": \"macarthur\",\"count\": 0,\"geometry\": \"Point\",\"attributeCount\": 4,\"attributes\": [{\"attribute\": \"FULLNAME\",\"count\": 3,\"type\": \"string\",\"values\": [\"Macarthur\",\"Macarthur Fwy\",\"W Macarthur\"]},{\"attribute\": \"LINEARID\",\"count\": 17,\"type\": \"string\",\"values\": [\"1102155930810\",\"1102156241736\",\"1102156510290\",\"1102157651658\",\"1102638069562\",\"1102654601627\",\"1102654601663\",\"1102654602215\",\"1102954918511\",\"1103690383700\",\"1103690474249\",\"1103690474250\",\"1103690483026\",\"1103690483032\",\"1104474748623\",\"1104486090991\",\"1104486392881\"]},{\"attribute\": \"MTFCC\",\"count\": 2,\"type\": \"string\",\"values\": [\"S1100\",\"S1400\"]},{\"attribute\": \"RTTYP\",\"count\": 1,\"type\": \"string\",\"values\": [\"M\"]}]}]}", +"tilestats": "{\"layerCount\": 1,\"layers\": [{\"layer\": \"macarthur\",\"count\": 0,\"geometry\": \"Point\",\"attributeCount\": 4,\"attributes\": [{\"attribute\": \"FULLNAME\",\"count\": 3,\"type\": \"string\",\"values\": [\"Macarthur\",\"Macarthur Fwy\",\"W Macarthur\"]},{\"attribute\": \"LINEARID\",\"count\": 4,\"type\": \"string\",\"values\": [\"1102156510290\",\"1104486392881\",\"first\",\"second\"]},{\"attribute\": \"MTFCC\",\"count\": 2,\"type\": \"string\",\"values\": [\"S1100\",\"S1400\"]},{\"attribute\": \"RTTYP\",\"count\": 1,\"type\": \"string\",\"values\": [\"M\"]}]}]}", "type": "overlay", "version": "2" }, "features": [ diff --git a/tests/muni/decode/multi.mbtiles.json b/tests/muni/decode/multi.mbtiles.json index 3c27aa6..fd5ecd5 100644 --- a/tests/muni/decode/multi.mbtiles.json +++ b/tests/muni/decode/multi.mbtiles.json @@ -7,7 +7,7 @@ "maxzoom": "11", "minzoom": "11", "name": "tests/muni/decode/multi.mbtiles", -"tilestats": "{\"layerCount\": 2,\"layers\": [{\"layer\": \"muni\",\"count\": 4592,\"geometry\": \"Point\",\"attributeCount\": 1,\"attributes\": [{\"attribute\": \"name\",\"count\": 1000,\"type\": \"string\",\"values\": [\"101 Dakota St\",\"1095 CONNECTICUT ST\",\"10th Ave & Ortega St\",\"10th Ave & Pacheco St\",\"10th Ave & Quintara St\",\"11th St & Bryant St\",\"11th St & Folsom St\",\"11th St & Harrison St\",\"11th St & Howard St\",\"11th St & Market St\",\"11th St & Mission St\",\"13th St & Gateview Ave\",\"14 Dakota St\",\"14th Ave & Quintara St\",\"14th Ave & Santiago St\",\"14th Ave & Taraval St\",\"14th Ave & Ulloa St\",\"14th St & Alpine Ter\",\"14th St & Castro St\",\"14th St & Church St\",\"14th St & Noe St\",\"14th St & SANCHEZ ST\",\"14th St & Sanchez St\",\"15th Ave & Noriega St\",\"15th Ave & Ortega St\",\"15th Ave & Pacheco St\",\"15th Ave & Quintara St\",\"15th Ave & Taraval St\",\"15th Ave & Ulloa St\",\"15th Ave & West Portal Ave\",\"15th St & Mission St\",\"164 Addison St\",\"1697 7th Ave\",\"16th Ave & Lawton St\",\"16th Ave & Lomita Ave\",\"16th Ave & Moraga St\",\"16th Ave & Noriega St\",\"16th Ave & Ortega St\",\"16th Ave & Pacheco St\",\"16th St & Bryant St\",\"16th St & Church St\",\"16th St & Dolores St\",\"16th St & Guerrero St\",\"16th St & Harrison St\",\"16th St & Kansas St\",\"16th St & Mission St\",\"16th St & Potrero Ave\",\"16th St & San Bruno Ave\",\"16th St & Shotwell St\",\"16th St & Valencia St\",\"16th St & Vermont St\",\"170 Buckingham Way\",\"1730 3rd St\",\"17TH ST & KANSAS ST\",\"17th Ave & Rivera St\",\"17th Ave & Santiago St\",\"17th St & Belvedere St\",\"17th St & Castro St\",\"17th St & Clayton St\",\"17th St & Cole St\",\"17th St & De Haro St\",\"17th St & Diamond St\",\"17th St & Kansas St\",\"17th St & Noe St\",\"17th St & Wisconsin St\",\"18th St & 3rd St\",\"18th St & Castro St\",\"18th St & Church St\",\"18th St & Connecticut St\",\"18th St & Danvers St\",\"18th St & Diamond St\",\"18th St & Dolores St\",\"18th St & Eureka St\",\"18th St & Guerrero St\",\"18th St & Hattie St\",\"18th St & Market St\",\"18th St & Minnesota St\",\"18th St & Mission St\",\"18th St & Noe St\",\"18th St & Pennsylvania Ave\",\"18th St & Sanchez St\",\"18th St & Texas St\",\"18th St & Valencia St\",\"190 Buckingham Way\",\"19TH AVE & HOLLOWAY\",\"19TH AVE & HOLLOWAY Ave\",\"19TH AVE & LINCOLN WAY\",\"19TH AVE & Holloway Ave\",\"19th Ave & Banbury Dr\",\"19th Ave & Buckingham Way\",\"19th Ave & Crespi Dr\",\"19th Ave & Eucalyptus Dr\",\"19th Ave & Holloway Ave\",\"19th Ave & Irving St\",\"19th Ave & Judah St\",\"19th Ave & Junipero Serra Blvd\",\"19th Ave & Kirkham St\",\"19th Ave & Lawton St\",\"19th Ave & Lincoln Way\",\"19th Ave & Moraga St\"]}]},{\"layer\": \"subway\",\"count\": 19,\"geometry\": \"Point\",\"attributeCount\": 1,\"attributes\": [{\"attribute\": \"name\",\"count\": 18,\"type\": \"string\",\"values\": [\"Metro Castro Station/Downtown\",\"Metro Castro Station/Outbound\",\"Metro Church Station/Downtown\",\"Metro Church Station/Outbound\",\"Metro Civic Center Station/Downtn\",\"Metro Civic Center Station/Downtown\",\"Metro Civic Center Station/Outbd\",\"Metro Embarcadero Station\",\"Metro Embarcadero Station/Downtown\",\"Metro Forest Hill Station/Downtown\",\"Metro Montgomery Station/Downtown\",\"Metro Montgomery Station/Outbound\",\"Metro Powell Station/Downtown\",\"Metro Powell Station/Outbound\",\"Metro Van Ness Station\",\"Metro Van Ness Station/Downtown\",\"Metro Van Ness Station/Outbound\",\"Van Ness Station Outbound\"]}]}]}", +"tilestats": "{\"layerCount\": 2,\"layers\": [{\"layer\": \"muni\",\"count\": 4592,\"geometry\": \"Point\",\"attributeCount\": 1,\"attributes\": [{\"attribute\": \"name\",\"count\": 1000,\"type\": \"string\",\"values\": [\" 4th St & Brannan St\",\" Conzelman Rd & Mccullough Rd\",\"100 O'Shaughnessy Blvd\",\"101 Dakota St\",\"1095 CONNECTICUT ST\",\"10th Ave & Ortega St\",\"10th Ave & Pacheco St\",\"10th Ave & Quintara St\",\"1100 Lake Merced Blvd\",\"115 TELEGRAPH Hill Blvd\",\"117 Warren Dr\",\"11th St & Bryant St\",\"11th St & Folsom St\",\"11th St & Harrison St\",\"11th St & Howard St\",\"11th St & Market St\",\"11th St & Mission St\",\"11th St/btw Market & Mission\",\"120 Portola Dr\",\"126 Miraloma Dr\",\"13th St & Gateview Ave\",\"14 Dakota St\",\"14th Avenue & Geary Boulevard\",\"14th Ave & Quintara St\",\"14th Ave & Santiago St\",\"14th Ave & Taraval St\",\"14th Ave & Ulloa St\",\"14th St & Alpine Ter\",\"14th St & Castro St\",\"14th St & Church St\",\"14th St & Mission St\",\"14th St & Noe St\",\"14th St & SANCHEZ ST\",\"14th St & Sanchez St\",\"150 Otis St\",\"15th Ave & Noriega St\",\"15th Ave & Ortega St\",\"15th Ave & Pacheco St\",\"15th Ave & Quintara St\",\"15th Ave & Taraval St\",\"15th Ave & Ulloa St\",\"15th Ave & West Portal Ave\",\"15th St & Mission St\",\"16 th St & South Van Ness\",\"164 Addison St\",\"1650 Geneva Ave\",\"1697 7th Ave\",\"16th Ave & Lawton St\",\"16th Ave & Lomita Ave\",\"16th Ave & Moraga St\",\"16th Ave & Noriega St\",\"16th Ave & Ortega St\",\"16th Ave & Pacheco St\",\"16th Avenue at Lawton Street\",\"16th St & 4th St\",\"16th St & Bryant St\",\"16th St & Church St\",\"16th St & Dolores St\",\"16th St & Folsom St\",\"16th St & Guerrero St\",\"16th St & Harrison St\",\"16th St & Kansas St\",\"16th St & Mission St\",\"16th St & Missouri St\",\"16th St & Potrero Ave\",\"16th St & San Bruno Ave\",\"16th St & Shotwell St\",\"16th St & South Van Ness\",\"16th St & Valencia St\",\"16th St & Vermont St\",\"16th St & Wisconsin St\",\"16th St& Rhode Island St\",\"16th Street & 4th Street\",\"16th Street & Missouri St\",\"16th Street & Rhode Islandi St\",\"16th Street & Wisconsin St\",\"170 Buckingham Way\",\"1701 Geneva Ave\",\"1721 Geneva Ave\",\"1725 Sunnydale Ave\",\"1730 3rd St\",\"1731 3RD ST\",\"1750 Geneva Ave\",\"176 Rhode Island St\",\"1798 Laguna Honda Blvd\",\"17TH ST & KANSAS ST\",\"17th Ave & Quintara St\",\"17th Ave & Rivera St\",\"17th Ave & Santiago St\",\"17th St & Belvedere St\",\"17th St & Castro St\",\"17th St & Clayton St\",\"17th St & Cole St\",\"17th St & De Haro St\",\"17th St & Diamond St\",\"17th St & Kansas St\",\"17th St & Noe St\",\"17th St & Wisconsin St\",\"1800 Sunnydale Ave\",\"18th St & 3rd St\"]}]},{\"layer\": \"subway\",\"count\": 19,\"geometry\": \"Point\",\"attributeCount\": 1,\"attributes\": [{\"attribute\": \"name\",\"count\": 18,\"type\": \"string\",\"values\": [\"Metro Castro Station/Downtown\",\"Metro Castro Station/Outbound\",\"Metro Church Station/Downtown\",\"Metro Church Station/Outbound\",\"Metro Civic Center Station/Downtn\",\"Metro Civic Center Station/Downtown\",\"Metro Civic Center Station/Outbd\",\"Metro Embarcadero Station\",\"Metro Embarcadero Station/Downtown\",\"Metro Forest Hill Station/Downtown\",\"Metro Montgomery Station/Downtown\",\"Metro Montgomery Station/Outbound\",\"Metro Powell Station/Downtown\",\"Metro Powell Station/Outbound\",\"Metro Van Ness Station\",\"Metro Van Ness Station/Downtown\",\"Metro Van Ness Station/Outbound\",\"Van Ness Station Outbound\"]}]}]}", "type": "overlay", "version": "2" }, "features": [ diff --git a/tile-join.cpp b/tile-join.cpp index 361cf06..e43c64d 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -105,15 +105,12 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::map for_tilestats; - if (feat.has_id) { outfeature.has_id = true; outfeature.id = feat.id; } - std::map attributes; - std::map types; + std::map> attributes; std::vector key_order; for (size_t t = 0; t + 1 < feat.tags.size(); t += 2) { @@ -152,15 +149,12 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::map(key, val)); - types.insert(std::pair(key, type)); - key_order.push_back(key); - type_and_string tas; tas.type = type; tas.string = value; - for_tilestats.insert(std::pair(key, tas)); + attributes.insert(std::pair>(key, std::pair(val, tas))); + key_order.push_back(key); } if (header.size() > 0 && strcmp(key, header[0].c_str()) == 0) { @@ -199,37 +193,31 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::map(sjoinkey, outval)); - types.insert(std::pair(sjoinkey, attr_type)); - key_order.push_back(sjoinkey); type_and_string tas; tas.type = outval.type; tas.string = joinval; - for_tilestats.insert(std::pair(joinkey, tas)); + attributes.insert(std::pair>(joinkey, std::pair(outval, tas))); + key_order.push_back(joinkey); } } } } } - // To keep attributes in their original order instead of alphabetical - for (auto k : key_order) { - auto fa = attributes.find(k); - - if (fa != attributes.end()) { - outlayer.tag(outfeature, k, fa->second); - attributes.erase(fa); - } - } - if (matched || !ifmatched) { + // To keep attributes in their original order instead of alphabetical + for (auto k : key_order) { + auto fa = attributes.find(k); + + if (fa != attributes.end()) { + outlayer.tag(outfeature, k, fa->second.first); + add_to_file_keys(file_keys->second.file_keys, k, fa->second.second); + attributes.erase(fa); + } + } + outfeature.type = feat.type; outfeature.geometry = feat.geometry; @@ -243,10 +231,6 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::mapsecond.file_keys, attr.first, attr.second); - } - if (z < file_keys->second.minzoom) { file_keys->second.minzoom = z; } @@ -1004,6 +988,11 @@ int main(int argc, char **argv) { int ifmatched = 0; CPUS = sysconf(_SC_NPROCESSORS_ONLN); + + const char *TIPPECANOE_MAX_THREADS = getenv("TIPPECANOE_MAX_THREADS"); + if (TIPPECANOE_MAX_THREADS != NULL) { + CPUS = atoi(TIPPECANOE_MAX_THREADS); + } if (CPUS < 1) { CPUS = 1; }