Skip to content

Commit

Permalink
Merge pull request #4172 from hove-io/access_points_depth_2
Browse files Browse the repository at this point in the history
depth=2 for access_points objects
  • Loading branch information
azime authored Jan 29, 2024
2 parents 0fa8377 + dfe03fb commit 6dd63a1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ def _async_request(self):
for mode in self._modes:
object_type = type_pb2.STOP_POINT
filter = None
# if access_point is true, access points are filled in stop points
depth = 3 if self._request["_access_points"] else 2
depth = 2
if mode == fm.FallbackModes.car.name:
depth = 2
object_type = type_pb2.POI
filter = "poi_type.uri=\"poi_type:amenity:parking\""

Expand Down
22 changes: 19 additions & 3 deletions source/jormungandr/tests/access_points_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def access_point_is_present(access_point_list, access_point_name):
@dataset({"access_points_test": {}})
class TestAccessPoints(AbstractTestFixture):
def test_access_points_with_stop_points(self):
r = self.query_region('stop_points?depth=3')
r = self.query_region('stop_points?depth=2')
assert len(get_not_null(r, 'stop_points')) == 7

for sp in r['stop_points']:
Expand Down Expand Up @@ -82,7 +82,7 @@ def test_access_points_with_stop_points(self):
assert ap['traversal_time'] == 26
assert ap['access_point']['access_point_code'] == "access_point_code_4"

# without depth=3
# without depth=2
r = self.query_region('stop_points')
assert len(get_not_null(r, 'stop_points')) == 7

Expand All @@ -94,8 +94,15 @@ def test_access_points_with_stop_points(self):
if sp['name'] == 'spC':
assert "access_points" not in sp

def test_access_points_with_stop_points_depth_1(self):
r = self.query_region('stop_points?depth=1')
assert len(get_not_null(r, 'stop_points')) == 7

for sp in r['stop_points']:
assert "access_points" not in sp

def test_access_points_with_places_nearby(self):
response = self.query_region("coords/2.362795;48.872871/places_nearby?depth=3")
response = self.query_region("coords/2.362795;48.872871/places_nearby?depth=2")
assert len(response['places_nearby']) > 0
is_valid_places(response['places_nearby'])

Expand All @@ -117,6 +124,15 @@ def test_access_points_with_places_nearby(self):
assert ap['length'] == 10
assert ap['traversal_time'] == 23

def test_access_points_with_places_nearby_depth_1(self):
response = self.query_region("coords/2.362795;48.872871/places_nearby?depth=1")
assert len(response['places_nearby']) > 0
is_valid_places(response['places_nearby'])
sp_places_nearby = [sp for sp in response['places_nearby'] if sp["embedded_type"] == "stop_point"]
assert len(sp_places_nearby) == 6
for pn in sp_places_nearby:
assert "access_points" not in pn['stop_point']

def test_access_points_api(self):
r = self.query_region('access_points')
assert len(get_not_null(r, 'access_points')) == 3
Expand Down
2 changes: 1 addition & 1 deletion source/type/pb_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ void PbCreator::Filler::fill_pb_object(const nt::StopPoint* sp, pbnavitia::StopP
fill(sp->admin_list, stop_point->mutable_administrative_regions());
}
// access points
if (depth > 2) {
if (depth > 1) {
fill_access_points(sp->access_points, stop_point);
}

Expand Down

0 comments on commit 6dd63a1

Please sign in to comment.