以米为单位的2D开放式街道地图数据表示 [英] 2D Open Street Map Data Representation in Meters

查看:72
本文介绍了以米为单位的2D开放式街道地图数据表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将OSM数据转换为开源Minecraft端口(使用javascript- voxel.js 编写) .编写javascript表示法时,会将每个体素(任意定义为立方米)创建为从单个原点(x,y,z)(0,0,0)开始的关系.

I am in the process of converting OSM data into an open source Minecraft port (written in javascript - voxel.js). The javascript rendition is written such that each voxel (arbitrarily defined as a cubic meter) is created as a relation from a single point of origin (x,y,z)(0,0,0).

例如,如果要创建立方块体素,则只需生成体素作为与原点(0,0,0)的关系即可:[[0,0,0),(1,0 ,0),(0,1,0)...].

As an example, if one wanted to create a cubic chunk of voxels, one would simply generate voxels as a relation to the origin (0,0,0) : [(0,0,0),(1,0,0), (0,1,0)...].

我的问题是:我已经导出了OSM数据,并且标准XML输出(.osm)绘制了纬度和经度的节点.我最初的想法是,我可以使用

My question is this: I've exported OSM data, and the standard XML output (.osm) plots nodes in latitude and longitude. My initial thought is that I can create a map by calculating the distance of each node from an arbitrary point of origin (0,0,0) = (37.77559, -122.41392) using the Haversine formula, convert the distance to meters, find the bearing, and plot it as a relation to (0,0,0).

但是,我注意到,还有许多其他导出格式可用:(.osm.pbf,.osm2pgsql,.imposm).我假设它们以类似的方式绘制节点(纬度,经度),但是其中一些能够直接导入数据库(例如PostgreSQL).

I've noticed, however, that there are a number of other export formats available: (.osm.pbf, .osm2pgsql, .imposm). I'm assuming they plot nodes in a similar fashion (lat, lng), but some of them have the ability to import directly into a database (e.g. PostgreSQL).

我听说过人们使用诸如PostGIS之类的PG插件,但是(因为这是我第一次涉足GIS),我不了解他们的功能以及Postem是否对有所帮助将OSM数据绘制到2D体素网格中.

I've heard of people using PG add-ons like PostGIS, but (as this is my first dive into GIS) I'm unfamiliar with their capabilities and whether something like PostGIS would help me in plotting OSM data into a 2D voxel grid.

PostGIS等附加组件中是否有功能可以让我动态计算两个纬度/经度点之间的距离,并以x,y方式绘制它们?

Are there functions within add-ons like PostGIS that would enable me to dynamically calculate the distance between two Lat/Lng points, and plot them in an x,y fashion?

我猜,从根本上讲,我的问题是:如果我创建一个将OSM数据绘制到x,y网格中的脚本,那我将重新发明轮子,还是有一种更有效的方法来做到这一点?

I guess, fundamentally, my question is: if I create a script that plots OSM data into an x,y grid would I be reinventing the wheel, or is there a more efficient way to do this?

推荐答案

您需要从球形坐标(LatLon,使用WGS84)转换为笛卡尔坐标,例如google球形墨卡托.

You need to transform from the spherical coordinates (LatLon, using WGS84) to cartesian coordinates, like googles spherical mercator.

使用伪代码

    transform(double lat, double lon) {

double wgs84radius = 6378137;
double shift = PI * wgs84radius;
double x = lon * shift / 180;
double y = log(tan((90+lat)*PI/360)/ (PI/180);
return {x,y}
}

这是最简单的方法.请记住,纬度/经度是角度,而x和y是距(0/0)的距离

This is the simplest way. Keep in mind that Lat/Lon are angles, while x and y are distances from (0/0)

这篇关于以米为单位的2D开放式街道地图数据表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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