Skip to content

Commit e304133

Browse files
author
Stephanie Reeder
committed
fix sample code to work with creating an inherited object
1 parent 13b664b commit e304133

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

Examples/Sample.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from odm2api.ODMconnection import dbconnection
1111
from odm2api.ODM2.services.readService import *
12+
from odm2api.ODM2.services import CreateODM2
1213
# Create a connection to the ODM2 database
1314
# ----------------------------------------
1415

@@ -24,6 +25,7 @@
2425

2526
#_session = session_factory.getSession()
2627
read = ReadODM2(session_factory)
28+
create =CreateODM2(session_factory)
2729

2830

2931

@@ -80,18 +82,14 @@
8082
#add sampling feature
8183
print "\n------------ Create Sampling Feature --------- \n",
8284
try:
83-
from odm2api.ODM2.models import SamplingFeatures
84-
newsf = SamplingFeatures()
85+
# from odm2api.ODM2.models import SamplingFeatures
8586
session = session_factory.getSession()
86-
newsf.FeatureGeometry = "POINT(-111.946 41.718)"
87-
newsf.Elevation_m=100
88-
newsf.ElevationDatumCV=sf.ElevationDatumCV
89-
newsf.SamplingFeatureCode= "TestSF"
90-
newsf.SamplingFeatureDescription = "this is a test to add Feature Geomotry"
91-
newsf.SamplingFeatureGeotypeCV= "Point"
92-
newsf.SamplingFeatureTypeCV=sf.SamplingFeatureTypeCV
93-
newsf.SamplingFeatureUUID= sf.SamplingFeatureUUID+"2"
94-
session.add(newsf)
87+
newsf = Sites(FeatureGeometryWKT = "POINT(-111.946 41.718)", Elevation_m=100, ElevationDatumCV=sf.ElevationDatumCV,
88+
SamplingFeatureCode= "TestSF",SamplingFeatureDescription = "this is a test to add Feature Geomotry",
89+
SamplingFeatureGeotypeCV= "Point", SamplingFeatureTypeCV=sf.SamplingFeatureTypeCV,SamplingFeatureUUID= sf.SamplingFeatureUUID+"2",
90+
SiteTypeCV="cave", Latitude= "100", Longitude= "-100", SpatialReferenceID= 0)
91+
92+
create.createSamplingFeature(newsf)
9593
#session.commit()
9694
print "new sampling feature added to database", newsf
9795

odm2api/ODM2/models.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,16 @@ def shape(self):
306306
return geomshape
307307

308308
def __repr__(self):
309-
geom = self.shape()
310-
if geom is not None:
311-
geomkt = geom.wkt
312-
else:
313-
geomkt = None
309+
# geom = self.shape()
310+
# if geom is not None:
311+
# geomkt = geom.wkt
312+
# else:
313+
# geomkt = None
314314

315315
return "<SamplingFeatures('%s', '%s', '%s', '%s', '%s')>" % (
316316
self.SamplingFeatureCode, self.SamplingFeatureName, self.SamplingFeatureDescription,
317-
self.Elevation_m, geomkt)
317+
# self.Elevation_m, geomkt)
318+
self.Elevation_m, self.FeatureGeometry)
318319

319320

320321
GeometryDDL(SamplingFeatures.__table__) # Geoalchemy1

0 commit comments

Comments
 (0)