Open ThangLeQuoc opened 4 months ago
Up
Feature is actively developed on branch integrate_gis_data, will ship it to the release soon Sneak peak:
When trying to check the validity of geom records, there are some records failed the check MySQL
SELECT *
FROM vn_gis vg
WHERE ST_IsValid(gis_geom) IS FALSE;
The result is the same for Microsoft SQL Server, so we need to take time looking into the faulty geo record issue.
Using PostGis ST_IsValidReason reveal the following problem to the multipolygon
SELECT vn_gis.code, vn_gis."level", ST_IsValidReason(gis_geom)
FROM vn_gis
WHERE ST_IsValid(gis_geom) IS FALSE;
code | level | st_isvalidreason |
---|---|---|
184 | district | Ring Self-intersection[106.59603 21.99901] |
617 | district | Self-intersection[108.001813 15.001936] |
515 | district | Ring Self-intersection[108.001816 15.370833] |
516 | district | Self-intersection[108.001813 15.002585] |
511 | district | Self-intersection[108.001816 15.370833] |
512 | district | Ring Self-intersection[108.001818 15.601409] |
62 | province | Self-intersection[108.001813 15.001936] |
645 | district | Self-intersection[108.001798 13.107198] |
646 | district | Self-intersection[108.001798 13.106812] |
639 | district | Ring Self-intersection[108.001801 13.600474] |
660 | district | Ring Self-intersection[107.755919 11.998976] |
661 | district | Self-intersection[107.755977 11.998976] |
666 | district | Self-intersection[107.455934 11.998978] |
667 | district | Self-intersection[107.455603 11.998978] |
86 | province | Ring Self-intersection[106.074994 9.944899] |
Validity rule of a Polygon
Some of the rules of polygon validity feel obvious, and others feel arbitrary (and in fact, are arbitrary).
- Polygon rings must close.
- Rings that define holes should be inside rings that define exterior boundaries.
- Rings may not self-intersect (they may neither touch nor cross themselves).
- Rings may not touch other rings, except at a point.
- Elements of multi-polygons may not touch each other.
Checking further, the self intersection look like this on the map
List of invalid geo_gis items:
SELECT *
FROM vn_gis vg
WHERE code IN ('617','184','515','516','511','512','62','645','646','639','660','661','666','667','86');
Include geographical data Geographical data referenced from daohoangson/dvhcvn repository, his repository GIS resource is awesome. Don't hesitate to give his amazing repository a star as well