A
A
Alexander Savchuk2016-01-10 23:09:09
Django
Alexander Savchuk, 2016-01-10 23:09:09

How to get distances between two IP addresses using Django GIS?

How to get the distance between two IP addresses using Django GIS ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
markeev, 2016-01-16
@MrLinch

The answer to the question can consist of 2 parts. 1 - you need to get the coordinates of both IP addresses, 2 - determine the distance between 2 points.

from django.contrib.gis.geoip import GeoIP

g = GeoIP()
g.lon_lat('65.55.39.10')

https://docs.djangoproject.com/en/1.9/ref/contrib/...
from django.contrib.gis.geos import Point, GEOSGeometry

pnt = GEOSGeometry('SRID=4326;POINT(40.396764 -3.68042)')
pnt2 = GEOSGeometry('SRID=4326;POINT( 48.835797 2.329102  )')
pnt.distance(pnt2)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question