If you read the previous recipe about custom projections, you might have noticed the note about data that crosses the edge of projections and how it doesn't usually render properly. When working on data near -180 or 180 degrees longitude, you are going to have this issue. Maps showing far Eastern Russia, Fiji, New Zealand, and the South Pacific, to name a few places, will often contend with this issue.
The required solution really depends on what you're trying to do. If you just need a map of such areas, pick a locally suitable projection. If you have existing data from other sources, it may be cut along the edge and you might need to stitch it back together. As for worldwide maps, sometimes you have to trim .01 degrees of the edge of your data so that it doesn't display oddly.
To follow this recipe, you will need the honolulu-flights.shp layer and the SpatiaLite database new-zealand.sqlite from the sample data.
Load the honolulu-flights.shp layer in QGIS. This layer represents great circles flight lines from the Honolulu airport. As you can see, it is displayed in a very strange manner, as some flight lines cross the dateline meridian:

To display this layer correctly, we can select a suitable projection for your map. To do this, perform the following steps:

Another option is to clip data to the dateline meridian. This can be done with the ogr2ogr tool from the GDAL toolset. To do this, perform the following steps:
honolulu-flights.shp is located, for example, the following directory:
cd c:\data
ogr2ogr -wrapdateline honolulu-flights-wrapped.shp honolulu-flights.shp
honolulu-flights-wrapped.shp layer into QGIS, you will now see that flights wrapped on the dateline meridian are displayed correctly:
nz-coastlines-and-islands layer from the new-zealand.sqlite database. You should see two sets of polygons far from each other. This is New Zealand and Chatham islands, which should be located nearby:
To display them correctly, we can use the ST_Shift_Longitude function available in the SpatiaLite. To do this, perform the following steps:
new-zealand database.
UPDATE "nz-coastlines-and-islands" SET Geometry=ST_Shift_Longitude(Geometry)
nz-coastlines-and-islands layer from QGIS and add it again. Now, New Zealand and Chatham islands will be displayed correctly, as follows:
It is worth mentioning that the ST_Shift_Longitude function is also available in PostGIS.
When we enable 'on the fly' CRS transformation, every geometry is reprojected to the given CRS (in our case Pacific centered) so that coordinates now have the same sign.
The ogr2ogr tool with the -wrapdateline option splits all geometries that cross the dateline and write them to the output file. Geometries that do not cross the dateline are copied without changes.
The ST_Shift_Longitude function translates negative longitudes by 360 and as a result, all the data will be in the range of 0-360 degrees and displayed correctly.