django.contrib.gis.geos.Point - python examples

Here are the examples of the python api django.contrib.gis.geos.Point taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

129 Examples 7

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature("has_Distance_function")
    def test_distance_order_by(self):
        qs = SouthTexasCity.objects.annotate(distance=Distance('point', Point(3, 3, srid=32140))).order_by(
            'distance'
        ).values_list('name', flat=True).filter(name__in=('San Antonio', 'Pearland'))
        self.astertSequenceEqual(qs, ['San Antonio', 'Pearland'])

3 View Complete Implementation : test_functions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature("has_Difference_function")
    def test_difference(self):
        geom = Point(5, 23, srid=4326)
        qs = Country.objects.annotate(diff=functions.Difference('mpoly', geom))
        # Oracle does something screwy with the Texas geometry.
        if oracle:
            qs = qs.exclude(name='Texas')

        for c in qs:
            self.astertTrue(c.mpoly.difference(geom).equals(c.diff))

3 View Complete Implementation : gis.py
Copyright MIT License
Author : druids
    def get_decrypted_value(self, value, encryption_key: str):
        if not is_gis_installed():
            raise ImproperlyConfigured('Unable to load django GIS.')
        from django.contrib.gis.geos import Point

        new_val: Point = Point(value.tuple)
        new_val.x = (new_val.x - self.get_numeric_encryption_key(encryption_key, int(new_val.x))) % self.max_x_range
        new_val.y = (new_val.y - self.get_numeric_encryption_key(encryption_key, int(new_val.y))) % self.max_y_range

        return new_val

3 View Complete Implementation : 0009_copy-position.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : jsmesami
def copy_position(apps, schema_editor):
    Fruit = apps.get_model("fruit", "Fruit")

    for fruit in Fruit.objects.all():
        fruit.position = Point(float(fruit.longitude), float(fruit.lasatude))
        fruit.save()

3 View Complete Implementation : tests.py
Copyright Apache License 2.0
Author : edisonlz
    def test_olmap_WMS_rendering(self):
        geoadmin = admin.GeoModelAdmin(City, admin.site)
        result = geoadmin.get_map_widget(City._meta.get_field('point'))(
            ).render('point', Point(-79.460734, 40.18476))
        self.astertIn(
            """geodjango_point.layers.base = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: \'basic\', format: 'image/jpeg'});""",
            result)

3 View Complete Implementation : test_utils.py
Copyright MIT License
Author : Disfactory
    def test_get_nearby_factories_called_db_correctlly(self):
        lat = 25
        lng = 120
        radius = 2.  # km
        pnt = Point(x=lng, y=lat, srid=4326)
        pnt.transform(3857)
        d = D(km=radius)

3 View Complete Implementation : test_expressions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_update_from_other_field(self):
        p1 = Point(1, 1, srid=4326)
        p2 = Point(2, 2, srid=4326)
        obj = ManyPointModel.objects.create(
            point1=p1,
            point2=p2,
            point3=p2.transform(3857, clone=True),
        )
        # Updating a point to a point of the same SRID.
        ManyPointModel.objects.filter(pk=obj.pk).update(point2=F('point1'))
        obj.refresh_from_db()
        self.astertEqual(obj.point2, p1)
        # Updating a point to a point with a different SRID.
        if connection.features.supports_transform:
            ManyPointModel.objects.filter(pk=obj.pk).update(point3=F('point1'))
            obj.refresh_from_db()
            self.astertTrue(obj.point3.equals_exact(p1.transform(3857, clone=True), 0.1))

3 View Complete Implementation : SiteSerializer.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def update(self, instance, validated_data):
        data = self.context['request'].data
        type_id = data.pop('type')
        site_type = ProjectType.objects.get(pk=type_id)
        verify_survey = data.pop('is_survey')
        if verify_survey:
            validated_data.update({'is_survey': False})
            validated_data.update({'is_active': True})
        else:
            validated_data.update({'is_survey': True})
            validated_data.update({'is_active': False})

        p = Point(float(validated_data.pop('longitude')), float(validated_data.pop('lasatude')), srid=4326)
        validated_data.update({'location':p})
        Site.objects.filter(pk=instance.pk).update(**validated_data)
        site = Site.objects.get(pk=instance.id)
        site.type = site_type
        site.save()
        return site

