diff --git a/__init__.py b/__init__.py old mode 100755 new mode 100644 index 63b7f1ef..6d86b1bc --- a/__init__.py +++ b/__init__.py @@ -234,8 +234,8 @@ def draw(self, context): self.layout.operator("tesselation.voronoi", icon_value=icons_dict["voronoi"].icon_id, text='Voronoi') if EARTH_SPHERE: self.layout.operator("earth.sphere", icon="WORLD", text='lonlat to sphere') - #self.layout.operator("earth.curvature", icon="SPHERECURVE", text='Earth curvature correction') - self.layout.operator("earth.curvature", icon_value=icons_dict["curve"].icon_id, text='Earth curvature correction') + #self.layout.operator("surface.curvature", icon="SPHERECURVE", text='Earth curvature correction') + self.layout.operator("surface.curvature", icon_value=icons_dict["curve"].icon_id, text='Surface curvature correction') class VIEW3D_MT_menu_gis_object(bpy.types.Menu): bl_label = "Object" diff --git a/operators/mesh_earth_sphere.py b/operators/mesh_earth_sphere.py index 676926ad..094685a2 100644 --- a/operators/mesh_earth_sphere.py +++ b/operators/mesh_earth_sphere.py @@ -55,19 +55,21 @@ def execute(self, context): return {'FINISHED'} -EARTH_RADIUS = 6378137 #meters -def getZDelta(d): +#EARTH_RADIUS = 6378137 #meters +def getZDelta(d, radius=6378137): '''delta value for adjusting z across earth curvature http://webhelp.infovista.com/Planet/62/Subsystems/Raster/Content/help/analysis/viewshedanalysis.html''' - return sqrt(EARTH_RADIUS**2 + d**2) - EARTH_RADIUS + return sqrt(radius**2 + d**2) - radius -class OBJECT_OT_earth_curvature(Operator): - bl_idname = "earth.curvature" - bl_label = "Earth curvature correction" +class OBJECT_OT_surface_curvature(Operator): + bl_idname = "surface.curvature" + bl_label = "Surface curvature correction" bl_description = "Apply earth curvature correction for viewsheed analysis" bl_options = {"REGISTER", "UNDO"} + radius: IntProperty(name = "Radius", default=6378137, description="Sphere radius", min=1) + def execute(self, context): scn = bpy.context.scene obj = bpy.context.view_layer.objects.active @@ -85,14 +87,14 @@ def execute(self, context): for vertex in mesh.vertices: d = (viewpt.xy - vertex.co.xy).length - vertex.co.z = vertex.co.z - getZDelta(d) + vertex.co.z = vertex.co.z - getZDelta(d, self.radius) return {'FINISHED'} classes = [ OBJECT_OT_earth_sphere, - OBJECT_OT_earth_curvature + OBJECT_OT_surface_curvature ] def register():