Skip to content

Add vector tile and layer in debug client for AreaStops - #4565

Merged
hannesj merged 27 commits into
opentripplanner:dev-2.xfrom
entur:otp2_debug_area_stops
Dec 5, 2022
Merged

Add vector tile and layer in debug client for AreaStops#4565
hannesj merged 27 commits into
opentripplanner:dev-2.xfrom
entur:otp2_debug_area_stops

Conversation

@hannesj

@hannesj hannesj commented Nov 3, 2022

Copy link
Copy Markdown
Contributor

Summary

Currently it is not possible to visualize the coverage areas of individual flex areas. Add a vector tile layer and use it in the debug client.

TODO: We need to decide how to do configuration fir this, should we do it automatically or require the user to do it. Currently this requires the vector tile sandbox feature to be enabled and the following layer to be included.

EDIT: Now always enabled

  "vectorTileLayers": [
    {
      "name": "debugAreaStops",
      "type": "AreaStop",
      "mapper": "DebugClient",
      "cacheMaxSeconds": 600
    }
  ],

@hannesj hannesj added !New Feature A functional feature targeting the end user. +Sandbox This will be implemented as a Sandbox feature labels Nov 3, 2022
@hannesj hannesj added this to the 2.3 milestone Nov 3, 2022
@hannesj
hannesj requested a review from a team as a code owner November 3, 2022 08:51
@leonardehrenfried

Copy link
Copy Markdown
Member

What if we create a new endpoint and enable it when APIGraphInspectorTile=true?

If you want it to part of the regular vector tiles endpoint, you can add a mapping in router-config.json.

@hannesj

hannesj commented Nov 22, 2022

Copy link
Copy Markdown
Contributor Author

I will split the vector tiles API in tow, one as is in sandbox, and one in the core OTP code, which has a fixed set of debug layers.

@t2gran t2gran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I a not qualified to review the JS code, but the rest looks ok.