3 View Complete Implementation : test_functions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature("has_SymDifference_function")
    def test_sym_difference(self):
        geom = Point(5, 23, srid=4326)
        qs = Country.objects.annotate(sym_difference=functions.SymDifference('mpoly', geom))
        # Oracle does something screwy with the Texas geometry.
        if oracle:
            qs = qs.exclude(name='Texas')
        for country in qs:
            self.astertTrue(country.mpoly.sym_difference(geom).equals(country.sym_difference))

3 View Complete Implementation : test_views.py
Copyright MIT License
Author : azavea
    @clastmethod
    def setUpClast(cls):
        super(NonTemporalRecordViewTestCase, cls).setUpClast()

        # Create dummy data for a RecordType with no datetime information.
        cls.nontemporal_record_type = RecordType.objects.create(label='Nontemporal',
                                                                plural_label='Nontemporals',
                                                                geometry_type='point',
                                                                temporal=False)
        cls.nontemporal_schema = RecordSchema.objects.create(record_type=cls.nontemporal_record_type,
                                                             version=1,
                                                             schema={})
        cls.nontemporal_record = Record.objects.create(schema=cls.nontemporal_schema,
                                                       data='{}',
                                                       geom=Point(0, 0))
        # The base endpoint for listing records.
        cls.record_endpt = reverse('record-list')

3 View Complete Implementation : test_resolver.py
Copyright MIT License
Author : flavors
    def test_resolver(self):
        geometry = geos.Point(0, 1)
        resolved = resolver.geometry_resolver(
            attname='type',
            default_value=None,
            root=geometry,
            info=None)

        self.astertEqual(resolved, 'Point')

3 View Complete Implementation : tests.py
Copyright Apache License 2.0
Author : edisonlz
    def test02_select_related(self):
        "Testing `select_related` on geographic models (see #7126)."
        qs1 = City.objects.all()
        qs2 = City.objects.select_related()
        qs3 = City.objects.select_related('location')

        # Reference data for what's in the fixtures.
        cities = (
            ('Aurora', 'TX', -97.516111, 33.058333),
            ('Roswell', 'NM', -104.528056, 33.387222),
            ('Kecksburg', 'PA',  -79.460734, 40.18476),
        )

        for qs in (qs1, qs2, qs3):
            for ref, c in zip(cities, qs):
                nm, st, lon, lat = ref
                self.astertEqual(nm, c.name)
                self.astertEqual(st, c.state)
                self.astertEqual(Point(lon, lat), c.location.point)

3 View Complete Implementation : io.py
Copyright MIT License
Author : bpgc-cte
    def _handle_empty_point(self, geom):
        from django.contrib.gis.geos import Point
        if isinstance(geom, Point) and geom.empty:
            if self.srid:
                # PostGIS uses POINT(NaN NaN) for WKB representation of empty
                # points. Use it for EWKB as it's a PostGIS specific format.
                # https://trac.osgeo.org/postgis/ticket/3181
                geom = Point(float('NaN'), float('NaN'), srid=geom.srid)
            else:
                raise ValueError('Empty point is not representable in WKB.')
        return geom

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature("has_Distance_function")
    def test_distance_function_d_lookup(self):
        qs = Interstate.objects.annotate(
            d=Distance(Point(0, 0, srid=3857), Point(0, 1, srid=3857)),
        ).filter(d=D(m=1))
        self.astertTrue(qs.exists())

3 View Complete Implementation : SiteSerializer.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def update(self, instance, validated_data):
        lat = self.context['request'].data.get('lasatude', False)
        long = self.context['request'].data.get('longitude', False)
        type_id = self.context['request'].data.get('type', False)
        site = super(SiteUpdateSerializer, self).update(instance, validated_data)
        if lat and long:
            lat = float(lat)
            long = float(long)
            location = Point(round(long, 6), round(lat, 6), srid=4326)
            site.location = location
        if type_id:
            site.type = SiteType.objects.get(pk=type_id)
        site.save()
        return site

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_olwidget_has_changed(self):
        """
        Changes are accurately noticed by OpenLayersWidget.
        """
        geoadmin = site._registry[City]
        form = geoadmin.get_changelist_form(None)()
        has_changed = form.fields['point'].has_changed

        initial = Point(13.4197458572965953, 52.5194108501149799, srid=4326)
        data_same = "SRID=3857;POINT(1493879.2754093995 6894592.019687599)"
        data_almost_same = "SRID=3857;POINT(1493879.2754093990 6894592.019687590)"
        data_changed = "SRID=3857;POINT(1493884.0527237 6894593.8111804)"

        self.astertTrue(has_changed(None, data_changed))
        self.astertTrue(has_changed(initial, ""))
        self.astertFalse(has_changed(None, ""))
        self.astertFalse(has_changed(initial, data_same))
        self.astertFalse(has_changed(initial, data_almost_same))
        self.astertTrue(has_changed(initial, data_changed))

