Archive for July, 2007

Disaster Steak

(preamble: if you know me well enough, you’ll know that I use the term “disaster” in multiple modes / contexts. In this case, “disaster steak” is a good thing).

the beginning

This was a steak night. I had some friends over this weekend and sparked up the BBQ. I picked up some (big) sirloin steaks from Costco, made sure beer was stocked and away I went. Here’s how one makes a simple steak to die for:

  • wash down steaks with cold water
  • place steaks in a large bowl
  • douse steaks with balsamic vinegar (white or red) and rub
  • douse steaks with olive oil and rub
  • sprinkle steaks with Montreal steak spice (you can make your own if you really want)
  • seal the bowl and place in the fridge for an hour or so to let the steaks marinate
  • heat up the BBQ and slap on the steaks (N.B. have booze, appetizers, both, or whatever you want along the way — it’s always better than everyone just sitting there watching [and waiting]!)

appetizerson the BBQ

  • cook steaks as desired (I like mine _well_ done)
  • serve and enjoy!

bon appetite!

Click on any of the photos to see the whole process in pictures. Pretty simple, not much fuss and tastes awesome — disaster!

Anyone have any pointers or other ideas? I’d be glad to hear them!

MacBook, baby

I cashed in some Aeroplan points and decided to pick up a MacBook. Now I have to wait for the Aeroplan redemption to arrive via postal mail (they have security codes which have to be physically issued / used, so can’t do it until then), and then I’m in. I should have it sometime this week, at which point I’ll post my experiences.

I currently use FC7 at home, and have always been intrigued by Macs, so I’m looking forward to this! Until then, any advice / helpers / lessons learned out there would be great!

OWSlib and mapscript

My first major code contribution to MapServer was a server side implementation of OWS Common 1.0.0. For those who are not aware, OWS Common is a specification which unifies common XML constructs, etc. used by OGC specifications, such as Capabilities metadata, exception reports and bounding box encodings. The benefit of OWS Common is that specifications, and subsequently server implementations, can focus on their core specific functionality while leveraging the common bits.

A good example here is MapServer’s SOS server support, which leverages mapowscommon.c, making mapogcsos.c alot lighter as a result. Client implementations can additionally write OWS Common parsers as reusable functionality which they can then use when writing their, say, WFS and SOS clients. I really believe that this is a benefit for those developing SDI components (i.e. why should contact information be encoded differently for WMS and WFS, really?); just imagine the reduction in code as a result of OWS Common!

Sean recently pointed me to OWSlib, a python lib for working with OGC Web Services. I initially thought it would be great to write an OWS Common client / parser for OWSlib, so that when WFS 1.1.0 and SOS 1.0.0 clients are developed, they can use an OWS Common class between them.

But then I thought why not just implement this in MapServer, and have the functionality exposed via mapscript?

Reprojecting in Python

My previous post declared my plugging my nose and jumping into Python GIS stuff. Advice and info from Sean have been valuable in getting familiar with things, though I’ll be the first to admit I’m still green (writing Python like a Perl / C hack 🙂 ).

So here’s one of my first attempts at solving a real world problem: reprojecting a bunch of points from a CSV file:

#!/usr/bin/python
import sys
import mapscript

if (len(sys.argv) == 1):
	print sys.argv[0] + " <csvfile>"
	sys.exit(1)
else:
	projInObj  = mapscript.projectionObj("init=epsg:32619")
	projOutObj = mapscript.projectionObj("init=epsg:4326")
	print "id,geom,zone"
	f = open(sys.argv[1], 'r')
	for line in f:
		s = line.strip()
		k = s.split(",")
		wkt = "POINT(" + k[1] + " " + k[2] + ")"
		shape = mapscript.shapeObj.fromWKT(wkt) # man, I love WKT!!
		shape.project(projInObj, projOutObj)
		print k[0] + "," + shape.toWKT() + "," + k[3]
	f.close()

And that’s it! So now you can take the CSV output with the geometry encoded as WKT and hook it up to MapServer with some simple OGR OVF syntax in your mapfile:

CONNECTIONTYPE OGR
CONNECTION "<OGRVRTDataSource>
<OGRVRTLayer name='nb'>
<SrcDataSource>./nb.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<GeometryField encoding='WKT' field='geom'/>
</OGRVRTLayer>
</OGRVRTDataSource>"

Mind you, you might question why to reproject when MapServer can do this for you, but I digress. There’s probably more eloquent ways to do this than what’s been done above via mapscript, eh?

Modified: 14 July 2007 18:41:57 EST