Making Great Circle Arcs which look good on Web Mercator map?
You could calculate the Geodesics. Saying you want to show the geodesic from A to B, you could first calculate the distance and azimuth from A to B (inverse Geodesic problem) and then calculate points from A to several points between A and B (direct Geodesic problem). I have added a simple script in Python using GeographicLib just outputting the stuff in GeoJSON:
from geographiclib.geodesic import Geodesic
from geojson import MultiLineString
def geodesic(lat1, lon1, lat2, lon2, steps):
inverse = Geodesic.WGS84.Inverse(lat1, lon1, lat2, lon2)
linestrings = []
coordinates = []
for i in range(0, steps + 1):
direct = Geodesic.WGS84.Direct(inverse['lat1'], inverse['lon1'], inverse['azi1'], (i / float(steps)) * inverse['s12'])
if len(coordinates) > 0:
if (coordinates[-1][0] < -90 and direct['lon2'] > 90) or (coordinates[-1][0] > 90 and direct['lon2'] < -90):
linestrings.append(coordinates)
coordinates = []
coordinates.append((direct['lon2'], direct['lat2']))
linestrings.append(coordinates)
geojson = MultiLineString(linestrings)
return geojson
linestrings = []
# San Francisco: 37.7793, -122.4192
# Bangalore: 12.9, 77.616667
for linestring in geodesic(37.7793, -122.4192, 12.95, 77.616667, 100)['coordinates']:
linestrings.append(linestring)
# Boston: 42.357778, -71.059444
# Bangalore: 12.9, 77.616667
for linestring in geodesic(42.357778, -71.059444, 12.95, 77.616667, 100)['coordinates']:
linestrings.append(linestring)
print(MultiLineString(linestrings))
The result is the true geodesic between the points in WGS-84. Of course, you could then transform the coordinates to whatever projection you need. The result visualized on geojson.io looks like this:
The principles in this blog post transfer over to general purpose PostGIS.
http://blog.cartodb.com/jets-and-datelines/
Basically, use ST_Segmentize
on geography, and a bit of magic to slice date-line crossing lines.