C中的地理编码查找 [英] Geocode lookup in C

查看:58
本文介绍了C中的地理编码查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做一个超快速的地理编码查找,返回城镇、城市或国家输入的坐标.我的知识是基本的,但据我所知,用 C 语言编写它是一个好的开始.我认为拥有这样的树结构是有意义的:

I want to do a super fast geocode lookup, returning co-ordinates for an input of Town, City or Country. My knowledge is basic but from what I understand writing it in C is a good start. I was thinking it makes sense to have a tree structure like this:

  • 英格兰
    • 肯特
    • 奥尔平顿
    • 查塔姆
    • 罗切斯特
    • 多佛
    • 爱登布里奇
    • 斯温顿
    • 马姆斯伯里

    在我的文件/数据库中,我将有坐标和城镇/城市名称.如果给我的程序命名为Kent",我想要一个可以以最快的方式返回与Kent"相关的坐标的程序

    In my file / database I will have the co-ordinate and the town/city name. If give my program the name "Kent" I want a program that can return me the co-ordinate assoaited with "Kent" in the fastest way possible

    出于性能原因,我应该将数据存储在二进制文件还是 SQL 数据库中?搜索这些数据的最佳方法是什么?也许二叉树搜索?数据应该如何存储?也许?

    Should I store the data in a binary file or a SQL database for performance reasons? What is the best method of searching this data? Perhaps binary tree searching? How should the data be stored? perhaps?

    推荐答案

    这里有一些建议,但仅此而已:

    Here's a little advice, but not much more than that:

    如果您想按名称或名称前缀查找地点,如您所希望的那样,那么您不建议建立一个将数据存储在国家、地区、城镇的层次结构中的数据结构正如你所建议的那样.如果您的操作支配了您的数据结构的使用,您通常最好选择适合该操作的数据结构.

    If you want to find places by name, or name prefix, as you indicate that you wish to, then you would be ill-advised to set up a data structure which stores the data in a hierarchy of country, region, town as you suggest you might. If you have an operation that dominates the use of your data structure you are generally best picking the data structure to suit the operation.

    在这种情况下,按字母顺序排列的地点列表更适合您的查询.对于不是最顶层的每个地方,您可能希望添加对其父"名称的某种引用.如果您有一个按字母顺序排列的地点列表,您可能还想考虑一个索引,可能是一个直接指向列表中以字母表中的每个字母开头的第一个位置的索引.

    In this case an alphabetical list of places would be more suited to your queries. To each place not at the topmost level you would want to add some kind of reference to the name of its 'parent'. If you have an alphabetical list of places you might also want to consider an index , perhaps one which points directly to the first place in the list which starts with each letter of the alphabet.

    当你描述你的问题时,它似乎与在字典中存储单词有更多的共同点(我的意思是你在其中查找单词而不是任何特定编程语言中的任何特定集合数据类型的事情同名)而不是大多数以地理编码为幌子的内容.

    As you describe your problem it seems to have much more in common with storing words in a dictionary (I mean the sort of thing in which you look up words rather than any particular collection data-type in any specific programming language which goes under the same name) than with most of what goes under the guise of geo-coding.

    我的猜测是,一个包含世界上所有城镇、城市、地区和国家(及其坐标)的名称的地名词典可以存储在一个非常简单的数据结构中(基本上一个列表),带有一两个索引,用于快速定位第一个 A 地名、第一个 B 等.只需稍加压缩,您就可以将其保存在大多数现代台式电脑的内存中.

    My guess would be that a gazetteer including the names of all the world's towns, cities, regions and countries (and their coordinates) which have a population over, say, 1000, could be stored in a very simple data structure (basically a list) with an index or two for rapid location of the first A place-name, the first B, and so on. With a little compression you could probably hold this in the memory of most modern desktop PCs.

    这篇关于C中的地理编码查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