Beispiel #1
0
 def _find_edge_from_path_to_segment(self, path, oriented_segment):
     edges = []
     for edge in oriented_segment.line.edges:
         if (edge.sid1 == oriented_segment and edge.sid2 == path[-1]) or \
            (edge.sid1 == path[-1] and edge.sid2 == oriented_segment):
             edges.append(gfapy.OrientedLine(edge, "+"))
         elif (edge.sid1 == oriented_segment.inverted() and
               edge.sid2 == path[-1].inverted()) or\
              (edge.sid1 == path[-1].inverted() and
               edge.sid2 == oriented_segment.inverted()):
             edges.append(gfapy.OrientedLine(edge, "-"))
     if len(edges) == 0:
         raise gfapy.NotFoundError(
             "Path is not valid, segments are not contiguous\n" +
             "Line: {}\n".format(self) + "Previous elements:\n" +
             "".join(["  {} ({})\n".format(e, e.line)
                      for e in path]) + "Current element:\n" +
             "  {} ({})\n".format(oriented_segment, oriented_segment.line))
     elif len(edges) > 1:
         raise gfapy.NotUniqueError(
             "Path is not unique\n" + "Line: {}\n".format(self) +
             "Previous elements:\n" +
             "".join(["  {} ({})\n".format(e, e.line)
                      for e in path]) + "Current element:\n" +
             "  {} ({})\n".format(oriented_segment, oriented_segment.line) +
             "Possible edges\n" +
             "".join(["  {} ({})\n".format(e, e.line) for e in edges]))
     return edges[0]
Beispiel #2
0
 def _process_not_unique(self, previous):
   """
   .. note::
     SUBCLASSES may overwrite this method
     if some kind of non unique lines shall be
     tolerated or handled differently (eg complement links)
   """
   raise gfapy.NotUniqueError(
     "Line: {}\n".format(str(self))+
     "Line or ID not unique\n"+
     "Matching previous line: {}".format(str(previous))
     )
Beispiel #3
0
 def _initialize_tag(self, n, t, s, errmsginfo=None):
     if (self.vlevel > 0):
         if n in self._data:
             raise gfapy.NotUniqueError(
                 "Tag {} found multiple times".format(n))
         elif self._is_predefined_tag(n):
             self._validate_predefined_tag_type(n, t)
         else:
             self._validate_custom_tagname(n)
             self._datatype[n] = t
     else:
         if not self._field_datatype(t):
             self._datatype[n] = t
     self._init_field_value(n, t, s, errmsginfo=errmsginfo)
Beispiel #4
0
 def _import_tags_of_previous_group_definition(self, previous):
     for tag in previous.tagnames:
         prv = previous.get(tag)
         cur = self.get(tag)
         if cur:
             if cur != prv:
                 raise gfapy.NotUniqueError(
                     "Same tag defined differently in " +
                     "multiple group lines with same ID\n" +
                     "Previous tag definition: {}\n".format(prv) +
                     "New tag definition: {}\n".format(cur) +
                     "Group ID: {}".format(self.name))
         else:
             self.set(tag, prv)