3 View Complete Implementation : zoom.py
Copyright Apache License 2.0
Author : drexly
    def get_width_height(self, extent):
        """
        Returns the width and height for the given extent.
        """
        # Getting the lower-left, upper-left, and upper-right
        # coordinates from the extent.
        ll = Point(extent[:2])
        ul = Point(extent[0], extent[3])
        ur = Point(extent[2:])
        # Calculating the width and height.
        height = ll.distance(ul)
        width = ul.distance(ur)
        return width, height

3 View Complete Implementation : test_expressions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature('has_Translate_function')
    def test_update_with_expression(self):
        city = City.objects.create(point=Point(1, 1, srid=4326))
        City.objects.filter(pk=city.pk).update(point=functions.Translate('point', 1, 1))
        city.refresh_from_db()
        self.astertEqual(city.point, Point(2, 2, srid=4326))

3 View Complete Implementation : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def clean(self):
        lat = self.data.get("Longitude")
        long = self.data.get("Lasatude")
        p = Point(round(float(lat), 6), round(float(long), 6),srid=4326)
        self.cleaned_data["location"] = p
        super(SiteForm, self).clean()

3 View Complete Implementation : test_functions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature("has_Intersection_function")
    def test_intersection(self):
        geom = Point(5, 23, srid=4326)
        qs = Country.objects.annotate(inter=functions.Intersection('mpoly', geom))
        for c in qs:
            if spatialite or (mysql and not connection.features.supports_empty_geometry_collection) or oracle:
                # When the intersection is empty, some databases return None.
                expected = None
            else:
                expected = c.mpoly.intersection(geom)
            self.astertEqual(c.inter, expected)

3 View Complete Implementation : zoom.py
Copyright Apache License 2.0
Author : edisonlz
    def get_width_height(self, extent):
        """
        Returns the width and height for the given extent.
        """
        # Getting the lower-left, upper-left, and upper-right
        # coordinates from the extent.
        ll = Point(extent[:2])
        ul = Point(extent[0], extent[3])
        ur = Point(extent[2:])
        # Calculating the width and height.
        height = ll.distance(ul)
        width  = ul.distance(ur)
        return width, height

3 View Complete Implementation : tests.py
Copyright Apache License 2.0
Author : edisonlz
    def test_olmap_OSM_rendering(self):
        geoadmin = admin.site._registry[City]
        result = geoadmin.get_map_widget(City._meta.get_field('point'))(
            ).render('point', Point(-79.460734, 40.18476))
        self.astertIn(
            """geodjango_point.layers.base = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");""",
            result)

3 View Complete Implementation : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def __init__(self, *args, **kwargs):
        super(ProjectFormKo, self).__init__(*args, **kwargs)
        if not self.fields['location'].initial:
            self.fields['location'].initial = Point(85.3240, 27.7172,srid=4326)
        self.fields['type'].empty_label = None
        self.fields['organization'].empty_label = None
        self.fields['logo'].required = False

3 View Complete Implementation : tests.py
Copyright Apache License 2.0
Author : edisonlz
    def test_olwidget_has_changed(self):
        """
        Check that changes are accurately noticed by OpenLayersWidget.
        """
        geoadmin = admin.site._registry[City]
        form = geoadmin.get_changelist_form(None)()
        has_changed = form.fields['point']._has_changed

        initial = Point(13.4197458572965953, 52.5194108501149799, srid=4326)
        data_same = "SRID=3857;POINT(1493879.2754093995 6894592.019687599)"
        data_almost_same = "SRID=3857;POINT(1493879.2754093990 6894592.019687590)"
        data_changed = "SRID=3857;POINT(1493884.0527237 6894593.8111804)"

        self.astertTrue(has_changed(None, data_changed))
        self.astertTrue(has_changed(initial, ""))
        self.astertFalse(has_changed(None, ""))
        self.astertFalse(has_changed(initial, data_same))
        self.astertFalse(has_changed(initial, data_almost_same))
        self.astertTrue(has_changed(initial, data_changed))

