コード例 #1
0
def compute_dim_descriptor_from_patch(uncompressed_patch, connection_string):
    """ given a patch, extract points and compute dim descriptors"""
    import pg_pointcloud_classes as pgp
  
    #convert patch to numpy array 
    GD = pgp.create_GD_if_not_exists()
    #cache mecanism for patch schema
    if 'rc' not in GD:  # creating the rc dict if necessary
        GD['rc'] = dict()
    if 'schemas' not in GD['rc']:  # creating the schemas dict if necessary
    	GD['rc']['schemas'] = dict() 
    
    restrict_dim = ["x","y","z"]
    pt_arr, (mschema,endianness, compression, npoints) = \
        pgp.patch_string_buff_to_numpy(uncompressed_patch, GD['rc']['schemas'], connection_string)
    #pt_arr, (mschema,endianness, compression, npoints) = pgp.patch_string_buff_to_numpy(uncompressed_patch, temp_schema, [])
    numpy_double, mschema = pgp.patch_numpy_to_numpy_double( \
        pt_arr[ restrict_dim], mschema,use_scale_offset=True,dim_to_use=restrict_dim) 
    ###########
    #warning: to be removed ! @TODO 
    #numpy_double[:,0] = numpy_double[:,0]  + 649000
    #numpy_double[:,1] = numpy_double[:,1]  + 6840000
    ########### 
    #computing descriptors 
    descriptors = compute_descriptors_from_points(numpy_double)
    return descriptors
コード例 #2
0
def reordering_patch_following_midoc(uncompressed_patch, tot_level, stop_level,
                                     connection_string):
    """ main function : reorder patch following midoc ordering"""
    import pg_pointcloud_classes as pgp
    import midoc_ordering as midoc

    ################# only for test
    temp_schema = dict()
    temp_schema["1"] = artificial_schema()
    #################

    #convert patch to numpy array
    GD = pgp.create_GD_if_not_exists()
    #cache mecanism for patch schema
    if 'rc' not in GD:  # creating the rc dict if necessary
        GD['rc'] = dict()
    if 'schemas' not in GD['rc']:  # creating the schemas dict if necessary
        GD['rc']['schemas'] = dict()

    restrict_dim = ["x", "y", "z"]
    pt_arr, (mschema,endianness, compression, npoints) = \
        pgp.patch_string_buff_to_numpy(uncompressed_patch, GD['rc']['schemas'], connection_string)

    #pt_arr, (mschema,endianness, compression, npoints) = pgp.patch_string_buff_to_numpy(uncompressed_patch, temp_schema, [])
    numpy_double, mschema = pgp.patch_numpy_to_numpy_double(
        pt_arr[restrict_dim],
        mschema,
        use_scale_offset=True,
        dim_to_use=restrict_dim)

    ######################
    # WARNING DEBUG
    # to be removed
    # numpy_double [:,0] = numpy_double [:,0] #+ 649000
    #numpy_double [:,1] = numpy_double [:,1] + 6840000
    ######################

    #keep only the relevant dimensions
    pt_xyz = numpy_double
    num_points = npoints

    #compute midoc ordering
    result = midoc.order_by_octree(pt_xyz, tot_level, stop_level)
    result_completed = midoc.complete_and_shuffle_result(result, num_points)
    pt_per_class = midoc.count_points_per_class(result, stop_level)
    #transfer ordering to full points
    reordered_arr = pt_arr[result_completed[:, 0].astype('int32')]
    #create new patch

    wkb_ordered_patch = pgp.numpy_double_to_WKB_patch(reordered_arr, mschema)
    return wkb_ordered_patch, pt_per_class
コード例 #3
0
def export_one_patch(gid, connection_string, conn,cur,schemas,f ):
    """ """
    import pg_pointcloud_classes as pgp
    import numpy as np
    #get the patch
    patch_query = 'SELECT pc_uncompress(patch) FROM trafi_pollu.goudron WHERE gid = %s'
    cur.execute(patch_query,(gid,))
    patch_tmp = cur.fetchall()
    
    #convert patch to numpy double     
    numpy_arr = pgp.patch_string_buff_to_numpy(patch_tmp[0][0],schemas,connection_string)
    np.save(f, np.array(numpy_arr))
    numpy_arr = None
    return
