eurostat / searoute

Compute shortest maritime routes between ports

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Impossible to rebuild shp file with information suez and panam straits

mhadjis opened this issue · comments

Without any changes to the marnet_densified.geojson, I rebuilt the marnet_plus_5KM.shp.
However, this file does not contain information about suez and panam straits.
Therefore, we don't have the possibility to allow the route to go through the Suez channel or not. It is always suez.
Perhaps there is a mistake on the geojson file?
Do you have an alternative proposal we should consider?

Hi Emmanuel,
To make it possible to handle suez/panama channels, you have to add a new property/field to the marnet_plus_XKM.shp file. The name of this new property must be desc_. This property should be populated only for the network section(s) passing by the suez/panama channels with the following values:.

  • suez for the Suez channel section(s)
  • "panama" for the Panama channel section(s)

You can see how this information is then handled in the class SeaRouting, here:

	private EdgeWeighter buildEdgeWeighter(boolean allowSuez, boolean allowPanama) {
		return new DijkstraIterator.EdgeWeighter() {
			public double getWeight(Edge e) {
				...
				String desc = (String)f.getAttribute("desc_");
				if(!allowSuez && "suez".equals(desc)) return Double.MAX_VALUE;
				if(!allowPanama && "panama".equals(desc)) return Double.MAX_VALUE;
				return GeoDistanceUtil.getLengthGeoKM((Geometry)f.getDefaultGeometry());
			}
		};
	}

It basically assigns an infinite weight value to these sections, to ensure the routing algorithm avoids them.

(I just enriched the documentation with this information)