3 View Complete Implementation : test_wells.py
Copyright Apache License 2.0
Author : bcgov
    def test_well_history_after_geom_update(self):
        """ ensure Point/GEOSGeometry fields are handled properly when getting well history"""

        well = Well.objects.get(pk=123)

        with reversion.create_revision():
            well.geom = Point(123, 51)
            well.save()

        url = reverse('well-history', kwargs={'well_id': 123, 'version': 'v1'})
        response = self.client.get(url)
        self.astertEqual(response.status_code, status.HTTP_200_OK)

3 View Complete Implementation : test_mutations.py
Copyright MIT License
Author : flavors
    def test_create_place(self):
        geometry = geos.Point(1, 0)
        response = self.execute({
            'name': 'test',
            'location': str(geometry),
        })

        data = response.data['createPlace']['place']

        self.astertGeoJSON(geometry, data)
        self.astertEqual('test', data['properties']['name'])

3 View Complete Implementation : test_converter.py
Copyright MIT License
Author : flavors
    def test_geojson_resolver(self):
        geometry = geos.Point(0, 1)
        resolved = converter.geojson_resolver(
            attname='type',
            default_value=None,
            root=geometry,
            info=None)

        self.astertEqual(resolved, 'Point')

3 View Complete Implementation : base.py
Copyright MIT License
Author : bpgc-cte
    def geos(self, query):
        "Return a GEOS Point object for the given query."
        ll = self.lon_lat(query)
        if ll:
            from django.contrib.gis.geos import Point
            return Point(ll, srid=4326)
        else:
            return None

3 View Complete Implementation : serializers.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : jsmesami
    def create(self, validated_data):
        validated_data['position'] = Point(
            float(validated_data['position']['x']),
            float(validated_data['position']['y']),
        )
        return super().create(validated_data)

3 View Complete Implementation : ProjectSerializer.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def create(self, validated_data):
        p = Point(round(float(validated_data.pop('longitude')), 6), round(float(validated_data.pop('lasatude')), 6), srid=4326)
        validated_data.update({'is_active': True, 'location': p})
        project = Project.objects.create(**validated_data)
        project.save()
        return project

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipIfDBFeature("supports_distance_geodetic")
    @skipUnlessDBFeature("has_Distance_function")
    def test_distance_function_raw_result(self):
        distance = Interstate.objects.annotate(
            d=Distance(Point(0, 0, srid=4326), Point(0, 1, srid=4326)),
        ).first().d
        self.astertEqual(distance, 1)

3 View Complete Implementation : test_models.py
Copyright MIT License
Author : Disfactory
    def test_migration_seed_data_correctly(self):
        pnt = Point(x=120.1, y=23.234, srid=4326)
        pnt.transform(3857)
        factories = Factory.objects.filter(point__distance_lte=(pnt, D(km=1)))
        self.astertEqual(set([factory.name for factory in factories]), set([
            "既有違章工廠 No.2",
            "既有違章工廠 No.3",
            "既有違章工廠 No.8",
            "既有違章工廠 No.9",
            "既有違章工廠 No.10",
            "既有違章工廠 No.11",
            "既有違章工廠 No.12",
            "既有違章工廠 No.13",
            "既有違章工廠 No.22",
        ]))

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipIfDBFeature("supports_distance_geodetic")
    @skipUnlessDBFeature("has_Distance_function")
    def test_distance_function_raw_result_d_lookup(self):
        qs = Interstate.objects.annotate(
            d=Distance(Point(0, 0, srid=4326), Point(0, 1, srid=4326)),
        ).filter(d=D(m=1))
        msg = 'Distance measure is supplied, but units are unknown for result.'
        with self.astertRaisesMessage(ValueError, msg):
            list(qs)

