void object::test<1>() { PrecisionModel pm; ensure(pm.isFloating()); ensure_equals(pm.getMaximumSignificantDigits(), 16); ensure_equals(pm.getScale(), 0); }
void PrecisionModel::New(const FunctionCallbackInfo<Value>& args) { Isolate* isolate = Isolate::GetCurrent(); HandleScope scope(isolate); PrecisionModel *model; if (args.Length() == 0) { model = new PrecisionModel(); } else { if (args[0]->IsString()) { //type if(args[0]->ToString()->Equals(String::NewFromUtf8(isolate, "FIXED"))) { model = new PrecisionModel(geos::geom::PrecisionModel::FIXED); } else if (args[0]->ToString()->Equals(String::NewFromUtf8(isolate, "FLOATING"))) { model = new PrecisionModel(geos::geom::PrecisionModel::FLOATING); } else { model = new PrecisionModel(geos::geom::PrecisionModel::FLOATING_SINGLE); } } else { //double model = new PrecisionModel(args[0]->NumberValue()); } } model->Wrap(args.This()); args.GetReturnValue().Set(args.This()); }
Handle<Value> PrecisionModel::New(const geos::geom::PrecisionModel *m) { Isolate* isolate = Isolate::GetCurrent(); HandleScope scope(isolate); PrecisionModel *model = new PrecisionModel(m); Handle<Value> ext = External::New(isolate, model); Local<Function> cons = Local<Function>::New(isolate, constructor); Handle<Object> obj = cons->NewInstance(1, &ext); model->Wrap(obj); return obj; }
/*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); }
/*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); }
Coordinate computePoint(const LineSegment& seg, double dist) { double dx = seg.p1.x - seg.p0.x; double dy = seg.p1.y - seg.p0.y; double len = seg.getLength(); Coordinate pt(dist * dx / len, dist * dy / len); pm.makePrecise(pt); return pt; }
void preciseCoordinateTester(const PrecisionModel& pm, double x1, double y1, double x2, double y2) { Coordinate p(x1, y1); pm.makePrecise(p); Coordinate pPrecise(x2, y2); ensure(p.equals2D(pPrecise)); }
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); } }
/*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); }
bool operator==(const PrecisionModel& a, const PrecisionModel& b) { return a.isFloating() == b.isFloating() && a.getScale() == b.getScale(); }