フィールドデータのDjango、geodjango、postgresqlを使ってデータベースを構築しています。データには緯度と経度が含まれます。私のタスクの 1 つは、既に収集されたデータを取り込むことです。.json ファイルを使用してメタデータを定義し、いくつかのコードを記述していくつかの json ファイルをバッチ処理したいと考えています。
これまでのところ、モデルは次のとおりです。
class deployment(models.Model):                                                                          
    '''                                                                                                  
    @brief This is the abstract deployment class.                                                        
        '''                                                                                                  
        startPosition=models.PointField()                                                                    
        startTimeStamp=models.DateTimeField()                                                                
        endTimeStamp=models.DateTimeField()                                                                  
        missionAim=models.TextField()                                                                        
        minDepth=models.FloatField() # IT seems there is no double in Django                                 
        maxDepth=models.FloatField()                                                                         
class auvDeployment(deployment):                                                                         
    '''                                                                                                  
    @brief AUV meta data                                                                                 
    '''                                                                                                  
    #==================================================#                                                 
    # StartPosition : <point>                                                                            
    # distanceCovered : <double>                                                                         
    # startTimeStamp : <dateTime>                                                                        
    # endTimeStamp : <dateTime>                                                                          
    # transectShape : <>                                                                                 
    # missionAim : <Text>                                                                                
    # minDepth : <double>                                                                                
    # maxDepth : <double>                                                                                
    #--------------------------------------------------#                                                 
    # Maybe need to add unique AUV fields here later when                                                
    # we have more deployments                                                                           
    #==================================================#                                                 
    transectShape=models.PolygonField()                                                                  
    distanceCovered=models.FloatField()      
そして、データを取り込むために使用したい関数
@staticmethod                                                                                        
def importDeploymentFromFile(file):                                                                  
    '''                                                                                              
    @brief This function reads in a metadta file that includes campaign information. Destinction between deployment types is made on the fine name.  <type><deployment>.<supported text> auvdeployment.json 
    @param file The file that holds the metata data.  formats include .json todo:-> .xml .yaml       
    '''                                                                                              
    catamiWebPortal.logging.info("Importing metadata from " + file)                                  
    fileName, fileExtension = os.path.splitext(file)                                                 
    if fileExtension == '.json':                                                                     
        if os.path.basename(fileName.upper()) == 'AUVDEPLOYMENT':                                    
            catamiWebPortal.logging.info("Found valid deployment file")                              
            data = json.load(open(file))                                                             
            Model = auvDeployment(**data)                                                            
            Model.save()           
そして、私がこれで読み込もうとしているファイル
{
"id":1,
"startTimeStamp":"2011-09-09 13:20:00",
"endTimeStamp":"2011-10-19 14:23:54",
"missionAim":"for fun times, call luke",
"minDepth":10.0,
"maxDepth":20.0,
"startPosition":{{"type": "PointField", "coordinates": [ 5.000000, 23.000000 ] }}, 
"distanceCovered":20.0
}
私が得ているエラーはこれです
TypeError: cannot set auvDeployment GeometryProxy with value of type: <type 'dict'>
モデルとファイルから地理タイプを削除すると。ファイルを読み取り、データベース テーブルに入力します。
ジオタイプを使用してデータファイルを解析する方法についてアドバイスをいただければ幸いです。
ありがとう