def joinSegmentTables(fromTable, intoTable):
 intoTableKeys = intoTable.keys()
 fromTableKeys = fromTable.keys()
 joinedKeyTable = {}
 concatenatedTableKeys = (intoTableKeys + fromTableKeys)
 for concatenatedTableKey in concatenatedTableKeys:
  joinedKeyTable[concatenatedTableKey] = None
 joinedKeys = joinedKeyTable.keys()
 joinedKeys.sort()
 for joinedKey in joinedKeys:
  xIntersectionIndexList = []
  if (joinedKey in intoTable):
   addXIntersectionIndexesFromSegments(0, intoTable[joinedKey], xIntersectionIndexList)
  if (joinedKey in fromTable):
   addXIntersectionIndexesFromSegments(1, fromTable[joinedKey], xIntersectionIndexList)
  xIntersections = getJoinOfXIntersectionIndexes(xIntersectionIndexList)
  lineSegments = getSegmentsFromXIntersections(xIntersections, joinedKey)
  if (len(lineSegments) > 0):
   intoTable[joinedKey] = lineSegments
  else:
   print 'This should never happen, there are no line segments in joinSegments in euclidean'

def joinSegmentTables ( fromTable , intoTable ) : intoTableKeys = intoTable . keys ( ) fromTableKeys = fromTable . keys ( ) joinedKeyTable = { } concatenatedTableKeys = ( intoTableKeys + fromTableKeys ) for concatenatedTableKey in concatenatedTableKeys : joinedKeyTable [ concatenatedTableKey ] = None joinedKeys = joinedKeyTable . keys ( ) joinedKeys . sort ( ) for joinedKey in joinedKeys : xIntersectionIndexList = [ ] if ( joinedKey in intoTable ) : addXIntersectionIndexesFromSegments ( 0 , intoTable [ joinedKey ] , xIntersectionIndexList ) if ( joinedKey in fromTable ) : addXIntersectionIndexesFromSegments ( 1 , fromTable [ joinedKey ] , xIntersectionIndexList ) xIntersections = getJoinOfXIntersectionIndexes ( xIntersectionIndexList ) lineSegments = getSegmentsFromXIntersections ( xIntersections , joinedKey ) if ( len ( lineSegments ) > 0 ) : intoTable [ joinedKey ] = lineSegments else : print 'This should never happen, there are no line segments in joinSegments in euclidean'
join both segment tables and put the join into the intotable .