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
3
View Complete Implementation : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
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
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 : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
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
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 : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
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 : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
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 : forms.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
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 : ProjectSerializer.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
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 : SiteSerializer.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
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 : SiteSerializer.py
Copyright BSD 2-Clause "Simplified" License
Author : awemulya
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