Index: liblwgeom/lwspheroid.c
===================================================================
--- liblwgeom/lwspheroid.c	(revision 5333)
+++ liblwgeom/lwspheroid.c	(working copy)
@@ -430,6 +430,8 @@
 
 		LWDEBUGF(4, "in_south %d", in_south);
 
+		LWDEBUGF(4, "crosses_dateline(a, b) %d", crosses_dateline(&a, &b) );
+
 		if ( crosses_dateline(&a, &b) )
 		{
 			double shift;
@@ -439,15 +441,18 @@
 			else
 				shift = (M_PI - b1.lon) + 0.088; /* About 5deg more */
 
+			LWDEBUGF(4, "shift: %.8g", shift);
+			LWDEBUGF(4, "before shift a1(%.8g %.8g) b1(%.8g %.8g)", a1.lat, a1.lon, b1.lat, b1.lon);
 			point_shift(&a1, shift);
 			point_shift(&b1, shift);
+			LWDEBUGF(4, "after shift a1(%.8g %.8g) b1(%.8g %.8g)", a1.lat, a1.lon, b1.lat, b1.lon);
+			
 		}
 
-		LWDEBUGF(4, "crosses_dateline(a, b) %d", crosses_dateline(&a, &b) );
 
 		delta_lon = fabs(b1.lon - a1.lon);
 
-		LWDEBUGF(4, "(%.18g %.18g) (%.18g %.18g)", a1.lat, a1.lon, b1.lat, b1.lon);
+		LWDEBUGF(4, "a1(%.18g %.18g) b1(%.18g %.18g)", a1.lat, a1.lon, b1.lat, b1.lon);
 		LWDEBUGF(4, "delta_lon %.18g", delta_lon);
 		LWDEBUGF(4, "delta_lon_tolerance %.18g", delta_lon_tolerance);
 
Index: liblwgeom/cunit/cu_geodetic.c
===================================================================
--- liblwgeom/cunit/cu_geodetic.c	(revision 5333)
+++ liblwgeom/cunit/cu_geodetic.c	(working copy)
@@ -920,7 +920,6 @@
 	CU_ASSERT_DOUBLE_EQUAL(a1, 89.7211470368, 0.0001); /* sphere */
 	CU_ASSERT_DOUBLE_EQUAL(a2, 89.8684316032, 0.0001); /* spheroid */
 
-
 	/* Big-ass polygon */
 	lwg = lwgeom_from_ewkt("POLYGON((-2 3, -2 4, -1 4, -1 3, -2 3))", PARSER_CHECK_NONE);
 	lwgeom_calculate_gbox_geodetic(lwg, &gbox);
@@ -930,6 +929,33 @@
 	CU_ASSERT_DOUBLE_EQUAL(a1, 12341436880.1, 10.0); /* sphere */
 	CU_ASSERT_DOUBLE_EQUAL(a2, 12286574431.9, 10.0); /* spheroid */
 
+	/* One-degree square */
+	lwg = lwgeom_from_ewkt("POLYGON((8.5 2,8.5 1,9.5 1,9.5 2,8.5 2))", PARSER_CHECK_NONE);
+	lwgeom_calculate_gbox_geodetic(lwg, &gbox);
+	//a1 = lwgeom_area_sphere(lwg, &gbox, &s);
+	a2 = lwgeom_area_spheroid(lwg, &gbox, &s);
+	//printf("\nsphere: %.12g\nspheroid: %.12g\n", a1, a2);
+	CU_ASSERT_DOUBLE_EQUAL(a1, 12341436880.1, 10.0); /* sphere */
+	CU_ASSERT_DOUBLE_EQUAL(a2, 12304814950.073, 100.0); /* spheroid */
+
+	/* One-degree square *near* dateline */
+	lwg = lwgeom_from_ewkt("POLYGON((178.5 2,178.5 1,179.5 1,179.5 2,178.5 2))", PARSER_CHECK_NONE);
+	lwgeom_calculate_gbox_geodetic(lwg, &gbox);
+	//a1 = lwgeom_area_sphere(lwg, &gbox, &s);
+	a2 = lwgeom_area_spheroid(lwg, &gbox, &s);
+	//printf("\nsphere: %.12g\nspheroid: %.12g\n", a1, a2);
+	CU_ASSERT_DOUBLE_EQUAL(a1, 12341436880.1, 10.0); /* sphere */
+	CU_ASSERT_DOUBLE_EQUAL(a2, 12304814950.073, 100.0); /* spheroid */
+
+	/* One-degree square *across* dateline */
+	lwg = lwgeom_from_ewkt(" POLYGON((179.5 2,179.5 1,-179.5 1,-179.5 2,179.5 2))", PARSER_CHECK_NONE);
+	lwgeom_calculate_gbox_geodetic(lwg, &gbox);
+	a1 = lwgeom_area_sphere(lwg, &gbox, &s);
+	a2 = lwgeom_area_spheroid(lwg, &gbox, &s);
+	//printf("\nsphere: %.12g\nspheroid: %.12g\n", a1, a2);
+	//CU_ASSERT_DOUBLE_EQUAL(a1, 12341436880.1, 10.0); /* sphere */
+	CU_ASSERT_DOUBLE_EQUAL(a2, 12304814950.073, 100.0); /* spheroid */
+
 }
 
 
Index: liblwgeom/lwgeodetic.c
===================================================================
--- liblwgeom/lwgeodetic.c	(revision 5333)
+++ liblwgeom/lwgeodetic.c	(working copy)
@@ -131,6 +131,8 @@
 	double lon = p->lon + shift;
 	if ( lon > M_PI )
 		p->lon = -1.0 * M_PI + (lon - M_PI);
+	else
+		p->lon = lon;
 	return;
 }
 

