Java large datastructure for storing a matrix

后端 未结 9 1966
北恋
北恋 2021-01-13 02:17

I need to store a 2d matrix containing zip codes and the distance in km between each one of them. My client has an application that calculates the distances which are then s

9条回答
  •  暖寄归人
    2021-01-13 02:46

    I would have thought that you could calculate the distances on the fly. Presumably someone has already done this, so you simply need to find out what algorithm they used, and the input data; e.g. longitude/latitude of the notional centres of each ZIP code.

    EDIT: There are two commonly used algorithms for finding the (approximate) geodesic distance between two points given by longitude/latitude pairs.

    • The Vicenty formula is based on an ellipsoid approximation. It is more accurate, but more complicated to implement.

    • The Haversine formula is based on a spherical approximation. It is less accurate (0.3%), but simpler to implement.

提交回复
热议问题