Skip to content

Commit

Permalink
- Fixed _.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Raichev committed Nov 8, 2022
1 parent ad9891a commit 581f7c6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 137 deletions.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ Notes
Changes
========

4.0.5, 2022-YY-DD
4.0.5, 2022-11-08
-----------------
- Removed most type coercion in validation.
Probably more instructive for the user that way.
- Fixed `Issue 11 <https://gitlab.com/mrcagney/make_gtfs/-/issues/11>`_.


4.0.4, 2022-10-19
Expand Down
130 changes: 1 addition & 129 deletions data/auckland/speed_zones.geojson
Original file line number Diff line number Diff line change
@@ -1,129 +1 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"speed": 200,
"speed_zone_id": "a",
"route_type": 3
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
174.76552963256836,
-36.84198795415702
],
[
174.7753143310547,
-36.86671222190732
],
[
174.78355407714844,
-36.858334338156325
],
[
174.76552963256836,
-36.84198795415702
]
]
]
}
},
{
"type": "Feature",
"properties": {
"speed": 100,
"speed_zone_id": "b",
"route_type": 3
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
174.76106643676758,
-36.84294960290717
],
[
174.73634719848633,
-36.868497553806066
],
[
174.76982116699216,
-36.867261559242756
],
[
174.76106643676758,
-36.84294960290717
]
]
]
}
},
{
"type": "Feature",
"properties": {
"speed": 100,
"speed_zone_id": "b",
"route_type": 2
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
174.76106643676758,
-36.84294960290717
],
[
174.73634719848633,
-36.868497553806066
],
[
174.76982116699216,
-36.867261559242756
],
[
174.76106643676758,
-36.84294960290717
]
]
]
}
},
{
"type": "Feature",
"properties": {
"speed": 200,
"speed_zone_id": "c",
"route_type": 2
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
174.75831985473633,
-36.843636487467585
],
[
174.72707748413083,
-36.84913134182603
],
[
174.73257064819336,
-36.86616288062215
],
[
174.75831985473633,
-36.843636487467585
]
]
]
}
}
]
}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"shape_id":"","speed_zone_id":"b","route_type":3,"speed":100},"geometry":{"coordinates":[[[174.76736043357516,-36.84179324765078],[174.7557411745173,-36.85934428591189],[174.77803528270158,-36.87180496532289],[174.79034130103025,-36.85339076851254],[174.76736043357516,-36.84179324765078]]],"type":"Polygon"}},{"type":"Feature","properties":{"shape_id":"","speed_zone_id":"b","route_type":2,"speed":100},"geometry":{"coordinates":[[[174.76736043357516,-36.84179324765078],[174.7557411745173,-36.85934428591189],[174.77803528270158,-36.87180496532289],[174.79034130103025,-36.85339076851254],[174.76736043357516,-36.84179324765078]]],"type":"Polygon"}},{"type":"Feature","properties":{"speed_zone_id":"a","route_type":3,"speed":200},"geometry":{"coordinates":[[[174.74412069842128,-36.84729893247791],[174.73515720368863,-36.84663909049593],[174.74973178543615,-36.860554159183835],[174.7518536704664,-36.8563292730222],[174.74412069842128,-36.84729893247791]]],"type":"Polygon"}}]}
10 changes: 8 additions & 2 deletions make_gtfs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,11 @@ def compute_dists(group):
for shape_id, group in shapes_g.groupby("shape_id"):
bd = group.boundary_points.iat[0]
if bd and not bd.is_empty:
for point in bd.geoms:
if isinstance(bd, sg.Point):
bpoints = [bd]
else:
bpoints = bd.geoms
for point in bpoints:
dist = group.geometry.iat[0].project(point)
rows.append([shape_id, dist, point])

Expand Down Expand Up @@ -773,7 +777,9 @@ def build_feed(
calendar, service_by_window = build_calendar_etc(pfeed)
routes = build_routes(pfeed)
shapes = build_shapes(pfeed)
stops = build_stops(pfeed, shapes, offset=stop_offset, n=num_stops_per_shape, spacing=stop_spacing)
stops = build_stops(
pfeed, shapes, offset=stop_offset, n=num_stops_per_shape, spacing=stop_spacing
)
trips = build_trips(pfeed, routes, service_by_window)
stop_times = build_stop_times(pfeed, routes, shapes, stops, trips, buffer=buffer)

Expand Down
2 changes: 1 addition & 1 deletion notebooks/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.7"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down
9 changes: 5 additions & 4 deletions tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ def test_check_speed_zones():
with pytest.raises(pa.errors.SchemaError):
check_speed_zones(pfeed)

# Check coercion
# pfeed = sample.copy()
# pfeed.speed_zones["route_type"].iat[0] = 3
# assert isinstance(check_speed_zones(pfeed), pd.DataFrame)
# Set bad route type
pfeed = sample.copy()
pfeed.speed_zones["route_type"].iat[0] = "3"
with pytest.raises(pa.errors.SchemaError):
check_speed_zones(pfeed)

# Make speed zones IDs collide within a route type
pfeed = sample.copy()
Expand Down

0 comments on commit 581f7c6

Please sign in to comment.