Tag Archive for 'Library'

Re-projecting vectors in JavaScript

I know, it eventually all boils down to maths. But it still blows my mind that you can re-project geographic features on-the-fly with a few lines of JavaScript in a web browser.

How?

There is this great library PROJ.4, that does everything you’d ever want in terms of cartographic projections. A few smart people have ported PROJ.4 to JavaScript, called Proj4js then.

Proj4js works great in combination with OpenLayers, a popular JavaScript web mapping framework, and allows on-the-fly projections between any spatial reference systems browser applications.

<script src="proj4js-compressed.js"></script>
<script src="http://openlayers.org/api/OpenLayers.js"></script>

Define the spatial reference you’re planning to use. Check Spatial Reference for the exact projection parameters and include them in your code.

Proj4js.defs["EPSG:26986"] = "+title=Massachusetts Mainland NAD83 +proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";

Adding all desired projections to the OpenLayers script…

projOSM = new OpenLayers.Projection("EPSG:900913");
projWGS84 = new OpenLayers.Projection("EPSG:4326");
projMassGIS = new OpenLayers.Projection("EPSG:26986");

map = new OpenLayers.Map ("map", {
	maxExtent: new OpenLayers.Bounds( -20037508.34, -20037508.34, 20037508.34, 20037508.34),
	maxResolution: 156543.0399,
	units: 'm',
	projection: projOSM,
	displayProjection: projWGS84,
	allOverlays: false
});

osm = new OpenLayers.Layer.OSM(
	"OpenStreetMap",
       "http://tile.openstreetmap.org/${z}/${x}/${y}.png"
);

openspace = new OpenLayers.Layer.WFS("Open space", "http://giswebservices.massgis.state.ma.us/geoserver/wfs", {
	typename: "massgis:GISDATA.OPENSPACE_POLY"
}, {
	projection: projMassGIS
	attribution: "<a href='http://www.mass.gov/mgis/'>MassGIS</a>"
});

…results in an interactive map with MassGIS Open Space WFS vector features overlayed on an OpenStreetMap base layer, using WGS84 lat/lon as display coordinates.

On a sidenote: OpenLayers comes with a Python proxy to retrieve information from remote servers via an XMLHttpRequest. Here is a good how-to get Python play well with IIS 6 on Windows Server 2003, which was quite useful.

Don’t forget to add the domains you’re trying to access to the Python proxy. For MassGIS you would add following string for instance:

allowedHosts = ['giswebservices.massgis.state.ma.us']

The middle of the world

MappariumA fascinating concept: because unhappy with conventional map presentations where every map feature has another distance to the map viewer, the architect Lindsay Churchill turned a globe inside out and put the viewer into the center. The result is the Mapparium, a three-story glass globe, at The Mary Baker Eddy Library in Boston. A must-visit especially for people who like maps and cartography.

The glass surface produces interesting acoustics inside. You can speak to your friend standing at the other end of the room by whispering to the wall, or standing in the center of the globe you’ll hear yourself talking in surround sound. A recommended visit for sound artists and engineers too I’d guess.

The map itself is a historical snapshot of what the world looked like in the nineteen-thirties – Russia is the Soviet Union, Colonies in Africa and Yugoslavia as one country. It’s interesting to see how the political world has changed. Especially at that scale.

Out for a Picnik

m-dorfIt took a TechCrunch post to direct my attention to Picnik, an amazing online photo editor. Among other photo services, it already integrates very well with Flickr using the Flickr authentication API. You can retrieve from Flickr, edit in Picnik and save back to Flickr seamlessly. Apparently the Flickr user interface will get another button soon to make the editing process with Picnik even more easier.

My first thought was that I won’t need iPhoto anymore. Ever since I bought the DSLR I only use iPhoto to manage the snapshots I take with my smaller camera. If I’m going to upload directly from my smaller camera to Flickr and do rudimentary editing like cropping and basic color adjustments there in Picnik, which does an excellent job as I found out last weekend, I could skip iPhoto entirely. The Flickr-Picnik workflow should work at least as good as the workflow in iPhoto.

Technically no problem but there would still be this unpleasant feeling in my stomach region of giving the control over my images totally out of my hands. Stomach says no, so I rather stay some more time with the local iPhoto library as primary library and the Flickr account as secondary “fun” library.

However, Picnik will be a great addition to Flickr and I’m pretty looking forward to it!

Drawing charts

Spicing up your tabular data with some charts and graphs is always a good idea. It helps your users reading and understanding your data better and makes your information system look a bit nicer.

Most systems are judged on the visual impression of their front-end, no matter how strong and complex your database concept might be. So never forget to polish the user interface a bit up before releasing it. Just have a look at some software reviews in Apple forums and you know what I’m talking about.

However, nice designed charts help users to quickly understand what the data is about, you know, a picture is worth a thousand words.

Searching for libraries to dynamically draw charts I came over PlotKit. It looks very interesting and I’ll definitely have a second closer look at it. What I’m wondering is, if you could modify PlotKit in order the get some nice thematic SVG maps drawn. Easy and quick interactive online maps, good usability and no need of setting up an entire mapserver environment.

Since thematic maps basically are sort of charts, graphical elements representing data, it should be possible. Well, I’ll see…

Ha! iTunes 7

Hey, this new flip-through-your-music-collection feature is simply A.M.A.Z.I.N.G!

It almost feels like going through good old large-sized vinyls. The best point is that suddenly it’s possible again to recognize music by its cover art. Great!

I never would’ve thought that cover art can be an such an important part of mp3s. Without cover art this new visual music browsing method would be pretty useless…