Plotting Auckland with OSMnx

kinow @ Jan 05, 2017 10:39:03 ()

A couple of days ago I saw a thread in reddit about OSMnx. It is a utilty for interacting with the OpenStreeMap (OSM) API, manipulate it in pure Python and using libraries like NetworkX (a Python graph package).

With it you can do things like visualize cul-de-sacs or one-way streets, plot shortest-path routes, or calculate stats like intersection density, average node connectivity, or betweenness centrality. Or simply plot the OSM data as in the graph above.

The source code is hosted at GitHub: https://github.com/gboeing/osmnx.

OSMnx is a Python 2+3 package that lets you download spatial geometries and construct, project, visualize, and analyze street networks from OpenStreetMap’s APIs. Users can download and construct walkable, drivable, or bikable urban networks with a single line of Python code, and then easily analyze and visualize them.

The only issue I found while creating the map for Auckland using the example from the project README, was that the script would exit with the following error: “ValueError: Geometry must be a shapely Polygon or MultiPolygon”.

After looking at the list of dependencies and finding that everything seemed to be OK, I started looking at the project issues. And thankfully someone else had found the same issue and the maintainer of the project answered how to fix it.

The issue was that the OSM API returns two entries for Auckland , where the first one is a Point, and the second is the one that we want (a Polygon). The application defaults to using the first element, so in order to change it you have to give a which_result argument.

#!/usr/bin/env python3

import osmnx as ox
G = ox.graph_from_place('Auckland, NZ', network_type='drive', which_result=2)

And after that, and after waiting a few minutes, you should get your map :-)

Happy hacking!

Drawing Terra Celta vocal Elcio

kinow @ Jan 04, 2017 19:40:03 ()

Terra Celta band‘s vocal, Elcio.

Brazil is not only Samba, there is (good) celtic music in there too :-)

Terra Celta (“Celtic Land”) is a Brazilian Celtic comedy rock band formed in 2005, and based in Londrina, Paraná. They are noted for making Celtic rock in Portuguese language (initially English), with often humorous lyrics. The group performs live with traditional Celtic/Irish clothing. Besides performing Irish music, the members also research the subject, by attending Celtic music festivals in Europe.
Terra Celta vocal Elcio
Terra Celta vocal Elcio


Contributing to Krita

kinow @ Jan 03, 2017 11:40:03 ()

As I mentioned in the last post, I have been learning Qt and using C and C++ again. Since I used C and C++ more during university (about 10 years ago, phew), decided to read real code.

I used Photoshop, Illustrator, and Fireworks a lot when I was younger and had more time to spend drawing. But some time ago I switched to Inkscape for vector graphics, which I use at work for presentations. So it was only natural to try Krita now.

Since I was going to try Krita, I thought why not check out and build from source, and then in case I found any bugs, contribute back? Or maybe from time to time triage issues, find low hanging ones, and send a patch?

Well, turns out the Krita project has a great community, and it is super easy to send contributions. So far I submitted three patches, some were included in 3.x releases.

While the patches are rather small, they are suggestions on how to fix memory segmentation faults, or strange behaviours in the interface. For these issues, I had to learn more about Qt components, signals and emitting events, and, of course, work with pointers, arrays, Qt data structures, etc. In other words, lots of (geek) fun!

In other words, by contributing to Krita, I am not only helping the project and giving a little back to the community, but also refreshing my memory on C and C++, and slowly learning Qt - which is not very hard if you worked with Swing/AWT, Delphi, Visual Basic, Gtk, etc.

What are you waiting to contribute to Krita? The developers that maintain the project answer tickets and questions posted to reddit in a good time, and are extremely easy to work with.

Read more here how to build from source, and here on how to submit patches.

Happy hacking!

Debugging an application that freezes the X server

kinow @ Jan 02, 2017 00:39:03 ()

Some time ago, I decided to start writing C++ again, and picked Krita for that. Krita is written in C++ and Qt. The bug I was working on involved a memory issue when changing the UI.

The problem was that this UI change would result in, not only Krita, but the whole X server freezing. My set up was basically Ubuntu 16.04.1 LTS, with Eclipse, Qt5, and the latest version of Krita checked out via git.

Initially I spent some time looking at the logs, tracing the binary, even downloaded some Qt utility tools to look at the events and what was happening with the application when it froze.

However, eventually I realized I was going to spend more time on this part of the issue, rather than on the memory bug. So decided to look for a work-around.

Thankfully someone else blogged about a similar issue and saved me a lot of time :-) Here’s how I did it, following the instructions in this blog post.

$ sudo apt-get install xnest -y
$ cd krita_install/
$ Xnest :10
$ twm -display :10
$ export DISPLAY=:10
$ ./krita

That’s it. You should have Krita running in a separate window, with Xnest, and within this window the twm window manager running. So when it freezes, at least you can still debug your application in Eclipse or whatever IDE you prefer.

Happy hacking!

Drawing sketch: Uh!

kinow @ Dec 19, 2016 19:40:03 ()


Uh! progress
Uh! progress

And final work here.


For redditgetsdrawn