/// <summary> /// Adds a stop. /// </summary> /// <returns></returns> public static uint AddStop(this TransitDb db, Stop stop) { var attributes = new AttributeCollection(); attributes.AddOrReplace("id", stop.Id); attributes.AddNotNullOrWhiteSpace("code", stop.Code); attributes.AddNotNullOrWhiteSpace("description", stop.Description); attributes.AddNotNullOrWhiteSpace("location_type", stop.LocationType == null ? string.Empty : stop.LocationType.Value.ToInvariantString()); attributes.AddNotNullOrWhiteSpace("name", stop.Name); attributes.AddNotNullOrWhiteSpace("timezone", stop.Timezone); attributes.AddNotNullOrWhiteSpace("url", stop.Url); attributes.AddNotNullOrWhiteSpace("wheelchairboarding", stop.WheelchairBoarding); attributes.AddNotNullOrWhiteSpace("zone", stop.Zone); var metaId = db.StopAttributes.Add(attributes); return(db.AddStop((float)stop.Latitude, (float)stop.Longitude, metaId)); }
/// <summary> /// Adds an agency. /// </summary> public static uint AddAgency(this TransitDb db, Agency agency) { var attributes = new AttributeCollection(); attributes.AddOrReplace("id", agency.Id.ToStringEmptyWhenNull()); attributes.AddNotNullOrWhiteSpace("fare_url", agency.FareURL); attributes.AddNotNullOrWhiteSpace("language_code", agency.LanguageCode); attributes.AddNotNullOrWhiteSpace("name", agency.Name); attributes.AddNotNullOrWhiteSpace("phone", agency.Phone); attributes.AddNotNullOrWhiteSpace("timezone", agency.Timezone); attributes.AddNotNullOrWhiteSpace("url", agency.URL); return(db.AgencyAttributes.Add(attributes)); }
/// <summary> /// Adds a trip for the given agency. /// </summary> public static uint AddTrip(this TransitDb db, Trip trip, global::GTFS.Entities.Route route, uint agencyId, uint scheduleId) { var attributes = new AttributeCollection(); attributes.AddOrReplace("id", trip.Id); attributes.AddNotNullOrWhiteSpace("accessibility_type", trip.AccessibilityType == null ? string.Empty : trip.AccessibilityType.ToInvariantString()); attributes.AddNotNullOrWhiteSpace("block_id", trip.BlockId); attributes.AddNotNullOrWhiteSpace("direction", trip.Direction == null ? string.Empty : trip.Direction.ToInvariantString()); attributes.AddNotNullOrWhiteSpace("headsign", trip.Headsign); attributes.AddNotNullOrWhiteSpace("route_id", trip.RouteId); attributes.AddNotNullOrWhiteSpace("service_id", trip.ServiceId); attributes.AddNotNullOrWhiteSpace("shape_id", trip.ShapeId); attributes.AddNotNullOrWhiteSpace("short_name", trip.ShortName); attributes.AddNotNullOrWhiteSpace("route_color", route.Color.ToHexColorString()); attributes.AddNotNullOrWhiteSpace("route_description", route.Description); attributes.AddNotNullOrWhiteSpace("route_long_name", route.LongName); attributes.AddNotNullOrWhiteSpace("route_short_name", route.ShortName); attributes.AddNotNullOrWhiteSpace("route_text_color", route.TextColor.ToHexColorString()); var metaId = db.TripAttributes.Add(attributes); return(db.AddTrip(scheduleId, agencyId, metaId)); }