Ruler Object Service¶
Service for accessing ruler object. To set the length and the direction modify “Count” and and “Angle”. Ruler objects can be loaded and its content modified and sent back to windPRO. A small example can be found below.
import time
import os
from windproapi.utils import get_windpro_sample_path
from windproapi import WindProApi
from windproapi import nan_to_skipvalue
# Opening windPRO
_windproapi = WindProApi()
working_dir = os.path.join(get_windpro_sample_path('3.6'), 'ObjRulerService')
os.makedirs(working_dir, exist_ok=True)
_windproapi.start_windpro_random_port()
# Project service for making a new project
project_service = _windproapi.get_service('ProjectService')
objects_service = _windproapi.get_service('ObjectsService')
obj_ruler_service = _windproapi.get_service('ObjRulerService')
# Project path and location
project_path = os.path.join(working_dir, 'test.w36p')
lng = 10.
lat = 55.
# Making a new empty project and saving it
project_service.NewProject(lng=lng, lat=lat, filename=project_path)
# Making new radar object and getting its parameters
obj = objects_service.AddObject(apiObjType='Ruler',
lat=lat,
lng=lng,
userDesc='Length')
ruler_object = obj_ruler_service.GetRulerObject(obj.Handle)
# Setting some parameter
ruler_object.Angle = 120
ruler_object.Count = 5
ruler_object.Distance = 1000
ruler_object.LabelsOnTicks = True
nan_to_skipvalue(ruler_object)
obj_ruler_service.SetRulerObject(ruler_object)