Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intersection operation returns geometry with some coordinates with the incorrect precision for the PrecisionModel used #990

Open
dbotija-RatedPower opened this issue Jul 13, 2023 · 1 comment

Comments

@dbotija-RatedPower
Copy link

Hi, I found a case where I have two geometries, created with a PrecisionModel with scale 10000, and the intersecting geometry result have some coordinates with more decimals than it should have (4).

I replicated it in a unit test:

@Test
void intersectionPrecisionIssue() throws ParseException {
  PrecisionModel precisionModel = new PrecisionModel(10000);
  GeometryFactory jtsGeometryFactory = new GeometryFactory(precisionModel);
  
  WKTReader reader = new WKTReader(jtsGeometryFactory);
  Geometry polygon1 = reader.read("POLYGON ((18270.0442 4093.366, 18270.0442 4136.5772, 18270.1562 4137.0371, 18365.2813 4320.7098, 18371.2196 4306.0107, 18371.3956 4305.6304, 18372.3693 4303.7719, 18372.8271 4303.0744, 18374.1447 4301.4424, 18374.4237 4301.1298, 18382.1461 4293.29, 18466.5478 4195.7056, 18467.1167 4195.1597, 18468.2233 4194.2795, 18468.5443 4194.0477, 18500.4094 4173.228, 18505.4339 4168.1271, 18505.8255 4167.7759, 18507.8925 4166.1413, 18508.3244 4165.8412, 18555.726 4137.0858, 18556.5044 4136.5772, 18563.5213 4131.9926, 18564.0319 4131.7071, 18565.9201 4130.8159, 18566.2129 4130.7241, 18569.3143 4128.8427, 18569.8295 4128.5765, 18570.8922 4128.1162, 18572.49 4127.4242, 18573.6008 4127.1136, 18576.4737 4126.719, 18577.052 4126.6795, 18642.3008 4126.6801, 18713.7325 4109.5628, 18723.1374 4105.754, 18729.7373 4103.0812, 18730.2452 4102.9119, 18752.8122 4096.939, 18865.3335 4067.1574, 18946.5485 4033.1466, 18974.9936 4017.4059, 18984.0767 4011.492, 18997.4862 4002.7613, 19020.4646 3987.8004, 19020.959 3987.5235, 19022.7875 3986.6544, 19023.6753 3986.3474, 19024.9942 3986.0494, 19025.3674 3985.9824, 19065.0917 3980.6688, 19124.2595 3972.7544, 19124.6829 3972.7192, 19126.1988 3972.6692, 19127.0414 3972.7254, 19174.4375 3980.6688, 19238.4397 3991.3953, 19239.5027 3991.7208, 19241.6778 3992.7141, 19242.2629 3993.0393, 19242.714 3993.3387, 19247.2962 3994.0553, 19248.2187 3994.3086, 19250.8963 3995.3802, 19251.7396 3995.8338, 19253.3222 3996.9316, 19253.6279 3997.1649, 19255.2062 3998.4862, 19270.7417 4011.492, 19273.3567 4013.6812, 19296.6796 4029.1642, 19343.3123 4036.4951, 19418.9728 4025.8157, 19419.389 4025.7777, 19421.4788 4025.6902, 19422.31 4025.737, 19424.3763 4026.0585, 19425.1829 4026.2667, 19427.1468 4026.9851, 19427.8973 4027.3465, 19429.6834 4028.4342, 19430.3492 4028.9353, 19431.8887 4030.3506, 19432.4439 4030.972, 19433.6777 4032.6605, 19434.1009 4033.378, 19434.9816 4035.2747, 19435.2568 4036.0612, 19435.7505 4038.0932, 19435.8669 4038.9183, 19435.9546 4041.0071, 19435.8707 4042.0438, 19435.2384 4045.1098, 19434.9053 4046.0951, 19433.9979 4047.9797, 19433.564 4048.6922, 19432.3066 4050.3624, 19431.584 4051.1106, 19429.1501 4053.0793, 19428.0763 4053.7126, 19425.1759 4054.8904, 19424.1715 4055.1609, 19403.4223 4058.0926, 19403.3854 4058.3713, 19403.3165 4058.6384, 19403.1295 4059.3631, 19402.3264 4061.4136, 19401.8408 4062.3152, 19401.3402 4063.0241, 19400.992 4063.5172, 19400.4557 4064.1392, 19399.392 4065.1551, 19398.7467 4065.6618, 19397.5076 4066.4544, 19396.7766 4066.8279, 19395.4087 4067.3673, 19394.4178 4067.6255, 19392.2354 4067.9199, 19391.2108 4067.9334, 19358.6586 4064.4173, 19344.1888 4066.4617, 19343.4415 4066.5008, 19341.5645 4066.4333, 19341.1869 4066.4028, 19287.6402 4059.6685, 19284.1928 4059.2349, 19283.4051 4059.0586, 19282.117 4058.6384, 19281.472 4058.428, 19280.555 4058.0023, 19277.9648 4056.4008, 19277.4716 4056.0448, 19246.8216 4030.3851, 19234.5756 4022.2262, 19134.5694 4006.6258, 19040.5397 4015.1734, 18977.6476 4049.9676, 18934.5636 4077.9859, 18934.1733 4078.2112, 18932.7388 4078.9408, 18931.9022 4079.2604, 18881.9788 4092.5088, 18841.0142 4109.6506, 18840.3647 4109.8628, 18789.4329 4122.0772, 18783.1322 4123.5882, 18714.8015 4139.9752, 18673.2886 4156.4119, 18672.9236 4156.5376, 18671.6011 4156.9267, 18670.8491 4157.0759, 18669.479 4157.221, 18669.0945 4157.2441, 18577.7922 4158.5996, 18541.908 4180.3666, 18523.2578 4192.5494, 18399.4103 4318.282, 18394.8256 4327.211, 18383.333 4355.565, 18485.0487 4551.963, 18619.6375 4504.3857, 18620.0379 4504.266, 18622.0689 4503.7659, 18622.8933 4503.6469, 18624.9818 4503.5526, 18626.0185 4503.6331, 18629.0865 4504.2555, 18630.073 4504.5856, 18631.9605 4505.487, 18632.6739 4505.9183, 18634.3487 4507.1705, 18634.9638 4507.7323, 18636.3622 4509.2872, 18636.8561 4509.9585, 18637.9242 4511.7564, 18638.2773 4512.5107, 18638.9742 4514.4823, 18639.1736 4515.2915, 18639.4724 4517.3613, 18639.51 4518.1935, 18639.3993 4520.2817, 18639.2739 4521.1054, 18638.7579 4523.132, 18638.4742 4523.9153, 18637.5728 4525.8022, 18637.1417 4526.5151, 18635.8895 4528.1899, 18635.3277 4528.805, 18633.7728 4530.2034, 18633.1016 4530.6972, 18631.3038 4531.7653, 18630.5502 4532.1182, 18498.8893 4578.6871, 18658.8615 4887.5695, 19002.0755 5512.9955, 19002.9522 5513.5144, 19020.2262 5513.5144, 19020.7448 5513.3694, 19027.8789 5509.0427, 19028.3159 5493.9659, 19027.6769 5481.6912, 19027.6719 5481.5954, 19027.6742 5481.1139, 19027.8062 5478.9646, 19029.5947 5449.8438, 19031.121 5397.1848, 19031.1436 5396.8531, 19031.322 5395.1954, 19031.3709 5394.8644, 19033.7472 5382.2332, 19034.951 5362.6333, 19035.054 5361.9288, 19048.0084 5306.3658, 19048.116 5305.9852, 19048.5635 5304.6445, 19048.8804 5303.9248, 19049.5669 5302.6901, 19049.7749 5302.354, 19064.0178 5281.5569, 19064.372 5281.1077, 19065.7429 5279.5917, 19066.4554 5278.9624, 19096.0843 5258.1891, 19097.0743 5257.6739, 19098.9971 5256.9762, 19084.1289 5212.9695, 19015.8957 5149.5445, 19015.632 5149.2767, 19014.3722 5147.8787, 19013.9222 5147.281, 19012.9274 5145.6843, 19012.743 5145.3569, 19001.5682 5123.2887, 19000.7612 5122.3226, 19000.3225 5121.6883, 18999.6409 5120.4817, 18999.4638 5120.1314, 18995.5274 5111.3592, 18971.7251 5064.3539, 18971.5617 5063.9898, 18970.8292 5062.1278, 18970.7008 5061.7501, 18955.6961 5009.7455, 18955.6001 5009.3386, 18955.2205 5007.2816, 18955.1503 5006.4533, 18955.2063 5002.2765, 18951.6321 4989.6715, 18951.5331 4989.2367, 18951.2615 4987.6669, 18951.2023 4986.7835, 18954.0639 4910.2505, 18954.1051 4909.7977, 18956.684 4892.0624, 18957.967 4796.3742, 18953.5307 4771.4035, 18938.7392 4721.8666, 18938.6353 4721.4393, 18938.2268 4719.2763, 18938.1538 4718.4077, 18939.1333 4666.3094, 18939.1615 4665.8933, 18939.4023 4663.8441, 18939.5762 4663.0426, 18940.2059 4661.0785, 18940.3506 4660.6925, 18943.4069 4653.6078, 18943.7321 4642.8822, 18943.7655 4642.4638, 18943.9573 4640.9866, 18944.144 4640.1779, 18944.6191 4638.7665, 18944.959 4638.0102, 18945.6989 4636.7183, 18945.9235 4636.3672, 18958.4305 4618.7824, 18962.3458 4609.7065, 18962.6048 4609.2018, 18964.0661 4606.7687, 18964.5803 4606.0948, 18964.6372 4606.0203, 18965.9469 4604.6501, 18966.2206 4604.3882, 18967.1662 4603.5609, 18972.7008 4598.7184, 18989.377 4575.2716, 18989.9062 4574.5276, 19018.8158 4533.8806, 19047.817 4485.1227, 19048.3099 4484.4531, 19049.7084 4482.8983, 19050.3236 4482.3364, 19051.9985 4481.0844, 19052.7114 4480.6535, 19054.5985 4479.7522, 19055.3819 4479.4685, 19057.4085 4478.9527, 19058.2322 4478.8273, 19060.3204 4478.7168, 19061.1527 4478.7546, 19063.2224 4479.0536, 19064.0314 4479.253, 19065.7062 4479.8452, 19066.003 4479.9501, 19066.7574 4480.3034, 19067.9458 4481.0096, 19068.5552 4481.3717, 19069.2264 4481.8656, 19070.7811 4483.2641, 19071.3428 4483.8791, 19072.5949 4485.554, 19073.026 4486.2672, 19073.9272 4488.1543, 19074.2108 4488.9375, 19074.7266 4490.964, 19074.852 4491.7877, 19074.9625 4493.876, 19074.9247 4494.7086, 19074.6256 4496.7777, 19074.3522 4497.7804, 19073.9959 4498.6504, 19074.1614 4499.3146, 19074.2876 4500.3401, 19074.2884 4501.8232, 19074.2082 4502.647, 19073.9217 4504.1012, 19073.601 4505.0817, 19072.6597 4507.0923, 19072.3553 4507.6351, 19058.7808 4528.156, 19058.1262 4529.1456, 19052.2834 4537.9783, 19052.1784 4538.1297, 19045.316 4547.5856, 19012.2533 4603.1662, 19011.7203 4603.8797, 19010.1972 4605.5259, 19009.8763 4605.838, 18991.1462 4622.2278, 18986.9397 4628.0241, 18971.8385 4663.0305, 18970.6087 4703.2176, 18979.7966 4755.1998, 18987.5966 4781.3973, 18987.7569 4782.2376, 18987.946 4784.3866, 18987.962 4784.8171, 18987.752 4800.2093, 18993.7617 4834.2101, 18993.8235 4835.1111, 18993.7619 4836.7333, 18993.7205 4837.1855, 18986.58 4886.1307, 18984.9976 5002.1263, 18997.2202 5045.1621, 19011.6101 5077.0738, 19028.0533 5109.5452, 19113.3146 5196.3859, 19113.5951 5196.7016, 19114.5381 5197.8754, 19115.0879 5198.7654, 19116.0278 5200.8146, 19116.2475 5201.4056, 19129.2727 5246.4391, 19173.539 5231.3256, 19174.1142 5231.1732, 19176.2177 5230.7711, 19177.4094 5230.7138, 19179.542 5230.9122, 19180.5166 5231.1202, 19181.8714 5231.5809, 19182.5991 5231.9074, 19183.8432 5232.6127, 19184.182 5232.8265, 19252.9775 5280.9115, 19254.4706 5283.66, 19516.5363 5072.15, 19514.8805 5071.3258, 19513.8035 5068.3601, 19513.8457 5067.0399, 19513.1375 5058.9932, 19513.1211 5058.6209, 19513.1183 5013.6239, 19513.1371 5013.2244, 19513.3251 5011.2316, 19513.4737 5010.4496, 19514.0298 5008.5275, 19514.1588 5008.1493, 19515.9177 5003.6901, 19516.0195 5003.0376, 19525.0552 4971.3497, 19525.4781 4970.3619, 19536.3826 4951.8056, 19542.1665 4937.1416, 19542.3419 4936.7547, 19543.3152 4934.8653, 19543.7749 4934.1564, 19545.1022 4932.4975, 19545.3837 4932.1797, 19554.8757 4922.4834, 19575.3991 4891.9123, 19575.8717 4891.3276, 19576.812 4890.3547, 19577.0869 4890.0946, 19590.7736 4878.2505, 19591.1135 4877.9853, 19592.3747 4877.1003, 19593.124 4876.6805, 19594.5375 4876.0671, 19595.3564 4875.8064, 19596.8649 4875.4898, 19597.6937 4875.3994, 19604.3226 4875.3304, 19604.4593 4875.2143, 19617.1423 4865.418, 19617.4966 4865.172, 19618.8029 4864.36, 19619.7758 4863.9139, 19621.9728 4863.2255, 19623.2403 4863.0311, 19625.5431 4863.0293, 19626.1866 4863.0778, 19651.6483 4866.9577, 19652.0956 4867.0507, 19653.6725 4867.4681, 19654.52 4867.7926, 19655.9726 4868.5354, 19656.3675 4868.765, 19704.8638 4900.5545, 19705.302 4900.884, 19706.79 4902.1612, 19707.1797 4902.5416, 19758.1339 4959.1085, 19848.9881 4866.6475, 19881.0894 4826.6274, 19883.1181 4822.137, 19890.3583 4803.7241, 19894.0564 4745.5813, 19876.1746 4660.7667, 19876.0931 4660.1792, 19875.9489 4658.0656, 19875.9961 4657.0822, 19876.2273 4655.6856, 19876.4277 4654.9227, 19876.9127 4653.5937, 19877.0656 4653.2286, 19891.1249 4623.6032, 19891.1258 4611.6147, 19891.1491 4611.1709, 19891.3816 4608.9582, 19891.5652 4608.0923, 19892.2511 4605.9754, 19892.41 4605.5605, 19896.7381 4595.8141, 19897.2478 4566.253, 19897.3872 4565.2445, 19897.9466 4563.1192, 19898.1453 4562.5384, 19905.8817 4544.3384, 19892.6421 4495.5157, 19892.5545 4495.1177, 19892.2116 4493.1066, 19892.1522 4492.2969, 19892.198 4490.2577, 19892.2936 4489.4515, 19892.7262 4487.4586, 19892.8329 4487.061, 19892.9503 4486.6952, 19891.5671 4480.9266, 19891.4895 4480.5148, 19891.2855 4479.0318, 19891.2535 4478.199, 19891.3428 4476.705, 19891.474 4475.8814, 19891.8532 4474.4341, 19891.9791 4474.035, 19948.6571 4321.033, 19946.851 4266.294, 19945.2127 4250.11, 19945.1911 4249.694, 19945.1852 4247.611, 19945.3083 4246.5835, 19946.0535 4243.555, 19946.1965 4243.1158, 19946.3946 4241.3655, 19946.6319 4240.368, 19964.2001 4192.9123, 19968.2046 4152.1643, 19968.2755 4151.7037, 19968.7564 4149.4216, 19969.0456 4148.5402, 19970.0103 4146.4165, 19970.226 4146.0035, 19973.2474 4140.9179, 19973.6551 4137.4622, 19973.7314 4137.0185, 19973.8317 4136.5772, 19974.0872 4135.4526, 19974.4753 4134.4062, 19975.5998 4132.2816, 19975.9662 4131.7062, 19983.7622 4121.397, 19986.5549 4117.704, 19987.1188 4117.0932, 19987.7192 4116.5586, 19991.3778 4110.4005, 19992.8954 4105.754, 19998.9222 4087.3009, 20006.865 4062.9815, 20007.0141 4062.5912, 20007.8556 4060.6763, 20008.2636 4059.9506, 20009.462 4058.2368, 20010.0041 4057.6041, 20011.5138 4056.1571, 20012.1688 4055.6423, 20013.9318 4054.5176, 20014.6746 4054.1406, 20016.6231 4053.3814, 20017.4255 4053.1564, 20019.4847 4052.792, 20020.3153 4052.728, 20022.4061 4052.7723, 20023.2335 4052.8715, 20025.2754 4053.3229, 20026.0672 4053.5815, 20027.9818 4054.4225, 20028.7082 4054.8308, 20030.4219 4056.0292, 20031.0547 4056.5714, 20032.5013 4058.0808, 20033.1237 4058.9142, 20034.6759 4061.6327, 20034.7082 4061.7099, 20035.0772 4062.5922, 20035.6421 4064.6062, 20035.7874 4065.4275, 20035.948 4067.5119, 20035.9006 4068.5501, 20035.3763 4071.6367, 20035.2247 4072.2494, 20034.7082 4073.8243, 20018.7995 4122.3334, 20018.4184 4123.174, 20003.5216 4148.339, 19996.5845 4187.6469, 19996.5001 4188.024, 19996.1392 4189.3505, 19996.022 4189.7156, 19993.8942 4195.4396, 19992.7365 4207.0943, 19992.5784 4207.8944, 19991.987 4209.8676, 19991.85 4210.2554, 19975.2748 4250.8068, 19981.9388 4317.2115, 19981.9385 4318.0626, 19976.8875 4368.113, 19976.8304 4368.4999, 19976.4606 4370.396, 19976.1717 4371.3112, 19974.9948 4373.9543, 19974.7243 4374.4651, 19944.683 4422.9146, 19923.0991 4490.3836, 19930.3466 4520.5451, 19937.4422 4546.7197, 19937.5636 4547.3558, 19937.9268 4550.5788, 19937.95 4551.2262, 19936.9408 4576.2117, 19936.9056 4576.6122, 19936.6349 4578.6053, 19936.4533 4579.384, 19935.8143 4581.2904, 19935.6689 4581.6645, 19925.1755 4605.2965, 19924.9364 4616.8047, 19924.9024 4617.2601, 19924.6937 4618.8782, 19924.482 4619.7612, 19923.9342 4621.2983, 19923.7584 4621.7188, 19920.9403 4627.558, 19920.9027 4649.7315, 19920.8124 4650.5955, 19920.3614 4652.7488, 19920.2494 4653.1733, 19913.4001 4674.5699, 19927.8641 4751.9796, 19927.9352 4752.8624, 19927.8815 4755.0952, 19927.8468 4755.544, 19920.6489 4810.5903, 19920.4613 4811.3994, 19919.7905 4813.3853, 19919.6352 4813.7791, 19905.2447 4845.5416, 19904.9083 4846.1472, 19903.936 4847.6038, 19903.73 4847.8866, 19876.7302 4881.9019, 19876.5125 4882.1551, 19828.0419 4934.2348, 19820.3542 4942.495, 19779.2543 4986.6552, 19811.8541 5033.572, 19845.7268 5013.0286, 19846.0939 5012.6379, 19923.4953 4865.0103, 20058.8227 4334.3529, 20074.6533 4319.9445, 20221.3477 4296.9173, 20291.2682 4163.5581, 20291.9748 4160.1805, 20292.2085 4159.4237, 20292.7529 4158.11, 20292.9222 4157.75, 20304.1205 4136.5772, 20311.8162 4122.0267, 20320.4228 4105.754, 20323.0813 4100.7275, 20326.9762 4090.5511, 20332.9547 4074.9308, 20334.0693 4072.0185, 20342.1362 4046.1623, 20352.4862 4012.9882, 20352.9214 4012.0305, 20353.252 4011.492, 20354.1063 4010.1004, 20354.7644 4009.2778, 20355.8492 4008.2223, 20356.5101 4007.6964, 20357.7817 4006.8766, 20358.533 4006.492, 20359.9416 4005.9396, 20360.7544 4005.7109, 20362.2438 4005.448, 20363.2956 4005.3948, 20364.0365 4005.4495, 20364.8762 4000.5356, 20365.8762 3994.6835, 20365.8762 3871.9068, 20365.6803 3871.3124, 20365.1695 3870.9508, 20166.5897 3810.026, 20006.5022 3778.6665, 20001.2864 3777.6448, 19845.2082 3747.0707, 19843.9365 3746.8216, 19524.7342 3684.2932, 19520.0868 3683.3828, 19365.5542 3653.1115, 19362.737 3652.5596, 19211.8402 3623.0005, 19205.3871 3621.7364, 18883.7862 3558.7381, 18881.5374 3558.2976, 18730.0722 3528.6271, 18724.1875 3527.4744, 18570.8922 3497.4454, 18566.8377 3496.6512, 18561.7328 3495.6512, 18538.4582 3495.6512, 18537.6515 3496.0602, 18428.6953 3644.779, 18442.8607 3639.8697, 18465.9244 3625.9082, 18512.842 3578.3046, 18513.1498 3578.0216, 18514.7573 3576.6834, 18515.4459 3576.2161, 18517.283 3575.217, 18518.0504 3574.8926, 18520.0471 3574.2711, 18520.8631 3574.1027, 18522.9427 3573.8827, 18523.7757 3573.8767, 18525.8582 3574.0666, 18526.6766 3574.2232, 18528.6821 3574.8158, 18529.4542 3575.1291, 18531.3055 3576.1016, 18532.0014 3576.5594, 18533.6275 3577.8743, 18534.2209 3578.4592, 18535.5592 3580.0661, 18536.0272 3580.7556, 18537.0262 3582.5927, 18537.3505 3583.3602, 18537.9717 3585.3564, 18538.157 3586.3799, 18538.3333 3589.5054, 18538.2643 3590.5432, 18537.8713 3592.5976, 18537.635 3593.3973, 18536.8488 3595.3345, 18536.343 3596.2427, 18534.4966 3598.7711, 18534.0898 3599.2496, 18511.9043 3621.7364, 18508.1382 3625.5536, 18485.22 3648.7831, 18484.6889 3649.2392, 18483.2608 3650.2744, 18482.9605 3650.4733, 18479.4992 3652.5596, 18477.8182 3653.5728, 18455.9651 3666.7448, 18455.1645 3667.12, 18408.3019 3683.3828, 18402.9788 3685.2301, 18402.2921 3685.4058, 18400.541 3685.7011, 18400.1893 3685.7454, 18399.9042 3685.7693, 18398.8184 3685.8603, 18285.8822 4021.2669, 18364.0945 3988.9214, 18401.5799 3951.9006, 18402.1855 3951.404, 18447.8528 3920.5205, 18448.5573 3920.1355, 18450.4107 3919.34, 18450.7912 3919.1979, 18533.9332 3892.5812, 18534.8485 3892.3959, 18591.8319 3887.2742, 18602.9347 3881.974, 18602.7567 3880.6604, 18602.7208 3879.9432, 18602.7898 3877.9474, 18602.94 3876.9653, 18603.7344 3874.0821, 18604.1084 3873.1616, 18605.0718 3871.4113, 18605.5188 3870.7536, 18606.7909 3869.214, 18607.075 3868.903, 18613.871 3862.1654, 18614.4853 3861.661, 18616.1832 3860.5148, 18617.0901 3860.05, 18619.968 3858.9883, 18620.9599 3858.7527, 18622.9958 3858.5217, 18624.0147 3858.529, 18627.0578 3858.9187, 18627.658 3859.04, 18658.4416 3867.611, 18684.4448 3857.3809, 18685.8224 3855.5836, 18692.1722 3847.2994, 18705.239 3830.252, 18705.489 3829.955, 18706.8088 3828.525, 18707.383 3828.0067, 18708.9395 3826.8401, 18709.2608 3826.6215, 18745.7143 3804.1858, 18746.0805 3803.9845, 18747.9609 3803.0684, 18748.7415 3802.7788, 18750.7639 3802.247, 18751.5866 3802.1151, 18753.6739 3801.9881, 18754.5063 3802.0193, 18756.5783 3802.3019, 18757.3888 3802.4948, 18759.3659 3803.1762, 18760.1235 3803.5238, 18761.9291 3804.5777, 18762.7564 3805.2079, 18764.9958 3807.3953, 18765.6453 3808.2076, 18766.7418 3809.9888, 18767.1073 3810.7387, 18767.8344 3812.6988, 18768.074 3813.7106, 18768.4175 3816.8222, 18768.4043 3817.8625, 18768.1218 3819.935, 18767.9287 3820.746, 18767.2474 3822.7225, 18766.7904 3823.6573, 18765.0817 3826.2802, 18764.256 3827.2132, 18761.8598 3829.2282, 18761.3523 3829.5947, 18727.2453 3850.5892, 18705.611 3878.8199, 18705.2302 3879.2526, 18703.1835 3881.2822, 18702.2679 3881.9723, 18699.7527 3883.3812, 18699.2318 3883.6282, 18664.7087 3897.2115, 18664.1469 3897.3886, 18661.282 3898.078, 18660.3106 3898.1959, 18658.3421 3898.2065, 18657.5615 3898.1385, 18655.6253 3897.7877, 18655.2433 3897.7001, 18634.1088 3891.8171, 18633.941 3893.6173, 18633.6433 3894.8309, 18632.4564 3897.7346, 18631.8186 3898.8093, 18629.8385 3901.2422, 18628.9164 3902.0844, 18626.3142 3903.837, 18625.7632 3904.1511, 18601.3678 3915.7358, 18600.4815 3916.0422, 18597.7078 3916.669, 18597.1465 3916.7569, 18540.3179 3921.7981, 18461.939 3946.9559, 18420.8408 3974.7508, 18382.9994 4012.1906, 18382.6927 4012.4659, 18381.0926 4013.7679, 18380.4094 4014.2218, 18378.5897 4015.1918, 18378.2176 4015.3676, 18274.3464 4058.4135, 18274.3538 4058.6384, 18274.9598 4077.1013, 18274.9352 4077.7182, 18274.5849 4080.8165, 18274.3444 4081.8226, 18271.0442 4090.6816, 18270.0442 4093.366))");
  Geometry polygon2 = reader.read("POLYGON ((18271.0442 4090.6816, 18271.0442 4136.5772, 18295.8498 4136.5772, 18295.8426 4136.5878, 18295.9088 4136.6328, 18378.2446 4015.3991, 18378.6077 4015.2276, 18380.4299 4014.2562, 18381.1163 4013.8001, 18382.7187 4012.4963, 18383.0268 4012.2197, 18420.8663 3974.7819, 18461.9567 3946.9922, 18540.3259 3921.8375, 18597.1514 3916.7966, 18597.7153 3916.7083, 18600.4925 3916.0807, 18601.383 3915.7729, 18625.7757 3904.1894, 18657.5635 3898.1788, 18658.3405 3898.2465, 18660.3131 3898.2359, 18661.2891 3898.1174, 18664.1576 3897.4272, 18664.7221 3897.2492, 18699.2477 3883.6649, 18699.7711 3883.4168, 18702.2898 3882.0059, 18703.2097 3881.3125, 18705.2593 3879.28, 18705.6419 3878.8453, 18727.2726 3850.6194, 18761.3745 3829.628, 18761.8844 3829.2598, 18764.284 3827.2419, 18765.1136 3826.3045, 18766.8253 3823.6771, 18767.2844 3822.7379, 18767.9672 3820.7572, 18768.1612 3819.9424, 18768.4443 3817.8655, 18768.4575 3816.8203, 18768.1135 3813.7038, 18767.8728 3812.6872, 18767.1441 3810.7229, 18766.7769 3809.9695, 18765.6781 3808.1845, 18765.0255 3807.3684, 18762.7826 3805.1776, 18761.9514 3804.5444, 18760.142 3803.4883, 18759.3808 3803.139, 18757.4 3802.4563, 18756.5857 3802.2625, 18754.5098 3801.9794, 18753.6734 3801.9481, 18751.5822 3802.0753, 18750.7556 3802.2078, 18748.7294 3802.7406, 18747.9451 3803.0316, 18746.0621 3803.949, 18745.6942 3804.1512, 18709.2391 3826.5879, 18708.9162 3826.8075, 18707.3576 3827.9758, 18706.7806 3828.4965, 18705.459 3829.9285, 18705.2078 3830.2269, 18692.1722 3847.2337, 18692.1722 3761.3216, 18775.5522 3761.3216, 18775.5522 3871.9068, 18712.7982 3871.9068, 18712.7982 3902.73, 18682.4782 3902.73, 18682.4782 3996.992, 18470.2382 3996.992, 18470.2382 4136.5772, 18556.5044 4136.5772, 18563.5213 4131.9926, 18564.0319 4131.7071, 18565.9201 4130.8159, 18566.2129 4130.7241, 18569.3143 4128.8427, 18569.8295 4128.5765, 18570.8922 4128.1162, 18570.8922 4105.754, 18723.1374 4105.754, 18729.7373 4103.0812, 18730.2452 4102.9119, 18752.8122 4096.939, 18752.8122 4011.492, 18984.0767 4011.492, 18997.4862 4002.7613, 18997.4862 3980.6688, 19065.0917 3980.6688, 19124.2595 3972.7544, 19124.6829 3972.7192, 19126.1988 3972.6692, 19127.0414 3972.7254, 19174.4375 3980.6688, 19255.2062 3980.6688, 19255.2062 3998.4862, 19270.7417 4011.492, 19439.2402 4011.492, 19439.2402 4058.6384, 19403.3165 4058.6384, 19403.1295 4059.3631, 19402.3264 4061.4136, 19401.8408 4062.3152, 19401.3402 4063.0241, 19401.3402 4122.0772, 19287.6402 4122.0772, 19287.6402 4059.6685, 19284.1928 4059.2349, 19283.4051 4059.0586, 19282.117 4058.6384, 19242.1602 4058.6384, 19242.1602 4027.8152, 19018.1122 4027.8152, 19018.1122 4058.6384, 18965.0522 4058.6384, 18965.0522 4122.0772, 18789.4329 4122.0772, 18783.1322 4123.5882, 18783.1322 4152.9004, 18682.4782 4152.9004, 18682.4782 4247.1624, 18576.3582 4247.1624, 18576.3582 4386.7476, 18667.3182 4386.7476, 18667.3182 4511.8328, 18674.8982 4511.8328, 18674.8982 4622.418, 18621.8382 4622.418, 18621.8382 4762.0032, 18659.7382 4762.0032, 18659.7382 4887.0884, 18722.4922 4887.0884, 18722.4922 4762.0032, 18785.2462 4762.0032, 18785.2462 4636.918, 18944.4262 4636.918, 18944.4262 4606.0948, 18964.53 4606.0948, 18964.033 4606.7462, 18962.5698 4609.1823, 18962.3096 4609.6894, 18958.3954 4618.7627, 18945.8903 4636.3448, 18945.6647 4636.6976, 18944.9233 4637.992, 18944.5818 4638.7519, 18944.1055 4640.167, 18943.9179 4640.9795, 18943.7257 4642.4596, 18943.6924 4642.8768, 18940.1671 4661.0686, 18939.5375 4663.0322, 18939.3628 4663.8375, 18939.1217 4665.8896, 18939.0933 4666.3077, 18938.1138 4718.409, 18938.1871 4719.2817, 18938.5962 4721.4477, 18938.7006 4721.8771, 18953.4917 4771.4128, 18957.927 4796.3775, 18956.644 4892.0592, 18954.0654 4909.793, 18954.024 4910.2479, 18951.1622 4986.7841, 18951.2217 4987.6717, 18951.4939 4989.2446, 18951.593 4989.6799, 18955.1812 5007.2892, 18955.5609 5009.3468, 18955.6574 5009.7556, 18970.6626 5061.7621, 18970.7916 5062.1416, 18971.5248 5064.0053, 18971.689 5064.3711, 18995.4913 5111.3764, 18999.4277 5120.1486, 18999.6056 5120.5006, 19000.2874 5121.7074, 19012.7079 5145.376, 19012.893 5145.7047, 19013.8892 5147.3036, 19014.3413 5147.9042, 19015.5951 5149.2955, 19048.5221 5304.6422, 19048.0778 5305.9734, 19047.9697 5306.3558, 19035.0167 5361.9128, 19027.7583 5372.9292, 19002.9522 5372.9292, 19002.9522 5512.5144, 19020.2262 5512.5144, 19020.2262 5481.6912, 19027.6769 5481.6912, 19027.6719 5481.5954, 19027.6742 5481.1139, 19027.8062 5478.9646, 19027.8062 5372.9771, 19027.8176 5372.9846, 19035.0913 5361.9448, 19048.0471 5306.3758, 19048.1542 5305.997, 19048.6049 5304.6468, 19015.6689 5149.2579, 19014.4031 5147.8532, 19013.9552 5147.2584, 19012.9618 5145.6639, 19012.7781 5145.3378, 19000.3576 5121.6692, 18999.6762 5120.4628, 18999.4999 5120.1142, 18995.5635 5111.342, 18971.7612 5064.3367, 18971.5986 5063.9743, 18970.8668 5062.114, 18970.739 5061.7381, 18955.7348 5009.7354, 18955.6393 5009.3304, 18955.2598 5007.274, 18951.6712 4989.6631, 18951.5723 4989.2288, 18951.3013 4987.6621, 18951.2424 4986.7829, 18954.1038 4910.2531, 18954.1448 4909.8024, 18956.724 4892.0656, 18958.007 4796.3709, 18953.5697 4771.3942, 18938.7778 4721.8561, 18938.6744 4721.4309, 18938.2665 4719.2709, 18938.1938 4718.4064, 18939.1733 4666.3111, 18939.2013 4665.897, 18939.4418 4663.8507, 18939.6149 4663.053, 18940.2447 4661.0884, 18943.7718 4642.8876, 18943.8053 4642.468, 18943.9967 4640.9937, 18944.1825 4640.1888, 18944.6564 4638.7811, 18944.9947 4638.0284, 18945.7331 4636.739, 18945.9567 4636.3896, 18958.4656 4618.8021, 18962.382 4609.7236, 18962.6398 4609.2213, 18964.0992 4606.7912, 18964.6676 4606.0463, 18965.9752 4604.6784, 18966.2476 4604.4177, 18972.7307 4598.7454, 19018.8493 4533.9025, 19047.8504 4485.1448, 19048.341 4484.4784, 19049.7368 4482.9265, 19050.3491 4482.3673, 19052.0209 4481.1176, 19052.7304 4480.6887, 19054.614 4479.7891, 19055.3937 4479.5068, 19057.4165 4478.9919, 19058.2363 4478.8671, 19060.3205 4478.7568, 19061.1489 4478.7945, 19063.2147 4479.0929, 19064.0199 4479.2914, 19065.9878 4479.9872, 19066.7387 4480.3388, 19068.5331 4481.4051, 19069.2011 4481.8967, 19070.7529 4483.2925, 19071.3119 4483.9046, 19072.5617 4485.5764, 19072.9908 4486.2862, 19073.8903 4488.1698, 19074.1725 4488.9493, 19074.6874 4490.972, 19074.8122 4491.7918, 19074.9225 4493.8762, 19074.8848 4494.7048, 19074.5858 4496.7735, 19074.2485 4501.8199, 19074.1686 4502.6412, 19073.8829 4504.0911, 19073.5637 4505.0669, 19072.6241 4507.074, 19072.3211 4507.6143, 19052.2503 4537.9559, 19052.1458 4538.1066, 19045.2786 4547.5691, 19042.9262 4558.9751, 19042.9262 4636.958, 19219.4439 4636.958, 19287.6752 4511.8522, 19358.0008 4386.7819, 19830.0569 4261.7015, 19946.6615 4240.4033, 19964.2394 4192.9213, 19968.2443 4152.1693, 19968.3149 4151.7109, 19968.7951 4149.432, 19969.0829 4148.5548, 19970.0472 4146.432, 19973.8701 4136.5889, 19974.1256 4135.464, 19974.5119 4134.4226, 19975.6344 4132.3017, 19975.9991 4131.729, 19986.5856 4117.7297, 19987.1469 4117.1218, 19987.7504 4116.5844, 19991.4144 4110.4171, 20006.9027 4062.9949, 20007.0511 4062.6064, 20007.8914 4060.6942, 20008.2975 4059.9719, 20009.4937 4058.2613, 20010.0332 4057.6316, 20011.5401 4056.1873, 20012.192 4055.675, 20013.9517 4054.5524, 20014.691 4054.1772, 20016.6358 4053.4194, 20017.4344 4053.1954, 20019.4897 4052.8317, 20020.3164 4052.768, 20022.4033 4052.8122, 20023.2268 4052.911, 20025.2648 4053.3615, 20026.0529 4053.6189, 20027.9639 4054.4583, 20028.6869 4054.8647, 20030.3974 4056.0609, 20031.0272 4056.6005, 20032.4707 4058.1067, 20033.0902 4058.9362, 20034.6399 4061.6504, 20035.0393 4062.6054, 20035.6031 4064.6151, 20035.7477 4065.4325, 20035.9079 4067.5125, 20035.8608 4068.5458, 20035.3371 4071.6285, 20035.1862 4072.2383, 20034.6701 4073.8121, 20019.5102 4122.0646, 19996.546 4187.6359, 19996.4613 4188.0144, 19996.1008 4189.3391, 19995.9832 4189.7057, 19992.6972 4207.0867, 19992.5395 4207.8848, 19991.949 4209.8552, 19991.8126 4210.2412, 19975.234 4250.8009, 19981.8988 4317.2135, 19981.8985 4318.0606, 19976.8478 4368.1081, 19976.791 4368.4931, 19976.4218 4370.3861, 19976.1342 4371.297, 19974.9588 4373.9368, 19974.6896 4374.4452, 19944.6437 4422.9021, 19937.402 4546.7223, 19937.524 4547.3618, 19937.8869 4550.5818, 19937.91 4551.2261, 19936.9009 4576.2091, 19936.8658 4576.6078, 19936.595 4578.6016, 19927.824 4751.9802, 19927.8952 4752.8635, 19927.8415 4755.0932, 19927.807 4755.5399, 19920.6095 4810.5832, 19920.4228 4811.3885, 19919.7529 4813.3716, 19919.5984 4813.7635, 19905.2089 4845.5236, 19904.8741 4846.1263, 19903.9032 4847.5809, 19903.6982 4847.8624, 19876.6994 4881.8764, 19876.4827 4882.1284, 19828.0126 4934.2075, 19827.9854 4934.2368, 19828.0147 4934.2641, 19820.3609 4942.4878, 19820.3542 4942.485, 19820.3471 4942.4879, 19820.3442 4942.495, 19820.3471 4942.5021, 19820.3542 4942.505, 19820.3542 5012.1736, 19845.2082 5012.1736, 19845.2082 4934.2348, 19828.0965 4934.2348, 19876.5423 4882.1818, 19876.761 4881.9274, 19903.7618 4847.9108, 19903.9688 4847.6267, 19904.9425 4846.1681, 19905.2805 4845.5596, 19919.672 4813.7947, 19919.8281 4813.399, 19920.4998 4811.4103, 19920.6883 4810.5974, 19927.886 4755.5524, 20058.8577 4334.3752, 20074.6767 4319.9773, 20180.8654 4261.6953, 20291.3046 4163.5792, 20292.0136 4160.1905, 20292.2462 4159.4373, 20292.7895 4158.1262, 20292.958 4157.7679, 20323.1178 4100.7441, 20334.1071 4072.0316, 20352.5236 4013.0025, 20352.9568 4012.0493, 20354.1391 4010.1234, 20354.7941 4009.3047, 20355.8757 4008.2524, 20356.5334 4007.7289, 20357.8017 4006.9113, 20358.5495 4006.5285, 20359.9544 4005.9776, 20360.7633 4005.7499, 20362.2483 4005.4878, 20363.2951 4005.4349, 20364.0698 4005.4921, 20364.9162 4000.539, 20364.9162 3871.8774, 20166.5995 3809.9872, 18566.8416 3496.6112, 18538.4183 3496.6112, 18538.2933 3589.504, 18538.2246 3590.5381, 18537.8324 3592.5882, 18537.5972 3593.3841, 18536.8127 3595.3172, 18536.3092 3596.2211, 18534.4652 3598.7463, 18534.0603 3599.2226, 18485.1927 3648.7538, 18484.6641 3649.2078, 18483.238 3650.2415, 18482.9391 3650.4395, 18455.9462 3666.7095, 18455.1494 3667.0829, 18402.9673 3685.1918, 18402.2838 3685.3666, 18400.5352 3685.6615, 18400.1851 3685.7056, 18398.7821 3685.8232, 18392.2842 3746.8195, 18392.2842 3886.4468, 18447.4968 3886.4468, 18533.9358 3892.6215, 18534.8597 3892.4344, 18613.8914 3862.2004, 18614.5092 3861.6931, 18616.2036 3860.5493, 18617.1062 3860.0867, 18619.9796 3859.0267, 18620.9668 3858.7922, 18622.9979 3858.5617, 18624.012 3858.569, 18627.0513 3858.9582, 18627.6555 3859.0803, 18674.8997 3855.6236, 18685.8421 3855.6236, 18705.2702 3830.2771, 18705.519 3829.9815, 18706.837 3828.5535, 18707.4084 3828.0376, 18708.9628 3826.8727, 18709.2825 3826.6551, 18745.7344 3804.2204, 18746.0989 3804.02, 18747.9767 3803.1052, 18748.7536 3802.817, 18750.7722 3802.2862, 18751.591 3802.1549, 18753.6744 3802.0281, 18754.5028 3802.0592, 18756.5709 3802.3413, 18757.3776 3802.5333, 18759.351 3803.2134, 18760.105 3803.5593, 18761.9068 3804.611, 18762.7302 3805.2382, 18764.9661 3807.4222, 18765.6125 3808.2307, 18766.7067 3810.0081, 18767.0705 3810.7545, 18767.796 3812.7104, 18768.0345 3813.7174, 18768.3775 3816.8241, 18768.3643 3817.8595, 18768.0824 3819.9276, 18767.8902 3820.7348, 18767.2104 3822.7071, 18766.7555 3823.6375, 18765.0498 3826.2559, 18764.228 3827.1845, 18761.8352 3829.1966, 18761.3301 3829.5614, 18727.218 3850.559, 18705.5801 3878.7945, 18705.2011 3879.2252, 18703.1573 3881.2519, 18702.246 3881.9387, 18699.7343 3883.3456, 18699.2159 3883.5915, 18664.6953 3897.1738, 18664.1362 3897.35, 18661.2749 3898.0386, 18660.3081 3898.1559, 18658.3437 3898.1665, 18657.5595 3898.0982, 18625.7507 3904.1128, 18601.3526 3915.6987, 18600.4705 3916.0037, 18597.7003 3916.6297, 18597.1416 3916.7172, 18540.3099 3921.7587, 18461.9213 3946.9196, 18420.8153 3974.7197, 18382.972 4012.1615, 18382.6667 4012.4355, 18381.0689 4013.7357, 18380.3889 4014.1874, 18378.5717 4015.156, 18378.1906 4015.3361, 18295.8982 4136.506, 18295.8982 4058.6384, 18274.3538 4058.6384, 18274.9598 4077.1013, 18274.9352 4077.7182, 18274.5849 4080.8165, 18274.3444 4081.8226, 18271.0442 4090.6816))");
  Geometry intersection = polygon1.intersection(polygon2);
  
  List<Coordinate> coordinatesWithMoreDecimals = new ArrayList<>();
  for(Coordinate coordinate : intersection.getCoordinates()) {
	  BigDecimal decimalCoordinate = new BigDecimal(String.valueOf(coordinate.getX()));
	  if(decimalCoordinate.scale() > 4) {
		  coordinatesWithMoreDecimals.add(coordinate);
		  System.out.println(coordinate);
	  }
  }
  Assertions.assertTrue(coordinatesWithMoreDecimals.isEmpty());
}

This test fails because the intersection geometry has these coordinates with the x value not being rounded to 4 decimal places:

(19035.040399999998, 5362.0221, NaN)
(19074.572500000002, 4496.9724, NaN)
(19973.771099999998, 4136.8438, NaN)
(20074.769800000002, 4319.9262, NaN)
(20291.215799999998, 4163.6581, NaN)
(18627.772100000002, 3859.0718, NaN)

I have problems with those coordinates later in my code when using the equals() between the ones with the not rounded x value and the rounded ones, as they are not equal anymore.
For example here ((Polygon) intersection).getExteriorRing().getPointN(128) and reader.read("POINT (19035.0404 5362.0221)") they are both POINT (19035.0404 5362.0221), but they are not equal to each other.

I think this is a very uncommon case because I use the intersection operation extensively and this is the first time I have found this issue. Also it seems like it only affects the x value of the coordinate and not the y.

@MansoorAhmadi
Copy link

We have a similar issue. Please, look at this issue, there seems to a similarity : #991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants