o ÎØøa– ã@sJddlmZmZddlmZddlmZGdd„deƒZGdd„dƒZdS) é)ÚCoordTransformÚSpatialReference©ÚSerializerDoesNotExist)Ú SerializercsPeZdZdZ‡fdd„Zdd„Zdd„Z‡fdd „Zd d „Z‡fd d „Z ‡Z S)rz< Convert a queryset to GeoJSON, http://geojson.org/ csltƒ ¡|j dd¡|_|j dd¡|_|jdur0|jdur2|j|jvr4g|j¢|j‘|_dSdSdSdS)NÚgeometry_fieldÚsridiæ)ÚsuperÚ _init_optionsÚ json_kwargsÚpoprrÚselected_fields©Úself©Ú __class__©úH/usr/lib/python3/dist-packages/django/contrib/gis/serializers/geojson.pyr s  þzSerializer._init_optionscCs$| ¡i|_|j d|j¡dS)Nzg{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "EPSG:%d"}}, "features": [)r Ú_ctsÚstreamÚwriterrrrrÚstart_serializationsÿÿzSerializer.start_serializationcCs|j d¡dS)Nz]})rrrrrrÚend_serializationszSerializer.end_serializationcsJtƒ |¡d|_|jdur!|jjD]}t|dƒr |j|_dSqdSdS)NÚ geom_type)r Ú start_objectÚ _geometryrÚ_metaÚfieldsÚhasattrÚname©rÚobjÚfieldrrrrs    þýzSerializer.start_objectcCs¼d|jdœ}|jdusd|jvr!d|dvr!|jj |¡|dd<|jrX|jj|jkrN|jj|jvrCt|jƒ}t |jj |ƒ|j|jj<|j  |j|jj¡t |jj ƒ|d<|Sd|d<|S)NÚFeature)ÚtypeÚ propertiesÚpkr%Úgeometry)Ú_currentr rr&Úvalue_to_stringrrrrrÚsrsÚ transformÚevalÚgeojson)rr!Údatar*rrrÚget_dump_object&s þ  ÿzSerializer.get_dump_objectcs.|j|jkr| |¡|_dStƒ ||¡dS)N)rrÚvalue_from_objectrr Ú handle_fieldr rrrr1:s zSerializer.handle_field) Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrrr/r1Ú __classcell__rrrrrs   rc@seZdZdd„ZdS)Ú DeserializercOstdƒ‚)Nz*geojson is a serialization-only serializerr)rÚargsÚkwargsrrrÚ__init__BszDeserializer.__init__N)r2r3r4r:rrrrr7As r7N) Údjango.contrib.gis.gdalrrÚdjango.core.serializers.baserÚdjango.core.serializers.jsonrÚJSONSerializerr7rrrrÚs   ;