How to use update_feature method in lettuce-tools

Best Python code snippet using lettuce-tools_python

core_update_future_scenario.py

Source:core_update_future_scenario.py Github

copy

Full Screen

1# UrbanFootprint v1.52# Copyright (C) 2017 Calthorpe Analytics3#4# This file is part of UrbanFootprint version 1.55#6# UrbanFootprint is distributed under the terms of the GNU General7# Public License version 3, as published by the Free Software Foundation. This8# code is distributed WITHOUT ANY WARRANTY, without implied warranty of9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General10# Public License v3 for more details; see <http://www.gnu.org/licenses/>.11from decimal import Decimal12from footprint.main.lib.functions import map_to_dict13from footprint.main.models.analysis_module.core_module.core_revert_to_base_condition import \14 core_end_state_revert_to_base_condition15from footprint.main.models.built_form.flat_built_form import FlatBuiltForm16from footprint.main.models.geospatial.db_entity_keys import DbEntityKey17import logging18__author__ = 'calthorpe_analytics'19logger = logging.getLogger(__name__)20def calculate_land_development_category(feature):21 if feature.intersection_density_sqmi >= 150 and feature.emp / feature.acres_gross > 70:22 land_development_category = 'urban'23 elif feature.intersection_density_sqmi >= 150 and feature.du / feature.acres_gross > 45:24 land_development_category = 'urban'25 elif feature.intersection_density_sqmi >= 150 and feature.emp / feature.acres_gross <= 70:26 land_development_category = 'compact'27 elif feature.intersection_density_sqmi >= 150 and feature.du / feature.acres_gross <= 45:28 land_development_category = 'compact'29 elif feature.intersection_density_sqmi < 150:30 land_development_category = 'standard'31 else:32 land_development_category = None33 feature.land_development_category = land_development_category34 feature.save()35def update_future_scenario(config_entity, annotated_features):36 base_class = config_entity.db_entity_feature_class(DbEntityKey.BASE_CANVAS)37 logger.info("annotating features for {0}".format(config_entity))38 flat_built_forms = map_to_dict(39 lambda flat_built_form: [flat_built_form.built_form_id, flat_built_form],40 FlatBuiltForm.objects.filter(built_form_id__in=map(lambda feature: feature.built_form.id,41 filter(lambda feature: feature.built_form, annotated_features)))42 )43 logger.info("processing {0} future scenario features".format(len(annotated_features)))44 for update_feature in annotated_features:45 base = base_class.objects.get(id=update_feature.base_canvas)46 flat_built_form = flat_built_forms.get(update_feature.built_form.id, FlatBuiltForm()) if update_feature.built_form else FlatBuiltForm()47 if not update_feature.built_form_id:48 # If the user reverted the built_form, it will be null and we need to set it to the base built_form49 core_end_state_revert_to_base_condition(update_feature, base)50 continue51 applied_acres = update_feature.acres_developable * update_feature.dev_pct * update_feature.gross_net_pct52 density_adjusted_acres = applied_acres * update_feature.density_pct53 remaining_development = (1 - update_feature.dev_pct)54 update_feature.built_form_key = flat_built_form.key55 update_feature.built_form_base = base.built_form_key56 update_feature.intersection_density_sqmi = flat_built_form.intersection_density * update_feature.dev_pct * \57 update_feature.gross_net_pct * update_feature.density_pct58 update_feature.acres_parcel_res = flat_built_form.acres_parcel_residential * applied_acres + remaining_development \59 * update_feature.acres_parcel_res60 update_feature.acres_parcel_emp = flat_built_form.acres_parcel_employment * applied_acres + remaining_development \61 * update_feature.acres_parcel_emp62 update_feature.acres_parcel_mixed_use = flat_built_form.acres_parcel_mixed_use * applied_acres + \63 remaining_development * update_feature.acres_parcel_mixed_use64 update_feature.acres_parcel_no_use = update_feature.acres_developable - applied_acres if update_feature.clear_flag is True else \65 (update_feature.acres_developable - applied_acres) + remaining_development * update_feature.acres_parcel_no_use66 update_feature.acres_parcel = update_feature.acres_parcel_res + update_feature.acres_parcel_emp + \67 update_feature.acres_parcel_mixed_use + update_feature.acres_parcel_no_use68 update_feature.pop = flat_built_form.population_density * density_adjusted_acres + remaining_development * update_feature.pop69 update_feature.hh = flat_built_form.household_density * density_adjusted_acres + remaining_development * update_feature.hh70 update_feature.du = flat_built_form.dwelling_unit_density * density_adjusted_acres + remaining_development * update_feature.du71 update_feature.du_detsf_ll = flat_built_form.single_family_large_lot_density * density_adjusted_acres + \72 remaining_development * update_feature.du_detsf_ll73 update_feature.du_detsf_sl = flat_built_form.single_family_small_lot_density * density_adjusted_acres + \74 remaining_development * update_feature.du_detsf_sl75 update_feature.du_detsf = update_feature.du_detsf_sl + update_feature.du_detsf_ll76 update_feature.du_attsf = flat_built_form.attached_single_family_density * density_adjusted_acres + \77 remaining_development * update_feature.du_attsf78 update_feature.du_mf2to4 = flat_built_form.multifamily_2_to_4_density * density_adjusted_acres + remaining_development * update_feature.du_mf2to479 update_feature.du_mf5p = flat_built_form.multifamily_5_plus_density * density_adjusted_acres + remaining_development * update_feature.du_mf5p80 update_feature.du_mf = update_feature.du_mf2to4 + update_feature.du_mf5p81 update_feature.emp = flat_built_form.employment_density * density_adjusted_acres + remaining_development * update_feature.emp82 update_feature.emp_ret = flat_built_form.retail_density * density_adjusted_acres + remaining_development * update_feature.emp_ret83 update_feature.emp_off = (flat_built_form.office_services_density + flat_built_form.medical_services_density) * density_adjusted_acres + remaining_development * update_feature.emp_off84 update_feature.emp_pub = (flat_built_form.education_services_density + flat_built_form.public_admin_density) * density_adjusted_acres + remaining_development * update_feature.emp_pub85 update_feature.emp_ind = flat_built_form.industrial_density * density_adjusted_acres + remaining_development * update_feature.emp_ind86 update_feature.emp_ag = flat_built_form.agricultural_density * density_adjusted_acres + remaining_development * update_feature.emp_ag87 update_feature.emp_military = flat_built_form.military_density * density_adjusted_acres + remaining_development * update_feature.emp_military88 update_feature.emp_retail_services = flat_built_form.retail_services_density * density_adjusted_acres + remaining_development * update_feature.emp_retail_services89 update_feature.emp_restaurant = flat_built_form.restaurant_density * density_adjusted_acres + remaining_development * update_feature.emp_restaurant90 update_feature.emp_accommodation = flat_built_form.accommodation_density * density_adjusted_acres + remaining_development * update_feature.emp_accommodation91 update_feature.emp_arts_entertainment = flat_built_form.arts_entertainment_density * density_adjusted_acres + \92 remaining_development * update_feature.emp_arts_entertainment93 update_feature.emp_other_services = flat_built_form.other_services_density * density_adjusted_acres + \94 remaining_development * update_feature.emp_other_services95 update_feature.emp_office_services = flat_built_form.office_services_density * density_adjusted_acres + \96 remaining_development * update_feature.emp_office_services97 update_feature.emp_medical_services = flat_built_form.medical_services_density * density_adjusted_acres + \98 remaining_development * update_feature.emp_medical_services99 update_feature.emp_education = flat_built_form.education_services_density * density_adjusted_acres + \100 remaining_development * update_feature.emp_education101 update_feature.emp_public_admin = flat_built_form.public_admin_density * density_adjusted_acres + \102 remaining_development * update_feature.emp_public_admin103 update_feature.emp_wholesale = flat_built_form.wholesale_density * density_adjusted_acres + \104 remaining_development * update_feature.emp_wholesale105 update_feature.emp_transport_warehousing = flat_built_form.transport_warehouse_density * density_adjusted_acres + \106 remaining_development * update_feature.emp_transport_warehousing107 update_feature.emp_manufacturing = flat_built_form.manufacturing_density * density_adjusted_acres + remaining_development * update_feature.emp_manufacturing108 update_feature.emp_construction = flat_built_form.construction_utilities_density * Decimal(0.5) * density_adjusted_acres + remaining_development * update_feature.emp_construction109 update_feature.emp_utilities = flat_built_form.construction_utilities_density * Decimal(0.5) * density_adjusted_acres + remaining_development * update_feature.emp_utilities110 update_feature.emp_agriculture = flat_built_form.agriculture_density * density_adjusted_acres + remaining_development * update_feature.emp_agriculture111 update_feature.emp_extraction = flat_built_form.extraction_density * density_adjusted_acres + remaining_development * update_feature.emp_extraction112 update_feature.bldg_sqft_detsf_ll = flat_built_form.building_sqft_single_family_large_lot * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_detsf_ll113 update_feature.bldg_sqft_detsf_sl = flat_built_form.building_sqft_single_family_small_lot * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_detsf_sl114 update_feature.bldg_sqft_attsf = flat_built_form.building_sqft_attached_single_family * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_attsf115 update_feature.bldg_sqft_mf = (flat_built_form.building_sqft_multifamily_2_to_4 + flat_built_form.building_sqft_multifamily_5_plus) * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_mf116 update_feature.bldg_sqft_retail_services = flat_built_form.building_sqft_retail_services * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_retail_services117 update_feature.bldg_sqft_restaurant = flat_built_form.building_sqft_restaurant * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_restaurant118 update_feature.bldg_sqft_accommodation = flat_built_form.building_sqft_accommodation * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_accommodation119 update_feature.bldg_sqft_arts_entertainment = flat_built_form.building_sqft_arts_entertainment * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_arts_entertainment120 update_feature.bldg_sqft_other_services = flat_built_form.building_sqft_other_services * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_other_services121 update_feature.bldg_sqft_office_services = flat_built_form.building_sqft_office_services * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_office_services122 update_feature.bldg_sqft_public_admin = flat_built_form.building_sqft_public_admin * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_public_admin123 update_feature.bldg_sqft_medical_services = flat_built_form.building_sqft_medical_services * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_medical_services124 update_feature.bldg_sqft_education = flat_built_form.building_sqft_education_services * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_education125 update_feature.bldg_sqft_wholesale = flat_built_form.building_sqft_wholesale * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_wholesale126 update_feature.bldg_sqft_transport_warehousing = flat_built_form.building_sqft_transport_warehouse * density_adjusted_acres + remaining_development * update_feature.bldg_sqft_transport_warehousing127 update_feature.commercial_irrigated_sqft = flat_built_form.commercial_irrigated_square_feet * density_adjusted_acres + remaining_development * update_feature.commercial_irrigated_sqft128 update_feature.residential_irrigated_sqft = flat_built_form.residential_irrigated_square_feet * density_adjusted_acres + remaining_development * update_feature.residential_irrigated_sqft129 update_feature.acres_parcel_res_detsf_ll = flat_built_form.acres_parcel_residential_single_family_large_lot * applied_acres + remaining_development * update_feature.acres_parcel_res_detsf_ll130 update_feature.acres_parcel_res_detsf_sl = flat_built_form.acres_parcel_residential_single_family_small_lot * applied_acres + remaining_development * update_feature.acres_parcel_res_detsf_sl131 update_feature.acres_parcel_res_attsf = flat_built_form.acres_parcel_residential_attached_single_family * applied_acres + remaining_development * update_feature.acres_parcel_res_attsf132 update_feature.acres_parcel_res_mf = flat_built_form.acres_parcel_residential_multifamily * applied_acres + remaining_development * update_feature.acres_parcel_res_mf133 update_feature.acres_parcel_emp_ret = flat_built_form.acres_parcel_employment_retail * applied_acres + remaining_development * update_feature.acres_parcel_emp_ret134 update_feature.acres_parcel_emp_off = flat_built_form.acres_parcel_employment_office * applied_acres + remaining_development * update_feature.acres_parcel_emp_off135 update_feature.acres_parcel_emp_pub = flat_built_form.acres_parcel_employment_public * applied_acres + remaining_development * update_feature.acres_parcel_emp_pub136 update_feature.acres_parcel_emp_ind = flat_built_form.acres_parcel_employment_industrial * applied_acres + remaining_development * update_feature.acres_parcel_emp_ind137 update_feature.acres_parcel_emp_ag = flat_built_form.acres_parcel_employment_agriculture * applied_acres + remaining_development * update_feature.acres_parcel_emp_ag138 update_feature.save()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lettuce-tools automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful