mapPixelToCoords converts screen coordinates to world coordinates
mapCoordsToPixel converts world coordinates to screen coordinates
Am I understanding you right, that you'd now like to know the sprites position in the window's coordinate system relative to the view? If so, you'll first have to calculate the position of the view on the window, the use mapCoordsToPixel and subtract one from the other.
You should be able to extract the position calculation from the aspect ratio code you copied from somewhere (would also allow you to actually read and understand what the code does, instead of just copy & pasting
).
As for the example code you posted, I suggest you create an sf::FloatRect and use the contains() function instead of that unreadable if-statement.