Ejemplo n.º 1
0
 def testIntersections2(self, datum):
     # centers at 2 opposite corners of a "square" and
     # radius equal to length of square side, expecting
     # the other 2 as the intersections ... but the
     # longitudes are farther and farther out
     for d in (1, 2, 5, 10, 20, 30, 40):
         r = radians(2 * d) * R_M
         n = 'intersection2 (%s) %d' % (getattr(datum, 'name', datum), d)
         try:
             t = intersections2(d, -d, r, -d, d, r, datum=datum)
             if t[0] is t[1]:
                 s = latlonDMS(t[:1], prec=4, sep=', ') + ' abutting'
             else:
                 s = latlonDMS(t, prec=4, sep=', ')
             self.test(n, s, s)
         except IntersectionError as x:
             self.test(n, str(x), '2-tuple', known=True)
Ejemplo n.º 2
0
 def _max(i, r, t=''):
     s = latlonDMS(i, form=F_D, prec=-6, sep=', ')
     return '%s  %s, %s of Random%s' % (s, _100p(
         i.lat, r.lat, 2), _100p(i.lon, r.lon, 3), t)
Ejemplo n.º 3
0
    def testDiscrepancies(self):
        # Compare ellipsoidal intersections2 for EquidistantKarney
        # and Equidistant showing the differences in degrees
        # and as percentage of the reference RandomLatLon.  Also
        # show the first, spherical intersections2 gu-/estimates.

        # Equidistant implements Snyder's formulas for the sphere
        # for ellipsoidal projections.  That plus the (high) accuracy
        # of EquidistantKarney likely cause the discrepancies.  An
        # other factor may be the innate distortions of azimuthal
        # equidistance projections for distances beyond 10,000 Km
        # (about one quarter of the earth circumference), see
        # <https://WikiPedia.org/wiki/Azimuthal_equidistant_projection>
        from pygeodesy.ellipsoidalBase import _intersects2 as _ei2
        from pygeodesy.sphericalTrigonometry import _intersects2 as _si2

        def _100p(p, q, w):
            r = abs(100 * p / q) if q else 0
            return '%0*.3f%%' % (w + 4, r)

        def _max(i, r, t=''):
            s = latlonDMS(i, form=F_D, prec=-6, sep=', ')
            return '%s  %s, %s of Random%s' % (s, _100p(
                i.lat, r.lat, 2), _100p(i.lon, r.lon, 3), t)

        for m in (ellipsoidalKarney, ellipsoidalVincenty):
            LL = m.LatLon
            e = LL(0, 0)
            n = m.__name__
            # courtesy Samuel Čavoj <https://GitHub.com/mrJean1/PyGeodesy/issues/41>}
            R = RandomLatLon(LL, 90, 90)  # +/- 45
            r = R()
            s = latlonDMS(r, form=F_D, prec=-6) + ' Random +/- 45'
            self.test(n, s, s)
            for _ in range(12):  # 100+
                p, q = R(), R()
                r1 = r.distanceTo(p)
                r2 = r.distanceTo(q)
                t = []
                for E in (None, EquidistantKarney, Equidistant):
                    a = getattr(E, '__name__', 'Spherical')
                    try:
                        i1, i2 = _si2(p, r1, q, r2, LatLon=LL) if E is None else \
                                 _ei2(p, r1, q, r2, equidistant=E, LatLon=LL)
                        d, d2 = r.distanceTo(i1), r.distanceTo(i2)
                        if d2 < d:
                            d, i1, i2 = d2, i2, i1
                        s = latlonDMS((i1, i2), form=F_D, prec=-6, sep=', ')
                        s = '%s  d %g meter  %s' % (s, d, a)
                        self.test(n, s, s)
                        if E is not None:
                            t.append(i1)
                    except (IntersectionError, TypeError, ValueError) as x:
                        self.test(n, str(x), a, known=True)
                if len(t) == 2:
                    i1, i2 = t
                    i = LL(i1.lat - i2.lat, i1.lon - i2.lon)
                    s = _max(i, r)
                    self.test(n, s, s)
                    e = LL(max(abs(i.lat), e.lat), max(abs(i.lon), e.lon))
            s = _max(e, r, ', max')
            self.test(n, s, s, nt=1)
