Use single-quote quoting instead of backslash quoting

This commit is contained in:
Eric Fischer
2019-04-05 11:30:57 -07:00
parent 4f7459c797
commit f95b9bcc65
13 changed files with 32 additions and 17 deletions
+1 -1
View File
@@ -206,7 +206,7 @@ join-test: tile-join
cmp tests/join-population/merged.mbtiles.json.check tests/join-population/merged.mbtiles.json
cmp tests/join-population/windows.mbtiles.json.check tests/join-population/windows.mbtiles.json
rm -f tests/join-population/joined-null.mbtiles tests/join-population/joined-null.mbtiles.json.check
./tile-join -q -f -l macarthur -n "macarthur name" -N "macarthur description" -A "macarthur attribution" -o tests/join-population/just-macarthur.mbtiles tests/join-population/merged.mbtiles
./tile-join -q -f -l macarthur -n "macarthur name" -N "macarthur description" -A "macarthur's attribution" -o tests/join-population/just-macarthur.mbtiles tests/join-population/merged.mbtiles
./tile-join -q -f -L macarthur -o tests/join-population/no-macarthur.mbtiles tests/join-population/merged.mbtiles
./tippecanoe-decode -x generator tests/join-population/just-macarthur.mbtiles > tests/join-population/just-macarthur.mbtiles.json.check
./tippecanoe-decode -x generator tests/join-population/no-macarthur.mbtiles > tests/join-population/no-macarthur.mbtiles.json.check
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@
"center": "-122.299805,37.892187,12",
"description": "tests/join-population/tabblock_06001420.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:Land\\ area -L{\"file\":\\ \"tests/join-population/tabblock_06001420.json\",\\ \"description\":\\ \"population\"}; ./tile-join --quiet --force --no-tile-stats -o tests/join-population/joined-no-tile-stats.mbtiles -x GEOID10 -c tests/join-population/population.csv tests/join-population/tabblock_06001420.mbtiles",
"generator_options": "./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles '-YALAND10:Land area' '-L{\"file\": \"tests/join-population/tabblock_06001420.json\", \"description\": \"population\"}'; ./tile-join --quiet --force --no-tile-stats -o tests/join-population/joined-no-tile-stats.mbtiles -x GEOID10 -c tests/join-population/population.csv tests/join-population/tabblock_06001420.mbtiles",
"json": "{\"vector_layers\": [ { \"id\": \"tabblock_06001420\", \"description\": \"population\", \"minzoom\": 3, \"maxzoom\": 12, \"fields\": {\"ALAND10\": \"Land area\", \"AWATER10\": \"Number\", \"BLOCKCE10\": \"String\", \"COUNTYFP10\": \"String\", \"FUNCSTAT10\": \"String\", \"INTPTLAT10\": \"String\", \"INTPTLON10\": \"String\", \"MTFCC10\": \"String\", \"NAME10\": \"String\", \"STATEFP10\": \"String\", \"TRACTCE10\": \"String\", \"UACE10\": \"String\", \"UATYP10\": \"String\", \"UR10\": \"String\", \"population\": \"Mixed\"} } ]}",
"maxzoom": "12",
"minzoom": "0",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@
"center": "-122.299805,37.892187,12",
"description": "macarthur description",
"format": "pbf",
"generator_options": "./tippecanoe -q -f -Z5 -z10 -o tests/join-population/macarthur.mbtiles -l macarthur tests/join-population/macarthur.json; ./tippecanoe -q -f -d10 -D10 -Z9 -z11 -o tests/join-population/macarthur2.mbtiles -l macarthur tests/join-population/macarthur2.json; ./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:Land\\ area -L{\"file\":\\ \"tests/join-population/tabblock_06001420.json\",\\ \"description\":\\ \"population\"}; ./tile-join -q -f -o tests/join-population/merged.mbtiles tests/join-population/tabblock_06001420.mbtiles tests/join-population/macarthur.mbtiles tests/join-population/macarthur2.mbtiles; ./tile-join -q -f -l macarthur -n macarthur\\ name -N macarthur\\ description -A macarthur\\ attribution -o tests/join-population/just-macarthur.mbtiles tests/join-population/merged.mbtiles",
"generator_options": "./tippecanoe -q -f -Z5 -z10 -o tests/join-population/macarthur.mbtiles -l macarthur tests/join-population/macarthur.json; ./tippecanoe -q -f -d10 -D10 -Z9 -z11 -o tests/join-population/macarthur2.mbtiles -l macarthur tests/join-population/macarthur2.json; ./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles '-YALAND10:Land area' '-L{\"file\": \"tests/join-population/tabblock_06001420.json\", \"description\": \"population\"}'; ./tile-join -q -f -o tests/join-population/merged.mbtiles tests/join-population/tabblock_06001420.mbtiles tests/join-population/macarthur.mbtiles tests/join-population/macarthur2.mbtiles; ./tile-join -q -f -l macarthur -n 'macarthur name' -N 'macarthur description' -A 'macarthur attribution' -o tests/join-population/just-macarthur.mbtiles tests/join-population/merged.mbtiles",
"json": "{\"vector_layers\": [ { \"id\": \"macarthur\", \"description\": \"\", \"minzoom\": 5, \"maxzoom\": 11, \"fields\": {\"FULLNAME\": \"String\", \"LINEARID\": \"String\", \"MTFCC\": \"String\", \"RTTYP\": \"String\"} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"macarthur\",\"count\": 169,\"geometry\": \"LineString\",\"attributeCount\": 4,\"attributes\": [{\"attribute\": \"FULLNAME\",\"count\": 5,\"type\": \"string\",\"values\": [\"Macarthur\",\"Macarthur Blvd\",\"Macarthur Fwy\",\"W Macarthur\",\"W Macarthur Blvd\"]},{\"attribute\": \"LINEARID\",\"count\": 43,\"type\": \"string\",\"values\": [\"1102155930810\",\"1102156217102\",\"1102156241736\",\"1102156248968\",\"1102156510290\",\"1102157509691\",\"1102157651658\",\"1102406970092\",\"1102406970093\",\"1102406970094\",\"1102406970095\",\"1102407366406\",\"1102638069562\",\"1102638078801\",\"1102654601627\",\"1102654601663\",\"1102654602215\",\"1102954189105\",\"1102954918511\",\"1103690383700\",\"1103690474249\",\"1103690474250\",\"1103690483026\",\"1103690483032\",\"1103717593123\",\"1104469713187\",\"1104469713198\",\"1104474748623\",\"1104475134288\",\"1104475134436\",\"1104485605278\",\"1104485645649\",\"1104485773833\",\"1104486090991\",\"1104486392881\",\"1105089436004\",\"1105089465114\",\"1105089465116\",\"1105281275434\",\"1105281275687\",\"1105281275688\",\"1105281275689\",\"1105281275692\"]},{\"attribute\": \"MTFCC\",\"count\": 2,\"type\": \"string\",\"values\": [\"S1100\",\"S1400\"]},{\"attribute\": \"RTTYP\",\"count\": 1,\"type\": \"string\",\"values\": [\"M\"]}]}]}}",
"maxzoom": "12",
"minzoom": "0",
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -3,7 +3,7 @@
"center": "-122.167969,37.828608,10",
"description": "tests/join-population/macarthur2.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -f -Z5 -z10 -o tests/join-population/macarthur.mbtiles -l macarthur1 tests/join-population/macarthur.json; ./tippecanoe -q -f -Z5 -z10 -o tests/join-population/macarthur2.mbtiles -l macarthur2 tests/join-population/macarthur2.json; ./tile-join -q -R macarthur1:one --rename-layer=macarthur2:two -f -o tests/join-population/renamed.mbtiles tests/join-population/macarthur.mbtiles tests/join-population/macarthur2.mbtiles",
"generator_options": "./tippecanoe -q -f -Z5 -z10 -o tests/join-population/macarthur.mbtiles -l macarthur1 tests/join-population/macarthur.json; ./tippecanoe -q -f -Z5 -z10 -o tests/join-population/macarthur2.mbtiles -l macarthur2 tests/join-population/macarthur2.json; ./tile-join -q -R macarthur1:one '--rename-layer=macarthur2:two' -f -o tests/join-population/renamed.mbtiles tests/join-population/macarthur.mbtiles tests/join-population/macarthur2.mbtiles",
"json": "{\"vector_layers\": [ { \"id\": \"one\", \"description\": \"\", \"minzoom\": 5, \"maxzoom\": 10, \"fields\": {\"FULLNAME\": \"String\", \"LINEARID\": \"String\", \"MTFCC\": \"String\", \"RTTYP\": \"String\"} }, { \"id\": \"two\", \"description\": \"\", \"minzoom\": 5, \"maxzoom\": 10, \"fields\": {\"FULLNAME\": \"String\", \"LINEARID\": \"String\", \"MTFCC\": \"String\", \"RTTYP\": \"String\"} } ],\"tilestats\": {\"layerCount\": 2,\"layers\": [{\"layer\": \"one\",\"count\": 90,\"geometry\": \"LineString\",\"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\"]}]},{\"layer\": \"two\",\"count\": 154,\"geometry\": \"LineString\",\"attributeCount\": 4,\"attributes\": [{\"attribute\": \"FULLNAME\",\"count\": 2,\"type\": \"string\",\"values\": [\"Macarthur Blvd\",\"W Macarthur Blvd\"]},{\"attribute\": \"LINEARID\",\"count\": 26,\"type\": \"string\",\"values\": [\"1102156217102\",\"1102156248968\",\"1102157509691\",\"1102406970092\",\"1102406970093\",\"1102406970094\",\"1102406970095\",\"1102407366406\",\"1102638078801\",\"1102954189105\",\"1103717593123\",\"1104469713187\",\"1104469713198\",\"1104475134288\",\"1104475134436\",\"1104485605278\",\"1104485645649\",\"1104485773833\",\"1105089436004\",\"1105089465114\",\"1105089465116\",\"1105281275434\",\"1105281275687\",\"1105281275688\",\"1105281275689\",\"1105281275692\"]},{\"attribute\": \"MTFCC\",\"count\": 1,\"type\": \"string\",\"values\": [\"S1400\"]},{\"attribute\": \"RTTYP\",\"count\": 1,\"type\": \"string\",\"values\": [\"M\"]}]}]}}",
"maxzoom": "10",
"minzoom": "5",
+1 -1
View File
@@ -3,7 +3,7 @@
"center": "0.000000,0.000000,0",
"description": "tests/nonascii/out/-z0.json.check.mbtiles",
"format": "pbf",
"generator_options": "./tippecanoe -q -a@ -f -o tests/nonascii/out/-z0.json.check.mbtiles -z0 tests/nonascii/@@@.json tests/nonascii/堤防.json",
"generator_options": "./tippecanoe -q -a@ -f -o tests/nonascii/out/-z0.json.check.mbtiles -z0 tests/nonascii/@@@.json 'tests/nonascii/堤防.json'",
"json": "{\"vector_layers\": [ { \"id\": \"unknown0\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {} }, { \"id\": \"堤防\", \"description\": \"\", \"minzoom\": 0, \"maxzoom\": 0, \"fields\": {} } ],\"tilestats\": {\"layerCount\": 2,\"layers\": [{\"layer\": \"unknown0\",\"count\": 1,\"geometry\": \"LineString\",\"attributeCount\": 0,\"attributes\": []},{\"layer\": \"堤防\",\"count\": 1,\"geometry\": \"LineString\",\"attributeCount\": 0,\"attributes\": []}]}}",
"maxzoom": "0",
"minzoom": "0",
+18 -3
View File
@@ -138,14 +138,29 @@ std::string format_commandline(int argc, char **argv) {
std::string out;
for (int i = 0; i < argc; i++) {
bool need_quote = false;
for (char *cp = argv[i]; *cp != '\0'; cp++) {
if (*cp == ' ' || *cp == '\\') {
out.push_back('\\');
out.push_back(*cp);
if (!isalpha(*cp) && !isdigit(*cp) &&
*cp != '/' && *cp != '-' && *cp != '_' && *cp != '@' && *cp != ':' &&
*cp != '.' && *cp != '%' && *cp != ',') {
need_quote = true;
break;
}
}
if (need_quote) {
out.push_back('\'');
for (char *cp = argv[i]; *cp != '\0'; cp++) {
if (*cp == '\'') {
out.append("'\"'\"'");
} else {
out.push_back(*cp);
}
}
out.push_back('\'');
} else {
out.append(argv[i]);
}
if (i + 1 < argc) {
out.push_back(' ');