Skip to content

Instantly share code, notes, and snippets.

@kalombos
kalombos / google_maps_polygon.py
Last active August 31, 2023 21:48
This is a solution for polygon selection in google maps. Some polygons can across antimeridian which will be getting wrong by postgis when you make ST_Within query, for example. So, this function allows to split polygon to multipolygon, parts of wich are contained in both hemispheres if needs
# -*- coding: utf-8 -*-
from django.contrib.gis.geos import MultiPolygon, GEOSGeometry
from django.db import connection
def is_crossed_antimeridian(polygon):
crossed = False
coords = []
for polygon_set in polygon:
for (lng, lat) in polygon_set:
@myronmarston
myronmarston / ways_to_use_vcr.rb
Created April 13, 2012 15:00
Ways to use VCR for a request made by a let block
# 1) Use VCR.use_cassette in your let block. This will use
# the cassette just for requests made by creating bar, not
# for anything else in your test.
let(:foo) { VCR.use_cassette("foo") { create(:bar) } }
it "uses foo" do
foo
end
# 2) Wrap the it block that uses #foo in VCR.use_cassette.