技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
serialization【数据与研究】Serialize GeoDjango geometries and model instances as GeoJSON-compatible Geometry, Feature, or FeatureCollection data with validated input, IDs, properties, bboxes, precision, deduplication, transforms, and automatic field mapping.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this skill when a DRF endpoint must read or write GeoJSON geometry values or
emit GeoJSON Feature / FeatureCollection objects. Start with
references/api-reference.md for exact public
names, defaults, output shape, and validation messages. Use
references/workflows.md for complete serializer
recipes and references/troubleshooting.md when
GeoDjango, geometry parsing, SRIDs, fields, or null/empty values fail.
GeometryField for a model geometry field or a plain serializer geometry
value. Configure precision, remove_duplicates, auto_bbox, and
transform only when the representation needs them.GeometrySerializerMethodField when a serializer method computes the
geometry. Return a GEOSGeometry or None.GeoFeatureModelSerializer for one GeoJSON Feature; pass many=True
for a FeatureCollection. Set Meta.geo_field explicitly, including
None for a geometry-less model, and choose id_field, properties, and bbox
behavior deliberately.get_properties() and unformat_geojson() together when the GeoJSON
properties object is not the model's ordinary serializer fields.rest_framework_gis after rest_framework in
INSTALLED_APPS so its app config registers GeoDjango fields with DRF's
ModelSerializer mapping. An explicitly declared GeometryField works
without relying on automatic mapping.GEOSGeometry; send a JSON string when a multipart form cannot
carry a nested dictionary.properties plus optional geometry, id, and
writable bbox. A partial update may omit geometry; DRF then retains the
instance value.The deterministic, database-free smoke check is linked from references/workflows.md. From the runtime skill root, run:
python sub-skills/serialization/scripts/geometry_smoke.py --help
python sub-skills/serialization/scripts/geometry_smoke.py