public JtsBinaryCodec(JtsSpatialContext ctx, JtsSpatialContextFactory factory) { super(ctx, factory); //note: ctx.geometryFactory hasn't been set yet useFloat = (factory.precisionModel.getType() == PrecisionModel.FLOATING_SINGLE); }
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(); }
/** * 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())); } }
/** * 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())); } }
/** * 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; }
private void computeGeometry() { bufferOriginalPrecision(); if (resultGeometry != null) return; PrecisionModel argPM = argGeom.getFactory().getPrecisionModel(); if (argPM.getType() == PrecisionModel.FIXED) bufferFixedPrecision(argPM); else bufferReducedPrecision(); }