コード例 #4
0
def export_one_patch(gid, connection_string, conn,cur,schemas,f ):
    """ """
    import pg_pointcloud_classes as pgp
    import numpy as np
    #get the patch
    patch_query = 'SELECT pc_uncompress(patch) FROM tmob_20140616.riegl_pcpatch_space_int WHERE gid = %s'
    cur.execute(patch_query,(gid,))
    patch_tmp = cur.fetchall()
    
    #convert patch to numpy double     
    numpy_arr = pgp.patch_string_buff_to_numpy(patch_tmp[0][0],schemas,connection_string)
    np.save(f, np.array(numpy_arr))
    numpy_arr = None
    return
コード例 #5
0
ファイル: rc_patch_LOD.py プロジェクト: Remi-C/PPPP_utilities
def reordering_patch_following_midoc(uncompressed_patch, tot_level, stop_level, connection_string):
    """ main function : reorder patch following midoc ordering"""
    import pg_pointcloud_classes as pgp
    import midoc_ordering as midoc
     
    
    ################# only for test
    temp_schema = dict()
    temp_schema["1"]= artificial_schema()
    #################
    
    #convert patch to numpy array 
    GD = pgp.create_GD_if_not_exists()
    #cache mecanism for patch schema
    if 'rc' not in GD:  # creating the rc dict if necessary
        GD['rc'] = dict()
    if 'schemas' not in GD['rc']:  # creating the schemas dict if necessary
    	GD['rc']['schemas'] = dict()
 
    
    restrict_dim = ["x","y","z"]
    pt_arr, (mschema,endianness, compression, npoints) = \
        pgp.patch_string_buff_to_numpy(uncompressed_patch, GD['rc']['schemas'], connection_string)
        
    #pt_arr, (mschema,endianness, compression, npoints) = pgp.patch_string_buff_to_numpy(uncompressed_patch, temp_schema, [])
    numpy_double, mschema = pgp.patch_numpy_to_numpy_double(pt_arr[ restrict_dim], mschema,use_scale_offset=True,dim_to_use=restrict_dim)
     
    ######################
    # WARNING DEBUG
    # to be removed
    # numpy_double [:,0] = numpy_double [:,0] #+ 649000
    #numpy_double [:,1] = numpy_double [:,1] + 6840000
    ######################
      
    #keep only the relevant dimensions   
    pt_xyz = numpy_double
    num_points = npoints
    
    #compute midoc ordering 
    result = midoc.order_by_octree(pt_xyz, tot_level, stop_level)
    result_completed = midoc.complete_and_shuffle_result(result, num_points)
    pt_per_class = midoc.count_points_per_class(result, stop_level)
    #transfer ordering to full points 
    reordered_arr = pt_arr[result_completed[:,0].astype('int32')] 
    #create new patch
    
    wkb_ordered_patch = pgp.numpy_double_to_WKB_patch(reordered_arr, mschema)
    return wkb_ordered_patch, pt_per_class
コード例 #6
0
"""

import pg_pointcloud_classes as pc

patch_text = """0104000000000000000A00000060AE0A00819E03002D07000060AE0A0090A803000E09000060AE0A0005990300040B000060AE0A00A69D0300F30B000060AE0A00499D0300180C000060AE0A00EAA803001A09000060AE0A00E9B20300390A000060AE0A00C5AD0300190A000060AE0A00DCBC03008410000060AE0A003FCF0300E3140000"""

connection_string = """host=172.16.3.50 dbname=vosges user=postgres password=postgres port=5432"""
global GD        
GD = {}

if 'rc' not in GD:  # creating the rc dict if necessary
    GD['rc'] = dict()
if 'schemas' not in GD['rc']:  # creating the schemas dict if necessary
    GD['rc']['schemas'] = dict()
  
np_points,(mschema,endianness, compression, npoints) = pc.patch_string_buff_to_numpy(patch_text, GD['rc']['schemas'], connection_string)

print np_points



pc.create_schemas_if_not_exists()

print GD['rc']['schemas']



import psycopg2 
# Connect to an existing database
conn = psycopg2.connect("dbname=test_pointcloud user=postgres password=postgres port=5433") 
# Open a cursor to perform database operations