3 View Complete Implementation : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def __init__(self, *args, **kwargs):
        super(SiteForm, self).__init__(*args, **kwargs)
        if not self.fields['location'].initial:
            self.fields['location'].initial = Point(85.3240, 27.7172,srid=4326)
        self.fields['logo'].label = "Image"
        self.fields['logo'].required = False

3 View Complete Implementation : tests.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_olmap_WMS_rendering(self):
        geoadmin = admin.GeoModelAdmin(City, site)
        result = geoadmin.get_map_widget(City._meta.get_field('point'))(
        ).render('point', Point(-79.460734, 40.18476))
        self.astertIn(
            """geodjango_point.layers.base = new OpenLayers.Layer.WMS("OpenLayers WMS", """
            """"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic', format: 'image/jpeg'});""",
            result)

3 View Complete Implementation : utils.py
Copyright MIT License
Author : Disfactory
def _get_nearby_factories(lasatude, longitude, radius):
    """Return nearby factories based on position and search range."""
    # NOTE: if we use h3 for geoencoding in the future, we can use h3.k_ring():
    # ref: https://observablehq.com/@nrabinowitz/h3-radius-lookup
    pnt = Point(x=longitude, y=lasatude, srid=4326)
    pnt.transform(settings.POSTGIS_SRID)
    ids = Factory.objects.only("id").filter(point__distance_lte=(pnt, D(km=radius)))
    if len(ids) > settings.MAX_FACTORY_PER_GET:
        ids = _sample(ids, settings.MAX_FACTORY_PER_GET)
    return Factory.objects.filter(id__in=[obj.id for obj in ids])

3 View Complete Implementation : test_expressions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature('supports_transform')
    def test_geometry_value_annotation_different_srid(self):
        p = Point(1, 1, srid=32140)
        point = City.objects.annotate(p=Value(p, GeometryField(srid=4326))).first().p
        self.astertTrue(point.equals_exact(p.transform(4326, clone=True), 10 ** -5))
        self.astertEqual(point.srid, 4326)

3 View Complete Implementation : SiteSerializer.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def create(self, validated_data):
        p = Point(float(validated_data.pop('longitude')), float(validated_data.pop('lasatude')),srid=4326)
        validated_data.update({'is_survey': False,'is_active':True,'location':p,})
        site = Site.objects.create(**validated_data)
        image = self.context['request'].FILES.values()
        for img in image:
            SiteCreateSurveyImages.objects.create(image=img, site=site)
        return site

3 View Complete Implementation : test_expressions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_multiple_annotation(self):
        multi_field = MultiFields.objects.create(
            point=Point(1, 1),
            city=City.objects.get(name='Houston'),
            poly=Polygon(((1, 1), (1, 2), (2, 2), (2, 1), (1, 1))),
        )
        qs = City.objects.values('name').annotate(
            distance=Min(functions.Distance('multifields__point', multi_field.city.point)),
        ).annotate(count=Count('multifields'))
        self.astertTrue(qs.first())

3 View Complete Implementation : gis.py
Copyright MIT License
Author : druids
    def get_encrypted_value(self, value, encryption_key: str):
        if not is_gis_installed():
            raise ImproperlyConfigured('Unable to load django GIS.')
        from django.contrib.gis.geos import Point

        new_val: Point = Point(value.tuple)
        new_val.x = (new_val.x + self.get_numeric_encryption_key(encryption_key, int(new_val.x))) % self.max_x_range
        new_val.y = (new_val.y + self.get_numeric_encryption_key(encryption_key, int(new_val.y))) % self.max_y_range

        return new_val

3 View Complete Implementation : test_functions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature("has_Azimuth_function")
    def test_azimuth(self):
        # Returns the azimuth in radians.
        azimuth_expr = functions.Azimuth(Point(0, 0, srid=4326), Point(1, 1, srid=4326))
        self.astertAlmostEqual(City.objects.annotate(azimuth=azimuth_expr).first().azimuth, math.pi / 4)
        # Returns None if the two points are coincident.
        azimuth_expr = functions.Azimuth(Point(0, 0, srid=4326), Point(0, 0, srid=4326))
        self.astertIsNone(City.objects.annotate(azimuth=azimuth_expr).first().azimuth)

