Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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
无法使用Sketchup Ruby API获取Sketchup模型的位置绑定_Ruby_Gis_Sketchup - Fatal编程技术网

无法使用Sketchup Ruby API获取Sketchup模型的位置绑定

无法使用Sketchup Ruby API获取Sketchup模型的位置绑定,ruby,gis,sketchup,Ruby,Gis,Sketchup,我有一个位于地理位置的Sketchup 3d模型。我可以得到模型的地理位置,如下所示:- latitude = Sketchup.active_model.attribute_dictionaries["GeoReference"]["Latitude"] longitude = Sketchup.active_model.attribute_dictionaries["GeoReference"]["Longitude"] 现在我想在3D地球仪上渲染这个模型。所以我需要三维模型的位置边界

我有一个位于地理位置的Sketchup 3d模型。我可以得到模型的地理位置,如下所示:-

latitude = Sketchup.active_model.attribute_dictionaries["GeoReference"]["Latitude"]

longitude = Sketchup.active_model.attribute_dictionaries["GeoReference"]["Longitude"]
现在我想在3D地球仪上渲染这个模型。所以我需要三维模型的位置边界

基本上我需要在2d地图上的模型边界框

现在,我正在从模型的角点(8角点)提取相同的内容

但它返回简单的几何点,单位为米,英寸,具体取决于模型

例如,我上传了sketchup中的模型。以下是我使用上述模型代码得到的地理位置下角上角的值

geoLocation : 25.141407985864, 55.18563969191 //lat,long
lowerCorner : (-9483.01089", -6412.376053", -162.609524") // In inches
upperCorner : (-9483.01089", 6479.387909", 12882.651999") // In inches
所以我的第一个问题是我所做的是正确的还是错误的? 第二个问题是,如果第一个问题是“是”,那么如何以lat-long格式获取lowerCorner和upperCorner的值

但它返回简单的几何点,单位为米,英寸,具体取决于模型

返回一个
Geom::Point3d
。它的x、y和z成员是a。它总是返回SketchUp的内部值,即英寸

但是,当您使用
Length.to_s
时,它将使用当前模型的单位设置并将值格式化为该单位。当您调用
Geom::Point3d.to_s
时,它将使用
Length.to_s
。另一方面,如果调用
Geom::Point3d.inspect
它将打印内部单位(英寸),而不进行格式化

我建议您使用地理定位的API方法,而不是像那样直接利用模型的属性:

听上去你可能会觉得有用

示例-I将SketchUp模型地理定位到城市广场(地理位置:):

geoLocation : 25.141407985864, 55.18563969191 //lat,long
lowerCorner : (-9483.01089", -6412.376053", -162.609524") // In inches
upperCorner : (-9483.01089", 6479.387909", 12882.651999") // In inches
model = Sketchup.active_model
bounds = model.bounds
# Get the base of the boundingbox. No need to get the top - as the
# result doesn't contain altiture information.
(0..3).each { |i|
  pt = bounds.corner(i)
  latlong = model.point_to_latlong(pt)
  latitude = latlong.x.to_f
  longitude = latlong.y.to_f
  puts "#{pt.inspect} => #{longitude}, #{latitude}"
}