简体   繁体   English

使用 JTS 简化段列表

[英]Simplify segment list with JTS

I am testing with the JTS (Java Topology Suite) library to see if I can manage to simplify a list of segments.我正在使用 JTS(Java 拓扑套件)库进行测试,看看我是否可以设法简化段列表。 The truth is I know very little about this library and I'm a programming novice, so I don't know if what I'm trying to achieve is possible.事实是我对这个库知之甚少,而且我是一个编程新手,所以我不知道我想要实现的目标是否可行。

What I want is, to transform a MULTILINESTRING list like the following one:我想要的是转换一个 MULTILINESTRING 列表,如下所示:

MULTILINESTRING ((0 0, 50 50), (50 50, 100 100, 150 50), (50 150, 100 100, 150 150), (20 20, 80 80), (40 160, 70 130), (110 110, 140 140))

Into this:进入这个:

MULTILINESTRING ((40 160, 150 50), (0 0, 150 150))

In other words, what I want is to get a list with maximum segments, in terms of length.换句话说,我想要的是获得一个具有最大段的列表,就长度而言。 Is it possible to make that transformation, and if so, how?是否有可能进行这种转变,如果可以,如何进行?

Thank you very much.非常感谢。

It's not possible to get the answer you suggest purely with JTS methods.纯粹使用 JTS 方法不可能得到您建议的答案。 The closest you can get is to:您可以获得的最接近的是:

  • node the linework using Geometry.union()使用Geometry.union()对线条进行节点化
  • merge the noded linework using LineMerger使用LineMerger合并节点线条
  • simplify the linework using DouglasPeuckerSimplifier using a small tolerance使用小公差使用DouglasPeuckerSimplifier简化线条

That will give you:这会给你:

MULTILINESTRING ((0 0, 100 100), (40 160, 100 100), (100 100, 150 150), (100 100, 150 50))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM