def proj(self, co):
"""
:param co: coordinate
:return: transformed coordinate if self.pScene is defined
"""
if self.pScene is not None and self.pDXF is not None:
u = self.dxf_unit_scale
if len(co) == 3:
c1, c2, c3 = co
else:
c1, c2 = co
c3 = 0
if u != 1.0:
c1 *= u
c2 *= u
c3 *= u
# add
add = Vector((0, 0, 0))
if "latitude" in self.current_scene and "longitude" in self.current_scene:
if PYPROJ and type(self.pScene) not in (TransverseMercator, Indicator):
wgs84 = Proj(init="EPSG:4326")
cscn_lat = self.current_scene.get('latitude', 0)
cscn_lon = self.current_scene.get('longitude', 0)
cscn_alt = self.current_scene.get('altitude', 0)
add = Vector(transform(wgs84, self.pScene, cscn_lat, cscn_lon, cscn_alt))
# projection
newco = Vector(transform(self.pDXF, self.pScene, c1, c2, c3))
newco = newco - add
if any((c == float("inf") or c == float("-inf") for c in newco)):
self.errors.add("Projection results in +/- infinity coordinates.")
return newco
else:
u = self.dxf_unit_scale
if u != 1:
if len(co) == 3:
c1, c2, c3 = co
else:
c1, c2 = co
c3 = 0
c1 *= u
c2 *= u
c3 *= u
return Vector((c1, c2, c3))
else:
return Vector((co[0], co[1], co[2] if len(co) == 3 else 0))
评论列表
文章目录