def test_set_srs():
    """Test the set_srs() function"""

    rdnew = osr.SpatialReference()
    rdnew.SetFromUserInput("EPSG:28992")

    latlon = osr.SpatialReference()
    latlon.SetFromUserInput("EPSG:4326")

    adam_latlon = np.array(
        [4.904153991281891, 52.372337993959924, 42.97214563656598],
        dtype=np.float64)

    adam_rdnew = np.array([122104.0, 487272.0, 0.0], dtype=np.float64)

    pcA = pcl.PointCloud([[0., 0., 0.]])
    force_srs(pcA, srs=latlon, offset=adam_latlon)

    pcB = pcl.PointCloud([[0., 0., 0.]])
    force_srs(pcB, srs=rdnew, offset=adam_rdnew)

    # latlon [degrees] -> rdnew [m]
    set_srs(pcA, same_as=pcB)

    assert_less(
        np.max(np.square(np.asarray(pcA))), 1e-3**2,
        "Coordinate transform not accurate to 1 mm %s" % np.asarray(pcA))

    # rdnew [m] -> latlon [degrees]
    set_srs(pcB, srs=latlon, offset=[0, 0, 0])

    # check horizontal error [degrees]
    error = np.asarray(pcB)[0] - adam_latlon

    assert_less(
        np.max(np.square(error[0:2])), (1e-6)**2,
        "Coordinate transform rdnew->latlon not accurate to 1e-6 degree %s" %
        error[0:2])

    # check vertical error [m]
    assert_less(
        abs(error[2]), (1e-6),
        "Vertical Coordinate in of transform not accurate to 1e-6 meter %s" %
        abs(error[2]))
Example #2
0
def test_set_srs():
    """Test the set_srs() function"""

    rdnew = osr.SpatialReference()
    rdnew.SetFromUserInput( "EPSG:28992" )

    latlon = osr.SpatialReference()
    latlon.SetFromUserInput( "EPSG:4326" )

    adam_latlon = np.array(
        [4.904153991281891, 52.372337993959924, 42.97214563656598],
        dtype=np.float64)

    adam_rdnew = np.array([122104.0, 487272.0, 0.0], dtype=np.float64)

    pcA = pcl.PointCloud ( [[0.,0.,0.]] )
    force_srs( pcA, srs=latlon, offset=adam_latlon )

    pcB = pcl.PointCloud ( [[0., 0., 0.]] )
    force_srs( pcB, srs=rdnew, offset=adam_rdnew )

    # latlon [degrees] -> rdnew [m]
    set_srs( pcA, same_as=pcB )

    assert_less( np.max( np.square( np.asarray( pcA ) ) ), 1e-3 ** 2,
        "Coordinate transform not accurate to 1 mm %s" % np.asarray(pcA) )


    # rdnew [m] -> latlon [degrees]
    set_srs( pcB, srs=latlon, offset=[0,0,0] )

    # check horizontal error [degrees]
    error = np.asarray(pcB)[0] - adam_latlon

    assert_less( np.max( np.square(error[0:2]) ), (1e-6) ** 2,
        "Coordinate transform rdnew->latlon not accurate to 1e-6 degree %s"
         % error[0:2] )

    # check vertical error [m]
    assert_less( abs(error[2]) , (1e-6) ,
        "Vertical Coordinate in of transform not accurate to 1e-6 meter %s"
         % abs(error[2]) )
    assert os.path.exists(footprintcsv), footprintcsv + ' does not exist'

    #####
    # Setup * the low-res drivemap
    #       * footprint
    #       * pointcloud
    #       * up-vector

    log("Reading drivemap", drivemapfile)
    drivemap = load(drivemapfile)
    force_srs(drivemap, srs="EPSG:32633")

    log("Reading footprint", footprintcsv)
    footprint = load(footprintcsv)
    force_srs(footprint, srs="EPSG:32633")
    set_srs(footprint, same_as=drivemap)

    log("Reading object", sourcefile)
    pointcloud = load(sourcefile)

    Up = None
    try:
        with open(up_file) as f:
            dic = json.load(f)
        Up = np.array(dic['estimatedUpDirection'])
        log("Reading up_file", up_file)
    except:
        log("Cannot parse upfile, skipping")

    initial_registration(pointcloud,
                         Up,
Example #4
0
    assert os.path.exists(footprintcsv), footprintcsv + ' does not exist'

    #####
    # Setup * the low-res drivemap
    #       * footprint
    #       * pointcloud
    #       * up-vector

    log("Reading drivemap", drivemapfile)
    drivemap = load(drivemapfile)
    force_srs(drivemap, srs="EPSG:32633")

    log("Reading footprint", footprintcsv)
    footprint = load(footprintcsv)
    force_srs(footprint, srs="EPSG:32633")
    set_srs(footprint, same_as=drivemap)

    log("Reading object", sourcefile)
    pointcloud = load(sourcefile)

    Up = None
    try:
        with open(up_file) as f:
            dic = json.load(f)
        Up = np.array(dic['estimatedUpDirection'])
        log("Reading up_file", up_file)
    except:
        log("Cannot parse upfile, skipping")

    initial_registration(pointcloud, Up, drivemap,
                         trust_up=Trust_up, initial_scale=Initial_scale)