def testPushLine(self): npt, wpt, wpi = poialign.getPoiAndEntranceLocations( Pt(0, 1), osmcmd.Chain([Pt(-10, 0), Pt(10, 0)]), 2) self.assertAlmostEqual(npt.x, 0) self.assertAlmostEqual(npt.y, 2) self.assertAlmostEqual(wpt.x, 0) self.assertAlmostEqual(wpt.y, 0) self.assertEqual(wpi, (0, 1))
def testPullInsideAngle(self): npt, wpt, wpi = poialign.getPoiAndEntranceLocations( Pt(4, 3), osmcmd.Chain([Pt(0, 10), Pt(0, 0), Pt(10, 0)]), 2) self.assertAlmostEqual(npt.x, 4) self.assertAlmostEqual(npt.y, 2) self.assertAlmostEqual(wpt.x, 4) self.assertAlmostEqual(wpt.y, 0) self.assertEqual(wpi, (1, 2))
def testPushInsideAcuteAngle2(self): npt, wpt, wpi = poialign.getPoiAndEntranceLocations( Pt(2, 0), osmcmd.Chain([Pt(10, 5), Pt(0, 0), Pt(10, -5)]), math.sqrt(5)) self.assertAlmostEqual(npt.x, 5, places=3) self.assertAlmostEqual(npt.y, 0, places=3) self.assertAlmostEqual(wpt.x, 0, places=3) self.assertAlmostEqual(wpt.y, 0, places=3) self.assertEqual(wpi, (1, ))
def testPushInsideAngleSide(self): npt, wpt, wpi = poialign.getPoiAndEntranceLocations( Pt(1, 5), osmcmd.Chain([Pt(0, 10), Pt(0, 0), Pt(10, 0)]), 2) self.assertAlmostEqual(npt.x, 2) self.assertAlmostEqual(npt.y, 5) self.assertAlmostEqual(wpt.x, 0) self.assertAlmostEqual(wpt.y, 5) self.assertEqual(wpi, (0, 1))
def testPushInsideBluntAngle(self): npt, wpt, wpi = poialign.getPoiAndEntranceLocations( Pt(1, 0), osmcmd.Chain([Pt(10, 50), Pt(0, 0), Pt(10, -50)]), 10) self.assertGreater(npt.x, 10) self.assertAlmostEqual(npt.y, 0, places=3) self.assertAlmostEqual(wpt.x, 0, places=3) self.assertAlmostEqual(wpt.y, 0, places=3) self.assertEqual(wpi, (1, ))
def testPushOutsideAngle(self): npt, wpt, wpi = poialign.getPoiAndEntranceLocations( Pt(0, 21), osmcmd.Chain([Pt(-10, 0), Pt(0, 20), Pt(20, 0)]), 2) self.assertAlmostEqual(npt.x, 0) self.assertAlmostEqual(npt.y, 22) self.assertAlmostEqual(wpt.x, 0) self.assertAlmostEqual(wpt.y, 20) self.assertEqual(wpi, (1, ))
def testPushBeak(self): npt, wpt, wpi = poialign.getPoiAndEntranceLocations( Pt(1, 1), osmcmd.Chain( [Pt(0, 10), Pt(0, 1), Pt(-100, -100), Pt(1, 0), Pt(10, 0)]), 2) self.assertAlmostEqual(npt.x, 2) self.assertAlmostEqual(npt.y, 2)
def getBuildingChainAroundIndex(j): pts = [] if 0 < j < len(buildingWayNodeIds) - 1: pts = buildingChain.points[j - 1:j + 2] elif isBuildingWayClosed: pts = [ buildingChain.points[-2], buildingChain.points[0], buildingChain.points[1] ] elif j == 0: pts = buildingChain.points[:2] else: pts = buildingChain.points[-2:] return osmcmd.Chain(pts)