<commit_before>from rest_framework_gis import serializers as gis_serializers
from rest_framework_gis.fields import GeometrySerializerMethodField

from osmaxx.excerptexport.models import Excerpt
from osmaxx.excerptexport.models.bounding_geometry import BoundingGeometry
from osmaxx.utilities.shortcuts import get_actual


class BoundingGeometrySerializer(gis_serializers.GeoFeatureModelSerializer):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    geom = GeometrySerializerMethodField()

    def get_geom(self, obj):
        actual = get_actual(obj)
        return actual.geometry

    class Meta:
        geo_field = 'geom'
        model = BoundingGeometry
        fields = ['id']
        auto_bbox = True


class BoundingGeometryFromExcerptSerializer(gis_serializers.GeoFeatureModelSerializer):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    geom = GeometrySerializerMethodField()

    def get_geom(self, obj):
        bounding_geometry = obj.bounding_geometry_raw_reference
        actual = get_actual(bounding_geometry)
        return actual.geometry

    class Meta:
        geo_field = 'geom'
        model = Excerpt
        fields = ['id']
        auto_bbox = True<commit_msg>serialize the type of geometry for geojson<commit_after>from rest_framework_gis import serializers as gis_serializers
from rest_framework_gis.fields import GeometrySerializerMethodField

from osmaxx.excerptexport.models import Excerpt
from osmaxx.excerptexport.models.bounding_geometry import BoundingGeometry
from osmaxx.utilities.shortcuts import get_actual


class BoundingGeometrySerializer(gis_serializers.GeoFeatureModelSerializer):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    geom = GeometrySerializerMethodField()

    def get_geom(self, obj):
        actual = get_actual(obj)
        return actual.geometry

    class Meta:
        geo_field = 'geom'
        model = BoundingGeometry
        fields = ['id', 'type_of_geometry']
        auto_bbox = True


class BoundingGeometryFromExcerptSerializer(gis_serializers.GeoFeatureModelSerializer):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    geom = GeometrySerializerMethodField()

    def get_geom(self, obj):
        bounding_geometry = obj.bounding_geometry_raw_reference
        actual = get_actual(bounding_geometry)
        return actual.geometry

    class Meta:
        geo_field = 'geom'
        model = Excerpt
        fields = ['id', 'type_of_geometry']
        auto_bbox = True
{'fraction_non_alphanumeric': 0.07867335133050521, 'fraction_numerical': 0.0, 'mean_word_length': 3.759633027522936, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '9769', 'n_tokens_mistral': 783, 'n_tokens_neox': 731, 'n_words': 163}