Four short lines carry a lot of loneliness. The speaker has been at sea for a year, and instead of describing waves or weather, they look inward and find "the worm in my heart." A worm suggests something small, hidden, and slowly eating away at them. The poem never says exactly what it is, but judging by the setting, it could be homesickness, longing, or a gnawing restlessness.
The comparison that follows is the surprising part. This feeling is "like a train through / a city I never heard of." A train passes through a place without stopping, and the speaker doesn't even know the name of the city. That gives the feeling a sense of motion and strangeness: it moves through them, unfamiliar and out of their control. The mood is quiet, disoriented, and a little haunted. After a year away, the speaker seems cut off from the world and also from their own emotions.