djangosnippets.org: Latest snippets tagged with 'geodjango'https://djangosnippets.org/tags/geodjango/2012-10-31T19:32:30-05:00template code for &quot;Google v3 geocoding for Geodjango admin site&quot;2012-10-31T19:32:30-05:00samhaghttps://djangosnippets.org/snippets/2840/<p>Html code for <a href="http://djangosnippets.org/snippets/2839/">"Google v3 geocoding for Geodjango admin site"</a>
Rename the snippet as gmgdav3.html and save it to template/admin</p>
Freely redistributableGoogle v3 geocoding for Geodjango admin site2012-10-31T19:26:22-05:00samhaghttps://djangosnippets.org/snippets/2839/<p>This only works with Point geometry.
<a href="http://www.youtube.com/watch?v=gZ7_n177sTE&amp;list=HL1351725584&amp;feature=mh_lolz">video</a></p>
<p>Rename the snippet as gmgdav3.js and save it to template/admin with <a href="http://djangosnippets.org/snippets/2840/">gmgdav3.html</a></p>
<ul>
<li>
<ul>
<li><em>models.py</em>:</li>
</ul>
</li>
</ul>
<p><code>from django.contrib.gis.db import models</code> <br />
<code>class point(models.Model):</code> <br />
<code>address = models.CharField(max_length=100, help_text='Press "Tab" to refresh the map')</code> <br />
<code>longitude = models.FloatField ...</code></p>
Freely redistributableCollectionFrom (GeometryCollection &lt;-&gt; Geometry Fields!)2011-04-21T18:24:02-05:00philipnhttps://djangosnippets.org/snippets/2420/<p>Motivation: We can't use GeometryCollections to do filters, etc in GeoDjango due to incomplete underlying libraries. But with this CollectionFrom field we can get all the benefits of working with GeometryCollections but still query based on points, lines, polys.</p>
<p>If you're using GeometryCollectionFields and see this error:</p>
<p>DatabaseError ...</p>
Freely redistributableGeoDjango maps in admin TabularInlines2010-10-08T10:40:12-05:00alanBhttps://djangosnippets.org/snippets/2232/<p>This snippet adds support for OSM maps for GeometryField in Admin TabularInlines.</p>
<p>The one possible issue with this snippet is that the OSMGeoInlineForm has to know about the parent ModelAdmin which it does through the code</p>
<p><code>model_admin_instance = admin.sites.site._registry[self.parent_model]</code></p>
<p>which won't work if you don ...</p>
Freely redistributableForcing Right-Hand Rule (Counter Clockwise) Polygons in GeoDjango for Google Earth / KML2010-01-27T19:45:09-06:00gabejacksonhttps://djangosnippets.org/snippets/1895/<p>According to the KML Specification, Polygons must be oriented according to the Right-Hand Rule (Counter Clockwise orientation) for them to display correctly in Google Earth. Since not all Polygons are defined according to the Right-Hand Rule, you can use this code to orient them correctly when using GeoDjango.</p>
<p>Thanks goes ...</p>
Freely redistributableMap GPX files to 3D GeoDjango Models2009-11-16T13:39:17-06:00jbronnhttps://djangosnippets.org/snippets/1800/<p><code>GPXMapping</code> is a subclass of <code>LayerMapping</code> that imports GPX files into 3D GeoDjango models (requires Django 1.2 or SVN r11742 and higher). Here's an example of GeoDjango models for GPX points and tracks, respectively:</p>
<pre><code>from django.contrib.gis.db import models
class GPXPoint(models.Model):
timestamp = models.DateTimeField ...</code></pre>
Freely redistributablecompressing polygons for geodjango2009-06-09T15:34:05-05:00showellhttps://djangosnippets.org/snippets/1559/<p>The code shown allows you, in GeoDjango, to reduce the number of points in your polygons. It helps reduce storage needs and makes queries run faster, at the cost of some precision. It provides a variation on the simplify() method that comes with the GEOS API, allowing you to specify ...</p>
Freely redistributableWorldIP - access to IP database over API2008-09-11T15:22:25-05:00Alrondhttps://djangosnippets.org/snippets/1046/<p>The WorldIP database provides real-world geographical location. Database is more correct than <a href="http://www.wipmania.com/en/blog/why-worldip-data-rather-than-whois-data-examples/">Whois records and Whois-based databases</a>, that show geographic locations of network owners, and not the geographic location of Internet-connected PC or appliance itself.
See more: <a href="http://www.wipmania.com">WIPmania.com</a></p>
Freely redistributableMaxMind(R) GeoIP Lite CSV Import2007-07-18T20:55:43-05:00jbronnhttps://djangosnippets.org/snippets/328/<p>Use this script to import the Maxmind GeoIP lite CSV datasets into your database. This takes at least 200MB of RAM; the resulting database will be ~400MB. Stick in the same directory as the <a href="http://www.djangosnippets.org/snippets/327/">models</a>. Make sure to set <code>DEBUG=False</code> to prevent running out of memory during import.</p>
Freely redistributableMaxMind(R) GeoIP Lite geolocation models2007-07-18T20:49:11-05:00jbronnhttps://djangosnippets.org/snippets/327/<p>This provides GeoDjango models for the maxmind GeoIP Lite data products. Use the corresponding <a href="http://www.djangosnippets.org/snippets/328/">CSV import script</a> for data import. Requires: <a href="http://code.djangoproject.com/wiki/GeoDjango">GeoDjango</a> and the <a href="http://code.djangoproject.com/attachment/ticket/399/django-bigint-20070712.patch">BigIntegerField patch</a> by Peter Nixon. </p>
Freely redistributable