forked from project-open-data/esri2open
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
sqlite added
- Loading branch information
Calvin Metcalf
committed
Apr 10, 2013
1 parent
dbb26a0
commit bdda2c4
Showing
9 changed files
with
268 additions
and
41 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,64 @@ | |||
from struct import pack | |||
from sqlite3 import Binary | |||
def pts(c): | |||
return ["dd",[c.X,c.Y]] | |||
def linearRing(coordinates): | |||
partCount=coordinates.partCount | |||
i=0 | |||
values =[0] | |||
outnum = "I" | |||
out = ["I",[0]] | |||
while i<partCount: | |||
pt = coordinates.getPart(i) | |||
if pt: | |||
[ptrn,c]=pts(pt) | |||
outnum+=ptrn | |||
values[0]+=1 | |||
values.extend(c) | |||
else: | |||
out[0]+=outnum | |||
out[1][0]+=1 | |||
out[1].extend(values) | |||
values =[0] | |||
outnum = "I" | |||
i+=1 | |||
out[0]+=outnum | |||
out[1][0]+=1 | |||
out[1].extend(values) | |||
return out | |||
def makePoint(c): | |||
values = ["<BI",1,1] | |||
[ptrn,coords] = pts(c) | |||
values[0]+=ptrn | |||
values.extend(coords) | |||
return Binary(pack(*values)) | |||
def makeMultiPoint(c): | |||
values = ["<BI",1,4] | |||
[ptrn,coords]=linearRing(c) | |||
values[0]+=ptrn | |||
values.extend(coords) | |||
return Binary(pack(*values)) | |||
def makeMultiLineString(c): | |||
values = ["<BI",1,5] | |||
[ptrn,coords]=linearRing(c) | |||
values[0]+=ptrn | |||
values.extend(coords) | |||
return Binary(pack(*values)) | |||
def makeMultiPolygon(c): | |||
values = ["<BI",1,6] | |||
[ptrn,coords]=linearRing(c) | |||
values[0]+=ptrn | |||
values.extend(coords) | |||
return Binary(pack(*values)) | |||
|
|||
|
|||
|
|||
def getWKBFunc(type): | |||
if type == "point": | |||
return makePoint | |||
elif type == "multipoint": | |||
return makeMultiPoint | |||
elif type == "polyline": | |||
return makeMultiLineString | |||
elif type == "polygon": | |||
return makeMultiPolygon |
Oops, something went wrong.