Shape Object Service

Service for accessing shape object. Shape objects can be loaded and its content modified and sent back to windPRO. Properties of the object can be found here TApiObjShape. A small example can be found below.

"""
Copyright 2023 EMD International
License for this script: MIT https://opensource.org/license/mit/
License for windPRO commercial software: https://www.emd-international.com/contact-us/general-terms-conditions-sale/
"""

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('4.0'), 'ObjShapeService')
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_shape_service = _windproapi.get_service('ObjShapeService')

# Project path and location
project_path = os.path.join(working_dir, 'ObjShapeService.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='Shape',
                                lat=lat,
                                lng=lng,
                                userDesc='new shape')
shape_object = obj_shape_service.GetShapeObject(obj.Handle)

# Setting some parameter
# shape_object.MapShapeType = 'ApiCircle'
shape_object.Height = 4000
shape_object.Width = 1000

nan_to_skipvalue(shape_object)
obj_shape_service.SetShapeObject(shape_object)