Skip to main content

Posts

Showing posts from 2012

Fitting an ellipse to point data

Some time ago I wrote an R function to fit an ellipse to point data, using an algorithm developed by Radim Halíř and Jan Flusser 1 in Matlab, and posted it to the r-help list . The implementation was a bit hacky, returning odd results for some data. A couple of days ago, an email arrived from John Minter asking for a pointer to the original code. I replied with a link and mentioned that I'd be interested to know if John made any improvements to the code. About ten minutes later, John emailed again with a much improved version ! Not only is it more reliable, but also more efficient. So with many thanks to John, here is the improved code: fit.ellipse <- function (x, y = NULL) { # from: # http://r.789695.n4.nabble.com/Fitting-a-half-ellipse-curve-tp2719037p2720560.html # # Least squares fitting of an ellipse to point data # using the algorithm described in: # Radim Halir & Jan Flusser. 1998. # Numerically stable direct least squares fitting of ellipses

IDE errors with Maven projects after upgrading to NetBeans 7.2

A recent upgrade of NetBeans from version 7.1 to 7.2 seemed to cause problems with Maven multi-module projects. Normally, a newly created class in one Maven project module will be instantly visible to other modules open in the IDE, at least for editing purposes. But after the upgrade I started to see "cannot find symbol" errors in the IDE for such new classes. Despite this, a full build of the project would succeed. Googling for an answer drew a blank. The usual kludge fixes such as deleting the NetBeans cache (for NetBeans 7.2 on OSX this seems to have moved from ~/.netbeans to ~/Library/Application Support/Netbeans) and re-indexing my local repo didn't make any difference. Despair loomed. Happily, I stumbled across the cause of the problem after only a moderate amount of pulling of hair and gnashing of teeth. My Maven settings.xml file included this section... <profiles> <profile> <id>netbeans-ide</id> <

Build an application plus a separate library uber-jar using Maven

I've been working on a small Java application with a colleague to simulate animal movements and look at the efficiency of different survey methods. It uses the GeoTools library to support map projections and shapefile output. GeoTools is great but comes at a cost in terms of size: the jar for our little application alone is less than 50kb but bundling it with GeoTools and its dependencies blows that out to 20Mb. The application code has been changing on a daily basis as we explore ideas, add features and fix bugs. Working with my colleague at a distance, over a fairly feeble internet connection, I wanted to package the static libraries and the volatile application into separate jars so that he only needed to download the former once (another option would have been for my colleague to set up a local Maven repository but for various reasons this was impractical). A slight complication with bundling GeoTools modules into a single jar (aka uber-jar) is that individual modules make ext