簡體   English   中英

geomfromtext從檢索到的文本中插入spacespaceite

[英]geomfromtext insert in spatialite from retrived text

嘗試構建數據輸入表單時,我想根據經度.get()和緯度.get()值創建幾何點。 但是,下面粘貼的代碼不起作用,可能是由於我這邊的語法錯誤(我懷疑python會以字符串的形式讀取geofromtext的som部分),但不知道如何進行其他操作。

有人看到我的錯誤嗎?

我嘗試根據spacespaceite文檔的規范更改代碼,但到目前為止沒有成功。 我懷疑我這邊有一些語法錯誤frpm。

有沒有明顯的錯誤?

以下是相關代碼:

 date = datetime.date(int(year.get()),int(month.get()), int(day.get()))
 narratif=T.get("1.0","end-1c")


 c.execute("""INSERT INTO Incidents
   (Geometry, Datestamp, Description, Place, Latitude, Longitude, Precision, Intimidation, Destruction, Burglary,
   Carjacking, Theft, Assault, Sexualassault, Abduction, Homicide, Shooting, Explosive,  Narrative)
   VALUES(GeomFromText('POINT(? ?)', 4326),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""", (longitude.get(), latitude.get(), date, description.get(),place.get(),latitude.get(), longitude.get(), precision.get(), intimidation1.get(),destruction2.get(), burglary3.get(), carjacking4.get(), theft5.get(), assault6.get(), sexualassault7.get(), abduction8.get(), homicide9.get(), shooting10.get(), explosive11.get(), narratif))


 con.commit()

對於離子化,我能夠使其與以下代碼一起使用:

def get():
    try:

        date = datetime.date(int(year.get()),int(month.get()), int(day.get()))
        narratif=T.get("1.0","end-1c")
        c.execute("""INSERT INTO Incidents
   (Datestamp, Description, Place, Latitude, Longitude, Precision, Interpretation, Wounded, Killed, Intimidation, Destruction, Burglary,
   Carjacking, Theft, Assault, Sexualassault, Abduction, Homicide, Shooting, Explosive, Indirectfire, Intercommunity, Narrative)
   VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""", (date, description.get(),place.get(),latitude.get(), longitude.get(), precision.get(), interpretation.get(), wounded.get(), killed.get(), intimidation1.get(),destruction2.get(), burglary3.get(), carjacking4.get(), theft5.get(), assault6.get(), sexualassault7.get(), abduction8.get(), homicide9.get(), shooting10.get(), explosive11.get(), indirectfire12.get(), intercommunity13.get(), narratif ))
        c.execute('UPDATE Incidents SET Geometry=MakePoint(Longitude, Latitude, 4326) WHERE Incident_ID = (SELECT MAX(Incident_ID) FROM Incidents);')
        print("You just added an incident!")
        print(c.lastrowid)
        messagebox.showinfo("Incident added", "incident successfully added!")
    except:
        messagebox.showerror("No incident added", "Check for duplicates, empty fields or other sources of error") 
    con.commit()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM