Esempio n. 1
0
    def get_match_warning(self, div, match):
        # return a warning if there is something to warn about
        # or None if everything looks OK

        if not div.geography.geography:
            # If we haven't got a division geography to check against,
            # just assume its fine. Its probably fine.
            return None

        overlap = overlap_percent(OGRGeometry(div.geography.geography.ewkt),
                                  match.geom)
        if overlap >= SANITY_CHECK_TOLERANCE:
            # close enough
            return None

        warning = (
            "Found {code} as potential match for {div} " +
            "but BoundaryLine shape for {code} only covers {percent:.2f}% " +
            "of {div}'s area. Manual review required.")
        warning = warning.format(
            code=self.get_code_from_feature(match),
            div=div.official_identifier,
            percent=overlap,
        )
        return warning
Esempio n. 2
0
 def test_no_overlap(self):
     self.assertEqual(
         0,
         overlap_percent(
             OGRGeometry(
                 "SRID=4326;POLYGON((-1.9506903391078367 51.34241717557178,-1.8875189523890867 51.34241717557178,-1.8875189523890867 51.32354066802566,-1.9506903391078367 51.34241717557178))"
             ),
             OGRGeometry(
                 "SRID=4326;POLYGON((-1.9506903391078367 51.34241717557178,-1.8875189523890867 51.32354066802566,-1.9506903391078367 51.32354066802566,-1.9506903391078367 51.34241717557178))"
             ),
         ),
     )
Esempio n. 3
0
 def test_half_inside(self):
     self.assertEqual(
         50,
         round(
             overlap_percent(
                 OGRGeometry(
                     "SRID=4326;POLYGON((-1.9506903391078367 51.34241717557178,-1.8875189523890867 51.34241717557178,-1.8875189523890867 51.32354066802566,-1.9506903391078367 51.32354066802566,-1.9506903391078367 51.34241717557178))"
                 ),
                 OGRGeometry(
                     "SRID=4326;POLYGON((-1.9506903391078367 51.34241717557178,-1.8875189523890867 51.32354066802566,-1.9506903391078367 51.32354066802566,-1.9506903391078367 51.34241717557178))"
                 ),
             ),
             0,
         ),
     )