The JTS Topology Suite is an API of 2D spatial predicates and functions. http://www.vividsolutions.com/jts/JTSHome.htm