from time import sleep

import axipy
from axipy import provider_manager, Layer, Map, view_manager, Style, Feature

from createFromSelection.ui.tools.factoryObject import FactoryGeometry
from createFromSelection.ui.tools.map_tools import getEditableTable
str_mi_style=style='Pen (1, 2, 0) Brush (1, 16777215, 16777215)'
style=Style.from_mapinfo(str_mi_style)
path_tab=r"E:\Support\AxiomaTesting\CreateObj\TestPoints.tab"
tab=provider_manager.openfile(path_tab)
layer=Layer.create(tab)
map = Map([layer])
mapview = view_manager.create_mapview(map)

mapview.map.editable_layer=mapview.map.cosmetic
editable_tab=getEditableTable(mapview.map)
list_geometry=[]
for ft in tab.items():
    list_geometry.append(ft.geometry)
cls_factory=FactoryGeometry()
count_points=cls_factory.prepare_points(list_geometry)
geo_obj=cls_factory.createGeometry(axipy.GeometryType.LineString,tab.coordsystem)
ft_new=Feature({},geo_obj,style=style)
editable_tab.insert([ft_new])
print("End")
Style.Point()