Ejemplo n.º 4
0
    def testSpherical(self, module, Sph=True):  # MCCABE 13

        self.subtitle(module, 'Spherical')

        LatLon, Vct = module.LatLon, not Sph

        p = LatLon(51.8853, 0.2545)
        self.test('isSpherical', p.isSpherical, True)
        self.test('isEllipsoidal', p.isEllipsoidal, False)

        q = LatLon(49.0034, 2.5735)
        self.test('isSpherical', q.isSpherical, True)
        self.test('isEllipsoidal', q.isEllipsoidal, False)

        i = p.intersection(108.55, q, 32.44)
        self.test('intersection1', i.toStr(F_D),
                  '50.907608°N, 004.508575°E')  # 50.9076°N, 004.5086°E  # Trig
        self.test('intersection1', i.toStr(F_DMS),
                  '50°54′27.39″N, 004°30′30.87″E')
        self.test('intersection1', isinstance(i, LatLon), True)

        REO = LatLon(42.600, -117.866)
        BKE = LatLon(44.840, -117.806)
        i = REO.intersection(51, BKE, 137)
        self.test('intersection2', isinstance(i, LatLon), True)
        self.test('intersection2', i.toStr(F_D),
                  '43.5719°N, 116.188757°W')  # 43.572°N, 116.189°W
        self.test('intersection2', i.toStr(F_DMS),
                  '43°34′18.84″N, 116°11′19.53″W')

        # <https://GitHub.com/ChrisVeness/geodesy/issues/46>
        p = LatLon(51.8853, 0.2545)
        q = LatLon(51.8763, 0.2545)  # identical lon
        i = p.intersection(110.8878, q, 54.4525)
        self.test('intersection3', i,
                  '51.882166°N, 000.267801°E')  # 51°52′55.8″N, 000°16′04.08″E?

        p = LatLon(+30, 0)
        q = LatLon(-30, 0)  # identical, zero lon
        i = p.intersection(135, q, 45)
        self.test('intersection4',
                  i,
                  '00.0°N, 026.565051°E',
                  known=abs(i.lat) < 1e-6)

        p = LatLon(0, -30)
        q = LatLon(0, +30)  # identical, zero lat
        i = p.intersection(45, q, 315)
        self.test('intersection5',
                  i,
                  '26.565051°N, 000.0°W',
                  known=abs(i.lon) < 1e-6)

        # <https://GitHub.com/ChrisVeness/geodesy/blob/master/test/latlon-vectors-tests.js>
        STN = LatLon(51.8853, 0.2545)
        CDG = LatLon(49.0034, 2.5735)
        i = STN.intersection(108.547, CDG, 32.435)
        self.test('intersection6', i,
                  '50.907809°N, 004.50841°E')  # 50.9078°N, 004.5084°E

        # <https://GitHub.com/ChrisVeness/geodesy/blob/master/test/latlon-vectors-tests.js>
        # <https://GitHub.com/ChrisVeness/geodesy/blob/master/test/latlon-spherical-tests.js>
        N, E, S, W, p, q = 0, 90, 180, 270, LatLon(0, 1), LatLon(1, 0)
        self.test('toward 1,1 N,E nearest', p.intersection(N, q, E),
                  '00.999848°N, 001.0°E')
        self.test('toward 1,1 E,N nearest', q.intersection(E, p, N),
                  '00.999848°N, 001.0°E')
        self.test('toward 1,1 N,E antipodal',
                  LatLon(2, 1).intersection(N, q, E), '00.999848°S, 179.0°W')
        self.test('toward/away 1,1 N,W antipodal',
                  p.intersection(N, q, W),
                  '00.999848°S, 179.0°W',
                  known=Sph)
        self.test('toward/away 1,1 W,N antipodal', q.intersection(W, p, N),
                  '00.999848°S, 179.0°W')
        self.test('toward/away 1,1 S,E antipodal', p.intersection(S, q, E),
                  '00.999848°S, 179.0°W')
        self.test('toward/away 1,1 E,S antipodal',
                  q.intersection(E, p, S),
                  '00.999848°S, 179.0°W',
                  known=Sph)
        self.test('away 1,1 S,W antipodal', p.intersection(S, q, W),
                  '00.999848°S, 179.0°W')
        self.test('away 1,1 W,S antipodal', q.intersection(W, p, S),
                  '00.999848°S, 179.0°W')
        self.test('1E/90E N,E antipodal',
                  p.intersection(N, LatLon(1, 90), E),
                  '00.017454°S, 179.0°W',
                  known=Sph)
        self.test('1E/90E N,E nearest', p.intersection(N, LatLon(1, 92), E),
                  '00.017454°N, 179.0°W')

        # <https://GitHub.com/ChrisVeness/geodesy/blob/master/test/latlon-vectors-tests.js>
        p, r = LatLon(1, 3), LatLon(2, 2)
        self.test('brng+end 1a', q.intersection(p, r, S),
                  '01.000305°N, 002.0°E')
        self.test('brng+end 1b', r.intersection(S, q, p),
                  '01.000305°N, 002.0°E')
        self.test('brng+end 2a', q.intersection(p, r, N),
                  '01.000305°S, 178.0°W')
        self.test('brng+end 2b', r.intersection(N, q, p),
                  '01.000305°S, 178.0°W')

        i = LatLon(1, 1).intersection(LatLon(2, 2), LatLon(1, 4), LatLon(2, 3))
        self.test('intersection7', i,
                  '02.499372°N, 002.5°E')  # 02.4994°N, 002.5°E'

        p = LatLon(0, 0)
        self.test('maxLat0', p.maxLat(0), '90.0')
        self.test('maxLat1', p.maxLat(1), '89.0')
        self.test('maxLat90', p.maxLat(90), '0.0')
        self.test('minLat0', p.minLat(0), '-90.0')
        self.test('minLat1', p.minLat(1), '-89.0')
        self.test('minLat90', p.minLat(90), '-0.0', known=True)

        self.test('parse', p.parse('0, 0'), p)  # coverage

        if hasattr(LatLon, 'crossingParallels'):
            ps = p.crossingParallels(LatLon(60, 30), 30)
            t = ', '.join(map(lonDMS, ps))
            self.test('crossingParallels', t, '009°35′38.65″E, 170°24′21.35″E')

        if hasattr(LatLon, 'intersections2'):

            n = 'intersections2 (%s)' % (LatLon.__module__, )

            def _100p2(t, r, *s):
                e = max(abs(a.distanceTo(b) - r) for a in s for b in t) / r
                return e, '%g (%% of radius)' % (e, )  # percentages

            # <https://GIS.StackExchange.com/questions/48937/calculating-intersection-of-two-circles>
            p = LatLon(37.673442,
                       -90.234036)  # (-0.00323306, -0.7915,   0.61116)
            q = LatLon(36.109997,
                       -90.953669)  # (-0.0134464,  -0.807775, 0.589337)
            t = p.intersections2(0.0312705,
                                 q,
                                 0.0421788,
                                 radius=None,
                                 height=0)  # radii in radians
            self.test(n, latlonDMS(t, form=F_D, sep=', '),
                      '36.98931°N, 088.151425°W, 38.23838°N, 092.390487°W')

            t = LatLon(30, 0).intersections2(PI_4,
                                             LatLon(-30, 0),
                                             PI_4,
                                             radius=None)  # radii in radians
            s = latlonDMS(t, form=F_D, sep=', ')
            self.test(n,
                      s,
                      '00.0°N, 035.26439°W, 00.0°N, 035.26439°E',
                      known='S, ' in s)

            t = LatLon(0, 40).intersections2(PI_4,
                                             LatLon(0, -40),
                                             PI_4,
                                             radius=None)  # radii in radians
            s = latlonDMS(t, form=F_D, sep=', ')
            self.test(n,
                      s,
                      '22.622036°N, 000.0°E, 22.622036°S, 000.0°E',
                      known='W' in s)

            t = LatLon(30, 20).intersections2(PI_4,
                                              LatLon(-30, -20),
                                              PI_4,
                                              radius=None)  # radii in radians
            s = latlonDMS(t, form=F_D, sep=', ')
            self.test(n, s,
                      '14.612841°N, 026.110934°W, 14.612841°S, 026.110934°E')

            t = LatLon(0, 0).intersections2(PI_4,
                                            LatLon(0, 22.5),
                                            PI_4 / 2,
                                            radius=None)  # abutting
            s = latlonDMS(t, form=F_D, sep=', ')
            self.test(n,
                      s,
                      '00.000001°S, 045.0°E, 00.000001°N, 045.0°E',
                      known=True)  # N-S

            # centers at 2 opposite corners of a "square" and
            # radius equal to length of square side, expecting
            # the other 2 as the intersections ... but the
            # longitudes are farther and farther out
            for d in range(5, 66, 5):
                p = LatLon(d, -d)
                q = LatLon(-d, d)
                r = radians(2 * d) * R_M
                t = p.intersections2(r, q, r, radius=R_M)
                if t[0] is t[1]:
                    s = latlonDMS(t[:1], form=F_D, sep=', ') + ' abutting'
                else:
                    s = latlonDMS(t, form=F_D, sep=', ')
                d = '%s %d' % (n, d)
                self.test(d, s, s)
                _, s = _100p2(t, r, q, p)
                self.test(d, s, s)

            d_m = 5e-5  # 50 micrometer
            # courtesy Samuel Čavoj <https://GitHub.com/mrJean1/PyGeodesy/issues/41>}
            R = RandomLatLon(LatLon, 178, 178)  # +/- 89
            r = R()
            s = latlonDMS(r, form=F_D) + ' Random +/- 89'
            self.test(n, s, s)
            for _ in range(12):
                p, q = R(), R()
                try:  # see .testEllipsoidal
                    i1, i2 = p.intersections2(r.distanceTo(p),
                                              q,
                                              r.distanceTo(q),
                                              radius=R_M)
                    d, d2 = r.distanceTo(i1), r.distanceTo(i2)
                    if d2 < d:
                        d, i1, i2 = d2, i2, i1
                    s = '%s  d %g meter' % (latlonDMS(
                        (i1, i2), form=F_D, sep=', '), d)
                    self.test(n, s, s)
                    if d > d_m:
                        raise IntersectionError(d=d,
                                                fmt_name_value='%s (%g)',
                                                txt='over')
                except IntersectionError as x:
                    self.test(n, str(x), 'd < %g m' % (d_m),
                              known=True)  # too distant, near concetric, etc.

        if hasattr(LatLon, 'isenclosedBy'):
            p = LatLon(45.1, 1.1)

            b = LatLon(45, 1), LatLon(45, 2), LatLon(46, 2), LatLon(46, 1)
            for _ in self.testiter():
                self.test('isenclosedBy', p.isenclosedBy(b), True)

            b = LatLon(45, 1), LatLon(45,
                                      3), LatLon(46,
                                                 2), LatLon(47,
                                                            3), LatLon(47, 1)
            for _ in self.testiter():
                try:
                    self.test('isenclosedBy', p.isenclosedBy(b),
                              True)  # Nvector
                except ValueError as x:
                    t = str(x).replace(',)', ')')
                    self.test(
                        'isenclosedBy', t,
                        'points[3] (%s(47°00′00.0″N, 003°00′00.0″E)): not convex'
                        % (classname(p), ))

        p = LatLon(51.127, 1.338)
        q = LatLon(50.964, 1.853)
        b = p.rhumbBearingTo(q)
        self.test('rhumbBearingTo', b, 116.722, fmt='%.3f')  # 116.7

        d = p.rhumbDestination(40300, 116.7)
        self.test('rhumbDestination', d,
                  '50.964155°N, 001.853°E')  # 50.9642°N, 001.8530°E
        self.test('rhumbDestination', isinstance(d, LatLon), True)

        d = p.rhumbDistanceTo(q)
        self.test('rhumbDistanceTo', d, 40307.8, fmt='%.1f')  # XXX 40310 ?

        m = p.rhumbMidpointTo(q)
        self.test('rhumbMidpointo', m, '51.0455°N, 001.595727°E')
        self.test('rhumbMidpointo', isinstance(m, LatLon), True)

        b = LatLon(45, 1), LatLon(45, 2), LatLon(46, 2), LatLon(46, 1)
        self.test('areaOf', module.areaOf(b), '8.66605875e+09',
                  fmt='%.8e')  # 8666058750.718977
        self.test('perimeterOf',
                  module.perimeterOf(b, closed=True),
                  '3.78258541e+05',
                  fmt='%.8e')
        self.test('perimeterOf',
                  module.perimeterOf(b, closed=False),
                  '2.67063461e+05',
                  fmt='%.8e')

        c = LatLon(0, 0), LatLon(1, 0), LatLon(0, 1)
        self.test('areaOf', module.areaOf(c), '6.18e+09', fmt='%.2e')
        self.test('perimeterOf',
                  module.perimeterOf(c, closed=True),
                  '3.79639757e+05',
                  fmt='%.8e')
        self.test('perimeterOf',
                  module.perimeterOf(c, closed=False),
                  '2.68444678e+05',
                  fmt='%.8e')

        if hasattr(module, 'nearestOn2'):
            c, d = module.nearestOn2(p, b)
            self.test(
                'nearestOn2', c,
                '46.000996°N, 001.353049°E' if Vct else '46.0°N, 001.369324°E')
            self.test('nearestOn2',
                      d,
                      '569987.49' if Vct else '570101.83',
                      fmt='%.2f')
            d = p.distanceTo(c)
            self.test('distanceTo',
                      d,
                      '569987.49' if Vct else '570101.82',
                      fmt='%.2f')

            p = LatLon(47, 3)
            c, d = module.nearestOn2(p, b)
            self.test('nearestOn2', c,
                      '46.0°N, 002.0°E' if Vct else '46.0°N, 002.0°E')
            self.test('nearestOn2',
                      d,
                      '134989.80' if Vct else '134992.48',
                      fmt='%.2f')
            d = p.distanceTo(c)
            self.test('distanceTo',
                      d,
                      '134989.80' if Vct else '134989.80',
                      fmt='%.2f')

            p = LatLon(45, 2)
            b = LatLon(45, 1), LatLon(47, 3)
            if Vct:
                c, d = module.nearestOn2(p, b)
                self.test('nearestOn2', c, '45.330691°N, 001.318551°E')
                self.test('distance', d, '64856.28', fmt='%.2f')
            else:
                c, d, a = p.nearestOn3(b, adjust=False)
                self.test('nearestOn3', c, '45.5°N, 001.5°E')
                self.test('distance', d, '78626.79', fmt='%.2f')
                self.test('angle', a, '315.00', fmt='%.2f')
                a = p.compassAngleTo(c, adjust=False)
                self.test('compassAngleTo', a, '315.00', fmt='%.2f')
                c, d, a = p.nearestOn3(b, adjust=True)
                self.test('nearestOn3', c, '45.331319°N, 001.331319°E')
                self.test('distance', d, '64074.48', fmt='%.2f')
                self.test('angle', a, '305.10', fmt='%.2f')
            d = p.distanceTo(c)
            self.test('distanceTo',
                      d,
                      '64856.28' if Vct else '64074.12',
                      fmt='%.2f')
            a = p.compassAngleTo(c)  # adjust=True
            self.test('compassAngleTo',
                      a,
                      '304.54' if Vct else '305.10',
                      fmt='%.2f')
            # TrigTrue vs Nvector closests
            p = LatLon(45.330691, 001.318551)
            d = p.distanceTo(LatLon(45.331319, 001.331319))
            self.test('difference', d, '1000.53',
                      fmt='%.2f')  # PYCHOK test attr?

            if Sph:  # check nearestOn2/3 with closest on the segment
                b = LatLon(0,
                           1), LatLon(2,
                                      3), LatLon(4,
                                                 5), LatLon(6,
                                                            7), LatLon(8, 9)
                for i in range(8):
                    p = LatLon(i + 2, i)
                    c, d, a = p.nearestOn3(b, adjust=False)
                    t = LatLon(p.lat - 1.5, p.lon + 1.5).toStr(F_D, prec=6)
                    self.test('nearestOn3', c.toStr(F_D, prec=6), t)
                    self.test('distance', d, '235880.385', fmt='%.3f')
                    self.test('angle', a, '135.00', fmt='%.2f')

                n = module.meanOf(b)  # coverage
                self.test('meanOf', n.toStr(F_D, prec=6),
                          '04.004858°N, 004.990226°E')
                n = module.nearestOn3(p, b, LatLon=LatLon,
                                      adjust=False)[0]  # coverage
                self.test('nearestOn3', n, '07.5°N, 008.5°E')
                c = p.toCartesian()  # coverage
                self.test('toCartesian', c,
                          '[6245667.211, 766871.506, 996645.349]')

        if hasattr(module, 'ispolar'):
            p = LatLon(85, 90), LatLon(85, 0), LatLon(85,
                                                      -90), LatLon(85, -180)
            for _ in self.testiter():
                self.test('ispolar', module.ispolar(p),
                          'True')  # PYCHOK test attr?
            p = LatLon(85, 90), LatLon(85, 0), LatLon(85, -180)
            for _ in self.testiter():
                self.test('ispolar', module.ispolar(p), 'True',
                          known=True)  # PYCHOK test attr?
            p = [LatLon(*ll) for ll in Antarctica]  # PYCHOK test attr?
            for _ in self.testiter():
                self.test('ispolar', module.ispolar(p), 'True',
                          known=Vct)  # PYCHOK test attr?

        if hasattr(LatLon, 'nearestOn'):
            # <https://GitHub.com/mrJean1/PyGeodesy/issues/25>
            a = LatLon(1, 1, height=100)
            b = LatLon(2, 2, height=200)
            t = LatLon(1, 2).nearestOn(a, b).toStr(form=F_D, prec=1)
            self.test('nearestOn', t,
                      '01.5°N, 001.5°E, +149.99m')  # PYCHOK test attr?
            t = LatLon(1, 2).nearestOn2([a, b])[0].toStr(form=F_D, prec=1)
            self.test('nearestOn2', t,
                      '01.5°N, 001.5°E, +149.99m')  # PYCHOK test attr?
            t = a.midpointTo(b).toStr(form=F_D, prec=1)
            self.test('midpointTo', t,
                      '01.5°N, 001.5°E, +150.00m')  # PYCHOK test attr?
