0

I am using PostgreSQL with PostGIS (for spatial queries like ST_LineLocatePoint()) and pgRouting (for shortest path).

The road network I have does not include links for ferries, which is the preferable route in some cases, and is the shortest route predicted by Google/Bing etc. Our state (WA) has 10 ferries, so I can maybe manually connect the points to create links in QGIS and then potentially re-create the topology.

Is this a suggested approach for solving this problem? Is there any other easier or robust way to achieve this?

Another specific complication for my case is that the vehicles are electric, so the ferry section of the route, should not add distance to electric vehicle miles traveled. So, ideally the ferry section should have zero distance for all associated calculations. Is it possible to join the start and end points with a zero dist line? This would be analogous to shorting two points in an electric circuit.

1 Answer 1

3

When you modify your network by adding linestring segments, you also need to update the source and target attribute of each new linestring accordingly. You can run the pgr_createTopology function again, but you can also manually assign the source and target ID's. If you added a new vertex, you just need to make sure that you assign a unique vertex ID, that is then used as source or target ID.

Regarding the "zero" distance, pgRouting minimizes cost and you can define what is cost in your use case. It can be distance, but you can also have your custom cost function. So in your use case you could take power consumption as cost, and when vehicles use a ferry, the consumption would be zero.

2
  • This should work for me. I will updat here if I face any issues. I have two separate models. One needs the distance, which I can pre-calculate and use as cost with a zero value for ferry links. For another model, where enery consumption is needed, I can manually assign a zero cost to the specific links. Commented Dec 19, 2020 at 21:20
  • You can maintain as many cost-relevant attributes and formulas as you want and apply different use cases with different costs with every new query. That's the strenght of pgRouting.
    – dkastl
    Commented Dec 20, 2020 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.