a
    1$e                  	   @   s   d dl Z d dlZd dlmZ ddlmZmZ d dlmZ d dl	m
Z
 ejdded	ed
ejdddddeejedd ZdS )    N)
use_rs_opt   )obj_geneval_feature_expression)with_context_env)ObjectEncoderz/Calculate GeoJSON property by Python expression)
short_helpproperty_name
expressionz--overwriteTFz$Overwrite properties, default: False)is_flagdefaulthelpc                 C   s   t d}t|}t|D ]\}}|dp0|g}	t|	D ]`\}
}|sb||d v rbt d|t|||d |< |rt jddd t t	j
|td q:qd	S )
a  
    Create a new property on GeoJSON features using the specified expression.

    
    The expression is evaluated in a restricted namespace containing:
        - sum, pow, min, max and the imported math module
        - shape (optional, imported from shapely.geometry if available)
        - bool, int, str, len, float type conversions
        - f (the feature to be evaluated,
             allows item access via javascript-style dot notation using munch)

    The expression will be evaluated for each feature and its
    return value will be added to the properties
    as the specified property_name. Existing properties will not
    be overwritten by default (an Exception is raised).

    Example

    
    $ fio cat data.shp | fio calc sumAB  "f.properties.A + f.properties.B"

    stdinfeatures
propertiesz:{} already exists in properties; rename or use --overwriteF)nl)clsN)clickget_text_streamr   	enumerateget
UsageErrorformatr   echojsondumpsr   )ctxr	   r
   	overwriteZuse_rsr   sourceiobjr   jZfeat r#   J/var/www/html/django/DPS/env/lib/python3.9/site-packages/fiona/fio/calc.pycalc   s"    
r%   )r   r   Zcligjr   helpersr   r   Z	fiona.fior   Zfiona.modelr   commandargumentoptionpass_contextr%   r#   r#   r#   r$   <module>   s   

