Ë
    Wìqjø  ã                   óL   — d dl mZmZ d dlmZ  G d„ de«      Z G d„ de«      Zy)é    )ÚABCÚabstractmethod)ÚDecimalc                   ó@   — e Zd Zedeeeef      dedee   fd„«       Zy)ÚBoundaryIntersectionBackendÚroute_coordsÚ
boundariesÚreturnc                  ó   — y)zÏ
        route_coords: [(lng, lat), ...] in route order.
        boundaries: list of CountryBoundary instances.
        Returns: [{"country_code": str, "km": Decimal}, ...] for segments with km > 0.
        N© )Úselfr   r	   s      ú//var/www/html/truck-me/core/pricing/backends.pyÚintersect_route_with_boundariesz;BoundaryIntersectionBackend.intersect_route_with_boundaries   s   € ð 	ó    N)	Ú__name__Ú
__module__Ú__qualname__r   ÚlistÚtupleÚfloatÚdictr   r   r   r   r   r      s?   „ Øð¸DÀÀuÈeÀ|ÑATÑ<Uð Ðcgð ÐlpÐquÑlvò ó ñr   r   c                   ó   — e Zd Zd„ Zy)ÚShapelyBackendc                 óÜ  — ddl m}m} ddlm} dd l}t        |«      dk  rg S |j                  j                  ddd¬«      j                  } ||«      }g }	|D ]’  }
 ||
j                  «      }|j                  |«      sŒ'|j                  |«      }|j                  rŒE |||«      }t        t        |j                  d	z  «      «      }|dk  rŒu|	j!                  |
j"                  |d
œ«       Œ” |	S )Nr   )Ú
LineStringÚshape)Ú	transformé   z	EPSG:4326z	EPSG:3857T)Ú	always_xyiè  )Úcountry_codeÚkm)Úshapely.geometryr   r   Úshapely.opsr   ÚpyprojÚlenÚTransformerÚfrom_crsÚgeojsonÚ
intersectsÚintersectionÚis_emptyr   ÚstrÚlengthÚappendr    )r   r   r	   r   r   r   r$   ÚprojectÚrouteÚresultsÚboundaryÚpolyr*   Úintersection_mÚ	length_kms                  r   r   z.ShapelyBackend.intersect_route_with_boundaries   sô   € ß6Ý)Ûäˆ|Ó˜qÒ ØˆIà×$Ñ$×-Ñ-Ø˜°ð .ó 
ç
‰)ð 	ñ ˜<Ó(ˆØˆà"ò 	UˆHÙ˜×)Ñ)Ó*ˆDØ×#Ñ# DÔ)Øà ×-Ñ-¨dÓ3ˆLØ×$Ò$Øá& w°Ó=ˆNÜ¤ N×$9Ñ$9¸DÑ$@Ó AÓBˆIà˜AŠ~Øà�N‰N¨H×,AÑ,AÈÑSÕTð	Uð" ˆr   N)r   r   r   r   r   r   r   r   r      s   „ ó r   r   N)Úabcr   r   Údecimalr   r   r   r   r   r   ú<module>r8      s$   ðß #Ý ô #ô ô!Ð0õ !r   