Comment on lines +1 to +13
/* This program is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this from all js files?

I think that is safe according to our LICENCE.md file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ac do that as a separate PR.

@hannesj
hannesj force-pushed the otp2_debug_area_stops branch from 61db73a to 38eb276 Compare November 30, 2022 13:27
@codecov-commenter

codecov-commenter commented Nov 30, 2022

Copy link
Copy Markdown

Codecov Report

Base: 60.70% // Head: 60.69% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (91d7f87) compared to base (eb8cf1b).
Patch coverage: 14.04% of modified lines in pull request are covered.

Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #4565      +/-   ##
=============================================
- Coverage      60.70%   60.69%   -0.02%     
- Complexity     12240    12242       +2     
=============================================
  Files           1579     1584       +5     
  Lines          63414    63450      +36     
  Branches        6990     6987       -3     
=============================================
+ Hits           38498    38508      +10     
- Misses         22740    22768      +28     
+ Partials        2176     2174       -2     
Impacted Files Coverage Δ
...ipplanner/ext/vectortiles/VectorTilesResource.java 21.05% <0.00%> (+12.45%) ⬆️
...ers/stations/DigitransitStationPropertyMapper.java 0.00% <ø> (ø)
...tortiles/layers/stations/StationsLayerBuilder.java 0.00% <0.00%> (ø)
...es/layers/stops/DigitransitStopPropertyMapper.java 87.09% <ø> (ø)
...xt/vectortiles/layers/stops/StopsLayerBuilder.java 0.00% <0.00%> (ø)
.../DigitransitVehicleParkingGroupPropertyMapper.java 100.00% <ø> (ø)
...kings/DigitransitVehicleParkingPropertyMapper.java 100.00% <ø> (ø)
...arkings/StadtnaviVehicleParkingPropertyMapper.java 81.25% <ø> (ø)
...ayers/vehiclerental/VehicleRentalLayerBuilder.java 0.00% <0.00%> (ø)
...vehiclerental/VehicleRentalPlacesLayerBuilder.java 0.00% <ø> (ø)
... and 43 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment thread pom.xml
</dependency>
<dependency>
<groupId>com.wdtinc</groupId>
<groupId>io.github.ci-cmg</groupId>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at this fork. If I'm not mistaken, the only thing it adds is the migration to a newer JTS version. Am I seeing this correctly?

wdtinc/mapbox-vector-tile-java@master...CI-CMG:mapbox-vector-tile:master

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct. We use a newer version of JTS, and the previous one crashed on serializing polylines.

Comment thread src/main/java/org/opentripplanner/framework/io/HttpUtils.java Outdated
@leonardehrenfried

Copy link
Copy Markdown
Member

I tried it out with IBI's flex feeds in Atlanta and Seattle and it works really well.

@leonardehrenfried

Copy link
Copy Markdown
Member

image

Thanks!

@t2gran t2gran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this review I was "very" picky, I normally try not to - sorry for that. Things like using the least open access modifier should not take extra time when writing code - the default should be private.

import org.locationtech.jts.geom.Envelope;

/* http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames */
public class WebMercatorTile {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this class there is a mixture of (y, x) and (lat, lon). I would prefer to stick to (lat, lon). Then in the JavaDoc one the class level we could mention that lat == x and lon == y in JTS. I hope I got it right ;-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A JavaDoc comments would be nice. There are also some magic numbers in here witch to me is not obvious what means like tile2lat(y + 1, zoom), 180 and 360.

Most of the method are are public, but not used outside class/package -> convert them to private/package.

@hannesj hannesj Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X and Y in this class refer to the x and y index of the map, used in the URL. I added some clarifications to the code and removed unused parts, and made helpers private

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

double minLon = tile2lon(x, zoom);
double maxLon = tile2lon(x + 1, zoom);
return new Envelope(maxLon, minLon, maxLat, minLat);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first 4 lines of the 2 methods above are duplicates - not sure if there is an easy way to avoid it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I converted everything to the JTS envelope.


public class AreaStopsLayerBuilder extends LayerBuilder<AreaStop> {

private static final Map<MapperType, BiFunction<TransitService, Locale, PropertyMapper<AreaStop>>> mappers = Map.of(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you give this a name BiFunction<TransitService, Locale, PropertyMapper<AreaStop>> the code become much easier to read. What I mean is to create a private functional interface at the bottom of this class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/main/java/org/opentripplanner/inspector/vector/LayerBuilder.java Outdated
Comment on lines +27 to +28
new T2<>("id", input.getId().toString()),
new T2<>("name", i18NStringMapper.mapNonnullToApi(input.getName()))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The T2 class is deleted, you need to make a record here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pending on #4648

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import org.opentripplanner.transit.model.site.AreaStop;
import org.opentripplanner.transit.service.TransitService;

public class DebugClientAreaStopPropertyMapper extends PropertyMapper<AreaStop> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All public class definitions and methods should have JavaDoc, except methods inheriting the JavaDoc.

@t2gran

t2gran commented Dec 4, 2022

Copy link
Copy Markdown
Member

The unit test coverage is going down int this PR.

@leonardehrenfried

Copy link
Copy Markdown
Member

The unit test coverage is going down int this PR.

I'm not sure how it works exactly, but if you merge dev-2.x you get more up-do-date coverage data.

t2gran
t2gran previously approved these changes Dec 5, 2022
Comment on lines 13 to 16
/**
* Common functionality for creating a vector tile response.
*/
public class VectorTileUtils {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is VectorTileResponseFactory a better name?

@hannesj
hannesj merged commit b2402c9 into opentripplanner:dev-2.x Dec 5, 2022
@hannesj
hannesj deleted the otp2_debug_area_stops branch December 5, 2022 13:04
t2gran pushed a commit that referenced this pull request Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!New Feature A functional feature targeting the end user. +Sandbox This will be implemented as a Sandbox feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants