Skip to content

Instantly share code, notes, and snippets.

Javier de la Torre jatorre

Block or report user

Report or block jatorre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>OpenLayers – Vector tiles – Points aggregation | CARTO</title>
<link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>
<script src="https://openlayers.org/en/v4.6.4/examples/resources/mapbox-streets-v6-style.js"></script>
<style>
@jatorre
jatorre / README.md
Last active Jan 11, 2018
Example Mapbox + CARTO map using Vector Tiles
View README.md

Example Usage of CARTO Vector Tiles with MapboxGL

This example showcase how to simply use the new capabilities of CARTO for producing Mapbox Vector Tiles from its Maps API.

@jatorre
jatorre / readshp.py
Created Apr 24, 2011
A python script to detect encoding and SRID of a shapefile GUESSING its best
View readshp.py
from chardet.universaldetector import UniversalDetector
import os.path
import sys
import dbfUtils
import sys
from osgeo import osr
from urllib import urlencode
from urllib2 import urlopen
import json
@jatorre
jatorre / carto-basemap.json
Last active Jun 8, 2017
Testing CARTO Vector Tiles
View carto-basemap.json
{
"tiles": ["https://cartobase-a.global.ssl.fastly.net/omtvector/{z}/{x}/{y}.vt?api_key=de0f3965167a84e25fb5573409f071e7406619ef",
"https://cartobase-b.global.ssl.fastly.net/omtvector/{z}/{x}/{y}.vt?api_key=de0f3965167a84e25fb5573409f071e7406619ef",
"https://cartobase-c.global.ssl.fastly.net/omtvector/{z}/{x}/{y}.vt?api_key=de0f3965167a84e25fb5573409f071e7406619ef",
"https://cartobase-d.global.ssl.fastly.net/omtvector/{z}/{x}/{y}.vt?api_key=de0f3965167a84e25fb5573409f071e7406619ef"],
"name": "CARTO Map Tiles",
"format": "pbf",
"basename": "v3.5.mbtiles",
"id": "openmaptiles",
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-beta.2/leaflet.css">
<link rel="stylesheet" href="https://erasermap.com/css/main.css">
</head>
<body>
@jatorre
jatorre / gist:3892665
Created Oct 15, 2012
How to do many updates in a single query WAY faster
View gist:3892665
UPDATE counties_results o SET pres_dem_pct = n.pres_dem_pct, pres_gop_pct = n.pres_gop_pct,
pres_oth_pct = n.pres_oth_pct, pres_pctrpt = n.pres_pctrpt
FROM ( VALUES
(48.51, 39.69, 11.8, 100, 'AK', '02000'),
(51.65, 41.67, 6.68, 100 , 'AL' , '01001' ),
(52.14, 42.4, 5.46, 100 , 'AL' , '01003' ),
(51.94, 42.24, 5.82, 100 , 'AL' , '01005' ),
(60.28, 34.95, 4.76, 100 , 'AL' , '01007' ),
(53.19, 42.04, 4.77, 100 , 'AL' , '01009' ),
(45.07, 50.85, 4.08, 100 , 'AL' , '01011' ),
@jatorre
jatorre / gist:7401056
Created Nov 10, 2013
Removing the requirement for xml support on resolving tables function
View gist:7401056
-- Return an array of table names scanned by a given query
--
-- Requires PostgreSQL 9.x+
--
CREATE OR REPLACE FUNCTION CDB_QueryTables(query text)
RETURNS name[]
AS $$
DECLARE
exp JSON;
tables NAME[];
View gist:7336704
WITH summary_groups as(
WITH summary as (
select (row_number() over (order by time asc nulls last)+1)/2 as rownum,time
from sensor_log_2013_10_27_12_01
order by time asc)
SELECT
max(time) OVER(PARTITION BY rownum) -
min(time) OVER(PARTITION BY rownum) diff
FROM summary)
@jatorre
jatorre / gist:7210438
Created Oct 29, 2013
Geocoder/Reverse geocoder inside SQL
View gist:7210438
CREATE TYPE geocode_response AS (match_level text, latitude float, longitude float, address text, the_geom geometry);
CREATE OR REPLACE FUNCTION cdb_geocode(text) RETURNS SETOF geocode_response
AS $$ DECLARE
token text :='xxxx';
app_id text :='xxxx';
BEGIN
RETURN QUERY WITH geocode_response AS (
SELECT status, content_type,
content::json->'Response'->'View'->0->'Result'->0 as geocode_result
View gist:6623354
curl 'http://sz2.cartodb.com/tiles/layergroup' -H 'Pragma: no-cache' -H 'Origin: http://gfx.sueddeutsche.de' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: sz2.cartodb.com' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.37 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Referer: http://gfx.sueddeutsche.de/politik/2013-09-15_LandtagswahlBayernWahlkarte/' -H 'Connection: keep-alive' --data-binary '{"version":"1.0.1","stat_tag":"f8515466-04da-11e3-ad81-938373fbfdcf","layers":[{"type":"cartodb","options":{"sql":"Select * FROM wahlen_by_2013","cartocss":"#wahlen_by_2013{ polygon-fill: #dedcd0; line-opacity: 1; polygon-comp-op: multiply; line-width: .5; line-color: #fff; polygon-opacity: 0;} ","cartocss_version":"2.1.0","interactivity":["cartodb_id"]}},{"type":"cartodb","options":{"sql":"Select * FROM wahle
You can’t perform that action at this time.