1
我试图从中心坐标以特定比例创建边界框。我试图将其保持在8.5x11英寸纸张(612x792像素@ 72dpi)的宽高比内。从中心坐标创建边界框
我在下面使用的代码主要是作品,但高度似乎有点过高,一个字母的长宽比。我没有考虑mercator投影吗?我在这里错过了什么?
def bounding_box_from_point(center:, size:, scale_denominator:)
dpi = 72
inches_per_unit = 4374754
resolution = 1/(scale_denominator * inches_per_unit * dpi)
half_width_deg = (size.width * resolution)/2
half_height_deg = (size.height * resolution)/2
BoundingBox.new(
north: center.lat + half_height_deg,
south: center.lat - half_height_deg,
east: center.lon + half_width_deg,
west: center.lon - half_width_deg
)
end
调用bounding_box_from_point(center: center, size: size, scale_denominator: scale)
有:
scale = 0.0008861342166177423 (i.e. 1/18055.955520)
center = Geometry::Location.new(lat: 37.806336, lon: -122.270625)
size.width = 612,
size.height = 792
它返回:
west: -122.27172131608657,
east: -122.26952868391342,
south: 37.804917238005615
north: 37.80775476199439
如果你去http://www.openstreetmap.org/export和输入这些边界框坐标,你可以看到,比例不匹配一张8.5x11英寸的纸......它稍微高一点。我在这里做错了什么或不理解?
它不像墨卡托投影那么重要,因为当你离开赤道时,经线距离越近越好。你的地图不是太高,太瘦了, –
@RonJensen请看http://stackoverflow.com/a/2913249/4504607 –
那么你如何调整呢? – theartofbeing