Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
确保SQL数据库中地理数据的良好传播_Sql_Sql Server 2005_Google Maps - Fatal编程技术网

确保SQL数据库中地理数据的良好传播

确保SQL数据库中地理数据的良好传播,sql,sql-server-2005,google-maps,Sql,Sql Server 2005,Google Maps,为了在GoogleMaps上显示数据,我在SQLServer2005中有超过5万行的数据,并采用以下简化结构 PointID Latitude Longitude TypeID 我可以在边界框中选择一个小子集,以确保以下类型的适当混合: ..... ( @NELat float, @NELong float, @SWLat float, @SWLong float ) as select top 100 PointID, Latitude, Longitude, rank() over (p

为了在GoogleMaps上显示数据,我在SQLServer2005中有超过5万行的数据,并采用以下简化结构

PointID
Latitude
Longitude
TypeID
我可以在边界框中选择一个小子集,以确保以下类型的适当混合:

.....
(
@NELat float,
@NELong float,
@SWLat float,
@SWLong float
) 
as
select top 100 PointID, Latitude, Longitude,
rank() over (partition by PointTable.TypeID order by newid()) as NewRank
from PointTable
where
(
CONVERT(float, PointTable.Latitude) >= @SWLat and CONVERT(float, PointTable.Latitude) <=   @NELat and
CONVERT(float, PointTable.Longitude) >= @SWLong and CONVERT(float, PointTable.Longitude) <=  @NELong
)
order by NewRank
不幸的是,最初的数据偏向于一个特定的地理位置

确保检索到的数据具有良好的地理分布的最有效/计算速度最快的方法是什么

我不想对数据进行聚类,只是为了显示数据在边界框中更均匀的分布。 我可以创建一个边界框网格的子集,并在其上进行分区吗? 任何建议都会有很大帮助


我一直在研究SQLServer2008可用的地理数据类型,但它看起来不像是在2005年可用的。另外,我知道float不是存储坐标的最佳数据类型,但这并不取决于我。

我最后做的是:

扩展我的表以包含给定lat/lon的ID

PointID
Latitude
Longitude
TypeID
HTMID
HTMID是从使用空间数据库中的函数生成的,源代码可从Notes下载。我必须生成一个新的sampleKey.snk来构建示例项目。我跟着

然后HTMID可以四舍五入并用于按点分组

.....
(
@NELat float,
@NELong float,
@SWLat float,
@SWLong float
) 
as
select top 100 PointID, Latitude, Longitude,
rank() over (partition by PointTable.TypeID order by newid()) as NewRank,
rank() over (partition by round(PointTable.HTMID,-7) order by newid()) as HTMRank
from PointTable
where
(
CONVERT(float, PointTable.Latitude) >= @SWLat and CONVERT(float, PointTable.Latitude) <=   @NELat and
CONVERT(float, PointTable.Longitude) >= @SWLong and CONVERT(float, PointTable.Longitude) <=  @NELong
)
order by HTMRank, NewRank
这可能并不完全准确,如果不深入研究技术细节,我不会使用这个HTMID来计算任何更精确的东西——但它确实实现了我想要的