-
Notifications
You must be signed in to change notification settings - Fork 165
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
Raising InvalidGeometry for a valid one geometry #194
Comments
Yeah, I'm getting the same with my dataset (it's large, but it failed on the first example) {
"type": "MultiPolygon",
"coordinates": [
[
[
[
42.322,
-0.659
],
[
42.32,
-0.641
],
[
42.347,
-0.623
],
[
42.334,
-0.658
],
[
42.322,
-0.659
]
]
],
[
[
[
42.25,
-0.751
],
[
42.25,
-0.744
],
[
42.256,
-0.741
],
[
42.257,
-0.748
],
[
42.25,
-0.751
]
]
],
[
[
[
42.262,
-0.746
],
[
42.273,
-0.727
],
[
42.298,
-0.71
],
[
42.262,
-0.746
]
]
],
[
[
[
42.114,
-0.916
],
[
42.11,
-0.91
],
[
42.117,
-0.905
],
[
42.118,
-0.907
],
[
42.114,
-0.916
]
]
],
[
[
[
42.129,
-0.902
],
[
42.171,
-0.848
],
[
42.228,
-0.799
],
[
42.144,
-0.895
],
[
42.129,
-0.902
]
]
],
[
[
[
42.229,
-0.79
],
[
42.224,
-0.788
],
[
42.238,
-0.776
],
[
42.229,
-0.79
]
]
],
[
[
[
41.923,
-1.163
],
[
41.917,
-1.156
],
[
41.945,
-1.131
],
[
41.941,
-1.145
],
[
41.923,
-1.163
]
]
],
[
[
[
41.974,
-1.086
],
[
41.983,
-1.071
],
[
41.991,
-1.07
],
[
41.992,
-1.077
],
[
41.974,
-1.086
]
]
],
[
[
[
42.024,
-1.022
],
[
42.016,
-1.011
],
[
42.053,
-0.981
],
[
42.035,
-1.016
],
[
42.024,
-1.022
]
]
],
[
[
[
42.1,
-0.948
],
[
42.097,
-0.94
],
[
42.106,
-0.928
],
[
42.106,
-0.936
],
[
42.1,
-0.948
]
]
],
[
[
[
42.543,
-0.394
],
[
42.52,
-0.377
],
[
42.178,
-0.81
],
[
42.066,
-0.842
],
[
42.102,
-0.862
],
[
42.023,
-0.99
],
[
41.964,
-1.008
],
[
41.893,
-1.21
],
[
41.783,
-1.153
],
[
41.837,
-1.25
],
[
41.559,
-1.662
],
[
41.559,
-1.598
],
[
40.994,
-0.84
],
[
40.994,
2.823
],
[
41.331,
3.158
],
[
41.95,
4.063
],
[
42.079,
4.179
],
[
42.541,
4.211
],
[
42.844,
4.284
],
[
43.126,
4.635
],
[
43.531,
4.817
],
[
43.999,
4.957
],
[
44.97,
4.913
],
[
48.001,
8.001
],
[
47.001,
8.001
],
[
43.995,
9.003
],
[
43.643,
9.357
],
[
43.462,
9.416
],
[
43.396,
9.554
],
[
43.299,
9.606
],
[
43.255,
9.847
],
[
43.085,
9.905
],
[
43.009,
10.086
],
[
42.854,
10.219
],
[
42.799,
10.452
],
[
42.671,
10.617
],
[
42.91,
10.879
],
[
43.259,
11.461
],
[
43.305,
11.473
],
[
43.332,
11.424
],
[
43.455,
11.348
],
[
43.505,
11.372
],
[
43.515,
11.195
],
[
43.916,
10.713
],
[
44.306,
10.423
],
[
44.591,
10.378
],
[
44.959,
10.414
],
[
45.233,
10.56
],
[
45.32,
10.661
],
[
45.462,
10.665
],
[
45.805,
10.869
],
[
45.979,
10.778
],
[
46.237,
10.783
],
[
46.341,
10.694
],
[
46.433,
10.682
],
[
46.666,
10.747
],
[
47.1,
10.988
],
[
47.149,
11.063
],
[
47.414,
11.178
],
[
47.536,
11.182
],
[
47.698,
11.091
],
[
48.149,
11.129
],
[
48.354,
11.27
],
[
48.521,
11.31
],
[
48.658,
11.326
],
[
48.957,
11.241
],
[
49.425,
11.337
],
[
49.571,
11.454
],
[
49.946,
11.482
],
[
49.937,
11.513
],
[
50.075,
11.508
],
[
50.269,
11.587
],
[
50.476,
11.714
],
[
50.579,
11.911
],
[
50.806,
11.979
],
[
50.775,
11.988
],
[
50.797,
11.987
],
[
50.861,
11.946
],
[
50.975,
11.92
],
[
51.06,
11.871
],
[
51.28,
11.84
],
[
51.257,
11.679
],
[
51.125,
11.5
],
[
51.081,
11.315
],
[
51.094,
11.181
],
[
51.183,
11.143
],
[
51.119,
10.958
],
[
51.172,
10.576
],
[
51.029,
10.448
],
[
51.047,
10.411
],
[
51.235,
10.433
],
[
51.187,
10.544
],
[
51.392,
10.478
],
[
51.405,
10.416
],
[
51.375,
10.364
],
[
51.272,
10.376
],
[
51.249,
10.423
],
[
51.107,
10.41
],
[
50.899,
10.312
],
[
50.9,
9.994
],
[
50.802,
9.585
],
[
50.829,
9.419
],
[
50.657,
9.207
],
[
50.631,
9.064
],
[
50.442,
8.899
],
[
50.328,
8.542
],
[
50.129,
8.197
],
[
49.82,
7.923
],
[
49.823,
7.737
],
[
49.211,
6.745
],
[
49.065,
6.245
],
[
48.916,
5.928
],
[
48.205,
4.903
],
[
47.96,
4.474
],
[
46.686,
3.083
],
[
46.023,
2.439
],
[
44.764,
1.711
],
[
44.32,
1.375
],
[
43.448,
0.607
],
[
42.613,
-0.269
],
[
42.543,
-0.394
]
],
[
[
50.765,
11.97
],
[
50.764,
11.97
],
[
50.765,
11.97
],
[
50.765,
11.97
]
],
[
[
50.764,
11.97
],
[
50.763,
11.97
],
[
50.764,
11.968
],
[
50.764,
11.97
],
[
50.764,
11.97
]
],
[
[
50.77,
11.974
],
[
50.768,
11.972
],
[
50.77,
11.974
],
[
50.77,
11.974
]
]
],
[
[
[
45.006,
10.448
],
[
45.003,
10.452
],
[
45.006,
10.448
],
[
45.006,
10.448
]
]
],
[
[
[
43.477,
11.363
],
[
43.463,
11.36
],
[
43.468,
11.362
],
[
43.477,
11.363
]
]
],
[
[
[
43.477,
11.363
],
[
43.478,
11.363
],
[
43.478,
11.363
],
[
43.477,
11.363
]
]
],
[
[
[
43.496,
11.374
],
[
43.487,
11.369
],
[
43.495,
11.375
],
[
43.496,
11.374
]
]
],
[
[
[
43.496,
11.374
],
[
43.497,
11.374
],
[
43.497,
11.374
],
[
43.496,
11.374
]
]
],
[
[
[
43.455,
11.421
],
[
43.459,
11.446
],
[
43.473,
11.446
],
[
43.472,
11.433
],
[
43.455,
11.421
]
]
],
[
[
[
43.335,
11.448
],
[
43.356,
11.467
],
[
43.364,
11.495
],
[
43.36,
11.464
],
[
43.335,
11.448
]
]
],
[
[
[
50.759,
11.969
],
[
50.758,
11.969
],
[
50.761,
11.971
],
[
50.759,
11.969
]
]
],
[
[
[
43.451,
11.491
],
[
43.452,
11.5
],
[
43.465,
11.511
],
[
43.466,
11.509
],
[
43.451,
11.491
]
]
]
]
} GeoJSON is valid and I know which point throws it off - this is fine a = RGeo::Cartesian.preferred_factory.multi_polygon(decoded.first(13))
=> #<RGeo::Geos::CAPIMultiPolygonImpl:0x3ff4d9224580 "MULTIPOLYGON This is the end of the earth as we know it a = RGeo::Cartesian.preferred_factory.multi_polygon(decoded.first(14))
Traceback (most recent call last):
1: from (irb):84
RGeo::Error::InvalidGeometry (Parse error) The last point that works and the one that breaks it look like ap decoded[12..13]
[
[0] #<RGeo::Geos::CAPIPolygonImpl:0x3ff4d91c6b74 "POLYGON ((43.477 11.363, 43.463 11.36, 43.468 11.362, 43.477 11.363))">,
[1] #<RGeo::Geos::CAPIPolygonImpl:0x3ff4d91c65fc "POLYGON ((43.477 11.363, 43.478 11.363, 43.478 11.363, 43.477 11.363))">
] |
I have a hard time getting to the point where I understand why the geometry is incorrect or how to debug this. I'm using the Given this issue has been open for almost a year I am going to assume there's no active maintenance here, but if there is I can cook up a better example - data came from Geonames in GeoJSON format, this is just the end of the long series of attempts to debug this, but the result is pretty much the same as doing irb(main):090:0> data
=> {"type"=>"MultiPolygon", "coordinates"=>[[[[42.322, -0.659], [42.32, -0.641], [42.347, -0.623], [42.334, -0.658], [42.322, -0.659]]], [[[42.25, -0.751], [42.25, -0.744], [42.256, -0.741], [42.257, -0.748], [42.25, -0.751]]], [[[42.262, -0.746], [42.273, -0.727], [42.298, -0.71], [42.262, -0.746]]], [[[42.114, -0.916], [42.11, -0.91], [42.117, -0.905], [42.118, -0.907], [42.114, -0.916]]], [[[42.129, -0.902], [42.171, -0.848], [42.228, -0.799], [42.144, -0.895], [42.129, -0.902]]], [[[42.229, -0.79], [42.224, -0.788], [42.238, -0.776], [42.229, -0.79]]], [[[41.923, -1.163], [41.917, -1.156], [41.945, -1.131], [41.941, -1.145], [41.923, -1.163]]], [[[41.974, -1.086], [41.983, -1.071], [41.991, -1.07], [41.992, -1.077], [41.974, -1.086]]], [[[42.024, -1.022], [42.016, -1.011], [42.053, -0.981], [42.035, -1.016], [42.024, -1.022]]], [[[42.1, -0.948], [42.097, -0.94], [42.106, -0.928], [42.106, -0.936], [42.1, -0.948]]], [[[42.543, -0.394], [42.52, -0.377], [42.178, -0.81], [42.066, -0.842], [42.102, -0.862], [42.023, -0.99], [41.964, -1.008], [41.893, -1.21], [41.783, -1.153], [41.837, -1.25], [41.559, -1.662], [41.559, -1.598], [40.994, -0.84], [40.994, 2.823], [41.331, 3.158], [41.95, 4.063], [42.079, 4.179], [42.541, 4.211], [42.844, 4.284], [43.126, 4.635], [43.531, 4.817], [43.999, 4.957], [44.97, 4.913], [48.001, 8.001], [47.001, 8.001], [43.995, 9.003], [43.643, 9.357], [43.462, 9.416], [43.396, 9.554], [43.299, 9.606], [43.255, 9.847], [43.085, 9.905], [43.009, 10.086], [42.854, 10.219], [42.799, 10.452], [42.671, 10.617], [42.91, 10.879], [43.259, 11.461], [43.305, 11.473], [43.332, 11.424], [43.455, 11.348], [43.505, 11.372], [43.515, 11.195], [43.916, 10.713], [44.306, 10.423], [44.591, 10.378], [44.959, 10.414], [45.233, 10.56], [45.32, 10.661], [45.462, 10.665], [45.805, 10.869], [45.979, 10.778], [46.237, 10.783], [46.341, 10.694], [46.433, 10.682], [46.666, 10.747], [47.1, 10.988], [47.149, 11.063], [47.414, 11.178], [47.536, 11.182], [47.698, 11.091], [48.149, 11.129], [48.354, 11.27], [48.521, 11.31], [48.658, 11.326], [48.957, 11.241], [49.425, 11.337], [49.571, 11.454], [49.946, 11.482], [49.937, 11.513], [50.075, 11.508], [50.269, 11.587], [50.476, 11.714], [50.579, 11.911], [50.806, 11.979], [50.775, 11.988], [50.797, 11.987], [50.861, 11.946], [50.975, 11.92], [51.06, 11.871], [51.28, 11.84], [51.257, 11.679], [51.125, 11.5], [51.081, 11.315], [51.094, 11.181], [51.183, 11.143], [51.119, 10.958], [51.172, 10.576], [51.029, 10.448], [51.047, 10.411], [51.235, 10.433], [51.187, 10.544], [51.392, 10.478], [51.405, 10.416], [51.375, 10.364], [51.272, 10.376], [51.249, 10.423], [51.107, 10.41], [50.899, 10.312], [50.9, 9.994], [50.802, 9.585], [50.829, 9.419], [50.657, 9.207], [50.631, 9.064], [50.442, 8.899], [50.328, 8.542], [50.129, 8.197], [49.82, 7.923], [49.823, 7.737], [49.211, 6.745], [49.065, 6.245], [48.916, 5.928], [48.205, 4.903], [47.96, 4.474], [46.686, 3.083], [46.023, 2.439], [44.764, 1.711], [44.32, 1.375], [43.448, 0.607], [42.613, -0.269], [42.543, -0.394]], [[50.765, 11.97], [50.764, 11.97], [50.765, 11.97], [50.765, 11.97]], [[50.764, 11.97], [50.763, 11.97], [50.764, 11.968], [50.764, 11.97], [50.764, 11.97]], [[50.77, 11.974], [50.768, 11.972], [50.77, 11.974], [50.77, 11.974]]], [[[45.006, 10.448], [45.003, 10.452], [45.006, 10.448], [45.006, 10.448]]], [[[43.477, 11.363], [43.463, 11.36], [43.468, 11.362], [43.477, 11.363]]], [[[43.477, 11.363], [43.478, 11.363], [43.478, 11.363], [43.477, 11.363]]], [[[43.496, 11.374], [43.487, 11.369], [43.495, 11.375], [43.496, 11.374]]], [[[43.496, 11.374], [43.497, 11.374], [43.497, 11.374], [43.496, 11.374]]], [[[43.455, 11.421], [43.459, 11.446], [43.473, 11.446], [43.472, 11.433], [43.455, 11.421]]], [[[43.335, 11.448], [43.356, 11.467], [43.364, 11.495], [43.36, 11.464], [43.335, 11.448]]], [[[50.759, 11.969], [50.758, 11.969], [50.761, 11.971], [50.759, 11.969]]], [[[43.451, 11.491], [43.452, 11.5], [43.465, 11.511], [43.466, 11.509], [43.451, 11.491]]]]}
irb(main):091:0> geom = RGeo::GeoJSON.decode(data)
Traceback (most recent call last):
1: from (irb):91
RGeo::Error::InvalidGeometry (Parse error) |
🤔 ok, I was looking at the This seemed to work RGeo::Geos::CAPIFactory.create(uses_lenient_assertions: true).multi_polygon(decoded)
=> #<RGeo::Geos::CAPIMultiPolygonImpl:0x3ff4d91962d0 "MULTIPOLYGON (((42.322 -0.659, 42.32 -0.641, 42.347 - I'll validate the data I want (envelope for instance) but I guess that flag is helpful in some scenarios? 🤷♂ |
@dramalho I copied your data into http://geojsonlint.com/ and got
GeoJSON RFC 7946 states
Despite this, most software I've used seems to render Polygon/MultiPolygons with left-hand linear rings. I'm guessing If you're ever bored, I've found More than you ever wanted to know about GeoJSON to be a helpful resource which summarizes lots of details on the GeoJSON spec. |
It looks like both of the geometries posted have at least one self-intersection in them, which is causing the factories to raise As @dramalho pointed out, you can skip this check by passing the I'm going to close this since this is the expected behavior of the factories. |
I got this error
RGeo::Error::InvalidGeometry: LinearRing failed ring test
after run it:
linear_ring(points)
I didn't understand this error. I've already validated the GeoJSON data, and its valid.
Following data:
Providing few points like:
no error messages was raised.
Any ideas ?
The text was updated successfully, but these errors were encountered: