I've patched up some bugs to MapThing 1.2 (which I never got around to releasing anyway) and have added some performance-related enhancements.
In particular, MapThing objects can now be serialised -- this allows sketches using large numbers of files, or files containing complex geometries, to be loaded much more quickly from Java serialisation (.ser) files. I'll eventually add an example, but you'll currently need to write the code to do this yourself. That said, it's only a few lines and is quite straightforward.
However, serialisation does one very BAD THING: the connection to the underlying shape file is lost because the GT classes that underpin shape file reading and writing do not themselves support serialisation. This means that the data
cannot be reprojected on to the screen. So if you (re)launch the sketch at a different resolution or size from the one in use when the data was first serialised then it will most likely be
mis-projected.
In effect, serialisation is most useful if you want to use the shape files in a 'kiosk' context where you have full control of how the sketch is presented to the user. The start-up time can fall to as little as 10% (!!!) of the un-serialised start-up time; so in a kiosk context this can be a big plus but you pay for it with flexibility.
Things are also slowly getting smarter around parsing the column names in a file for x and y coordinates and also for making it easier for the developer to project multiple value columns from the same shape file without a lot of faffing. I suppose that a clone() function would be useful, but for now you have to follow the example PDE file for copying data.
Anyway, always happy to have feature requests -- I can't always implement them right away (or even at all) but I
do listen and
do try. Currently top of the 1.4 'to do' list is arrowheads on lines (beginning and/or end).
Oh, and I finally remembered to put this all in SVN so future releases should be a little more precise about what has changed.
I've updated MapThing with some useful features that will make it easier to project and present data:
1. You can now easily specify the name and value fields for use in labelling and colouring/sizing.
2. You can now colour code polygons, lines, and points using the value field and coloured according to a scale (you will need to manually specify the min and max values for the mapping, I'm afraid... for now)
3. You can now scale the size of points according to the value (you specify the desired radius for your expected maximum value)
4. You can now specify an offset for the labels
5. You can extract centroids from polygons (tested) and lines (not tested, but should work)
The demo should give you a sense of all the new features and there's always the included documentation (or the same is available online at
http://www.reades.com/MapThing/).
MapThing allows you to perform a range of useful mapping (in the geographical sense) functions within Processing and offers a collection of classes for reading ESRI-compliant Shape files (a.k.a. shapefiles) and CSV point data, and then displaying them as part of a sketch. My objective here was not to implement a full-fledged GIS system, but to make it as easy as possible to take a set of geographically coded file and do
something with them inside Processing without needing to think about how to map the coordinate spaces or how to read a shape file and extract useful information from it.
There are four main classes with which you want to concern yourself:
BoundingBox is how you define the geographic envelope within which the sketch is displayed, in effect it maps the geographic space on to the viewable space of the sketch itself;
Lines is used to read and display line-type shapefiles;
Points is used to read and display point-type shapefiles; and
Polygons is used to read and display polygon-type shapefiles.
You can also read in point data (tested) and line data (not tested) from CSV files and project this using the same mechanism.
The PDE sample file offers a working example of most of what is discussed above.
I notice that on the Contributed Libraries page (as well as in the various library wiki pages) there's no information on how to take the final step to actually publish a new library once you've finished development.
I
assume that this is because there's some QA/QC process in place for determining that the library isn't malicious and adheres to the latest standards, but it would be helpful if there were some information on this last step.
The reason I ask is that I finally got around to polishing (and testing as best I can) a library to allow users to load and display ESRI Shape files and geo-coded CSV files within in a sketch in a fairly painless fashion. I'd like to first ensure that I've got everything right with respect to hosting it at
http://www.reades.com/MapThing(.zip/.txt) and then to see how I get it distributed.