This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a list of IDs for all ways in the gdf | |
way_ids = gdf_bike.loc['way'].index.tolist() | |
# get a bbox, as per features_from_point() | |
bbox = ox.utils_geo.bbox_from_point(center, 5000) | |
# get a polygon we can use to query Overpass, as per features_from_bbox() | |
polygon = ox.utils_geo.bbox_to_poly(bbox) | |
# build results generator | |
response_jsons = ox._overpass._download_overpass_features(polygon, tags_bike) | |
# get the elements, assuming the generator only yielded one response | |
elements = next(response_jsons)['elements'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/tobych/6372218 | |
# Monkey patch to work around https://code.djangoproject.com/ticket/13843 | |
import django | |
from functools import wraps | |
def discard_exceptions(f): | |
@wraps(f) | |
def wrapper(*args, **kwds): | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def patched__del__(self): | |
if self.ptr: lgeos.finishGEOS_r(self.ptr) | |
import django | |
django.contrib.gis.geos.prototypes.threadsafe.GEOSContextHandle.__del__ = patched__del__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span class="statusLabel" data-status="{{ status.name }}">{{ status.name }}</span> | |
... | |
<script type="text/javascript"> | |
$('.statusLabel').addClass(function() { | |
var classes = { | |
"Never seen": 'label', | |
"OK": "label label-success", | |
"Relocated": "label label-warning", | |
"Missing": "label label-danger" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TruckResource(ModelResource): | |
class Meta: | |
queryset = Truck.objects.all() | |
list_allowed_methods = ['get'] | |
detail_allowed_methods = ['get'] | |
filtering = {'owner': ALL_WITH_RELATIONS, 'truck_number': ALL} |