鉴于以下输入:
如何计算位置"m"的经度/纬度?
我正在使用此公式来计算我的(我的)SQL数据库中条目之间的距离,该数据库具有十进制格式的纬度和经度字段:
6371 * ACOS(SIN(RADIANS( %lat1% )) * SIN(RADIANS( %lat2% )) + COS(RADIANS( %lat1% )) * COS(RADIANS( %lat2% )) * COS(RADIANS( %lon2% ) - RADIANS( %lon1% )))
Run Code Online (Sandbox Code Playgroud)
适当地替换%lat1%和%lat2%它可以在WHERE子句中用于查找另一个条目的某个半径内的条目,在ORDER BY子句中使用它与LIMIT一起将找到最近的x个条目等.
我写这篇文章主要是为了自己,但总是欢迎改进.:)
注意:如下面的Valerion所述,这以千米为单位计算.用适当的替代号码代替6371 以使用米,英里等.
我应该如何根据GeoPt属性创建一个返回最近实体(来自我当前位置)的GQL查询?我是否应该创建一个"距离"函数来计算一组距离合理的实体?
提前谢谢!
我一直未能成功找到一个由城市定义的美国大都会区(旧金山湾区,南湾,伯克希尔,纽约上州等)数据库.
有谁知道这样的事情是否存在?
维基百科有一个"州内地区"列表:
http://en.wikipedia.org/w/index.php?title=List_of_regions_of_the_United_States#Intrastate_regions
除了这将是每个50个州的痛苦,然后拉出该地区的文章,以找出哪个城市所说的区域组成.
来自联邦调查局的MSA和CSA列表没有帮助,因为它基于统计分组而不是通用名称.
非常感谢,提前
- 迈克尔
英国邮政编码的地理编码最有效和准确的方法是什么?使用内置的地理编码对象会导致大量模糊的结果(许多邮政编码只返回一般区域).
我可以通过JavaScript插入免费的英国邮政编码地理编码服务吗?
我写了一个脚本来向Google Maps的API发送地址并收回Lat和Lng.但是,我收到的错误消息是,我在20次左右的查询后超出了Google的速率限制.有什么我不考虑的吗?
我很感激任何帮助.我非常擅长使用API,所以更好地理解为什么我达到速率限制会非常有帮助.
从名为Location的csv文件中读取地址后,下面是我的相关代码.
for row in locations:
address = 'XXX, New Haven, CT'
first = re.search('^(.*),',row[0])
address = re.sub('XXX',first.group(), address)
lat, lng = gmaps.address_to_latlng(address)
Run Code Online (Sandbox Code Playgroud)
我的错误信息如下.
Traceback (most recent call last):
File "<input>", line 5, in <module>
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/googlemaps-1.
0.2-py2.7.egg/googlemaps.py", line 310, in address_to_latlng
return tuple(self.geocode(address)['Placemark'][0]['Point']['coordinates'][1
::-1])
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/googlemaps-1.
0.2-py2.7.egg/googlemaps.py", line 262, in geocode
raise GoogleMapsError(status_code, url, response)
GoogleMapsError: Error 620: G_GEO_TOO_MANY_QUERIES
Run Code Online (Sandbox Code Playgroud) 我有2个相关的导轨型号
class Location < ActiveRecord::Base
has_many :rates
geocoded_by ....
end
class Rate < ActiveRecord::Base
belongs_to :location
end
Run Code Online (Sandbox Code Playgroud)
我正在使用地理编码器宝石 - http://www.rubygeocoder.com
我想找到具有与pair用户相距一定距离的特定属性的所有费率.
在SQL中,我会对费率进行内部联接
SELECT * FROM rates INNER JOIN locations ON rates.location_id=locations.id;
Run Code Online (Sandbox Code Playgroud)
然后,插入where条件以对pair属性进行过滤,然后在结果表上使用Geocoder的near方法(near方法通过在查询中插入where条件来计算距离,使用位置上的纬度和经度属性)到只选择正确距离内的行
我怎么能在rails中做到这一点?我试过了
rates = Rate.joins(:locations)
Run Code Online (Sandbox Code Playgroud)
我明白了
ActiveRecord::ConfigurationError: Association named 'locations' was not found; perhaps you misspelled it?
Run Code Online (Sandbox Code Playgroud)
我想做这个
rates = Rate.joins(:locations).near(my_latitude, my_longitude, distance).where(:rates => {:pair => 'xxxx'})
Run Code Online (Sandbox Code Playgroud)
但我明白了
undefined method `near' for #<ActiveRecord::Relation:0xa075ff8>
Run Code Online (Sandbox Code Playgroud) 我试图找到一种方法来创建iOS的多个多边形地理围栏.我需要在一个城市中绘制多个区域来表示区域,街道等.从我到目前为止所读到的,iOS仅允许来自地理定位设备的圆形区域.
我正在尝试替换我创建的网站的 API 密钥,该网站采用给定地址并将其呈现在 Google 地图中。当我尝试使用它时,我得到了这个
和这个
You must enable Billing on the Google Cloud Project at https://console.cloud.google.com/project/_/billing/enable Learn more at https://developers.google.com/maps/gmp-get-started
Run Code Online (Sandbox Code Playgroud)
当我单击链接添加帐单时,没有任何变化。当我检查我的计费帐户以查看它是否附加到包含密钥的项目时,它已连接。当我检查项目本身是否有账单时,它说有。
另一个提出非常类似问题的人说要创建一个全新的项目和一个全新的计费帐户。我尝试了这个,但仍然遇到问题。我还尝试按照另一位用户的建议创建一个新的结算帐户作为“Google 地图平台”
我在这里完全不知所措。人们是否针对此问题找到了其他解决方案?
google-maps geocoding google-cloud-platform google-cloud-billing
我已经从人口普查局下载了美国所有城镇等的列表。这是一个随机样本:
dput(somewhere)
structure(list(state = structure(c(30L, 31L, 5L, 31L, 24L, 36L,
13L, 21L, 6L, 10L, 31L, 28L, 10L, 5L, 5L, 8L, 23L, 11L, 34L,
19L, 29L, 4L, 24L, 13L, 21L, 31L, 2L, 3L, 29L, 24L, 1L, 13L,
15L, 10L, 11L, 33L, 35L, 8L, 11L, 12L, 36L, 28L, 9L, 31L, 8L,
14L, 11L, 12L, 36L, 13L, 8L, 5L, 29L, 8L, 7L, 23L, 25L, 39L,
16L, 28L, 10L, 29L, 26L, 8L, 32L, 40L, 28L, 23L, 37L, 31L, 18L,
5L, 1L, 31L, 18L, 13L, …Run Code Online (Sandbox Code Playgroud) geocoding ×10
google-maps ×4
geolocation ×2
database ×1
dataframe ×1
geography ×1
gql ×1
ios ×1
list ×1
maps ×1
python ×1
r ×1
sql ×1
yahoo-maps ×1