I need to customize osm2po logic in defining possible speed limits of ways. osm2po takes into account only class of road while I need to consider one more parameter: is road inside or outside some city, i.e. for example: speed limit for higway=trunk inside city = 60km/h while outside it should be equal to 90km/h. What is a proper way to implement such logic? Is it feasible at all to do withing osm2po? Or may be it better/easier to load graph data into Postgres/PostGIS using osm2po generated sql-script and do speed/cost corrections there (assuming that we already have all city borders loaded into Postgres/PostGIS db) and use pgRouting as routing engine? Any advices highly appreciated.
Using the osm2po-API, namely overriding
de.cm.osm2po.converter.DefaultWayTagResolver.getSpeedInKmh() are 5 lines of code. Nevertheless you need some extra info for the areas. Which way (id) belongs to a city, which one does not? If you only have a set of polygons, you can also override
de.cm.osm2po.converter.GraphBuildInterceptor.getKmh(int, boolean) but this influences the creation of the osm2po-graph only, not the pgRouting-table. The advantage here is, that you can query the geometry of each way instead of matching its ID to some external data.
Well, there is a third option, the
de.cm.osm2po.converter.DefaultJoinInterceptor which combines both advantages but is very critical to use because it gives you full access to a resolved way before writing it for later conversion steps.