Skip to content

Commit 0f08ae5

Browse files
Stephanie ReederStephanie Reeder
authored andcommitted
remove any reference to Feature Geometry. remove geoalchemy dependency
1 parent 1dce754 commit 0f08ae5

File tree

4 files changed

+22
-88
lines changed

4 files changed

+22
-88
lines changed

Examples/APIDemo.ipynb

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@
5151
"metadata": {
5252
"collapsed": false
5353
},
54-
"outputs": [
55-
{
56-
"name": "stdout",
57-
"output_type": "stream",
58-
"text": [
59-
"USU3: Battery voltage\nUSU4: Turbidity\nUSU5: Turbidity\nUSU6: Turbidity\nUSU7: Turbidity\nUSU8: Turbidity\nUSU9: Turbidity\nUSU10: Temperature\nUSU13: Gage height\nUSU14: Temperature\nUSU15: Relative humidity\nUSU16: Precipitation\nUSU17: Battery voltage\nUSU18: Wind speed\nUSU19: Wind direction\nUSU20: Wind direction\nUSU21: Barometric pressure\nUSU22: Radiation, incoming shortwave\nUSU23: Battery voltage\nUSU24: Wind speed\nUSU25: Temperature\nUSU26: Temperature\nUSU27: Temperature\nUSU28: Relative humidity\nUSU29: Barometric pressure\nUSU30: Precipitation\nUSU31: Radiation, incoming shortwave\nUSU32: Oxygen, dissolved\nUSU33: Oxygen, dissolved percent of saturation\nUSU34: Specific conductance\nUSU35: pH\nUSU36: Temperature\nUSU37: Turbidity\nUSU39: Phosphorus, total\nUSU40: Phosphorus, total dissolved\nUSU41: Solids, total Suspended\nUSU44: Discharge\nUSU47: Solids, total suspended\nUSU48: Phosphorus, total\nUSU49: Distance\nUSU50: Snow Depth\nUSU51: Distance\nUSU52: Distance\nUSU53: Distance\nUSU54: Snow Depth\nUSU55: Snow Depth\nUSU56: Snow Depth\nUSU57: Volumetric water content\nUSU58: Electrical conductivity\nUSU59: Temperature\nUSU60: Temperature\nUSU61: Real dielectric constant\nUSU62: Imaginary dielectric constant\nUSU63: Alkalinity, carbonate plus bicarbonate\nUSU64: Nitrogen, total dissolved\nUSU65: Nitrogen, total\ntester: Wind speed\nTN: Nitrogen, total\nTP: Phosphorus, total\nTcoliform: Coliform, total\nE-coli: E-coli\nD180: delta-18O of H2O\nD2H: delta-D of H2O\n"
60-
]
61-
}
62-
],
54+
"outputs": [],
6355
"source": [
6456
"# Run some basic sample queries.\n",
6557
"# ------------------------------\n",
@@ -107,15 +99,7 @@
10799
"metadata": {
108100
"collapsed": false
109101
},
110-
"outputs": [
111-
{
112-
"name": "stdout",
113-
"output_type": "stream",
114-
"text": [
115-
"\n-------- Information about an SamplingFeature of type 'Site'---------\nUSU-LBR-Mendon: Little Bear River at Mendon Road near Mendon, Utah\nUSU-LBR-SFWeather: Little Bear River South Fork Weather Station near Avon, Utah\nUnable to demo getSamplingFeaturesByType cannot concatenate 'str' and 'NoneType' objects\n\n-------- Information about an individual SamplingFeature ---------\nThe following are some of the attributes of a SamplingFeature retrieved using getSamplingFeatureByCode(): \n\nSamplingFeatureCode: USU-LBR-Mendon\nSamplingFeatureName: Little Bear River at Mendon Road near Mendon, Utah\nSamplingFeatureDescription: Located below county road bridge at Mendon Road crossing\nSamplingFeatureGeotypeCV: Point\nSamplingFeatureGeometry: \u0000\u0000\u0000\u0000\u0001\u0001\u0000\u0000\u0000ž·±Ù‘ü[ÀŽ\u0007[ìöÛD@\nElevation_m: 1345.0\n"
116-
]
117-
}
118-
],
102+
"outputs": [],
119103
"source": [
120104
"# Get all of the SamplingFeatures from the database that are Sites\n",
121105
"\n",
@@ -151,15 +135,7 @@
151135
"metadata": {
152136
"collapsed": false
153137
},
154-
"outputs": [
155-
{
156-
"name": "stdout",
157-
"output_type": "stream",
158-
"text": [
159-
"\n------------ Create Sampling Feature --------- \nnew sampling feature added to database <SamplingFeatures('TestSF', 'None', 'this is a test to add Feature Geomotry', '100', 'None')>\n"
160-
]
161-
}
162-
],
138+
"outputs": [],
163139
"source": [
164140
"#add sampling feature\n",
165141
"print \"\\n------------ Create Sampling Feature --------- \\n\",\n",
@@ -189,15 +165,7 @@
189165
"metadata": {
190166
"collapsed": false
191167
},
192-
"outputs": [
193-
{
194-
"name": "stdout",
195-
"output_type": "stream",
196-
"text": [
197-
"\n------------ Foreign Key Example --------- \nUnable to demo Foreign Key Example: 'ReadODM2' object has no attribute 'getResult'\n"
198-
]
199-
}
200-
],
168+
"outputs": [],
201169
"source": [
202170
"# Drill down and get objects linked by foreign keys\n",
203171
"print \"\\n------------ Foreign Key Example --------- \\n\",\n",
@@ -261,15 +229,7 @@
261229
"metadata": {
262230
"collapsed": false
263231
},
264-
"outputs": [
265-
{
266-
"name": "stdout",
267-
"output_type": "stream",
268-
"text": [
269-
"\n-------- Example of Retrieving Time Series Result Values ---------\n ValueID ResultID DataValue ValueDateTime ValueDateTimeUTCOffset \\\n0 2240358 1 12.51435 2007-09-01 00:00:00 -7 \n1 2240541 1 12.51519 2007-09-01 00:30:00 -7 \n2 2350031 1 12.50344 2007-09-01 01:00:00 -7 \n3 2234346 1 12.49085 2007-09-01 01:30:00 -7 \n4 2344012 1 12.48413 2007-09-01 02:00:00 -7 \n\n CensorCodeCV QualityCodeCV TimeAggregationInterval \\\n0 Not censored Unknown 30.0 \n1 Not censored Unknown 30.0 \n2 Not censored Unknown 30.0 \n3 Not censored Unknown 30.0 \n4 Not censored Unknown 30.0 \n\n TimeAggregationIntervalUnitsID \n0 102 \n1 102 \n2 102 \n3 102 \n4 102 \nUnable to demo plotting of tsValues: name 'plt' is not defined\n"
270-
]
271-
}
272-
],
232+
"outputs": [],
273233
"source": [
274234
"# Get the values for a particular TimeSeriesResult\n",
275235
"print \"\\n-------- Example of Retrieving Time Series Result Values ---------\"\n",
@@ -301,6 +261,15 @@
301261
"except Exception as e:\n",
302262
" print \"Unable to demo plotting of tsValues: \", e"
303263
]
264+
},
265+
{
266+
"cell_type": "code",
267+
"execution_count": null,
268+
"metadata": {},
269+
"outputs": [],
270+
"source": [
271+
""
272+
]
304273
}
305274
],
306275
"metadata": {

Examples/Sample.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44

5-
# import matplotlib.pyplot as plt
5+
#import matplotlib.pyplot as plt
66

77

88

@@ -17,8 +17,8 @@
1717
#connect to database
1818
# createconnection (dbtype, servername, dbname, username, password)
1919
# session_factory = dbconnection.createConnection('connection type: sqlite|mysql|mssql|postgresql', '/your/path/to/db/goes/here', 2.0)#sqlite
20-
session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql
21-
# session_factory= dbconnection.createConnection('mssql', "(local)", "LBRODM2", "ODM", "odm")#win MSSQL
20+
# session_factory = dbconnection.createConnection('mysql', 'localhost', 'odm2', 'ODM', 'odm')#mysql
21+
session_factory= dbconnection.createConnection('mssql', "(local)", "ODM2", "ODM", "odm")#win MSSQL
2222
# session_factory= dbconnection.createConnection('mssql', "arroyoodm2", "", "ODM", "odm")#mac/linux MSSQL
2323
# session_factory = dbconnection.createConnection('sqlite', '/Users/stephanie/DEV/ODM2/usecases/WOF_to_ODM2/ODM2.sqlite', 2.0)
2424

odm2api/ODM2/models.py

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
from sqlalchemy import BigInteger, Column, Date, DateTime, Float, ForeignKey, Integer, String, Boolean, BLOB, case
1+
from sqlalchemy import BigInteger, Column, Date, DateTime, Float, ForeignKey, Integer, String, Boolean, case
22
from sqlalchemy.orm import relationship
33
from sqlalchemy.dialects import postgresql, mysql, sqlite
4-
# from sqlalchemy.dialects.sqlite import BIT
54

65

7-
from geoalchemy import GeometryDDL, GeometryColumn
8-
from geoalchemy.geometry import Geometry
9-
from shapely import wkb, wkt
10-
116
from odm2api.base import modelBase
12-
# from apiCustomType import Geometry
137

148
Base = modelBase.Base
159

@@ -18,8 +12,8 @@
1812
BigIntegerType = BigIntegerType.with_variant(postgresql.BIGINT(), 'postgresql')
1913
BigIntegerType = BigIntegerType.with_variant(mysql.BIGINT(), 'mysql')
2014

21-
# BooleanType = Boolean()
22-
# BooleanType =BooleanType.with_variant(sqlite.BIT(), 'sqlite')
15+
16+
2317

2418

2519
def is_hex(s):
@@ -279,9 +273,8 @@ class SamplingFeatures(Base):
279273
index=True)
280274
Elevation_m = Column('elevation_m', Float(53))
281275
ElevationDatumCV = Column('elevationdatumcv', ForeignKey(CVElevationDatum.Name), index=True)
282-
FeatureGeometry = Column('featuregeometry', String(50))#Geometry) #
276+
#FeatureGeometry = Column('featuregeometry', String(50))
283277
FeatureGeometryWKT = Column('featuregeometrywkt', String(50))
284-
# FeatureGeometry = Column('featuregeometry', BLOB) # custom geometry queries
285278
__mapper_args__ = {
286279
# 'polymorphic_on': SamplingFeatureTypeCV,
287280
"polymorphic_on":case([
@@ -293,42 +286,14 @@ class SamplingFeatures(Base):
293286
}
294287

295288

296-
297-
# def shape(self):
298-
# """
299-
# Method name based on shapely shapely.geometry.shape() function.
300-
# Returns a shapely geometry object
301-
# :return geomshape:
302-
# """
303-
# _FeatureGeometry = self.FeatureGeometry
304-
# geomshape = None
305-
# if _FeatureGeometry is not None:
306-
# print _FeatureGeometry
307-
# print _FeatureGeometry.geom_wkb
308-
# if is_hex(_FeatureGeometry.geom_wkb):
309-
# # to parse wkb hex string directly
310-
# geomshape = wkb.loads(_FeatureGeometry.geom_wkb, hex=True)
311-
# # _FeatureGeometry = GeometryColumn('featuregeometry', Geometry)
312-
# else:
313-
# geomshape = wkt.loads(str(_FeatureGeometry.geom_wkb))
314-
#
315-
# return geomshape
316-
317289
def __repr__(self):
318-
# geom = self.shape()
319-
# if geom is not None:
320-
# geomkt = geom.wkt
321-
# else:
322-
# geomkt = None
323290

324291
return "<SamplingFeatures('%s', '%s', '%s', '%s', '%s')>" % (
325292
self.SamplingFeatureCode, self.SamplingFeatureName, self.SamplingFeatureDescription,
326293
# self.Elevation_m, geomkt)
327294
self.Elevation_m, self.FeatureGeometryWKT)
328295

329296

330-
# GeometryDDL(SamplingFeatures.__table__) # Geoalchemy1
331-
332297

333298
class FeatureActions(Base):
334299
__tablename__ = u'featureactions'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pyodbc
22
six
33
sqlalchemy
4-
-e git+https://github.com/ODM2/[email protected]#egg=geoalchemy-0.7.4
4+
#-e git+https://github.com/ODM2/[email protected]#egg=geoalchemy-0.7.4
55
shapely
66
pandas
77
#psycopg2 # Commented out because I could not pip install it.

0 commit comments

Comments
 (0)