Route call based on endpoint IP?

I am looking for a way for outbound calls to route through a certain trunk based on the calling station’s SIP IP address… Does anyone know of a way to do this, or a module that exists that can accomplish it?

For a specific use case, I have some PJSIP extensions which log in to SIP phones and/or softphones from multiple physical locations. I’d like to be able to route emergency calls out a specific route based on their location so the proper caller ID for that location is used.

The only solution I have right now is to set up a separate extension for each location so an emergency CID can be configured on each one, and then set up follow me for the main extension so all of the phones ring. This works, but isn’t helpful for someone with a softphone who travels between locations. I’m hoping there’s a better way to do this.

I’m running FreePBX 13 and Asterisk 13

Thanks!

-Pat