Creating Isochrones and Isodistances using Googles Direction Search API

Introduction

Isochrone Isochrones are curves of equal travel time from a certain point of origin, another way of saying this would be that an Isochrone is an isoline for travel time, if the weighting factor is changed from time to distance, then the resulting curve is called an Isodistance.

In this post I will present a rough way to create an Isochrone and an Isodistance using google’s directions API.

Read more →

HTML Geolocation and Altitude

HTML5 Geolocation is a feature which allows the browser on a computer or a mobile phone, to acquire the position from the wifi, 2g/3g/4g network or GPS.

The HTML Geolocation API is used to get the geographical position of a user. Since this can compromise user privacy, the position is not available unless the user approves it. The simplest way to use it is through navigator.geolocation object ``` if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition);

Read more →

Classes and Inheritance in EcmaScript 6 (ES6 Harmony)

So if you are a JavaScript geek and haven’t yet heard,(if everyone is listening to ECMA announcements, who’s gonna drink beer :) ) ECMA 6 feature set has been drafted, its feature set is frozen, it is mostly being refined now. You can already program in it and compile it to current JavaScript. The JavaScript frameworks AngularJS and Ember.js will be based on it (with ways to opt out). Again, via cross-compilation.

Read more →

print two-dimensional array in spiral order

So I saw this problem in a book today about printing a 2d matrix in spiral order

Here are two solutions to it

Solution one.

def printSpiralTL(m,x1,y1,x2,y2):
    for i in range(x1,x2):
        print m[y1][i]
    for j in range(y1+1,y2+1):
        print m[j][x2-1]

    if x2-x1 > 0:
        printSpiralBL(m, x1, y1 + 1, x2-1, y2)
    

def printSpiralBL(m,x1,y1,x2,y2):
    for i in range(x2-1,x1-1,-1):
        print m[y2][i]
    for j in range(y2-1,y1-1,-1):
        print m[j][x1]
    if x2-x1 > 0:
        printSpiralTL(m, x1+1, y1, x2, y2-1)
    
m = [
    
    [1, 2, 3, 4], 
    [5, 6, 7, 8],
    [9, 0, 1, 2],   
    [3, 4, 5, 6], 
    [7, 8, 9, 1]
        
    ]

Output:

Read more →