本文整理汇总了Python中treemap.models.Tree.date_planted方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.date_planted方法的具体用法?Python Tree.date_planted怎么用?Python Tree.date_planted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treemap.models.Tree
的用法示例。
在下文中一共展示了Tree.date_planted方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_row
# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import date_planted [as 别名]
#.........这里部分代码省略.........
pass
elif sidewalk_damage is True or sidewalk_damage.lower() == "true" or sidewalk_damage.lower() == 'yes':
plot.sidewalk_damage = 2
else:
plot.sidewalk_damage = 1
plot.quick_save()
pnt = plot.geometry
n = Neighborhood.objects.filter(geometry__contains=pnt)
z = ZipCode.objects.filter(geometry__contains=pnt)
plot.neighborhoods = ""
plot.neighborhood.clear()
plot.zipcode = None
if n:
for nhood in n:
if nhood:
plot.neighborhoods = plot.neighborhoods + " " + nhood.id.__str__()
plot.neighborhood.add(nhood)
if z: plot.zipcode = z[0]
plot.quick_save()
if tree:
tree.plot = plot
tree.readonly = self.readonly
tree.import_event = self.import_event
tree.last_updated_by = self.updater
if row.get('OWNER'):
tree.tree_owner = str(row["OWNER"])
if row.get('STEWARD'):
tree.steward_name = str(row["STEWARD"])
if row.get('SPONSOR'):
tree.sponsor = str(row["SPONSOR"])
if row.get('DATEPLANTED'):
date_string = str(row['DATEPLANTED'])
try:
date = datetime.strptime(date_string, "%m/%d/%Y")
except:
pass
try:
date = datetime.strptime(date_string, "%Y/%m/%d")
except:
pass
if not date:
raise ValueError("Date strings must be in mm/dd/yyyy or yyyy/mm/dd format")
tree.date_planted = date.strftime("%Y-%m-%d")
if row.get('DIAMETER'):
tree.dbh = float(row['DIAMETER'])
if row.get('HEIGHT'):
tree.height = float(row['HEIGHT'])
if row.get('CANOPYHEIGHT'):
tree.canopy_height = float(row['CANOPYHEIGHT'])
if row.get('CONDITION'):
for k, v in choices['conditions']:
if v == row['CONDITION']:
tree.condition = k
break;
if row.get('CANOPYCONDITION'):
for k, v in choices['canopy_conditions']:
if v == row['CANOPYCONDITION']:
tree.canopy_condition = k
break;
tree.quick_save()
if row.get('PROJECT_1'):
for k, v in Choices().get_field_choices('local'):
if v == row['PROJECT_1']:
local = TreeFlags(key=k,tree=tree,reported_by=self.updater)
local.save()
break;
if row.get('PROJECT_2'):
for k, v in Choices().get_field_choices('local'):
if v == row['PROJECT_2']:
local = TreeFlags(key=k,tree=tree,reported_by=self.updater)
local.save()
break;
if row.get('PROJECT_3'):
for k, v in Choices().get_field_choices('local'):
if v == row['PROJECT_3']:
local = TreeFlags(key=k,tree=tree,reported_by=self.updater)
local.save()
break;
# rerun validation tests and store results
tree.validate_all()
示例2: test_result_map
# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import date_planted [as 别名]
def test_result_map(self):
##################################################################
# Test main result map page
# Note -> This page does not depend at all on the request
#
p1 = Plot(geometry=Point(50,50), last_updated_by=self.u, import_event=self.ie,present=True, width=100, length=100, data_owner=self.u)
p2 = Plot(geometry=Point(60,50), last_updated_by=self.u, import_event=self.ie,present=True, width=90, length=110, data_owner=self.u)
p1.save()
p2.save()
# For max/min plot size
p3 = Plot(geometry=Point(50,50), last_updated_by=self.u, import_event=self.ie,present=True, width=80, length=120, data_owner=self.u)
p4 = Plot(geometry=Point(60,50), last_updated_by=self.u, import_event=self.ie,present=True, width=70, length=130, data_owner=self.u)
p5 = Plot(geometry=Point(60,50), last_updated_by=self.u, import_event=self.ie,present=True, width=60, length=70, data_owner=self.u)
p3.save()
p4.save()
p5.save()
t3 = Tree(plot=p3, species=None, last_updated_by=self.u, import_event=self.ie,present=True)
t3.save()
t4 = Tree(plot=p4, species=None, last_updated_by=self.u, import_event=self.ie,present=True)
t4.save()
t5 = Tree(plot=p5, species=None, last_updated_by=self.u, import_event=self.ie,present=True)
t5.save()
t1 = Tree(plot=p1, species=None, last_updated_by=self.u, import_event=self.ie)
t1.present = True
current_year = datetime.now().year
t1.date_planted = date(1999,9,9)
t2 = Tree(plot=p2, species=None, last_updated_by=self.u, import_event=self.ie)
t1.present = True
t1.save()
t2.save()
set_auto_now(t1, "last_updated", False)
t1.last_updated = date(1999,9,9)
t1.save()
response = self.client.get("/map/")
req = response.context
set_auto_now(t1, "last_updated", True)
# t1 and t2 should not be in the latest trees/plots because it excludes superuser edits
exp = set([])
got = set([t.pk for t in req['latest_trees']])
self.assertTrue(exp <= got)
got = set([t.pk for t in req['latest_plots']])
self.assertTrue(exp <= got)
# Check to verify platting dates
self.assertEquals(int(req['min_year']), 1999)
self.assertEquals(int(req['current_year']), current_year)
# Correct min/max plot sizes
self.assertEqual(int(req['min_plot']), 60)
self.assertEqual(int(req['max_plot']), 130)
min_updated = mktime(t1.last_updated.timetuple())
max_updated = mktime(t2.last_updated.timetuple())
self.assertEqual(req['min_updated'], min_updated)
self.assertEqual(req['max_updated'], max_updated)
示例3: handle_row
# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import date_planted [as 别名]
#.........这里部分代码省略.........
if z:
plot.zipcode = z[0]
plot.quick_save()
if tree:
tree.plot = plot
tree.readonly = self.readonly
tree.import_event = self.import_event
tree.last_updated_by = self.updater
if row.get("OWNER"):
tree.tree_owner = str(row["OWNER"])
if row.get("STEWARD"):
tree.steward_name = str(row["STEWARD"])
if row.get("SPONSOR"):
tree.sponsor = str(row["SPONSOR"])
if row.get("DATEPLANTED"):
date_string = str(row["DATEPLANTED"])
try:
date = datetime.strptime(date_string, "%m/%d/%Y")
except:
pass
try:
date = datetime.strptime(date_string, "%Y/%m/%d")
except:
pass
if not date:
raise ValueError("Date strings must be in mm/dd/yyyy or yyyy/mm/dd format")
tree.date_planted = date.strftime("%Y-%m-%d")
if row.get("DIAMETER"):
tree.dbh = float(row["DIAMETER"])
if row.get("HEIGHT"):
tree.height = float(row["HEIGHT"])
if row.get("CANOPYHEIGHT"):
tree.canopy_height = float(row["CANOPYHEIGHT"])
if row.get("CONDITION"):
for k, v in choices["conditions"]:
if v == row["CONDITION"]:
tree.condition = k
break
if row.get("CANOPYCONDITION"):
for k, v in choices["canopy_conditions"]:
if v == row["CANOPYCONDITION"]:
tree.canopy_condition = k
break
# FOR OTM INDIA
# GIRTH_CM", "GIRTH_M", "HEIGHT_FT", "HEIGHT_M", "NEST", "BURROWS", "FLOWERS", "FRUITS", "NAILS", "POSTER", "WIRES", "TREE_GUARD", "NUISANCE", "NUISANCE_DESC", "HEALTH_OF_TREE", "FOUND_ON_GROUND", "GROUND_DESCRIPTION", "RISK_ON_TREE", "RISK_DESC", "RARE", "ENDANGERED", "VULNERABLE", "PEST_AFFECTED", "REFER_TO_DEPT", "SPECIAL_OTHER", "SPECIAL_OTHER_DESCRIPTION", "LATITUDE", "LONGITUDE", "CREATION_DATE", "DEVICE_ID", "TIME", "DATE"])
if row.get("GIRTH_M"):
tree.girth_m = float(row["GIRTH_M"])
if row.get("HEIGHT_M"):
tree.height_m = float(row["HEIGHT_M"])
if row.get("NEST"):
tree.nest = str(row["NEST"])