What are the distance units in com.vividsolutions.jts.geom.Geometry class?

前端 未结 4 1683
温柔的废话
温柔的废话 2020-12-29 12:00

Our VB.NET project is using a Java library from Vivid Solutoins (com.vividsolutions.jts.geom.Geometry) to do Geometry calculations. The help is here: http://tsusiatsoftware

相关标签:
4条回答
  • 2020-12-29 12:34

    First of all, I don't know this API, I've just browsed the link you've given.

    Judging by the Javadocs for Coordinate, it says:

    [Coordinate is a] lightweight class used to store coordinates on the 2-dimensional Cartesian plane. It is distinct from Point, which is a subclass of Geometry. Unlike objects of type Point (which contain additional information such as an envelope, a precision model, and spatial reference system information)

    So it would seem that Geometry has no units as such, but Point, its subclass, does, and you can specify them.

    I wouldn't be surprised if the Geometry class doesn't have any units as such, and just represents the concept of a point in space in any particular coordinate system.

    0 讨论(0)
  • 2020-12-29 12:34

    As I recently worked on this library (http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html) and after investigation I found that the unit distance returned when call some of the methods distance calculation with this api will be in degree unit. To convert it to kilometer, assumes that value returned is d then you need to convert it to radian and multiply with earth radius 6371km. The formula would be d / 180 * PI * 6371.

    0 讨论(0)
  • 2020-12-29 12:43

    I confirmed with one of the author's of the library, and by testing it myself using geospatial files with different projections, that the distance units depend on the source file's CRS. This is covered in their FAQ here: https://locationtech.github.io/jts/jts-faq.html#B5

    A quick way to find this is to look up the EPSG code at http://epsg.io/ and find the units. For example, EPSG 3347 has units of metres.

    0 讨论(0)
  • 2020-12-29 12:55

    This is an old post, but here is the answer for anyone else who is looking, since incredibly the java docs do not state the units returned by the method. The distance returned is in central angle degrees. You can then use any number of formulas to convert to your required unit of measure. The simplest is to convert to radians. 1 radian = 180 degrees divided by pi (rad=180deg/pi). From there, you can multiply radians by the average radius of the earth in your choice of units (6371 km for instance) to get distance between two points. More accurate methods are also available, but you can look them up on the net.

    0 讨论(0)
提交回复
热议问题