Exemple #1
0
 def testSingleStop(self):
     feed = transitfeed.Schedule()
     kmlFile = self.GetTestDataPath('one_stop.kml')
     kmlparser.KmlParser().Parse(kmlFile, feed)
     stops = feed.GetStopList()
     self.assertEqual(1, len(stops))
     stop = stops[0]
     self.assertEqual(u'Stop Name', stop.stop_name)
     self.assertAlmostEqual(-93.239037, stop.stop_lon)
     self.assertAlmostEqual(44.854164, stop.stop_lat)
     write_output = StringIO()
     feed.WriteGoogleTransitFeed(write_output)
Exemple #2
0
  def runTest(self):
    gtfs_input = DataPath('good_feed.zip')
    feed1 = transitfeed.Loader(gtfs_input).Load()
    kmlwriter.KMLWriter().Write(feed1, self.kml_output)
    feed2 = transitfeed.Schedule()
    kmlparser.KmlParser().Parse(self.kml_output, feed2)

    stop_name_mapper = lambda x: x.stop_name

    stops1 = set(map(stop_name_mapper, feed1.GetStopList()))
    stops2 = set(map(stop_name_mapper, feed2.GetStopList()))

    self.assertEqual(stops1, stops2)
Exemple #3
0
 def testSingleShape(self):
     feed = transitfeed.Schedule()
     kmlFile = self.GetTestDataPath('one_line.kml')
     kmlparser.KmlParser().Parse(kmlFile, feed)
     shapes = feed.GetShapeList()
     self.assertEqual(1, len(shapes))
     shape = shapes[0]
     self.assertEqual(3, len(shape.points))
     self.assertAlmostEqual(44.854240, shape.points[0][0])
     self.assertAlmostEqual(-93.238861, shape.points[0][1])
     self.assertAlmostEqual(44.853081, shape.points[1][0])
     self.assertAlmostEqual(-93.238708, shape.points[1][1])
     self.assertAlmostEqual(44.852638, shape.points[2][0])
     self.assertAlmostEqual(-93.237923, shape.points[2][1])
     write_output = StringIO()
     feed.WriteGoogleTransitFeed(write_output)