Skip to content

Look up congressional districts client-side using only JavaScript and static files.

License

Notifications You must be signed in to change notification settings

ianh/district-tiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Need to turn long/lat points into US congressional districts?
Copy the 'tiles' directory into your web site and use the following code:

<script src="tiles/lookup.js"></script>
<script>
lookupDistrict(longitude, latitude, function (found, state, district) {
    if (found === "found") {
        // ...
    }
});
</script>

Calling lookupDistrict() finds the proper tile in the 'tiles' directory, then
tests each polygonal district in the tile until it finds one containing the
query point.  No requests are made to any service -- the tile data are hosted as
as static files.

To re-generate the 'tiles' directory, compile and run main.go.  It takes as
input a shapefile of congressional districts (available from the US Census
Bureau at http://www.census.gov/geo/maps-data/data/tiger-line.html) and slices
it up into tiles.  These tiles are adaptively sized and indexed using a
k-d tree -- see the code for details.

About

Look up congressional districts client-side using only JavaScript and static files.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published