Thursday, January 15, 2015

My git book

I think my git book in Croatian (LaTeX source here) can be now considered "finished". It started from a short document with the most basic git commands to help friends moving to git (from SVN and TFS). But as they kept asking me questions I was adding more and more content to the document. After a few months it had more than 60 pages of text, so I decided to make it a real book. It is now more than 150 pages, and it is (AFAIK) the only git introduction book in Croatian (and Bosnian and Serbian, since our languages are more like dialects than real languages).

The book is open source (Creative Commons Attribution-ShareAlike 3.0), and after more than 3 years from the initial commit more than 20 people helped me with patches and suggestions. Thank you all!

Wednesday, November 5, 2014

srtm.py and srtm.go

I just released go-elevations, it is a golang parser for the Shuttle Radar Topography Mission elevation data (SRTM).

In simpler words, it is a library which can give you a elevation for every point on Earth. At least, if the SRTM dataset is accurate.

Usage:

package main

import (
    "fmt"

    "github.com/tkrajina/go-elevations/geoelevations"
)

func main() {
    srtm, err := geoelevations.NewSrtm()
    if err != nil {
        panic(err.Error())
    }
    elevation, err := srtm.GetElevation(45.2775, 13.726111)
    if err != nil {
        panic(err.Error())
    }
    fmt.Println("ViĆĄnjan elevation is", elevation)
}
It is based on my previous srtm.py (python). And there is also a Ruby port.

Thursday, May 22, 2014

Leaflet editable polyline

I just rewrote my online GPS editing app to use leaflet and OSM layers instead of google map. One of the most difficult part was editable polylines. Leaflet already has support for editable polylines, but their performance deteriorates badly when the number of points reaches thousands.

That's why I wrote leaflet-editable-polylines. 

How it works? It doesn't show the editable markers until you zoom close enough. (That was the original problem, too many markers with too many event handlers to handle all the time). 

Check here for an example with 20,000 points.

Friday, February 28, 2014

OpenStreetMap TileStitcher

Another small Python geo utility library is ready. It is called OpenStreetMap TileStitcher.

The problem it solves is the following: You have an area on the Earth, and you want to have a continuous image of it. You can retrieve tiles (tiles are square images shown in various mapping webapps, like google maps, bing maps, or OSM), but you need to merge them and crop to your desired area.

OSM TileStitcher will do that for you.

Example:
slipy_map = mod_tilestitcher.SlippyMapTiles()
image = slipy_map.get_image((45.2775, 46.3785), (13.5261, 14.9271), 200, 200)
image.show()
More information in the README.

Friday, February 14, 2014

Echo http requests

At my previous workplace I had a problem when testing some API calls. The workflow is as follows:
  • The user registers his url (callback)
  • When an event happens we call his callback url
Now, this is all simple, but when testing it I need a publicly available (callback) url. But I have a private IP address and I'm behind a firewall. Now, having a new web server just to test if we received some https requests is complicated.

That's how Echo http requests is born. It is a very simple appengine application (in Python, source here). You just create a random string give somebody an url like http://echo-http-requests.appspot.com/push/YOUR_RANDOM_STRING_HERE. 

Later, you can retrieve all the requests received on that url with http://echo-http-requests.appspot.com/pull/YOUR_RANDOM_STRING_HERE .

The result is a simple JSON structure with all the headers, http method and body. 

In addition, you can use http://echo-http-requests.appspot.com/echo to get information about your own request.

BTW, Echo-http-requests is free, but... It runs on a free appengine quota. If your usage is too heavy, please download the code and run your own instance.