Get the shortest distance from a point

前端 未结 8 600
长发绾君心
长发绾君心 2021-01-01 06:36

I have this table in sqlite

Locations
ID
Lat ( latitude)
Lon ( longitude) 
Type
Name
City

I have for example 100 records what I need is to

8条回答
  •  青春惊慌失措
    2021-01-01 07:15

    Though this is not a best option.
    Let you are trying to figure out shortest distance within N mile/km radious for fixed no of locations/your location table data are not changing regularly.
    Add another column Distance_Index (DI) a self multi reference key ArrayType. Once run a procedure and update the DI with ID in ascending order accoording to distance from this DI. Now from next time onwords distance is with you. just make a query to the database and use it.
    Sample table data

    Now, in your problem no of location are less within N, then DI will not be too much long.Just as an opinion.

提交回复
热议问题