Ejemplo n.º 5
0
mykml = untangle.parse(inputFilename)  # Parse the XML input file

coords = []  # Prepare to store coordinates

for folder in mykml.kml.Document.Folder.Placemark:  # For each 'folder'...
    tmpcoordpair = latlonre.findall(
        folder.LineString.coordinates.cdata
    )  # Find all of the Regular Expression string matches

    for i in range(2):  # Since there are '2' pairs do the following...
        coord = LatLon_(tmpcoordpair[i * 2], tmpcoordpair[i * 2 + 1])
        coords.append({
            "folder":
            folder.name.cdata,
            "coord_deg":
            str(latlonDMS(coord, form='-d')).replace('°', ''),
            "coord_degmin":
            str(latlonDMS(coord, form='-dm')).replace('°',
                                                      ' ').replace('′', ''),
            "coord_degminsec":
            str(latlonDMS(coord, form='-dms')).replace('°', ' ').replace(
                '′', ' ').replace('″', ''),
        })

for coord in coords:
    print(coord)  # For debugging really...

csvHeaders = coords[0].keys()
with open(outputFilename, 'w', newline='', encoding='utf-8') as output_file:
    csv.register_dialect('easyout', delimiter=',', quoting=csv.QUOTE_ALL)
    dict_writer = csv.DictWriter(output_file, csvHeaders, dialect='easyout')
