MUM2: Day 2
Presentation
The presentation went well, and there was a lot of questions for me at the end of it and at the end of the session. Adena asked how many people I thought were straddling the proprietary-open source boundary and using SDE with MapServer. I responded that I don’t have any idea, but I do get questions somewhat often about how to glue them together…
MapScript
I am in the “Big SWIG of MapScript” session right now and will be listening to Sean give us the skinny on it. Expect more information later…
A Twisted Python implementation of a WMS server from Sean …
import os
import sys
import time
import getopt
import mapscript
# Twisted Python classes for web programming
from twisted.web import server, resource, static
from twisted.internet import reactor
CACHEDIR = './cache'
def usage():
print """Usage: twms.py -m mapfile -p port"""
def main():
# Get options
try:
opts, args = getopt.getopt(sys.argv[1:], ‘m:p:’)
except getopt.GetoptError:
usage()
sys.exit(2)
mapfile = None
port = None
for o, a in opts:
if o == ‘-m’:
mapfile = a
if o == ‘-p’:
port = int(a)
if not (mapfile or port):
usage()
sys.exit(2)
# ======================================================================
# Setup the web application
# Create empty root resource
root = resource.Resource()
# Insert a Twisted WMS Resource at path ‘twms’
root.putChild(’twms’, TwistedWMSResource(mapfile))
# Create a site instance, bind it to a port, and start up the
# Twisted reactor loop
site = server.Site(root)
reactor.listenTCP(port, site)
reactor.run()
# ==========================================================================
# WMS Server resource for Twisted
class TwistedWMSResource(resource.Resource):
“”"Publishes a mapfile as a WMS resource”"”
# Classes deriving from resource.Resource need to implement children.
# This class has no static children.
children = {}
def __init__(self, mapfile):
“”"Object Initialization”"”
# A TwistedWMSResource has a map attribute
self.map = mapscript.mapObj(mapfile)
# Turn on all layers of the map
for i in range(self.map.numlayers):
self.map.getLayer(i).status = mapscript.MS_ON
def getChild(self, path, req):
“”"All WMS requests are treated like dynamic child resources”"”
# Create an OWSRequest instance, like a single-value dictionary
wms_request = mapscript.OWSRequest()
# Push CGI parameters from req.args into the OWSRequest
for param, value in req.args.items():
wms_request.setParameter(param, value[0])
# Clone the master map before executing the request`
tmp_map = self.map.clone()
# The following two statements won’t be needed in 4.2.1
tmp_map.setFontSet(’fonts.txt’)
tmp_map.setSymbolSet(’symbols.txt’)
# Create an OWSRequest instance, like a single-value dictionary
wms_request = mapscript.OWSRequest()
# Push CGI parameters from req.args into the OWSRequest
for param, value in req.args.items():
wms_request.setParameter(param, value[0])
# Map updates its state from OWSRequest
tmp_map.loadOWSParameters(’1.1.1′, wms_request)
# Draw
image = tmp_map.draw()
# Save
cache_name = str(hash(req.uri))
cache_path = os.path.join(CACHEDIR, cache_name)
image.save(cache_path)
# Serve up the map from the image cache location
mimetype = image.format.mimetype
return static.File(cache_path, mimetype)
if __name__ == ‘__main__’:
main()
The Boat Cruise
After the afternoon sessions with Sean, I prepared for the boat
cruise by getting a jacket and catching the bus. The food line
was long and slow, but the beer line was short, and it
necessitated much technical discussion about many subjects.
I spent quite a bit of time hanging out with Frank Warmerdam,
listening to him pontificate on subjects ranging from SCO,
Sun, GeoJP2, the second system effect, developing proprietary
software and the mindset of it, and making it as an independent consultant.
Frank is a very animated and passionate speaker when it comes
to technology issues, he is very good at communicating
his views, and it was fun to listen to him
I also spent some time talking to Norman Vine and Chris Hodgson
discussing using the GPU (video card) for vector math and
transformation operations. Norman says that we should be taking
advantage of all of the computing power we virutally get for
free to do the kinds of things we need to do in geography/GIS
applications. If you think about it, it really makes sense.
He gave me the names of some open source libraries that could
be used to do those kinds of things. For raster data, this
is one area that should really be pursued.
Last November, I purchased a Powerbook G4 for my fiance to use
in her Phd program. When I got it, I was really excited, and I
still love to play with the thing, even though I don’t get
full time with it. After talking to Sean and his MapServer
development with the mac, I am going to make my next machine
a G5. The only piece of software really holding me back is
ArcView 3.x, with which I use for a lot of consulting development.
However, I already have a PC that I can do much of that with,
and I don’t want to limit the rest of my computing experience
just because of one application.