Hey,
While this won't help you for data from the SPARQL endpoint, the Geo library can be of use when working with coordinates from Wikidata/Wikibase.
https://github.com/DataValues/Geo/
This library is used by Wikibase and can thus both parse the coordinates coming from the wiki software and format coordinates to a format the wiki software supports. This library is also used by Semantic MediaWiki [0] and the Maps extension [1], so aids interoperability there as well.
[0] https://www.semantic-mediawiki.org [1] https://github.com/JeroenDeDauw/Maps#maps
Cheers
-- Jeroen De Dauw | www.EntropyWins.wtf https://entropywins.wtf | www.Professional.Wiki https://professional.wiki/ Software Crafter | Entrepreneur | Speaker | Strategist | Contributor to Wikimedia and Open Source ~=[,,_,,]:3