Beispiel #1
0
/*private*/
void
BufferOp::bufferFixedPrecision(const PrecisionModel& fixedPM)
{


	PrecisionModel pm(1.0); // fixed as well

#if 0 /* FIXME: MCIndexSnapRounder seems to be still bogus */
  snapround::MCIndexSnapRounder inoder(pm);
#else
  algorithm::LineIntersector li(&fixedPM);
  IntersectionAdder ia(li);
  MCIndexNoder inoder(&ia);
#endif

	ScaledNoder noder(inoder, fixedPM.getScale());

	BufferBuilder bufBuilder(bufParams);
	bufBuilder.setWorkingPrecisionModel(&fixedPM);

	bufBuilder.setNoder(&noder);

	// Reduce precision of the input geometry
	//
	// NOTE: this reduction is not in JTS and should supposedly 
	//       not be needed because the PrecisionModel we pass
	//       to the BufferBuilder above (with setWorkingPrecisionModel)
	//       should be used to round coordinates emitted by the
	//       OffsetCurveBuilder, thus effectively producing a fully
	//       rounded input to the noder.
	//       Nonetheless the amount of scrambling done by rounding here
	//       is known to fix at least one case in which MCIndexNoder
	//       would fail: http://trac.osgeo.org/geos/ticket/605
	//
	// TODO: follow JTS in MCIndexSnapRounder usage
	//
	const Geometry *workGeom = argGeom;
	const PrecisionModel& argPM = *(argGeom->getFactory()->getPrecisionModel());
	std::auto_ptr<Geometry> fixedGeom;
	if ( argPM.getType() != PrecisionModel::FIXED || argPM.getScale() != fixedPM.getScale() )
	{
		using precision::GeometryPrecisionReducer;
		fixedGeom = GeometryPrecisionReducer::reduce(*argGeom, fixedPM);
		workGeom = fixedGeom.get();
	}

	// this may throw an exception, if robustness errors are encountered
	resultGeometry = bufBuilder.buffer(workGeom, distance);
}
 void object::test<1>()
 {
     PrecisionModel pm;
     ensure(pm.isFloating());
     ensure_equals(pm.getMaximumSignificantDigits(), 16);
     ensure_equals(pm.getScale(), 0);
 }
Beispiel #3
0
/*private*/
void
BufferOp::bufferFixedPrecision(const PrecisionModel& fixedPM)
{


	PrecisionModel pm(1.0); // fixed as well

#if 0 /* FIXME: MCIndexSnapRounder seems to be still bogus */
  snapround::MCIndexSnapRounder inoder(pm);
#else
  algorithm::LineIntersector li(&fixedPM);
  IntersectionAdder ia(li);
  MCIndexNoder inoder(&ia);
#endif

	ScaledNoder noder(inoder, fixedPM.getScale());

	BufferBuilder bufBuilder(bufParams);
	bufBuilder.setWorkingPrecisionModel(&fixedPM);

	bufBuilder.setNoder(&noder);

	// this may throw an exception, if robustness errors are encountered
	resultGeometry=bufBuilder.buffer(argGeom, distance);
}
        void checkSegment(double x, double y)
        {
          Coordinate seg0(0, 0);
          Coordinate seg1(x, y);
          LineSegment seg(seg0, seg1);

          for (int i = 0; i < 4; i++) {
            double dist = i;

            double gridSize = 1 / pm.getScale();

            checkPointsAtDistance(seg, dist, dist + 1.0 * gridSize);
            checkPointsAtDistance(seg, dist, dist + 2.0 * gridSize);
            checkPointsAtDistance(seg, dist, dist + 3.0 * gridSize);
            checkPointsAtDistance(seg, dist, dist + 4.0 * gridSize);
          }
        }
Beispiel #5
0
/*private*/
void
BufferOp::bufferFixedPrecision(const PrecisionModel& fixedPM)
{


	PrecisionModel pm(1.0); // fixed as well
	snapround::MCIndexSnapRounder inoder(pm); 

	ScaledNoder noder(inoder, fixedPM.getScale());

	BufferBuilder bufBuilder(bufParams);
	bufBuilder.setWorkingPrecisionModel(&fixedPM);

	bufBuilder.setNoder(&noder);

	// this may throw an exception, if robustness errors are encountered
	resultGeometry=bufBuilder.buffer(argGeom, distance);
}
Beispiel #6
0
bool operator==(const PrecisionModel& a, const PrecisionModel& b) {
	return a.isFloating() == b.isFloating() &&
			a.getScale() == b.getScale();
}