private String htmlTitle(PrecisionModel precisionModel) { String html = "Precision Model: scale=" + precisionModel.getScale() + StringUtil.newLine; html = "<div class='precisionModel'>" + html + "</div>"; return html; }
public String toString() { String description = "UNKNOWN"; if (modelType == FLOATING) { description = "Floating"; } else if (modelType == FLOATING_SINGLE) { description = "Floating-Single"; } else if (modelType == FIXED) { description = "Fixed (Scale=" + getScale() + ")"; } return description; }
public static String toXML(PrecisionModel precisionModel) { if (precisionModel.isFloating()) { return "<precisionModel type=\"FLOATING\"/>"; } return "<precisionModel type=\"FIXED\" scale=\"" + precisionModel.getScale() + "\"/>"; }
maxSigDigits = 6; } else if (modelType == FIXED) { maxSigDigits = 1 + (int) Math.ceil(Math.log(getScale()) / Math.log(10));
public void setPrecisionModel(PrecisionModel precisionModel) { this.precisionModel = precisionModel; Object modelType = precisionModel.getType(); rbFixed.setSelected(modelType == PrecisionModel.FIXED); rbFloating.setSelected(modelType == PrecisionModel.FLOATING); rbFloatingSingle.setSelected(modelType == PrecisionModel.FLOATING_SINGLE); if (modelType == PrecisionModel.FIXED) { txtScale.setText(Double.toString(precisionModel.getScale())); } updateDisplay(); }
public MCIndexSnapRounder(PrecisionModel pm) { this.pm = pm; li = new RobustLineIntersector(); li.setPrecisionModel(pm); scaleFactor = pm.getScale(); }
public SimpleSnapRounder(PrecisionModel pm) { this.pm = pm; li = new RobustLineIntersector(); li.setPrecisionModel(pm); scaleFactor = pm.getScale(); }
/** * Estimates the snap tolerance for a Geometry, taking into account its precision model. * * @param g a Geometry * @return the estimated snap tolerance */ public static double computeOverlaySnapTolerance(Geometry g) { double snapTolerance = computeSizeBasedSnapTolerance(g); /** * Overlay is carried out in the precision model * of the two inputs. * If this precision model is of type FIXED, then the snap tolerance * must reflect the precision grid size. * Specifically, the snap tolerance should be at least * the distance from a corner of a precision grid cell * to the centre point of the cell. */ PrecisionModel pm = g.getPrecisionModel(); if (pm.getType() == PrecisionModel.FIXED) { double fixedSnapTol = (1 / pm.getScale()) * 2 / 1.415; if (fixedSnapTol > snapTolerance) snapTolerance = fixedSnapTol; } return snapTolerance; }
public void testParameterlessConstructor() { PrecisionModel p = new PrecisionModel(); //Implicit precision model has scale 0 assertEquals(0, p.getScale(), 1E-10); }
private void bufferFixedPrecision(PrecisionModel fixedPM) { Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)), fixedPM.getScale()); BufferBuilder bufBuilder = new BufferBuilder(bufParams); bufBuilder.setWorkingPrecisionModel(fixedPM); bufBuilder.setNoder(noder); // this may throw an exception, if robustness errors are encountered resultGeometry = bufBuilder.buffer(argGeom, distance); } }
/** * Runs a ScaledNoder on input. * Input vertices should be rounded to precision model. * * @param geom * @param scaleFactor * @return the noded geometry */ public static Geometry scaledNoding(Geometry geom, double scaleFactor) { List segs = createSegmentStrings(geom); PrecisionModel fixedPM = new PrecisionModel(scaleFactor); Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)), fixedPM.getScale()); noder.computeNodes(segs); Collection nodedSegStrings = noder.getNodedSubstrings(); return SegmentStringUtil.toGeometry(nodedSegStrings, FunctionsUtil.getFactoryOrDefault(geom)); }
/** * Convert the supplied {@code PrecisionModel}. * * @param precisionModel the precision model * * @return the converted precision model */ private com.vividsolutions.jts.geom.PrecisionModel convertPrecisionModel( org.locationtech.jts.geom.PrecisionModel precisionModel) { if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FIXED) { return new com.vividsolutions.jts.geom.PrecisionModel(precisionModel.getScale()); } else if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FLOATING) { return new com.vividsolutions.jts.geom.PrecisionModel( com.vividsolutions.jts.geom.PrecisionModel.FLOATING); } else if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FLOATING_SINGLE) { return new com.vividsolutions.jts.geom.PrecisionModel( com.vividsolutions.jts.geom.PrecisionModel.FLOATING_SINGLE); } else { return new com.vividsolutions.jts.geom.PrecisionModel( new com.vividsolutions.jts.geom.PrecisionModel.Type( precisionModel.getType().toString())); } }
/** * Convert the supplied {@code PrecisionModel}. * * @param precisionModel the precision model * * @return the converted precision model */ private com.vividsolutions.jts.geom.PrecisionModel convertPrecisionModel( org.locationtech.jts.geom.PrecisionModel precisionModel) { if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FIXED) { return new com.vividsolutions.jts.geom.PrecisionModel(precisionModel.getScale()); } else if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FLOATING) { return new com.vividsolutions.jts.geom.PrecisionModel( com.vividsolutions.jts.geom.PrecisionModel.FLOATING); } else if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FLOATING_SINGLE) { return new com.vividsolutions.jts.geom.PrecisionModel( com.vividsolutions.jts.geom.PrecisionModel.FLOATING_SINGLE); } else { return new com.vividsolutions.jts.geom.PrecisionModel( new com.vividsolutions.jts.geom.PrecisionModel.Type( precisionModel.getType().toString())); } }
private void checkSegment(double x, double y) { Coordinate seg0 = new Coordinate(0, 0); Coordinate seg1 = new Coordinate(x, y); LineSegment seg = new LineSegment(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); } }
/** * Convert the supplied {@code PrecisionModel}. * * @param precisionModel the precision model * * @return the converted precision model */ private com.vividsolutions.jts.geom.PrecisionModel convertPrecisionModel( org.locationtech.jts.geom.PrecisionModel precisionModel) { if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FIXED) { return new com.vividsolutions.jts.geom.PrecisionModel(precisionModel.getScale()); } else if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FLOATING) { return new com.vividsolutions.jts.geom.PrecisionModel( com.vividsolutions.jts.geom.PrecisionModel.FLOATING); } else if (precisionModel.getType() == org.locationtech.jts.geom.PrecisionModel.FLOATING_SINGLE) { return new com.vividsolutions.jts.geom.PrecisionModel( com.vividsolutions.jts.geom.PrecisionModel.FLOATING_SINGLE); } else { return new com.vividsolutions.jts.geom.PrecisionModel( new com.vividsolutions.jts.geom.PrecisionModel.Type( precisionModel.getType().toString())); } }