Map connections with pokecrystal

Connecting two maps with identical widths/heights is simple enough, but I cannot figure out the formula being used for offsets. Guess and check sometimes works, but more often I'll adjust the map sizes to simplify things.

Here's an official example: east-west Ecruteak City (18h, 20w) to Route 42 (9h, 30w). For Ecruteak City it's simple: Route 42 is 9 tiles below its top and is 9 tiles high, so:

connection east, ROUTE_42, Route42, 9, 0, 9, ECRUTEAK_CITY

But I don't understand Route 42's corresponding connection:

connection west, ECRUTEAK_CITY, EcruteakCity, -3, 6, 12, ROUTE_42

Meanwhile I'm trying to adjust these maps in a similar configuration: east-west Island (15h, 17w) and Beach (11h, 21w). I'm confident in the east connection:

connection east, BEACH, Beach, 4, 0, 11, ISLAND

But this is the closest I've come to a working west connection:

connection west, ISLAND, Island, -2, 2, 15, BEACH

(The bottom part of the connection works both ways, but the upper part does not.)

I feel like there's an obvious mathematical formula that I'm missing. Is that the case?

(This is actually a bad example because I've realized while testing that the beach needs to be taller, since you can see more of it than currently exists. But the general problem stands.)

Edit: Just learned something else! If you Surf from one map directly onto another, the off-screen portion of the new map will not load. So I need to tweak those tiles on shore connecting those two maps.