Skip to content

Instantly share code, notes, and snippets.

@sahilshah-rr
Last active February 22, 2016 20:52
Show Gist options
  • Save sahilshah-rr/a1fc50851e058bb638d2 to your computer and use it in GitHub Desktop.
Save sahilshah-rr/a1fc50851e058bb638d2 to your computer and use it in GitHub Desktop.
Walkscore Travel Time API example
Display the source blob
Display the rendered blob
Raw
{
"type":"MultiPolygon",
"coordinates":[
[
[
[
-122.31558423613875,
37.900607735987805
],
[
-122.30711974969768,
37.900607735987805
],
[
-122.29019077681554,
37.88575855934291
],
[
-122.28172629037448,
37.87833397102047
],
[
-122.28172629037448,
37.87090938269802
],
[
-122.26479731749234,
37.85606020605312
],
[
-122.2478683446102,
37.841211029408235
],
[
-122.23093937172806,
37.82636185276334
],
[
-122.222474885287,
37.8189372644409
],
[
-122.222474885287,
37.81151267611845
],
[
-122.21401039884593,
37.804088087796
],
[
-122.21401039884593,
37.79666349947356
],
[
-122.222474885287,
37.78923891115111
],
[
-122.23940385816913,
37.78923891115111
],
[
-122.2478683446102,
37.78923891115111
],
[
-122.25633283105127,
37.79666349947356
],
[
-122.26479731749234,
37.79666349947356
],
[
-122.27326180393341,
37.78923891115111
],
[
-122.29019077681554,
37.78923891115111
],
[
-122.2986552632566,
37.781814322828666
],
[
-122.31558423613875,
37.781814322828666
],
[
-122.32404872257982,
37.78923891115111
],
[
-122.33251320902089,
37.78923891115111
],
[
-122.34097769546194,
37.79666349947356
],
[
-122.34944218190302,
37.79666349947356
],
[
-122.36637115478516,
37.781814322828666
],
[
-122.36637115478516,
37.76696514618377
],
[
-122.36637115478516,
37.75954055786133
],
[
-122.35790666834409,
37.752115969538885
],
[
-122.35790666834409,
37.744691381216434
],
[
-122.34944218190302,
37.73726679289399
],
[
-122.34944218190302,
37.722417616249096
],
[
-122.35790666834409,
37.71499302792665
],
[
-122.35790666834409,
37.70756843960421
],
[
-122.36637115478516,
37.70014385128176
],
[
-122.36637115478516,
37.68529467463687
],
[
-122.35790666834409,
37.67787008631442
],
[
-122.35790666834409,
37.67044549799198
],
[
-122.37483564122623,
37.65559632134708
],
[
-122.3833001276673,
37.64817173302464
],
[
-122.3833001276673,
37.64074714470219
],
[
-122.39176461410837,
37.633322556379746
],
[
-122.39176461410837,
37.6258979680573
],
[
-122.40022910054942,
37.61847337973485
],
[
-122.4086935869905,
37.61847337973485
],
[
-122.42562255987264,
37.633322556379746
],
[
-122.42562255987264,
37.64817173302464
],
[
-122.4340870463137,
37.65559632134708
],
[
-122.42562255987264,
37.663020909669534
],
[
-122.42562255987264,
37.67044549799198
],
[
-122.41715807343157,
37.67787008631442
],
[
-122.4340870463137,
37.692719262959315
],
[
-122.44255153275478,
37.692719262959315
],
[
-122.44255153275478,
37.67787008631442
],
[
-122.44255153275478,
37.663020909669534
],
[
-122.4340870463137,
37.65559632134708
],
[
-122.4340870463137,
37.64817173302464
],
[
-122.45101601919583,
37.633322556379746
],
[
-122.4594805056369,
37.64074714470219
],
[
-122.46794499207797,
37.64074714470219
],
[
-122.47640947851905,
37.64817173302464
],
[
-122.49333845140119,
37.64817173302464
],
[
-122.50180293784226,
37.65559632134708
],
[
-122.50180293784226,
37.67044549799198
],
[
-122.50180293784226,
37.68529467463687
],
[
-122.51026742428331,
37.692719262959315
],
[
-122.51026742428331,
37.70756843960421
],
[
-122.51026742428331,
37.722417616249096
],
[
-122.51026742428331,
37.72984220457155
],
[
-122.49333845140119,
37.744691381216434
],
[
-122.50180293784226,
37.744691381216434
],
[
-122.51873191072438,
37.75954055786133
],
[
-122.51873191072438,
37.77438973450622
],
[
-122.51026742428331,
37.781814322828666
],
[
-122.51026742428331,
37.78923891115111
],
[
-122.50180293784226,
37.79666349947356
],
[
-122.50180293784226,
37.81151267611845
],
[
-122.49333845140119,
37.8189372644409
],
[
-122.49333845140119,
37.833786441085785
],
[
-122.48487396496012,
37.841211029408235
],
[
-122.47640947851905,
37.841211029408235
],
[
-122.46794499207797,
37.833786441085785
],
[
-122.46794499207797,
37.82636185276334
],
[
-122.45101601919583,
37.82636185276334
],
[
-122.4340870463137,
37.82636185276334
],
[
-122.41715807343157,
37.82636185276334
],
[
-122.40022910054942,
37.82636185276334
],
[
-122.39176461410837,
37.8189372644409
],
[
-122.39176461410837,
37.82636185276334
],
[
-122.3833001276673,
37.833786441085785
],
[
-122.37483564122623,
37.833786441085785
],
[
-122.36637115478516,
37.841211029408235
],
[
-122.35790666834409,
37.833786441085785
],
[
-122.34944218190302,
37.833786441085785
],
[
-122.34097769546194,
37.841211029408235
],
[
-122.33251320902089,
37.841211029408235
],
[
-122.32404872257982,
37.84863561773068
],
[
-122.32404872257982,
37.86348479437557
],
[
-122.32404872257982,
37.87833397102047
],
[
-122.32404872257982,
37.893183147665354
],
[
-122.31558423613875,
37.900607735987805
]
]
]
]
}
http://api2.walkscore.com/api/v1/traveltime_polygon/json?wsapikey=<OUR_API_KEY>&origin=37.781321%2C-122.395843&mode=drive&time=30&congestion=1
{
"status":"OK",
"response":{
"origin":"37.781321,-122.395843",
"geometry":{
"type":"MultiPolygon",
"coordinates":[
[
[
[
-122.31558423613875,
37.900607735987805
],
[
-122.30711974969768,
37.900607735987805
],
[
-122.29019077681554,
37.88575855934291
],
[
-122.28172629037448,
37.87833397102047
],
[
-122.28172629037448,
37.87090938269802
],
[
-122.26479731749234,
37.85606020605312
],
[
-122.2478683446102,
37.841211029408235
],
[
-122.23093937172806,
37.82636185276334
],
[
-122.222474885287,
37.8189372644409
],
[
-122.222474885287,
37.81151267611845
],
[
-122.21401039884593,
37.804088087796
],
[
-122.21401039884593,
37.79666349947356
],
[
-122.222474885287,
37.78923891115111
],
[
-122.23940385816913,
37.78923891115111
],
[
-122.2478683446102,
37.78923891115111
],
[
-122.25633283105127,
37.79666349947356
],
[
-122.26479731749234,
37.79666349947356
],
[
-122.27326180393341,
37.78923891115111
],
[
-122.29019077681554,
37.78923891115111
],
[
-122.2986552632566,
37.781814322828666
],
[
-122.31558423613875,
37.781814322828666
],
[
-122.32404872257982,
37.78923891115111
],
[
-122.33251320902089,
37.78923891115111
],
[
-122.34097769546194,
37.79666349947356
],
[
-122.34944218190302,
37.79666349947356
],
[
-122.36637115478516,
37.781814322828666
],
[
-122.36637115478516,
37.76696514618377
],
[
-122.36637115478516,
37.75954055786133
],
[
-122.35790666834409,
37.752115969538885
],
[
-122.35790666834409,
37.744691381216434
],
[
-122.34944218190302,
37.73726679289399
],
[
-122.34944218190302,
37.722417616249096
],
[
-122.35790666834409,
37.71499302792665
],
[
-122.35790666834409,
37.70756843960421
],
[
-122.36637115478516,
37.70014385128176
],
[
-122.36637115478516,
37.68529467463687
],
[
-122.35790666834409,
37.67787008631442
],
[
-122.35790666834409,
37.67044549799198
],
[
-122.37483564122623,
37.65559632134708
],
[
-122.3833001276673,
37.64817173302464
],
[
-122.3833001276673,
37.64074714470219
],
[
-122.39176461410837,
37.633322556379746
],
[
-122.39176461410837,
37.6258979680573
],
[
-122.40022910054942,
37.61847337973485
],
[
-122.4086935869905,
37.61847337973485
],
[
-122.42562255987264,
37.633322556379746
],
[
-122.42562255987264,
37.64817173302464
],
[
-122.4340870463137,
37.65559632134708
],
[
-122.42562255987264,
37.663020909669534
],
[
-122.42562255987264,
37.67044549799198
],
[
-122.41715807343157,
37.67787008631442
],
[
-122.4340870463137,
37.692719262959315
],
[
-122.44255153275478,
37.692719262959315
],
[
-122.44255153275478,
37.67787008631442
],
[
-122.44255153275478,
37.663020909669534
],
[
-122.4340870463137,
37.65559632134708
],
[
-122.4340870463137,
37.64817173302464
],
[
-122.45101601919583,
37.633322556379746
],
[
-122.4594805056369,
37.64074714470219
],
[
-122.46794499207797,
37.64074714470219
],
[
-122.47640947851905,
37.64817173302464
],
[
-122.49333845140119,
37.64817173302464
],
[
-122.50180293784226,
37.65559632134708
],
[
-122.50180293784226,
37.67044549799198
],
[
-122.50180293784226,
37.68529467463687
],
[
-122.51026742428331,
37.692719262959315
],
[
-122.51026742428331,
37.70756843960421
],
[
-122.51026742428331,
37.722417616249096
],
[
-122.51026742428331,
37.72984220457155
],
[
-122.49333845140119,
37.744691381216434
],
[
-122.50180293784226,
37.744691381216434
],
[
-122.51873191072438,
37.75954055786133
],
[
-122.51873191072438,
37.77438973450622
],
[
-122.51026742428331,
37.781814322828666
],
[
-122.51026742428331,
37.78923891115111
],
[
-122.50180293784226,
37.79666349947356
],
[
-122.50180293784226,
37.81151267611845
],
[
-122.49333845140119,
37.8189372644409
],
[
-122.49333845140119,
37.833786441085785
],
[
-122.48487396496012,
37.841211029408235
],
[
-122.47640947851905,
37.841211029408235
],
[
-122.46794499207797,
37.833786441085785
],
[
-122.46794499207797,
37.82636185276334
],
[
-122.45101601919583,
37.82636185276334
],
[
-122.4340870463137,
37.82636185276334
],
[
-122.41715807343157,
37.82636185276334
],
[
-122.40022910054942,
37.82636185276334
],
[
-122.39176461410837,
37.8189372644409
],
[
-122.39176461410837,
37.82636185276334
],
[
-122.3833001276673,
37.833786441085785
],
[
-122.37483564122623,
37.833786441085785
],
[
-122.36637115478516,
37.841211029408235
],
[
-122.35790666834409,
37.833786441085785
],
[
-122.34944218190302,
37.833786441085785
],
[
-122.34097769546194,
37.841211029408235
],
[
-122.33251320902089,
37.841211029408235
],
[
-122.32404872257982,
37.84863561773068
],
[
-122.32404872257982,
37.86348479437557
],
[
-122.32404872257982,
37.87833397102047
],
[
-122.32404872257982,
37.893183147665354
],
[
-122.31558423613875,
37.900607735987805
]
]
]
]
},
"mode":"drive",
"precision":3,
"time":30
}
}
SELECT ST_IsValid(
ST_GeomFromGeoJSON(
'{"type":"MultiPolygon","coordinates":[[[[-122.315584236139,37.9006077359878],[-122.307119749698,37.9006077359878],[-122.290190776816,37.8857585593429],[-122.281726290374,37.8783339710205],[-122.281726290374,37.870909382698],[-122.264797317492,37.8560602060531],[-122.24786834461,37.8412110294082],[-122.230939371728,37.8263618527633],[-122.222474885287,37.8189372644409],[-122.222474885287,37.8115126761184],[-122.214010398846,37.804088087796],[-122.214010398846,37.7966634994736],[-122.222474885287,37.7892389111511],[-122.239403858169,37.7892389111511],[-122.24786834461,37.7892389111511],[-122.256332831051,37.7966634994736],[-122.264797317492,37.7966634994736],[-122.273261803933,37.7892389111511],[-122.290190776816,37.7892389111511],[-122.298655263257,37.7818143228287],[-122.315584236139,37.7818143228287],[-122.32404872258,37.7892389111511],[-122.332513209021,37.7892389111511],[-122.340977695462,37.7966634994736],[-122.349442181903,37.7966634994736],[-122.366371154785,37.7818143228287],[-122.366371154785,37.7669651461838],[-122.366371154785,37.7595405578613],[-122.357906668344,37.7521159695389],[-122.357906668344,37.7446913812164],[-122.349442181903,37.737266792894],[-122.349442181903,37.7224176162491],[-122.357906668344,37.7149930279267],[-122.357906668344,37.7075684396042],[-122.366371154785,37.7001438512818],[-122.366371154785,37.6852946746369],[-122.357906668344,37.6778700863144],[-122.357906668344,37.670445497992],[-122.374835641226,37.6555963213471],[-122.383300127667,37.6481717330246],[-122.383300127667,37.6407471447022],[-122.391764614108,37.6333225563797],[-122.391764614108,37.6258979680573],[-122.400229100549,37.6184733797349],[-122.40869358699,37.6184733797349],[-122.425622559873,37.6333225563797],[-122.425622559873,37.6481717330246],[-122.434087046314,37.6555963213471],[-122.425622559873,37.6630209096695],[-122.425622559873,37.670445497992],[-122.417158073432,37.6778700863144],[-122.434087046314,37.6927192629593],[-122.442551532755,37.6927192629593],[-122.442551532755,37.6778700863144],[-122.442551532755,37.6630209096695],[-122.434087046314,37.6555963213471],[-122.434087046314,37.6481717330246],[-122.451016019196,37.6333225563797],[-122.459480505637,37.6407471447022],[-122.467944992078,37.6407471447022],[-122.476409478519,37.6481717330246],[-122.493338451401,37.6481717330246],[-122.501802937842,37.6555963213471],[-122.501802937842,37.670445497992],[-122.501802937842,37.6852946746369],[-122.510267424283,37.6927192629593],[-122.510267424283,37.7075684396042],[-122.510267424283,37.7224176162491],[-122.510267424283,37.7298422045715],[-122.493338451401,37.7446913812164],[-122.501802937842,37.7446913812164],[-122.518731910724,37.7595405578613],[-122.518731910724,37.7743897345062],[-122.510267424283,37.7818143228287],[-122.510267424283,37.7892389111511],[-122.501802937842,37.7966634994736],[-122.501802937842,37.8115126761184],[-122.493338451401,37.8189372644409],[-122.493338451401,37.8337864410858],[-122.48487396496,37.8412110294082],[-122.476409478519,37.8412110294082],[-122.467944992078,37.8337864410858],[-122.467944992078,37.8263618527633],[-122.451016019196,37.8263618527633],[-122.434087046314,37.8263618527633],[-122.417158073432,37.8263618527633],[-122.400229100549,37.8263618527633],[-122.391764614108,37.8189372644409],[-122.391764614108,37.8263618527633],[-122.383300127667,37.8337864410858],[-122.374835641226,37.8337864410858],[-122.366371154785,37.8412110294082],[-122.357906668344,37.8337864410858],[-122.349442181903,37.8337864410858],[-122.340977695462,37.8412110294082],[-122.332513209021,37.8412110294082],[-122.32404872258,37.8486356177307],[-122.32404872258,37.8634847943756],[-122.32404872258,37.8783339710205],[-122.32404872258,37.8931831476654],[-122.315584236139,37.9006077359878]]]]}'
)
);
NOTICE: 00000: Ring Self-intersection at or near point -122.434087046314 37.655596321347097
LOCATION: pg_notice, lwgeom_pg.c:179
st_isvalid
────────────
f
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment