
    hTZ                    H   S SK Jr  S SKJrJrJrJr  S SKJr  S SK	r	S SK
r
S SKrS SKJr  S SKJrJrJrJrJrJr  S SKJrJrJrJrJrJr  S SKJr  S S	KJrJ r   S S
K!J"r"J#r#J$r$J%r%J&r&J'r'J(r(  S SK)J*r*  SSK+J,r,J-r-  SSK.J/r/  SSK0J1r1  SSK2J3r3J4r4  SSK5J6r6  \(       a  S SK7J8r8  S SK9J:r:  SS/r;\Rx                  " S5      r=\" S0 S\" SSS9_S\" SSS9_S\" S S!\R|                  " S S"5      \S#9_S$\" S%\R~                  \"S&9_S'\" S(\R~                  \"S&9_S)\" S*S\R                  \S#9_S+\" S,SS9_S-\" S.SS9_S/\" S0SS9_S1\" S2\R~                  \#\R                  \S39_S4\" S5\R                  \$\R                  \S39_S6\" S7S\R|                  " S S85      \S#9_S9\" S:S\R                  \S#9_S;\" S<S \R                  \S#9_S=\" S>S S9_S?\" S@S S9_SA\" SBSCSDSE9_\" SFSCSDSE9\" SGSCSDSE9\" SHSCSDSE9SI.E5      rD\" \D5      rESJrF " SK S\5      rGSOSL jrH\1 " SM S\/5      5       rISPSN jrJg)Q    )annotations)TYPE_CHECKINGSequenceIterableOptional)ElementTreeN)	validator)DXFAttributesDefSubclassDXFAttrXTypeRETURN_DEFAULTgroup_code_mapping)SUBCLASS_MARKERDXFStructureErrorDXF2010DXFTypeErrorDXFValueErrorInvalidGeoDataException)VertexArray)TagsDXFTag)NULLVECZ_AXISY_AXISUVecVec3Vec2Matrix44)split_mtext_string   )
base_classSubclassProcessor)	DXFObject)register_entity)default_copyCopyNotSupported   )units)DXFNamespace)AbstractTagWriterGeoDataMeshVerticesezdxfAcDbGeoDataversionZ   )defaultblock_record_handleiJ  0coordinate_typeF         )r2   r	   fixerdesign_point
   )xtyper2   reference_point   horizontal_unit_scale(   horizontal_units[   vertical_unit_scale)   vertical_units\   up_direction   )r<   r2   r	   r9   north_direction   scale_estimation_method_      user_scale_factor   sea_level_correctioni&  sea_level_elevation   coordinate_projection_radius   geo_rss_tagi.   T)r2   optionali1  i2  i3  )observation_from_tagobservation_to_tagobservation_coverage_taga/
  <?xml version="1.0" encoding="UTF-16" standalone="no" ?>
<Dictionary version="1.0" xmlns="http://www.osgeo.org/mapguide/coordinatesystem">

<ProjectedCoordinateSystem id="WORLD-MERCATOR">
<Name>WORLD-MERCATOR</Name>
<AdditionalInformation>
<ParameterItem type="CsMap">
<Key>CSQuadrantSimplified</Key>
<IntegerValue>1</IntegerValue>
</ParameterItem>
</AdditionalInformation>
<DomainOfValidity>
<Extent>
<GeographicElement>
<GeographicBoundingBox>
<WestBoundLongitude>-180.75</WestBoundLongitude>
<EastBoundLongitude>180.75</EastBoundLongitude>
<SouthBoundLatitude>-80.75</SouthBoundLatitude>
<NorthBoundLatitude>84.75</NorthBoundLatitude>
</GeographicBoundingBox>
</GeographicElement>
</Extent>
</DomainOfValidity>
<DatumId>WGS84</DatumId>
<Axis uom="Meter">
<CoordinateSystemAxis>
<AxisOrder>1</AxisOrder>
<AxisName>Easting</AxisName>
<AxisAbbreviation>E</AxisAbbreviation>
<AxisDirection>East</AxisDirection>
</CoordinateSystemAxis>
<CoordinateSystemAxis>
<AxisOrder>2</AxisOrder>
<AxisName>Northing</AxisName>
<AxisAbbreviation>N</AxisAbbreviation>
<AxisDirection>North</AxisDirection>
</CoordinateSystemAxis>
</Axis>
<Conversion>
<Projection>
<OperationMethodId>Mercator (variant B)</OperationMethodId>
<ParameterValue><OperationParameterId>Longitude of natural origin</OperationParameterId><Value uom="degree">0</Value></ParameterValue>
<ParameterValue><OperationParameterId>Standard Parallel</OperationParameterId><Value uom="degree">0</Value></ParameterValue>
<ParameterValue><OperationParameterId>Scaling factor for coord differences</OperationParameterId><Value uom="unity">1</Value></ParameterValue>
<ParameterValue><OperationParameterId>False easting</OperationParameterId><Value uom="Meter">0</Value></ParameterValue>
<ParameterValue><OperationParameterId>False northing</OperationParameterId><Value uom="Meter">0</Value></ParameterValue>
</Projection>
</Conversion>
</ProjectedCoordinateSystem>
<Alias id="3395" type="CoordinateSystem">
<ObjectId>WORLD-MERCATOR</ObjectId>
<Namespace>EPSG Code</Namespace>
</Alias>

<GeodeticDatum id="WGS84">
<Name>WGS84</Name>
<PrimeMeridianId>Greenwich</PrimeMeridianId>
<EllipsoidId>WGS84</EllipsoidId>
</GeodeticDatum>
<Alias id="6326" type="Datum">
<ObjectId>WGS84</ObjectId>
<Namespace>EPSG Code</Namespace>
</Alias>

<Ellipsoid id="WGS84">
<Name>WGS84</Name>
<SemiMajorAxis uom="meter">6.37814e+06</SemiMajorAxis>
<SecondDefiningParameter>
<SemiMinorAxis uom="meter">6.35675e+06</SemiMinorAxis>
</SecondDefiningParameter>
</Ellipsoid>
<Alias id="7030" type="Ellipsoid">
<ObjectId>WGS84</ObjectId>
<Namespace>EPSG Code</Namespace>
</Alias>

</Dictionary>
c                      \ rS rSrSrSrg)r-      r(    N)__name__
__module____qualname____firstlineno__VERTEX_SIZE__static_attributes__r]       H/var/www/html/env/lib/python3.13/site-packages/ezdxf/entities/geodata.pyr-   r-      s    Krd   c                    U S:  a  S$ S$ )Nr(   )rJ      )rg      r]   )r0   s    re   mesh_group_codesri      s    {800rd   c                     ^  \ rS rSrSrSr\" \\5      r	\
rSrSrSrSrSrSrSrSrSU 4S	 jjr\4S
 jr S   SU 4S jjjrSS jrSSS jjrS U 4S jjrS!S jrS!S jrS"S jrS#S jrSS.   S$S jjrS\ S.         S%S jjr!Sr"U =r#$ )&r,      zDXF GEODATA entityGEODATAr   r!   r(   r7   r8   c                z   > [         TU ]  5         [        5       U l        [        5       U l        / U l        SU l        g )NrV   )super__init__r-   source_verticestarget_verticesfacescoordinate_system_definition)self	__class__s    re   ro   GeoData.__init__   s1    +~+~*,
,.)rd   c                4    [        SU R                   S35      e)NzCopying of z not supported.)r'   DXFTYPE)rt   copy_strategys     re   copyGeoData.copy  s    T\\N/JKKrd   c                "  > [         TU ]  U5      nU(       aw  UR                  SSSS9nUR                  U[        SSS9nU R                  U5      nUS:  a  U R                  XC5        U$ [        R                  S5        UR                  S5        U$ )	Nr!   r1   r(   )subclass_index
group_coder2   F)logz9GEODATA version 1 found, perhaps loaded data is incorrectrI   )
rn   load_dxf_attribsdetect_implementation_versionfast_load_dxfattribsacdb_geo_data_group_codes!load_coordinate_system_definitionload_mesh_dataloggerwarningdiscard)rt   	processordxfr0   tagsru   s        re   r   GeoData.load_dxf_attribs  s     g&y1==  > G
 11.u 2 D 99$?D{##D2 
	 O -.
rd   c              #     #    / nU HD  nUR                   S;   a-  UR                  UR                  R                  SS5      5        M@  Uv   MF     [	        U5      (       a  SR                  U5      U l        g g 7f)N)-  /  ^J
rV   )codeappendvaluereplacelenjoinrs   )rt   r   linestags       re   r   )GeoData.load_coordinate_system_definition   sb     Cxx:%SYY..tT:;		 
 u::02D- s   A5A7c                   [        U5      u  p41 Skn/ nU H  u  pxXs:X  a  U R                  R                  U5        M'  Xt:X  a  U R                  R                  U5        MI  Xu;   d  MP  US:X  ak  [	        U5      (       a[  [	        U5      S:w  a  [        S[	        U5       S35      eU R                  R                  [        U5      5        UR                  5         UR                  U5        M     U(       a$  U R                  R                  [        U5      5        [	        U R                  5      [	        U R                  5      :w  a  [        S5      eg )N>   a   b   c   r   r7   3GEODATA face definition error: invalid index count .LGEODATA mesh definition error: source and target point count does not match.)	ri   rp   r   rq   r   r   rr   tupleclear)	rt   r   r0   srctargetface_indicesfacer   r   s	            re   r   GeoData.load_mesh_data+  s   &w/#KD{$$++E2$$++E2%2:#d))4yA~/%%(YKq2  JJ%%eDk2JJLE"   JJeDk*t##$D,@,@(AA#"  Brd   c                  > [         TU ]  U5        UR                  [        [        R
                  5        U R                  R                  S:  a  [        R                  S5        U R                  R                  U/ SQ5        U R                  U5        U R                  R                  U/ SQ5        U R                  U5        g)z(Export entity specific data as DXF tags.r(   zGexporting unsupported GEODATA version 1, this may corrupt the DXF file!)r0   r3   r5   r:   r=   r?   rA   rC   rE   rG   rI   rK   rN   rP   rQ   rS   )rU   rX   rY   rZ   N)rn   export_entity
