Permalink
Browse files

rings and polys have multiple parts in wkb

  • Loading branch information...
1 parent 20b4e20 commit 78f42f91c23f01959dcd166fc4aff816f0d626df Calvin Metcalf committed May 3, 2013
Showing with 24 additions and 21 deletions.
  1. BIN esri2open.tbx
  2. +3 −15 esri2open/prepare.py
  3. +19 −4 esri2open/wkb.py
  4. +1 −1 multiple.py
  5. +1 −1 single.py
View
Binary file not shown.
View
@@ -41,23 +41,11 @@ def prepareSqlite(out,featureClass,fileType,includeGeometry):
conn=Connection(out)
c=conn.cursor()
- c.execute("""CREATE TABLE spatial_ref_sys(
- srid INTEGER UNIQUE,
- auth_name TEXT,
- auth_srid TEXT,
- srtext TEXT
- )""")
- c.execute("insert into spatial_ref_sys(srid ,auth_name ,auth_srid ,srtext) values(?,?,?,?)",(4326, u'EPSG', 4326, u'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'))
name = splitext(split(out)[1])[0]
- c.execute("""CREATE TABLE geometry_columns (
- f_table_name VARCHAR,
- f_geometry_column VARCHAR,
- geometry_type INTEGER,
- coord_dimension INTEGER,
- srid INTEGER,
- geometry_format VARCHAR
- )""")
+ c.execute("""CREATE TABLE geometry_columns ( f_table_name VARCHAR, f_geometry_column VARCHAR, geometry_type INTEGER, coord_dimension INTEGER, srid INTEGER, geometry_format VARCHAR )""")
c.execute("""insert into geometry_columns( f_table_name, f_geometry_column, geometry_type, coord_dimension, srid, geometry_format) values(?,?,?,?,?,?)""",(name,"GEOMETRY",gType,2,4326,"WKB"))
+ c.execute("""CREATE TABLE spatial_ref_sys ( srid INTEGER UNIQUE, auth_name TEXT, auth_srid TEXT, srtext TEXT)""")
+ c.execute("insert into spatial_ref_sys(srid ,auth_name ,auth_srid ,srtext) values(?,?,?,?)",(4326, u'EPSG', 4326, u'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'))
c.execute("create table {0}({1})".format(name,", ".join(fieldNames)))
return [name,c,conn]
def prepareGeoJSON(outJSON,*args):
View
@@ -26,6 +26,23 @@ def linearRing(coordinates):
out[1][0]+=1
out[1].extend(values)
return out
+def multiRing(coordinates):
+ partCount=coordinates.partCount
+ i=0
+ values =[0]
+ outnum = "I"
+ out = ["I",[0]]
+ while i<partCount:
+ part = coordinates.getPart(i)
+ [ptrn,c]=linearRing(part)
+ outnum+=ptrn
+ values[0]+=1
+ values.extend(c)
+ 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.getPart(0))
@@ -40,19 +57,17 @@ def makeMultiPoint(c):
return Binary(pack(*values))
def makeMultiLineString(c):
values = ["<BI",1,5]
- [ptrn,coords]=linearRing(c.getPart(0))
+ [ptrn,coords]=multiRing(c)
values[0]+=ptrn
values.extend(coords)
return Binary(pack(*values))
def makeMultiPolygon(c):
values = ["<BI",1,6]
- [ptrn,coords]=linearRing(c.getPart(0))
+ [ptrn,coords]=multiRing(c)
values[0]+=ptrn
values.extend(coords)
return Binary(pack(*values))
-
-
def getWKBFunc(type):
if type == "point":
return makePoint
View
@@ -14,7 +14,7 @@ def getName(feature):
features = GetParameterAsText(0).split(";")
outFolder = GetParameterAsText(1)
outType = GetParameterAsText(2)
-includeGeometries = GetParameterAsText(3).lower()
+includeGeometries = ("geojson" if (GetParameterAsText(3)=="Default") else GetParameterAsText(3)).lower()
for feature in features:
if feature[0] in ("'",'"'):
feature = feature[1:-1]
View
@@ -1,3 +1,3 @@
from arcpy import GetParameterAsText
from esri2open import toOpen
-toOpen(GetParameterAsText(0),GetParameterAsText(1),GetParameterAsText(2))
+toOpen(GetParameterAsText(0),GetParameterAsText(1),("geojson" if (GetParameterAsText(2)=="Default") else GetParameterAsText(2)))

0 comments on commit 78f42f9

Please sign in to comment.