Area Object Service¶
The Area Object Service accesses area objects. It is possible to use a Get and Set method for getting access to the data and setting it in windPRO. It is possible to change the roughness class assigned to a certain area. An example to run the service 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'), 'New Salem\\3.6')
project_path = os.path.join(working_dir, 'New Salem.w36p')
_windproapi.start_windpro_random_port()
# Services
project_service = _windproapi.get_service('ProjectService')
objects_service = _windproapi.get_service('ObjectsService')
obj_area_service = _windproapi.get_service('ObjAreaService')
online_data_service = _windproapi.get_service('OnlineDataService')
# Loading New Salem project
project_service.LoadFromFile(filename=project_path)
# Downloading area data from online data
roughness_layer = objects_service.AddLayer(layerName='New Roughness Area', parentFolderHandle=0)
# Finding the site center latitude and longitude
site_center_obj = objects_service.GetObjects(apiObjType='SiteCenter')[0]
lat = site_center_obj.Lat
lng = site_center_obj.Lng
# Preparing download and
terrain_data_type = 'ODSRoughnessArea'
online_data_service.PrepareService(dataType=terrain_data_type, lat=lat, lon=lng)
terrain_services = online_data_service.GetServices(dataType=terrain_data_type)
print(terrain_services)
roughness_service_id = 'DataService_Rou_GlobCover'
roughness_handle = online_data_service.DownloadRoughnessData(dataType=terrain_data_type,
implId=roughness_service_id,
userDesc='Script added roughness',
lat=lat,
lon=lng,
width=30000,
height=30000)
# Loading information from the roughness file in ¨
area_obj = obj_area_service.GetAreaObject(roughness_handle)
# Setting roughness classes up for all items by 0.5
for item in area_obj.LTyp.LTypItems.TApiLTypItem:
item.Rou += 0.5
item.Name = 'increase roughness class by 0.5 from ' + item.Name
nan_to_skipvalue(area_obj)
obj_area_service.SetAreaObject(area_obj)