write_tag2r   acdb_geo_datanamer   r0   r   r   export_dxf_attribs#export_coordinate_system_definitionexport_mesh_data)rt   	tagwriterru   s     re   r   GeoData.export_entityG  s    i(_m.@.@A88aNN  	##	
* 	00;##	
 	i(rd   c                   [        U R                  5      [        U R                  5      :w  a  [        S5      e[	        U R
                  R                  5      u  p#UR                  S[        U R                  5      5        [        U R                  U R                  5       H'  u  pEUR                  X$5        UR                  X55        M)     UR                  S[        U R                  5      5        U R                   He  n[        U5      S:w  a  [        S[        U5       S35      eUu  pxn	UR                  SU5        UR                  SU5        UR                  S	U	5        Mg     g )
Nr   ]   `   r7   r   r   r   r   r   )r   rp   rq   r   ri   r   r0   r   zipwrite_vertexrr   )
rt   r   r   r   str   f1f2f3s
             re   r   GeoData.export_mesh_dataq  s1   t##$D,@,@(AA#"  'txx'7'78RT%9%9!:;,,d.B.BCDA""3*""6- D 	RTZZ1JJD4yA~' YKq*  JBB  R(  R(  R( rd   c                <   U R                   R                  SS5      n[        USS9n[        U5      S:X  a  UR	                  S5        [        U5      S:  a2  UR                  SUR                  S5      5        [        U5      S:  a  M2  UR                  S	US   5        g )
Nr   r      )sizer   rV   r!   r   r   )rs   r   r    r   r   r   pop)rt   r   textchunkss       re   r   +GeoData.export_coordinate_system_definition  s    0088tD#Ds3v;!MM"&kAo  fjjm4 &kAoS&),rd   c                    [         R                  " U R                  R                  5      [         R                  " U R                  R                  5      4$ N)r)   decoder   rA   rE   )rt   s    re   decoded_unitsGeoData.decoded_units  s:    ||DHH556HH##9
 
 	
rd   c                   U R                   n [        U5      n[        R                  " U5      nSnUR                  S5       HY  n UR                  S5      R                  nUR                  S5      S:X  d  M6  US:X  d  M>   [        UR                  S	5      5      n  O   SnUR                  S5       Hc  n UR                  S5      R                  nUS:X  d  M'   UR                  S5      R                  n	U	S;   a  SnOU	S;   a  SnO[        SU	 35      e  O   Uc  [        S5      eUc  [        S5      eX64$ ! [        R                   a    [        S5      ef = f! [         a    Sn GN	f = f! [         a    [        S
UR                  S	5       35      ef = f! [         a    Sn Nf = f! [         a    [        S5      ef = f)a8  Returns the EPSG index and axis-ordering, axis-ordering is ``True``
if fist axis is labeled "E" or "W" and ``False`` if first axis is
labeled "N" or "S".

If axis-ordering is ``False`` the CRS is not compatible with the
``__geo_interface__`` or GeoJSON (see chapter 3.1.1).

Raises:
    InvalidGeoDataException: for invalid or unknown XML data

The EPSG number is stored in a tag like:

.. code::

    <Alias id="27700" type="CoordinateSystem">
      <ObjectId>OSGB1936.NationalGrid</ObjectId>
      <Namespace>EPSG Code</Namespace>
    </Alias>

The axis-ordering is stored in a tag like:

.. code::

    <Axis uom="METER">
      <CoordinateSystemAxis>
        <AxisOrder>1</AxisOrder>
        <AxisName>Easting</AxisName>
        <AxisAbbreviation>E</AxisAbbreviation>
        <AxisDirection>east</AxisDirection>
      </CoordinateSystemAxis>
      <CoordinateSystemAxis>
        <AxisOrder>2</AxisOrder>
        <AxisName>Northing</AxisName>
        <AxisAbbreviation>N</AxisAbbreviation>
        <AxisDirection>north</AxisDirection>
      </CoordinateSystemAxis>
    </Axis>

z3failed to parse coordinate_system_definition as xmlNAlias	NamespacerV   typeCoordinateSystemz	EPSG Codeidzinvalid epsg number: z.//CoordinateSystemAxis	AxisOrder1AxisAbbreviationzfirst axis not defined)EWT)NSFzunknown first axis: z no EPSG code associated with CRSz!could not determine axis ordering)rs   _remove_xml_namespacesr   
fromstring
ParseErrorr   findallfindr   AttributeErrorgetint
ValueError)
rt   
definitionrootcrsalias	namespacexy_orderingaxis
axis_order
first_axiss
             re   get_crsGeoData.get_crs  s   P 66
	 0
;J))*5D \\'*E!JJ{388	 yy $669;Seiio.C
  + LL!:;D !YY{388
 S L!%+=!>!C!CJ +"&K:-"'K14H2UVV% <( ;)*LMM )*MNN##_ %% 	)E 	 " 	 " 1/		$/@A  "  
  & L12JKKLsG   !D8 EE.6FF+8 EE+*E+.(FF('F(+GF)	no_checksc                  U R                  5       u  p#U(       Gd  U R                  R                  [        R                  :w  Gd3  U R                  R
                  [        R                  :w  Gd
  [        R                  " U R                  R                  S5      (       a  U R                  R                  S:w  d  [        R                  " U R                  R                  S5      (       a  U R                  (       d  U R                  R                  R                  S5      (       aU  U R                  R                  S:w  d;  U R                  R                  S:w  d!  U R                  R                   S:w  d  U(       d'  [#        SU R                  R%                  5        S35      eU R                  R&                  nU R                  R(                  nU R                  R*                  n[        R,                  " UR.                  UR0                  5      [        R2                  S-  -
  * n[4        R6                  " UR0                  * UR.                  * S5      [4        R8                  " U R                  R:                  U R                  R<                  S5      -  [4        R>                  " U5      -  [4        R6                  " UR0                  UR.                  S5      -  nX4$ )	a  Returns the transformation matrix and the EPSG index to transform
WCS coordinates into CRS coordinates. Because of the lack of proper
documentation this method works only for tested configurations, set
argument `no_checks` to ``True`` to use the method for untested geodata
configurations, but the results may be incorrect.

Supports only "Local Grid" transformation!

Raises:
    InvalidGeoDataException: for untested geodata configurations

      ?r   )r   r   r!   rV   z Untested geodata configuration: zC.
You can try with no_checks=True but the results may be incorrect.r(   r!   ) r   r   r5   r,   
LOCAL_GRIDrK   NONEmathiscloserN   rP   rQ   rr   rG   rZ   rX   rY   r   all_existing_dxf_attribsr:   r=   rI   atan2yxpir   	translatescaler?   rC   z_rotate)	rt   r   epsgr   sourcer   norththetatransformations	            re   get_crs_transformationGeoData.get_crs_transformation  s    !LLN((G,>,>>8833w||C||DHH$>$>DD8800A5||DHH$@$@!DD::xx,,44Y??8844:8800B688.."4"-6xx88:; <01  &&))(( **UWWegg.1<=y688)Q7nn..0L0La &	'
   688Q78 	 ##rd   )r   r!   )rI   r   c               6   U R                   nUc  [        S5      eUR                  n[        S:X  a  [        S5      e[        R                  U   nUc  [        SU 35      eSU-  n[        U R
                  l        SU R
                  l        SU R
                  l        SU R
                  l	        [        R                  U R
                  l        [        R                  U R
                  l        SU R
                  l        X`R
                  l        XR
                  l        X`R
                  l        XR
                  l        [)        U5      U R
                  l        [)        U5      U R
                  l        [/        U5      U R
                  l        [3        U5      U l        g)a=  Setup local grid coordinate system. This method is designed to setup
CRS similar to `EPSG:3395 World Mercator`, the basic features of the
CRS should fulfill these assumptions:

    - base unit of reference coordinates is 1 meter
    - right-handed coordinate system: +Y=north/+X=east/+Z=up

The CRS string is not validated nor interpreted!

.. hint::

    The reference point must be a 2D cartesian map coordinate and not
    a globe (lon/lat) coordinate like stored in GeoJSON or GPS data.

Args:
    design_point: WCS coordinates of the CRS reference point
    reference_point: CRS reference point in 2D cartesian coordinates
    north_direction: north direction a 2D vertex, default is (0, 1)
    crs: Coordinate Reference System definition XML string, default is
        the definition string for `EPSG:3395 World Mercator`

NzValid DXF document required.r   zCDXF document requires units to be set, current state is "unitless".zUnsupported document units: r   rV   )docr   r)   METER_FACTORr   r   rG   rZ   rX   rY   r,   r   rK   r   r5   rP   rA   r?   rE   rC   r   r:   r=   r   rI   strrs   )	rt   r:   r=   rI   r   r  	wcs_unitsmeter_factorunit_factors	            re   setup_local_gridGeoData.setup_local_grid.  s<   < hh; >??II	A:X  )))4">yk JKKL( &,.)(*%&(#+2<<(#*#5#5 ()%$-! *5&"+'2$ !%\ 2#'#8 #'#8 ,/H)rd   )rs   rr   rp   rq   )returnNoner   )r   zOptional[SubclassProcessor]r
  r*   )r   r   r
  Iterable[DXFTag])r(   )r   r  r0   r   )r   r+   r
  r  )r   r+   )r
  z#tuple[Optional[str], Optional[str]])r
  ztuple[int, bool])r   boolr
  ztuple[Matrix44, int])
r:   r   r=   r   rI   r   r   r  r
  r  )$r^   r_   r`   ra   __doc__rx   r
   r"   r   
DXFATTRIBSr   MIN_DXF_VERSION_FOR_EXPORTUNKNOWNr   PROJECTED_GRID
GEOGRAPHICr   
USER_SCALE
GRID_SCALEPRISMOIDEALro   r&   rz   r   r   r   r   r   r   r   r   r   	EPSG_3395r  rc   __classcell__)ru   s   @re   r,   r,      s    Gz=9J!( GJNJ DJJK/ ". L 8<4	 2	?8()T)2-

]$@ $)5$ 5$	5$x !'=5 =5 	=5
 =5 =5 
=5 =5rd   c                2    [         R                  " SSU 5      $ )Nzxmlns="[^"]*"rV   )resub)
xml_strings    re   r   r   n  s    66/2z22rd   )r0   r   r
  ztuple[int, int])r  r  r
  r  )K
