3 ms·
Huh, the "carto" service this calls out to seems a bit interesting. Surely someone else has noticed this... Specifically the part where https://amtk.carto.co
by exikyut 8y ago
Huh, the "carto" service this calls out to seems a bit interesting. Surely someone else has noticed this...
Specifically the part where
https://amtk.carto.com/api/v1/map?stat_tag=API&config=%7B%22version%22%3A%221.3.0%22%2C%22stat_tag%22%3A%22API%22%2C%22layers%22%3A%5B%7B%22type%22%3A%22cartodb%22%2C%22options%22%3A%7B%22sql%22%3A%22SELECT%20*%20FROM%20national_route_shape_v16%22%2C%22cartocss%22%3A%22%23layer%20%7Bline-color%3A%20%23FF031D%3Bline-width%3A%202%3B%7D%22%2C%22cartocss_version%22%3A%222.1.0%22%7D%7D%5D%7D&callback=_cdbc_2486699862_1 https://amtk.carto.com/api/v1/map?stat_tag=API&config=%7B%22... is a URL-encoded request for the following encoded JSON:
https://amtk.carto.com/api/v1/map?stat_tag=API&config={
"version":"1.3.0",
"stat_tag":"API",
"layers": [{
"type":"cartodb",
"options":{
"sql": "SELECT * FROM national_route_shape_v16",
"cartocss": "#layer {line-color: #FF031D;line-width: 2;}",
"cartocss_version": "2.1.0"
}
}]
}
In case you don't see it:
SELECT * FROM ...
It does seem to be going through some mangling and parsing however. Carto's website doesn't look like it's from 1994, so my guess is that Someone™ read a book on "rapid-turnaround web development" upside down a few years ago, and now the current devs have to live with some poor decisions (raw SQL as form input) for the sake of legacy compatibility.
This being said, the error messages are quite fun:
> SELECT version();
{"errors":["Postgis Plugin: ERROR: column \"the_geom_webmercator\" does not exist\nLINE 1: ...ECT ST_AsTWKB(ST_Simplify(ST_RemoveRepeatedPoints(\"the_geom_...\n ^\nin executeQuery Full sql was: 'SELECT ST_AsTWKB(ST_Simplify(ST_RemoveRepeatedPoints(\"the_geom_webmercator\",1e-05),1e-05,true),5) AS geom FROM (SELECT version()) as cdbq WHERE \"the_geom_webmercator\" && ST_SetSRID('BOX3D(-20037508.3 20037508.25881302,-20037508.25881302 20037508.3)'::box3d, 3857)'\n"],"errors_with_context":[{"type":"layer","message":"Postgis Plugin: ERROR: column \"the_geom_webmercator\" does not exist\nLINE 1: ...ECT ST_AsTWKB(ST_Simplify(ST_RemoveRepeatedPoints(\"the_geom_...\n ^\nin executeQuery Full sql was: 'SELECT ST_AsTWKB(ST_Simplify(ST_RemoveRepeatedPoints(\"the_geom_webmercator\",1e-05),1e-05,true),5) AS geom FROM (SELECT version()) as cdbq WHERE \"the_geom_webmercator\" && ST_SetSRID('BOX3D(-20037508.3 20037508.25881302,-20037508.25881302 20037508.3)'::box3d, 3857)'\n","subtype":"query","layer":{"id":"layer0","index":0,"type":"mapnik"}}]}
The ">" prompt above is from this 4-second hacky script to make a shell:
tput reset; while true; do read -p '> ' x; echo '{"version":"1.3.0","stat_tag":"API","layers":[{"type":"cartodb","options":{"sql":"'"$x"'","cartocss":"#layer {line-color: #FF031D;line-width: 2;}","cartocss_version":"2.1.0"}}]}' | curl "https://amtk.carto.com/api/v1/map?stat_tag=API&config=$(php -r 'print urlencode(fgets(STDIN));')"; echo; done