genthalili / searoute-py

A python package to calculate the shortest sea route between two points on Earth.
Apache License 2.0
81 stars 17 forks source link

enhance network at runtime #42

Closed dcwtx closed 3 months ago

dcwtx commented 3 months ago

I have a new port that isn't represented with much resolution in the existing grid, and I wanted to add some nodes, edges (and maybe a port) to the main database but it's not clear to me how to do this. The existing grid takes the route out of the way to follow existing edges; I want to supplement them with new ones.

I tried to use the instructions in "Bring your own grid" - but by creating a new Marnet object, I start with an empty grid. I'd rather like to supplement the existing nodes and edges (and possibly ports) in the data directory for the package.

The docs aren't leading me clearly to a solution to this. Shouldn't it be relatively easy to add a new set of nodes/edges (like, 10 maybe - and possibly a port) to the overall base marnet?

Also it isn't clear to me how to use the ports database in the invocation. Some other references on Medium always start of by finding coordinates and using those as the start point, but I notice there are a lot of named ports in the .data.ports_dict.py file, but it's not clear how to refer to them.

dcwtx commented 3 months ago

Ok, with respect to the issue raised about editing the marnet grid at runtime, and looking a little further into NetworkX, it is clear that these add and delete functions are methods of the graph object G. Since searoute is implemented as a function, we'd have to implement a utility helper to construct the default graph from the provided data, and introduce some ways to modify it, then return it so that it could then be provided to the searoute function through the M= parameter to do computations on. I think it would be beneficial for the helper to have a geojson output function to improve visualization (I suspect that's in the base package somewhere, just not seeing it). I'll work on a pull request and suggest a way that it could be implemented.

dcwtx commented 3 months ago

After diving into it, this is obviously a much bigger task than I knew. One of the challenges is the nature of the marnet in the open ocean. I think if I were to do it from scratch, I wouldn't create such a dense grid over the open ocean. It seems to be a proxy for finding the great circle route, instead of having a sparse grid between "gateway" points that have a distance property calculated from the great circle method. A government publication linked here takes this approach; this would have simplified the network tremendously, requiring only port entrances to be gridded intensely out to each of the gateway points.

Great idea; wish I could contribute more. But I'll close this issue now.

dcwtx commented 3 months ago

Closing comment.