__future__r   typingr   r   r   r   	xml.etreer   r   r  loggingezdxf.lldxfr	   ezdxf.lldxf.attributesr
   r   r   r   r   r   ezdxf.lldxf.constr   r   r   r   r   r   ezdxf.lldxf.packedtagsr   ezdxf.lldxf.tagsr   r   
ezdxf.mathr   r   r   r   r   r   r   ezdxf.tools.textr    	dxfentityr"   r#   dxfobjr$   factoryr%   rz   r&   r'   rV   r)   ezdxf.entitiesr*   ezdxf.lldxf.tagwriterr+   __all__	getLoggerr   is_in_integer_rangepoint3dis_not_zerois_not_null_vectorpoint2dis_integer_boolr   r   r  r-   ri   r,   r   r]   rd   re   <module>r5     s   # > > !  	  !   / ) J J J / 4  $ 0 +7n
%			7	#a 	72q)a
 	wsC8a 	733Aq9 	
a" 	%--I#a( 	72U]]GL)a. 	 ++ 	"
/a@ 	GB2AaF 	wr15GaN 	'"a0OaP 	--22 
Qab 	7--22 
caz 	"733Aq9 	$
{aF 	W++ 	
GaT 	// 	!
Ua` 	wsA6aab 	'Q(?caf 	wsB>gah !(R$ G%c2E$+Cd$KmadJ /}= M	`; 1 A5i A5 A5H3rd   