bool geosIntersect(const LineSegment& ls1, Meters buffer, const LineSegment& ls2,
                     LineSegment& result)
  {
    boost::shared_ptr<Geometry> g1(ls1.toGeometry(*GeometryFactory::getDefaultInstance())->clone());
    boost::shared_ptr<Geometry> g2(ls2.toGeometry(*GeometryFactory::getDefaultInstance())->clone());
    boost::shared_ptr<Geometry> g(g1->buffer(buffer, 40));

    boost::shared_ptr<Geometry> i(g->intersection(g2.get()));

    if (i->isEmpty())
    {
      result.p0 = Coordinate::getNull();
      return false;
    }
    else if (i->getGeometryTypeId() == GEOS_POINT)
    {
      Point* p = dynamic_cast<Point*>(i.get());
      result.p0 = *(p->getCoordinate());
    }
    else if (i->getGeometryTypeId() == GEOS_LINESTRING)
    {
      LineString* ls = dynamic_cast<LineString*>(i.get());
      assert(ls->getNumPoints() == 2);
      result.p0 = *ls->getPointN(0)->getCoordinate();
      result.p1 = *ls->getPointN(1)->getCoordinate();
    }
    else
    {
      throw HootException();
    }
    return true;
  }