2 Star 42 Fork 31

小豆子 / jts-learning

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
precisionmodel.md 1.05 KB
AI 代码解读
一键复制 编辑 原始数据 按行查看 历史
小豆子 提交于 2023-07-12 17:18 . 经度计算

org.locationtech.jts.geom.PrecisionModel 使用说明

PrecisionModel 精度模式

说明

精度模型是数值计算的核心,JTS使用默认的双精度模型。当使用较大值时,java中内置的数学并不是非常精确,可以通过配置GeometryFactory的PrecisionModel使用不同的精度。

精度分类

FIXED: 固定精度表示坐标有固定的小数位数,小数点的位数由比例因子的对数10决定(log10 of the scale),Math.round(val * scale) / scale
FLOATING: JAVA中的double,双精度浮点型,参考IEEE-754标准
FLOATING_SINGLE: JAVA中的float,单精度浮点型,参考IEEE-754标准

操作示例

PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);

自定义经度范围

保留小数点后3位数,设置scala=1000

@Test
public void precisionModel(){
    PrecisionModel precisionModel = new PrecisionModel(1000);

    Coordinate c = new Coordinate(116.345678,32.456788);

    precisionModel.makePrecise(c);

    System.out.println(c);
}
1
https://gitee.com/shengshifeiyang/jts-learning.git
git@gitee.com:shengshifeiyang/jts-learning.git
shengshifeiyang
jts-learning
jts-learning
master

搜索帮助