示例#1
0
    def testGridDistances(self):
        for i in range(100):
            gsize = random.uniform(0., 1.) * 2. * 10.**random.uniform(4., 7.)
            north_grid, east_grid = num.meshgrid(
                num.linspace(-gsize / 2., gsize / 2., 11),
                num.linspace(-gsize / 2., gsize / 2., 11))

            north_grid = north_grid.flatten()
            east_grid = east_grid.flatten()

            lon = random.uniform(-180., 180.)
            lat = random.uniform(-90., 90.)

            lat_grid, lon_grid = orthodrome.ne_to_latlon(
                lat, lon, north_grid, east_grid)
            lat_grid_alt, lon_grid_alt = \
                orthodrome.ne_to_latlon_alternative_method(
                    lat, lon, north_grid, east_grid)

            for la, lo, no, ea in zip(lat_grid, lon_grid, north_grid,
                                      east_grid):
                a = orthodrome.Loc(lat=la, lon=lo)
                b = orthodrome.Loc(lat=lat, lon=lon)

                cd = orthodrome.cosdelta(a, b)
                assert cd <= 1.0
                d = num.arccos(cd) * earthradius
                d2 = math.sqrt(no**2 + ea**2)
                assert abs(d - d2) < 1.0e-3 or d2 < 10.
示例#2
0
 def testGridDistances(self):
     for i in range(100):
         w,h = 20,15
     
         km = 1000.
         gsize = random.uniform(0.,1.)*2.*10.**random.uniform(4.,7.)
         north_grid, east_grid = num.meshgrid(num.linspace(-gsize/2.,gsize/2.,11) ,
                                              num.linspace(-gsize/2.,gsize/2.,11) )
         
         north_grid = north_grid.flatten()
         east_grid = east_grid.flatten()
         
         lat_delta = gsize/config.earthradius*r2d*2.
         lon = random.uniform(-180.,180.)
         lat = random.uniform(-90.,90.)
                 
         lat_grid, lon_grid = orthodrome.ne_to_latlon(lat, lon, north_grid, east_grid)
         lat_grid_alt, lon_grid_alt = orthodrome.ne_to_latlon_alternative_method(lat, lon, north_grid, east_grid)
         
         for la, lo, no, ea in zip(lat_grid, lon_grid, north_grid, east_grid):
             a = Loc()
             a.lat = la 
             a.lon = lo
             b = Loc()
             b.lat = lat
             b.lon = lon
             
             d = num.arccos(orthodrome.cosdelta(a,b))*config.earthradius
             d2 = math.sqrt(no**2+ea**2)
             
             if abs(d-d2) > 1.0e-3 and d2 > 1.:
                 print 'x',a.lat, a.lon, b.lat,b.lon
                 print 'y',d, d2, d-d2
示例#3
0
 def testGridDistances(self):
     for i in range(100):
         w,h = 20,15
     
         km = 1000.
         gsize = random.uniform(0.,1.)*2.*10.**random.uniform(4.,7.)
         north_grid, east_grid = num.meshgrid(num.linspace(-gsize/2.,gsize/2.,11) ,
                                              num.linspace(-gsize/2.,gsize/2.,11) )
         
         north_grid = north_grid.flatten()
         east_grid = east_grid.flatten()
         
         lat_delta = gsize/config.earthradius*r2d*2.
         lon = random.uniform(-180.,180.)
         lat = random.uniform(-90.,90.)
                 
         lat_grid, lon_grid = orthodrome.ne_to_latlon(lat, lon, north_grid, east_grid)
         lat_grid_alt, lon_grid_alt = orthodrome.ne_to_latlon_alternative_method(lat, lon, north_grid, east_grid)
         
         for la, lo, no, ea in zip(lat_grid, lon_grid, north_grid, east_grid):
             a = Loc()
             a.lat = la 
             a.lon = lo
             b = Loc()
             b.lat = lat
             b.lon = lon
             
             cd = orthodrome.cosdelta(a,b)
             assert cd <= 1.0
             d = num.arccos(cd)*config.earthradius
             d2 = math.sqrt(no**2+ea**2)
             assert not (abs(d-d2) > 1.0e-3 and d2 > 1.)
示例#4
0
    def testGridDistances(self):
        for i in range(100):
            w, h = 20, 15

            km = 1000.0
            gsize = random.uniform(0.0, 1.0) * 2.0 * 10.0 ** random.uniform(4.0, 7.0)
            north_grid, east_grid = num.meshgrid(
                num.linspace(-gsize / 2.0, gsize / 2.0, 11), num.linspace(-gsize / 2.0, gsize / 2.0, 11)
            )

            north_grid = north_grid.flatten()
            east_grid = east_grid.flatten()

            lat_delta = gsize / config.earthradius * r2d * 2.0
            lon = random.uniform(-180.0, 180.0)
            lat = random.uniform(-90.0, 90.0)

            lat_grid, lon_grid = orthodrome.ne_to_latlon(lat, lon, north_grid, east_grid)
            lat_grid_alt, lon_grid_alt = orthodrome.ne_to_latlon_alternative_method(lat, lon, north_grid, east_grid)

            for la, lo, no, ea in zip(lat_grid, lon_grid, north_grid, east_grid):
                a = Loc()
                a.lat = la
                a.lon = lo
                b = Loc()
                b.lat = lat
                b.lon = lon

                d = num.arccos(orthodrome.cosdelta(a, b)) * config.earthradius
                d2 = math.sqrt(no ** 2 + ea ** 2)

                if abs(d - d2) > 1.0e-3 and d2 > 1.0:
                    print "x", a.lat, a.lon, b.lat, b.lon
                    print "y", d, d2, d - d2