1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 from CIM14
.CDPSM
.Unbalanced
.Element
import Element
23 class PositionPoint(Element
):
24 """Set of spatial coordinates that determine a point. A sequence of PositionPoints can be used to describe:
- physical location of non-point oriented objects like cables or lines, or
- area of an object like a substation, a geographical zone or a diagram object.
27 def __init__(self
, sequenceNumber
=0, xPosition
='', yPosition
='', Location
=None, *args
, **kw_args
):
28 """Initialises a new 'PositionPoint' instance.
30 @param sequenceNumber: Zero-relative sequence number of this point within a series of points.
31 @param xPosition: X axis position.
32 @param yPosition: Y axis position.
33 @param Location: Location that this position point describes.
35 #: Zero-relative sequence number of this point within a series of points.
36 self
.sequenceNumber
= sequenceNumber
39 self
.xPosition
= xPosition
42 self
.yPosition
= yPosition
45 self
.Location
= Location
47 super(PositionPoint
, self
).__init
__(*args
, **kw_args
)
49 _attrs
= ["sequenceNumber", "xPosition", "yPosition"]
50 _attr_types
= {"sequenceNumber": int, "xPosition": str, "yPosition": str}
51 _defaults
= {"sequenceNumber": 0, "xPosition": '', "yPosition": ''}
56 def getLocation(self
):
57 """Location that this position point describes.
61 def setLocation(self
, value
):
62 if self
._Location
is not None:
63 filtered
= [x
for x
in self
.Location
.PositionPoints
if x
!= self
]
64 self
._Location
._PositionPoints
= filtered
66 self
._Location
= value
67 if self
._Location
is not None:
68 if self
not in self
._Location
._PositionPoints
:
69 self
._Location
._PositionPoints
.append(self
)
71 Location
= property(getLocation
, setLocation
)