コード例 #1
0
def test_write_matsim_schedule_produces_semantically_equal_xml_to_input_matsim_xml(
        network_object_from_test_data, tmpdir):
    matsim_xml_writer.write_matsim_schedule(
        tmpdir, network_object_from_test_data.schedule)

    xml_diff.assert_semantically_equal(os.path.join(tmpdir, 'schedule.xml'),
                                       pt2matsim_schedule_file)
コード例 #2
0
def test_write_matsim_vehicles_produces_semantically_equal_xml_to_input_matsim_xml(
        network_object_from_test_data, tmpdir):
    network = network_object_from_test_data
    matsim_xml_writer.write_matsim_schedule(tmpdir, network.schedule)
    matsim_xml_writer.write_vehicles(tmpdir, network.schedule.vehicles,
                                     network.schedule.vehicle_types)

    xml_diff.assert_semantically_equal(os.path.join(tmpdir, 'vehicles.xml'),
                                       pt2matsim_vehicles_file)
コード例 #3
0
def test_write_matsim_schedule_produces_semantically_equal_xml_to_input_matsim_xml_if_stops_need_to_reprojected(
        network_object_from_test_data, tmpdir):
    # we change all the stops in the one service and one route that exists in the test data
    network_object_from_test_data.schedule.route(
        'VJbd8660f05fe6f744e58a66ae12bd66acbca88b98').reproject('epsg:3035')

    matsim_xml_writer.write_matsim_schedule(
        tmpdir, network_object_from_test_data.schedule)

    xml_diff.assert_semantically_equal(os.path.join(tmpdir, 'schedule.xml'),
                                       pt2matsim_schedule_file)
コード例 #4
0
def test_generates_valid_matsim_schedule_xml_file(
        network_object_from_test_data, schedule_dtd, tmpdir):
    matsim_xml_writer.write_matsim_schedule(
        tmpdir, network_object_from_test_data.schedule)

    generated_file_path = os.path.join(tmpdir, 'schedule.xml')
    xml_obj = lxml.etree.parse(generated_file_path)
    assert schedule_dtd.validate(xml_obj), \
        'Doc generated at {} is not valid against DTD due to {} errors - first error {}' \
            .format(generated_file_path,
                    len(schedule_dtd.error_log.filter_from_errors()),
                    schedule_dtd.error_log.filter_from_errors()[0])
コード例 #5
0
 def write_to_matsim(self, output_dir):
     persistence.ensure_dir(output_dir)
     vehicles = matsim_xml_writer.write_matsim_schedule(output_dir, self)
     matsim_xml_writer.write_vehicles(output_dir, vehicles)