Ejemplo n.º 6
0
    def testIntersections2(self, m, E, K, d_m):

        self.subtitle(m, 'Intersections2')
        n = E.__name__

        def _100p2(t, r, *s):
            e = max(abs(a.distanceTo(b) - r) for a in s for b in t) / r
            return e, '%g (%% of radius)' % (e, )  # percentages

        def _x(g_K):
            return '36.9879°N, 088.1564°W, 38.2441°N, 092.3835°W' if g_K else \
                   '36.9892°N, 088.152°W, 38.2377°N, 092.39°W'
            # '36.9893°N, 088.151°W, 38.2384°N, 092.3905°W'  # PYCHOK cf. sph.Trig

        # <https://GIS.StackExchange.com/questions/48937/calculating-intersection-of-two-circles>
        p = m.LatLon(37.673442,
                     -90.234036)  # (-0.00323306, -0.7915,   0.61116)
        q = m.LatLon(36.109997,
                     -90.953669)  # (-0.0134464,  -0.807775, 0.589337)

        t = p.intersections2(0.0312705 * R_M, q,
                             0.0421788 * R_M)  # radians to meter
        self.test(n, latlonDMS(t, form=F_D, prec=4, sep=', '),
                  _x(geographiclib))

        t = m.intersections2(
            p,
            0.0312705 * R_M,
            q,
            0.0421788 * R_M,  # radians to meter
            equidistant=E,
            LatLon=m.LatLon)
        self.test(n, latlonDMS(t, form=F_D, prec=4, sep=', '), _x(K))

        r = PI_4 * R_M
        t = m.intersections2(m.LatLon(30, 0),
                             r,
                             m.LatLon(-30, 0),
                             r,
                             equidistant=E,
                             LatLon=m.LatLon)
        e, s = _100p2(t, r, q, p)
        self.test(n,
                  latlonDMS(t, form=F_D, prec=4, sep=', '),
                  '00.0°N, 035.3478°W, 00.0°S, 035.3478°E'
                  if K else '00.0°S, 035.4073°W, 00.0°S, 035.4073°E',
                  known=True)  # 0.0
        # '00.0°N, 035.2644°W, 00.0°N, 035.2644°E'  # PYCHOK cf. sph.Trig
        self.test(n, s, s)

        t = m.intersections2(m.LatLon(0, 40),
                             r,
                             m.LatLon(0, -40),
                             r,
                             equidistant=E,
                             LatLon=m.LatLon)
        e, s = _100p2(t, r, q, p)
        self.test(n,
                  latlonDMS(t, form=F_D, prec=4, sep=', '),
                  '22.657°N, 000.0°E, 22.657°S, 000.0°E'
                  if K else '22.756°N, 000.0°W, 22.756°S, 000.0°W',
                  known=True)  # 0.0
        # '22.622°N, 000.0°E, 22.622°S, 000.0°E'  # PYCHOK cf. sph.Trig
        self.test(n, s, s)

        r = R_M * PI / 3
        t = m.intersections2(m.LatLon(30, 30),
                             r,
                             m.LatLon(-30, -30),
                             r,
                             equidistant=E,
                             LatLon=m.LatLon)
        e, s = _100p2(t, r, q, p)
        self.test(n,
                  latlonDMS(t, form=F_D, prec=4, sep=', '),
                  '29.4898°N, 040.1785°W, 29.4898°S, 040.1785°E'
                  if K else '29.2359°N, 040.2625°W, 29.2359°S, 040.2625°E',
                  knonw=e < 1.5)
        # '14.6128°N, 026.1109°W, 14.6128°S, 026.1109°E'  # PYCHOK cf. sph.Trig
        self.test(n, s, s)

        r = R_M * PI / 4
        t = m.intersections2(m.LatLon(0, 0),
                             r,
                             m.LatLon(0, 22.567),
                             r / 2,
                             equidistant=E,
                             LatLon=m.LatLon)
        e, s = _100p2(t, r, q, p)
        self.test(n,
                  latlonDMS(t, form=F_D, prec=4, sep=', '),
                  '02.7402°S, 044.885°E, 02.7402°N, 044.885°E'
                  if K else '01.1557°S, 045.0894°E, 01.1557°N, 045.0894°E',
                  knonw=e < 2.0)
        # '00.0001°S, 045.0°E,    0.00001°N, 045.0°E'  # PYCHOK cf. sph.Trig
        self.test(n, s, s)

        # centers at 2 opposite corners of a "square" and
        # radius equal to length of square side, expecting
        # the other 2 as the intersections ... but the
        # longitudes are farther and farther out
        for d in range(5, 66, 5):
            p = m.LatLon(d, -d)
            q = m.LatLon(-d, d)
            r = radians(2 * d) * R_M
            d = '%s %d' % (n, d)
            try:  # see .testSpherical
                t = m.intersections2(p,
                                     r,
                                     q,
                                     r,
                                     equidistant=E,
                                     LatLon=m.LatLon)
                if t[0] is t[1]:
                    s = latlonDMS(t[:1], form=F_D, prec=4,
                                  sep=', ') + ' abutting'
                else:
                    s = latlonDMS(t, form=F_D, prec=4, sep=', ')
                self.test(d, s, s)
                _, s = _100p2(t, r, q, p)
                self.test(d, s, s)
            except IntersectionError as x:  # XXX no convergence after 55 degrees
                self.test(n, str(x), '2-tuple', known=True)

        # courtesy Samuel Čavoj <https://GitHub.com/mrJean1/PyGeodesy/issues/41>}
        R = RandomLatLon(m.LatLon, 90, 90)  # +/- 45
        r = R()
        s = latlonDMS(r, form=F_D) + ' Random +/- 45'
        self.test(n, s, s)
        for _ in range(12):
            p, q = R(), R()
            try:  # see .testSpherical
                i1, i2 = m.intersections2(p,
                                          p.distanceTo(r),
                                          q,
                                          q.distanceTo(r),
                                          equidistant=E,
                                          LatLon=m.LatLon)
                d, d2 = r.distanceTo(i1), r.distanceTo(i2)
                if d2 < d:
                    d, i1, i2 = d2, i2, i1
                s = latlonDMS((i1, i2), form=F_D, sep=', ')
                s = '%s  d %g meter (iteration %d)' % (s, d, i1.iteration)
                self.test(n, s, s)
                if d > d_m:  # Equidistant >> EquidistantKarney, see .testAzimuthal
                    raise IntersectionError(d=d,
                                            fmt_name_value='%s (%g)',
                                            txt='over')
            except IntersectionError as x:
                self.test(n, str(x), 'd < %g m' % (d_m),
                          known=True)  # too distant, near concetric, etc.