Josh Kjenner
News
December 23, 2010
I have a website!
March 7, 2011
Finally got around to adding this site to Google's indexing. Made a few tweaks to the content while I was at it to (hopefully) tone done the smarminess.
Projects
Metroview
Metroview is an application that visualizes urban data. I initially created Metroview as a submission for the City of Edmonton’s apps4edmonton competition, which was conducted to encourage the use of municipal data made available through the city’s open data initiative. The version I submitted to that competition was pretty rough around the edges, and as a result I didn’t win anything. However, I think the program’s bones are pretty good, so I’ve continued to work on it, most recently adapting it to display the results of Edmonton’s 2010 municipal election.
Metroview screenshot

Metroview is written in Processing. If you’re interested, you can browse the source code at the project’s Google Code page, and run the most recent version of the program in applet form here.
I always get a kick out of a good infographic, so I decided to use the Metroview to create a print summarizing the results of the most recent municipal election. You can see a picture of it hanging on my wall below, and check out a medium-ish-resolution version here.

su2ds
Last updated: December 27, 2010
su2ds is a plug-in for Google Sketchup that facilitates the daylight analysis of buildings by allowing Sketchup to communicate with Daysim (a free, open-source daylight analysis program created by the National Research Council). It uses Sketchup to prepare the inputs necessary for daylight analysis in Daysim, and then displays within Sketchup the datasets generated from this analysis.
Screenshots of Daysim analysis results imported to Sketchup with su2ds

My intent with su2ds was making daylight analysis as easy as possible for the user. Daysim is a state-of-the-art analysis program, but it getting the necessary data in and out of it is a relatively complicated procedure that su2ds simplifies greatly relative to existing options. I’m currently working on an update that will further simplify this process by allowing users to complete a daylight analysis without leaving Sketchup.
Like all Sketchup plug-ins, su2ds is written in Ruby. It relies significantly on code from su2rad, a plug-in developed to export Sketchup geometry to the Radiance rendering program. Its source code is available on the project’s Google Code page.
Misc.
This section of the website is intended to host things I’ve created, found, or developed that other people, via the magic of Google, may one day find useful. Right now it just has a few chunks of Processing code. Maybe one day I’ll add a recipe or something like that.
Douglas-Peucker Processing code
Last updated: December 27, 2010
Metroview gets the data for drawing polls and neighbourhoods from the City of Edmonton’s open data repository. I hope I don’t sound like an ingrate when I say that this data isn’t perfect—specifically, there are areas in which the density of coordinate points is far to great to be useful, and in my program was causing some unpleasant visual artifacts. Thankfully, I discovered the Douglas-Peucker method, which was developed to solve problems like this one. The effects of this algorithm are shown in the picture below.
Image showing effects of Douglas-Peucker method on geographic data. The red dots indicate coordinate points eliminated by the algorithm, while the black dots indicate points that were retained.

I’ve implemented a version of the Douglas-Peucker method in Processing. Because the code is fairly long, instead of reproducing it on this page, I’ve linked to it here.
The code as it’s written takes two inputs: a PVector array of the coordinates that need conditioning, and a value for “epsilon,” which is essentially functions as the threshold the algorithm uses to eliminate points. The lower this parameter is set, the more points will be eliminated, and vice versa.
Polygon area Processing code
Last updated: December 27, 2010
While writing Metroview, I very quickly discovered that it would be useful to know the areas of the various neighbourhoods/polls/wards/etc I was plotting. Having no idea how to do this using actual math, I set about Googling and found something written in C by a guy named Darel Rex Finlay. The version I adapted for Processing can be found below.
Polygon area Processing code
// ----------------------------------------
// calculatePolygonArea
// note: returns area in the same units as are input
// also note: assumes input polygons are traced counter-clockwise
// this is based on an algorithm written in C by Darel Rex Finlay
// see http://www.alienryderflex.com/polygon_area/
// ----------------------------------------
float calculatePolygonArea(PVector[] poly) {
float out = 0;
int j = 0;
// iterate through polygon segments and calculate the area
// between each segment and y-axis
for(int i = 0; i < poly.length; i++) {
j += 1;
if(j==poly.length) j=0;
out += (poly[i].x + poly[j].x) * (poly[j].y - poly[i].y);
} // for
return out;
} // calculatePolygonAreaPoint in polygon Processing code
Last updated: December 27, 2010
If you’re writing an application that is essentially an interactive map, you’re very quickly going to need to know whether or not a set of coordinates is within a given polygon. Trust me, you will. If you’re like me, you probably won’t have any idea how to do this mathwise, and you’ll turn to Google. If you’re very, very similar to me, you’ll turn up this excellent resource from Darel Rex Finlay, and wish it was written in Processing instead of C. At this point, the only difference between you and I will be that you have someone who’s made your wish come true:
Point in polygon Processing code
// ----------------------------------------
// pointInPolygon
// checks if inputted point is within polygon;
// returns true if so, false if not
// this is based on an algorithm written in C by Darel Rex Finlay
// see http://www.alienryderflex.com/polygon/
// ----------------------------------------
boolean pointInPolygon(PVector[] poly, PVector poin) {
int i;
int j = poly.length - 1;
boolean oddNodes = false;
for(i = 0; i < poly.length; i++) {
if(((poly[i].y < poin.y) && (poly[j].y >= poin.y)) ||
((poly[j].y < poin.y) && (poly[i].y >= poin.y))) {
if((poly[i].x + (poin.y - poly[i].y) / (poly[j].y - poly[i].y) * (poly[j].x - poly[i].x)) < poin.x) {
if(oddNodes) {
oddNodes = false;
} else {
oddNodes = true;
} // if
} // if
} // if
j = i;
} // for
return oddNodes;
} // pointInPolygonAbout
As you may have gathered from the header, my name is Josh Kjenner. I created this website for two reasons:
I live in Edmonton, Alberta, Canada, and earn my living researching and performing daylight and energy simulation for a local architectural firm. Outside of work hours (and occasionally within them) I sit on the board of the Alberta Party. In the hours that remain outside of these activities, eating, sleeping, spending time with friends and family, and infrequently cleaning my apartment, I try to find excuses to work on things related to architecture and/or programming.
All material copyright Josh Kjenner, 2010.
Kidding. I have no idea who'd want to copy this.