Test: find county and plot location from digital coordinates by GeoDjango with MySQL

How It Works

First the program defines a county within the US territory. If this is a Massachusetts county, it further looks for a custom location. For testing purposes, two locations from Plymouth Co., MA were entered in the database: Myles Standish State Forest (MSSF) and one of the three small parcels comprising Massasoit National Wildlife Refuge, which is adjacent to MSSF. (The border of the MSSF is not perfectly defined in this example. The overlap was allowed as an experiment; as a result, a single location may be attributed to both properties.)
MySQL is sometimes called "a crippled spatial database": instead of considering real contours it operates with "bounding boxes" (technically, instead of function contains() it executes bbcontains()). This means you may find yourself in two (if not more) different counties/locations at the same time! As a workaround, I used an external function (in pure Python) applied to each regular spatial query result. The output includes a map generated by JavaScript library from "http://www.openlayers.org". This library is similar to the popular GoogleMaps, though it is a true open source, which does not require registration.

Test It Yourself

Sample predefined locations:
Or enter any coordinates within the US (in digital format)
Latitude: Longitude: