简体   繁体   English

需要使用JTS库在坐标周围创建圆

[英]need to create circle around coordinate using JTS library

i am trying to create circle around specific coordinate using below method which I got from some git hub repo. 我试图使用下面的方法从特定的git hub回购中创建围绕特定坐标的圆。

public static Geometry createCircle(Coordinate coordinate, double radius)
{
  GeometricShapeFactory shape = new GeometricShapeFactory(geomFactory);
  shape.setCentre(coordinate);
  shape.setSize(2 * radius);
  shape.setNumPoints(32);
  return shape.createCircle();
}

I want to pass the radius in miles, but looks like its taking in some other unit and the circle getting created is huge when I am giving 5 as radius. 我想以英里为单位传递半径,但看起来像它接受了其他单位,当我给定5作为半径时,创建的圆很大。 Can someone explain how can I use radius argument in miles in above example? 有人可以在上面的示例中解释如何在英里中使用radius参数吗?

JTS is geometry/topology library. JTS是几何/拓扑库。 As such, it uses whatever units the geometry is in. 因此,它使用几何图形中的任何单位。

Assuming you are working with a point that is a longitude, latitude pair, then the units are degrees of longitude/latitude. 假设您正在使用的是经度和纬度对的点,则单位为经度/纬度。 At the equator, a degree is around ~110 kilometers / 69 miles. 在赤道,度数约为〜110公里/ 69英里。

As a really quick fix, you could set your radius to something like 5/69. 作为快速解决方案,您可以将半径设置为5/69。 As a complete solution, you could apply GeoTools's (a Java geospatial library) GeodeticCalculator class [1] to the code you suggested to get a more accurate circle. 作为完整的解决方案,您可以将GeoTools(Java地理空间库)的GeodeticCalculator类[1]应用到您建议的代码中,以获得更精确的圆。

That solution will have some issues around the poles, but that's another issue... 该解决方案将围绕两极问题,但这是另一个问题。

[1] http://docs.geotools.org/stable/userguide/library/referencing/calculator.html [1] http://docs.geotools.org/stable/userguide/library/referencing/calculator.html

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

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