@@ -1058,6 +1058,88 @@ public void testCropIDL() {
10581058 assertEquals (10156058.722522344 , cropRing .getPoint (4 ).getY (),
10591059 0.00000000001 );
10601060
1061+ polygon = new Polygon ();
1062+ ring = new LineString ();
1063+ ring .addPoint (new Point (-120.0 , -90.0 ));
1064+ ring .addPoint (new Point (-120.0 , 0.0 ));
1065+ ring .addPoint (new Point (-180.0 , 0.0 ));
1066+ ring .addPoint (new Point (-180.0 , -90.0 ));
1067+ ring .addPoint (new Point (-120.0 , -90.0 ));
1068+ polygon .addRing (ring );
1069+
1070+ envelope = new GeometryEnvelope (
1071+ -GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1072+ -GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1073+ GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1074+ GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH );
1075+
1076+ meters = GeometryUtils .degreesToMeters (polygon );
1077+ crop = GeometryUtils .crop (meters , envelope );
1078+ degrees = GeometryUtils .metersToDegrees (crop );
1079+ GeometryUtils .minimizeWGS84Geometry (degrees );
1080+
1081+ cropRing = degrees .getRing (0 );
1082+ assertEquals (5 , cropRing .numPoints ());
1083+ assertTrue (cropRing .isClosed ());
1084+
1085+ assertEquals (-120.0 , cropRing .getPoint (0 ).getX (), 0.00000000001 );
1086+ assertEquals (GeometryConstants .WEB_MERCATOR_MIN_LAT_RANGE ,
1087+ cropRing .getPoint (0 ).getY (), 0.0 );
1088+
1089+ assertEquals (-120.0 , cropRing .getPoint (1 ).getX (), 0.0 );
1090+ assertEquals (0.0 , cropRing .getPoint (1 ).getY (), 0.0 );
1091+
1092+ assertEquals (-180.0 , cropRing .getPoint (2 ).getX (), 0.0 );
1093+ assertEquals (0.0 , cropRing .getPoint (2 ).getY (), 0.0 );
1094+
1095+ assertEquals (-180.0 , cropRing .getPoint (3 ).getX (), 0.0 );
1096+ assertEquals (GeometryConstants .WEB_MERCATOR_MIN_LAT_RANGE ,
1097+ cropRing .getPoint (3 ).getY (), 0.0 );
1098+
1099+ assertEquals (-120.0 , cropRing .getPoint (4 ).getX (), 0.00000000001 );
1100+ assertEquals (GeometryConstants .WEB_MERCATOR_MIN_LAT_RANGE ,
1101+ cropRing .getPoint (4 ).getY (), 0.0 );
1102+
1103+ polygon = new Polygon ();
1104+ ring = new LineString ();
1105+ ring .addPoint (new Point (-13358338.89519283 , -233606567.09255272 ));
1106+ ring .addPoint (new Point (-13358338.89519283 , 0.0 ));
1107+ ring .addPoint (new Point (
1108+ -GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH , 0.0 ));
1109+ ring .addPoint (
1110+ new Point (-GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1111+ -233606567.09255272 ));
1112+ ring .addPoint (new Point (-13358338.89519283 , -233606567.09255272 ));
1113+ polygon .addRing (ring );
1114+
1115+ crop = GeometryUtils .crop (polygon , envelope );
1116+
1117+ cropRing = crop .getRing (0 );
1118+ assertEquals (5 , cropRing .numPoints ());
1119+ assertTrue (cropRing .isClosed ());
1120+
1121+ assertEquals (-13358338.89519283 , cropRing .getPoint (0 ).getX (),
1122+ 0.00000001 );
1123+ assertEquals (-GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1124+ cropRing .getPoint (0 ).getY (), 0.00000001 );
1125+
1126+ assertEquals (-13358338.89519283 , cropRing .getPoint (1 ).getX (), 0.0 );
1127+ assertEquals (0.0 , cropRing .getPoint (1 ).getY (), 0.0 );
1128+
1129+ assertEquals (-GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1130+ cropRing .getPoint (2 ).getX (), 0.0 );
1131+ assertEquals (0.0 , cropRing .getPoint (2 ).getY (), 0.0 );
1132+
1133+ assertEquals (-GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1134+ cropRing .getPoint (3 ).getX (), 0.0 );
1135+ assertEquals (-GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1136+ cropRing .getPoint (3 ).getY (), 0.00000001 );
1137+
1138+ assertEquals (-13358338.89519283 , cropRing .getPoint (4 ).getX (),
1139+ 0.00000001 );
1140+ assertEquals (-GeometryConstants .WEB_MERCATOR_HALF_WORLD_WIDTH ,
1141+ cropRing .getPoint (4 ).getY (), 0.00000001 );
1142+
10611143 }
10621144
10631145 /**
0 commit comments