10 from opals
import pyDM
13 pf = pyDM.PolygonFactory()
14 lf = pyDM.AddInfoLayoutFactory()
15 lf.addColumn(pyDM.ColumnSemantic.Id)
16 lf.addColumn(pyDM.ColumnType.uint32,
"_RegionId")
17 layout = lf.getLayout()
19 filename =
"export_test.shp"
21 def create_window(xmin, ymin, xmax, ymax):
22 pf.addPoint(xmin, ymin)
23 pf.addPoint(xmax, ymin)
24 pf.addPoint(xmax, ymax)
25 pf.addPoint(xmin, ymax)
27 return pf.getPolygon()
30 def set_attribute(obj, value):
31 obj.setAddInfoView(layout,
False)
32 obj.info().set(1, value)
37 tableDef = pyDM.ShapeTableDefinition(layout, removeLeadingUnderscore=
True)
41 tableDef2 = pyDM.ShapeTableDefinition(names=[
"Id",
"RegionId"], types=[pyDM.ColumnType.uint32, pyDM.ColumnType.int32],
42 widths=[4, 8], decimals=[0, 0])
45 print(f
"Open shape file '{filename}'")
46 exp = pyDM.ExportShape(filename)
47 exp.setAttributeMapping(layout, tableDef, idCounterIdx=0)
49 print(
"Write two polygons")
51 poly1 = create_window(0,0,10,10)
52 set_attribute(poly1, 30)
56 poly2 = create_window(30,20,50,25)
57 set_attribute(poly2, 35)
61 print(
"Close shape file")