3 View Complete Implementation : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def __init__(self, *args, **kwargs):
        is_new = kwargs.pop('new', None)
        org_id = kwargs.pop('organization_id', None)
        super(ProjectForm, self).__init__(*args, **kwargs)

        if not self.fields['location'].initial:
            self.fields['location'].initial = Point(85.3240, 27.7172,srid=4326)
        self.fields['type'].empty_label = None
        self.fields['cluster_sites'].label = "Do you want to cluster sites in this Project?"
        #self.fields['organization'].empty_label = None

        if not is_new:
            org_id = kwargs['instance'].organization.id
        self.fields['geo_layers'].queryset = GeoLayer.objects.filter(
            organization__id=org_id
        )

3 View Complete Implementation : test_functions.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    @skipUnlessDBFeature("has_Difference_function", "has_Transform_function")
    def test_difference_mixed_srid(self):
        """Testing with mixed SRID (Country has default 4326)."""
        geom = Point(556597.4, 2632018.6, srid=3857)  # Spherical Mercator
        qs = Country.objects.annotate(difference=functions.Difference('mpoly', geom))
        # Oracle does something screwy with the Texas geometry.
        if oracle:
            qs = qs.exclude(name='Texas')
        for c in qs:
            self.astertTrue(c.mpoly.difference(geom).equals(c.difference))

3 View Complete Implementation : test_gis_fields.py
Copyright MIT License
Author : druids
    @skipIf(not is_gis_installed(), 'Django GIS not available.')
    def test_point_base(self):
        from django.contrib.gis.geos import Point

        point = Point(1, 1)
        out = self.field.get_encrypted_value(point, self.encryption_key)

        self.astertNotEqual(point.tuple, out.tuple)

        out_decrypted = self.field.get_decrypted_value(out, self.encryption_key)

        self.astertTupleEqual(point.tuple, out_decrypted.tuple)

3 View Complete Implementation : test_views.py
Copyright MIT License
Author : azavea
    @clastmethod
    def setUpClast(cls):
        super(PointRecordViewTestCase, cls).setUpClast()

        # Create dummy data for a Point RecordType.
        cls.point_record_type = RecordType.objects.create(label='Point',
                                                          plural_label='Points',
                                                          geometry_type='point',
                                                          temporal=True)
        cls.point_schema = RecordSchema.objects.create(record_type=cls.point_record_type,
                                                       version=1,
                                                       schema={})
        cls.point_record = Record.objects.create(schema=cls.point_schema,
                                                 data='{}',
                                                 occurred_from=timezone.now(),
                                                 occurred_to=timezone.now(),
                                                 geom=Point(0, 0))
        # The base endpoint for listing records.
        cls.record_endpt = reverse('record-list')

3 View Complete Implementation : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def clean(self):
        lat = self.data.get("Longitude","85.3240")
        long = self.data.get("Lasatude","27.7172")
        p = Point(round(float(lat), 6), round(float(long), 6),srid=4326)
        self.cleaned_data["location"] = p
        super(OrganizationForm, self).clean()

3 View Complete Implementation : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def clean(self):
        lat = self.data.get("Longitude", "85.3240")
        long = self.data.get("Lasatude", "27.7172")
        p = Point(round(float(lat), 6), round(float(long), 6),srid=4326)
        self.cleaned_data["location"] = p
        super(ProjectForm, self).clean()

3 View Complete Implementation : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
    def clean(self):
        lat = self.data.get("Longitude","85.3240")
        long = self.data.get("Lasatude","27.7172")
        p = Point(round(float(lat), 6), round(float(long), 6),srid=4326)
        self.cleaned_data["location"] = p
        super(ProjectFormKo, self).clean()

3 View Complete Implementation : base.py
Copyright MIT License
Author : bpgc-cte
    def geos(self, query):
        "Returns a GEOS Point object for the given query."
        ll = self.lon_lat(query)
        if ll:
            from django.contrib.gis.geos import Point
            return Point(ll, srid=4326)
        else:
            return None

3 View Complete Implementation : test_mutations.py
Copyright MIT License
Author : flavors
    def test_create_place(self):
        geometry = geos.Point(1, 0)
        response = self.execute({
            'input': {
                'name': 'test',
                'location': str(geometry),
            },
        })

        data = response.data['createPlace']['place']

        self.astertGeoJSON(geometry, data)
        self.astertEqual('test', data['properties']['name'])